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%20%22Image%20title%22?q=function&page=2417&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 28333 results for "function"(2063ms)

bikeInventorymain.tsx7 matches

@all•Updated 8 months ago
6const APP_ID = "5518c0f9-481c-4aa8-85cd-eee42bd45319";
7
8function BikeWindow({ bike, onSave, onClose, title }) {
9 const [brand, setBrand] = useState(bike?.brand || "");
10 const [model, setModel] = useState(bike?.model || "");
112}
113
114function App() {
115 const [bikes, setBikes] = useState([]);
116 const [error, setError] = useState(null);
315}
316
317function client() {
318 console.log("Client function called");
319 const root = document.getElementById("root");
320 if (root) {
327
328if (typeof document !== "undefined") {
329 console.log("Document is defined, calling client function");
330 client();
331} else {
333}
334
335async function server(request: Request): Promise<Response> {
336 console.log("Server function called");
337 return new Response(
338 `

sqliteExplorerAppREADME.md1 match

@flymaster•Updated 8 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

opensourcepledgeRedirectmain.tsx1 match

@vladh•Updated 8 months ago
1export default function(req: Request) {
2 const url = new URL(req.url);
3 const newUrl = "https://opensourcepledge.com" + url.pathname + url.search;

design32x32bitmapmain.tsx5 matches

@chekos•Updated 8 months ago
28};
29
30function generateName(pattern: string): string {
31 return pattern.replace(/<(\w+)>/g, (match, p1) => {
32 switch (p1) {
189const Pixel = ({ active }) => <div className={`pixel ${active ? "active" : ""}`} />;
190
191function App() {
192 const [size, setSize] = useState<{ width: number; height: number }>(DEFAULT_SIZE);
193 const [pixels, setPixels] = useState<boolean[]>(() =>
431}
432
433function client() {
434 try {
435 const root = createRoot(document.getElementById("root"));
452}
453
454async function server(request: Request): Promise<Response> {
455 return new Response(
456 `
467 <div id="root"></div>
468 <script>
469 window.onerror = function(message, source, lineno, colno, error) {
470 console.error("Global error caught:", message, "at", source, ":", lineno, ":", colno);
471 console.error("Error object:", error);

zestyJadeReptilemain.tsx1 match

@dm3agv•Updated 8 months ago
3import process from "node:process";
4
5export async function serverlessMatrixEchoBot(
6 req: express.Request,
7 res: express.Response,

capturePostHogEventmain.tsx1 match

@ianvph•Updated 8 months ago
1export async function capturePostHogEvent(
2 key: string,
3 distinct_id: string,

peculiarTanMouseREADME.md1 match

@jamisonl•Updated 8 months ago
1Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality

calculateTransitTimeValmain.tsx9 matches

@rochambeau314•Updated 8 months ago
8import { createRoot } from "https://esm.sh/react-dom/client";
9
10function App() {
11 const [origin, setOrigin] = useState("");
12 const [results, setResults] = useState([]);
149}
150
151function client() {
152 createRoot(document.getElementById("root")).render(<App />);
153}
157}
158
159export default async function server(request: Request): Promise<Response> {
160 console.log("Received request:", request.url);
161 const url = new URL(request.url);
285 });
286 } catch (error) {
287 console.error("Error in server function:", error);
288 return new Response(
289 JSON.stringify({ error: "An error occurred while calculating travel times", details: error.message }),
315}
316
317async function findNearest(origin: string, locations: any[], apiKey: string): Promise<any> {
318 console.log(`Finding nearest location among ${locations.length} options`);
319 const batchSize = 25; // Google Maps API typically allows up to 25 destinations per request
359}
360
361async function getDrivingTime(
362 origin: string,
363 destination: string,
388}
389
390async function getTransitTime(origin: string, destination: string, apiKey: string): Promise<string> {
391 const directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${
392 encodeURIComponent(origin)
405}
406
407async function getZipCode(address: string, apiKey: string): Promise<string> {
408 const geocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${
409 encodeURIComponent(address)
422}
423
424function getNextDayOfWeek(date: Date, dayOfWeek: string): Date {
425 const days = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
426 const targetDay = days.indexOf(dayOfWeek.toLowerCase());

free_open_routermain.tsx7 matches

@taras•Updated 8 months ago
59}
60
61// Factory function to create the appropriate KV instance
62export function createKV(): KV {
63 return isValTown ? new ValTownKV() : new DenoDeployKV();
64}
66const kv = createKV();
67
68function err(msg): Response {
69 return new Response(
70 JSON.stringify({
84}
85
86function isFreeModel(model: any) {
87 if (model.id.endsWith(":free")) {
88 return true;
98}
99
100function getModelValue(modelId: string): int {
101 const preferences = [
102 [/70b-versatile/],
132}
133
134async function listFreeModels(req: Request) {
135 // Get the current timestamp
136 const timestamp = Date.now();
227}
228
229export default async function(req: Request): Promise<Response> {
230 const url = new URL(req.url);
231 const pathname = url.pathname;

celinewaitlistmain.tsx1 match

@mbo•Updated 8 months ago
5 */
6
7async function server(request: Request): Promise<Response> {
8 const { blob } = await import("https://esm.town/v/std/blob");
9 const KEY = "celinewaitlist";

getFileEmail4 file matches

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

tuna8 file matches

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