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=2510&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 29089 results for "function"(1730ms)

browserbaseUtilsmain.tsx2 matches

@browserbase•Updated 9 months ago
5}
6
7export async function loadPageContent(url: string, options: LoadPageContentOptions = { textContent: false }) {
8 const browser = await puppeteer.connect({
9 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
33}
34
35export async function screenshotPage(url: string, options: ScreenshotPageOptions = { fullPage: true }) {
36 const browser = await puppeteer.connect({
37 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,

websiteChangeDetectionToolmain.tsx1 match

@browserbase•Updated 9 months ago
2import { email } from "https://esm.town/v/std/email?v=12";
3
4export default async function(interval: Interval) {
5 const bbLandingChanged = await hasWebsiteChanged("https://www.browserbase.com");
6 console.log("bbLandingChanged", bbLandingChanged);

sqliteExplorerAppREADME.md1 match

@peterhartree•Updated 9 months ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query

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
tuna

tuna9 file matches

@jxnblk•Updated 23 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.