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/image-url.jpg?q=function&page=2486&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 28846 results for "function"(6496ms)

stiffCoffeeLampreyREADME.md1 match

@maxm•Updated 9 months ago
11import { email } from "https://esm.town/v/std/email?v=13";
12
13export default async function (interval: Interval) {
14 const bookingInfo = await resyBot( {
15 slug: 'amaro-bar',

resyBotREADME.md1 match

@maxm•Updated 9 months ago
11import { email } from "https://esm.town/v/std/email?v=13";
12
13export default async function (interval: Interval) {
14 const bookingInfo = await resyBot( {
15 slug: 'amaro-bar',

frozenSapphireIguanamain.tsx9 matches

@rochambeau314•Updated 9 months ago
8import { createRoot } from "https://esm.sh/react-dom/client";
9
10function App() {
11 const [origin, setOrigin] = useState("");
12 const [results, setResults] = useState([]);
237}
238
239function client() {
240 createRoot(document.getElementById("root")).render(<App />);
241}
245}
246
247export default async function server(request: Request): Promise<Response> {
248 console.log("Received request:", request.url);
249 const url = new URL(request.url);
373 });
374 } catch (error) {
375 console.error("Error in server function:", error);
376 return new Response(JSON.stringify({ error: "An error occurred while calculating travel times", details: error.message }), {
377 headers: { "Content-Type": "application/json" },
397}
398
399async function findNearest(origin: string, locations: any[], apiKey: string): Promise<any> {
400 console.log(`Finding nearest location among ${locations.length} options`);
401 const batchSize = 25; // Google Maps API typically allows up to 25 destinations per request
439}
440
441async function getDrivingTime(origin: string, destination: string, apiKey: string, arrivalTime?: string, arrivalDay?: string): Promise<string> {
442 let directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${encodeURIComponent(origin)}&destination=${encodeURIComponent(destination)}&mode=driving&key=${apiKey}`;
443
460}
461
462async function getTransitTime(origin: string, destination: string, apiKey: string): Promise<string> {
463 const directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${encodeURIComponent(origin)}&destination=${encodeURIComponent(destination)}&mode=transit&key=${apiKey}`;
464
475}
476
477async function getZipCode(address: string, apiKey: string): Promise<string> {
478 const geocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(address)}&key=${apiKey}`;
479 const response = await fetch(geocodeUrl);
490}
491
492function getNextDayOfWeek(date: Date, dayOfWeek: string): Date {
493 const days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
494 const targetDay = days.indexOf(dayOfWeek.toLowerCase());

grievingYellowAspmain.tsx3 matches

@stevekrouse•Updated 9 months ago
6import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
7
8// Utility functions
9const performSingleRequest = async (url) => {
10 const start = performance.now();
46};
47
48// Helper function to safely format numbers
49const safeToFixed = (number, decimalPlaces) => {
50 return number !== undefined && number !== null
286}
287
288export default async function(req: Request): Promise<Response> {
289 const stream = await renderToReadableStream(<App />, { bootstrapModules: [import.meta.url] });
290 return new Response(stream, { headers: { "content-type": "text/html" } });

checkHackerNewsForPatreonmain.tsx2 matches

@mikker•Updated 9 months ago
9const TABLE_NAME = `${KEY}_notified_stories`;
10
11async function initializeDatabase() {
12 await sqlite.execute(`
13 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
19}
20
21async function checkHackerNewsForPatreon() {
22 await initializeDatabase();
23

serveUtilsmain.tsx4 matches

@g•Updated 9 months ago
1export function getFunctionComment(fn) {
2 try {
3 return fn.toString().match(/\/\*\s*(.+)\s*\*\//s)[1];
4 } catch (err) {
5 console.error(`Failed to get function comment: ${err.message}\n${fn.toString()}`);
6 throw err;
7 }
8}
9
10export function serve(fn, contentType = 'text/plain') {
11 return (ctx) => {
12 return new Response(getFunctionComment(fn), {
13 headers: {
14 'Content-Type': contentType,

timeZoneCompareToolmain.tsx6 matches

@paulkinlan•Updated 9 months ago
16];
17
18// Helper function to group timezones by country
19function groupTimezonesByCountry(timezones) {
20 return timezones.reduce((acc, zone) => {
21 const [continent, ...rest] = zone.split('/');
62];
63
64function TimezoneSelect({ onSelect }) {
65 const [selectedZone, setSelectedZone] = useState("");
66 const groupedTimezones = useMemo(() => groupTimezonesByCountry(DateTime.ZONE_NAMES || []), []);
101}
102
103function App({ initialTime }: { initialTime: string }) {
104 const [currentTime, setCurrentTime] = useState(DateTime.now());
105 const [userTimezone, setUserTimezone] = useState("");
163}
164
165function TimezoneRow({ zone, currentTime }: { zone: string; currentTime: DateTime }) {
166 const localTime = currentTime.setZone(zone || 'UTC');
167 const offset = localTime.offset / 60;
192}
193
194async function server(request: Request): Promise<Response> {
195 try {
196 // Set CORS headers

multipleBronzeCaterpillarmain.tsx1 match

@tbsvttr•Updated 9 months ago
1import { email } from "https://esm.town/v/std/email";
2
3export default async function handler(request: Request) {
4 if (request.method !== "POST") {
5 return Response.json({ message: "This val responds to POST requests." }, {

add_to_notion_w_aimain.tsx9 matches

@junhoca•Updated 9 months 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);

chatWithCerebrasmain.tsx3 matches

@lazyplatypus•Updated 9 months ago
5
6const MODELS = ["llama3.1-8b", "llama3.1-70b"];
7function App() {
8 const [messages, setMessages] = useState<Array<{ role: string; content: string }>>([]);
9 const [edits, setEdits] = useState<Array<{ id: number; content: string }>>(
128}
129
130function client() {
131 createRoot(document.getElementById("root")).render(<App />);
132}
136}
137
138async function server(request: Request): Promise<Response> {
139 if (request.method === "POST" && new URL(request.url).pathname === "/api/chat") {
140 const { messages, model } = await request.json();
tuna

tuna9 file matches

@jxnblk•Updated 4 hours ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.