Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=function&page=1639&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 18199 results for "function"(3853ms)

EmailKeysmain.tsx5 matches

@chet•Updated 1 year ago
3const db = new ValTupleStorage("email");
4
5export async function generateEmailKey() {
6 const key = Math.random().toString().slice(3);
7
17}
18
19export async function listEmailKeys() {
20 const emailKeys = await db.scan();
21 console.log("Email keys:", emailKeys);
22}
23
24export async function expireEmailKey(key: string) {
25 const expires = Date.now() - 1;
26 await db.write({ set: [{ key: [key], value: expires }] });
27}
28
29export async function authenticateEmailKey(key: string) {
30 const result = await db.scan({ gte: [key], lte: [key], limit: 1 });
31 if (result.length === 0) return "Invalid key.";
34}
35
36export async function resetEmailKeys() {
37 await db.destroy();
38}

add_to_notion_w_ai_webpagemain.tsx10 matches

@nerdymomocat•Updated 1 year ago
39});
40
41function createPrompt(title, description, properties) {
42 let prompt =
43 "You are processing content into a database. Based on the title of the database, its properties, their types and options, and any existing descriptions, infer appropriate values for the fields:\n";
84}
85
86function processProperties(jsonObject) {
87 const properties = jsonObject.properties;
88 const filteredProps = {};
115}
116
117async function get_and_save_notion_db_processed_properties(databaseId)
118{
119 const response = await notion.databases.retrieve({ database_id: databaseId });
126}
127
128async function get_notion_db_info(databaseId) {
129 databaseId = databaseId.replaceAll("-", "");
130 let db_info = null;
142}
143
144async function get_and_save_notion_db_info(databaseId) {
145 databaseId = databaseId.replaceAll("-", "");
146 let db_info = await get_and_save_notion_db_processed_properties(databaseId);
149}
150
151function createZodSchema(filteredProps) {
152 const schemaObject = {};
153
198}
199
200function convertToNotionProperties(responseValues, filteredProps) {
201 const notionProperties = {};
202
273}
274
275async function process_text(dbid, text) {
276 const db_info = await get_notion_db_info(dbid);
277 const processed_message = await client.chat.completions.create({
288}
289
290async function addToNotion(databaseId, text) {
291 databaseId = databaseId.replaceAll("-", "");
292 const properties = await process_text(databaseId, text);
301}
302
303export default async function(req: Request) {
304 if (req.method === "POST") {
305 const content = (await req.formData()).get("content");

add_to_notion_w_aimain.tsx9 matches

@nerdymomocat•Updated 1 year ago
35});
36
37function createPrompt(title, description, properties) {
38 let prompt =
39 "You are processing content into a database. Based on the title of the database, its properties, their types and options, and any existing descriptions, infer appropriate values for the fields:\n";
80}
81
82function processProperties(jsonObject) {
83 const properties = jsonObject.properties;
84 const filteredProps = {};
111}
112
113async function get_and_save_notion_db_processed_properties(databaseId)
114{
115 const response = await notion.databases.retrieve({ database_id: databaseId });
122}
123
124async function get_notion_db_info(databaseId) {
125 databaseId = databaseId.replaceAll("-", "");
126 let db_info = null;
137}
138
139async function get_and_save_notion_db_info(databaseId) {
140 databaseId = databaseId.replaceAll("-", "");
141 let db_info = await get_and_save_notion_db_processed_properties(databaseId);
144}
145
146function createZodSchema(filteredProps) {
147 const schemaObject = {};
148
193}
194
195function convertToNotionProperties(responseValues, filteredProps) {
196 const notionProperties = {};
197
268}
269
270async function process_text(dbid, text) {
271 const db_info = await get_notion_db_info(dbid);
272 const processed_message = await client.chat.completions.create({
283}
284
285async function addToNotion(databaseId, text) {
286 databaseId = databaseId.replaceAll("-", "");
287 const properties = await process_text(databaseId, text);

untitled_roseGuanacomain.tsx1 match

@stevekrouse•Updated 1 year ago
1import { html } from "https://esm.town/v/stevekrouse/html";
2
3export default async function(req: Request): Promise<Response> {
4 // return new Response("<h1>Hello FRC!</h1>", { headers: {
5 // "Content-Type": "text/html"

trendingreposmain.tsx7 matches

@jamesw•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// Helper function to format the date for GitHub API query
4function formatDate(daysAgo: number): string {
5 const date = new Date();
6 date.setDate(date.getDate() - daysAgo);
8}
9
10// Function to fetch top GitHub repositories based on stars and creation date
11async function topGitHubRepos(stars: number, daysAgo: number, timeframeDescription: string) {
12 const date = formatDate(daysAgo);
13 const query = `stars:>${stars} created:>${date}`;
23}
24
25// Function to get combined information for different criteria
26export async function getTopReposByCriteria() {
27 const reposLastWeek = await topGitHubRepos(1000, 7, "Created Last Week"); // Last week, over 1000 stars
28 const reposLastMonth = await topGitHubRepos(3000, 30, "Created Last Month"); // Last month, over 3000 stars
33}
34
35// Call the function to get and print the information
36getTopReposByCriteria().then(console.log);

prune_valmain.tsx1 match

@saolsen•Updated 1 year ago
1export async function prune_val(
2 val_id: string,
3 keep_versions: number[],

manifold_daily_loan_collectormain.tsx1 match

@case•Updated 1 year ago
1export default async function() {
2 const res = await fetch("https://api.manifold.markets/request-loan", {
3 headers: {

untitled_indigoMolluskmain.tsx2 matches

@willthereader•Updated 1 year ago
6import { post_idFetcher } from "https://esm.town/v/willthereader/post_idFetcher";
7
8export async function Sendingemail() {
9 // console.log("Sendingemail function called");
10 try {
11 let lastRunDate = new Date("2023-11-10T19:27:25.547Z");

react_maplibremain.tsx1 match

@hfu•Updated 1 year ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

untitled_beigeLemurmain.tsx1 match

@yuiseki•Updated 1 year ago
20};
21
22export default async function(req: Request) {
23 return new Response(
24 renderToString(

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.