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/$%7Bart_info.art.src%7D?q=function&page=1617&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 19302 results for "function"(3182ms)

notifymain.tsx1 match

@hlobil•Updated 10 months ago
2import process from "node:process";
3
4export async function notify(request: Request) {
5 if (request.method === "OPTIONS") {
6 return new Response("", {

staticChessREADME.md1 match

@injoon5•Updated 10 months ago
9Plain, brutalist, no bloat chess. Every page is only html and css. Every chess move is made by clicking a link. Send a link to your friend and they'll send you one back to make your move. No silly animations or slick interactivity to trip up your gameplay. When Google indexes this site will we successfully compute all possible chess moves?
10
11Functionality is quite limited, and things might be broken. Please let me know if you find bugs!
12
13Inspired by [this HN discussion](https://news.ycombinator.com/item?id=39456467) about sites that have all possible game states of tic-tac-toe.

sqliteExplorerAppREADME.md1 match

@willthereader•Updated 10 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

pubmedmain.tsx2 matches

@yawnxyz•Updated 10 months ago
8
9
10// PubMed search function (modified to accept more parameters)
11async function pubmedSearch(query, userId, additionalParams = {}) {
12 const url = 'https://www.pubmedisearch.com/api/fetch_articles';
13 const options = {

statusmain.tsx3 matches

@pomdtr•Updated 10 months ago
5import { renderToString } from "npm:react-dom/server";
6
7function StatusRow({ rows }) {
8 return (
9 <div className="w-full flex flex-col space-y-2">
28}
29
30function StatusSection({ url, rows }) {
31 const sectionRows = rows.filter(row => row[0] === url);
32 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
45
46export default async function(req: Request): Promise<Response> {
47 const { rows } = await sqlite.execute(
48 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",

honoJsPyodidemain.tsx3 matches

@tfayyaz•Updated 10 months ago
35 const code = document.getElementById("code");
36
37 function addToOutput(s) {
38 console.log(code.value)
39 console.log(s)
43 output.value = "Initializing...\\n";
44 // init Pyodide
45 async function main() {
46 let pyodide = await loadPyodide();
47 await pyodide.loadPackage("micropip");
54 let pyodideReadyPromise = main();
55
56 async function evaluatePython() {
57 let pyodide = await pyodideReadyPromise;
58 try {

fuchsiaMosquitomain.tsx1 match

@akalanala•Updated 10 months ago
10type Email = z.infer<typeof Email>;
11
12export default async function sendEmail(req: Request): Promise<Response> {
13 const pwd = Deno.env.get("gmail_cpeng_pwd");
14 if (!pwd) {

generateQRmain.tsx1 match

@neverstew•Updated 10 months ago
1import { qrcode } from "https://deno.land/x/qrcode/mod.ts";
2
3export async function generateQR(req: Request) {
4 let url: URL;
5 try {

ivoryGiraffemain.tsx1 match

@eczajk•Updated 10 months ago
2import { default as ical } from "npm:ical-generator";
3
4export default async function(req: Request): Promise<Response> {
5 const url = `https://api.phish.net/v5/shows/artist/phish.json?order_by=showdate&direction=desc&apikey=${
6 Deno.env.get("PHISH_NET_API_KEY")

getValsContextWindowmain.tsx7 matches

@janpaul123•Updated 10 months ago
4const cacheBlobKey = "getValsContextWindowCache3";
5
6export default async function getValsContextWindow(model: any) {
7 const fullCacheBlobKey = `${cacheBlobKey}-${model}`;
8 const cached = await blob.getJSON(fullCacheBlobKey);
194 import { render } from "npm:preact-render-to-string";
195
196 export default async function(req: Request) {
197 return new Response(
198 render(
223 const FLAT_TEMPLATES = sections.flatMap((section) => section.templates);
224
225 function tsResponse(code) {
226 return "```ts\n" + code + "\n```";
227 }
394 ### Utilities
395
396 Our Blob SDK also includes some utility functions to make working with blobs easier.
397
398 ##### Copy
432 role: "assistant",
433 content:
434 "\n```ts\nexport default async function (req: Request): Promise<Response> {\n return Response.json(\"Hello world\")\n}\n```",
435 },
436 {
441 role: "assistant",
442 content:
443 "\n```ts\nexport default async function(req: Request): Promise<Response> {\n const query = new URL(req.url).searchParams;\n\n // Read name from the querystring or body. Defaults to \"you\" if not present.\n const name = query.get(\"name\") || (await req.json().catch(() => ({}))).name || \"you\";\n\n // Returns the HTML response\n return new Response(`<h1>Hi ${name}!</h1>`, {\n headers: { \"Content-Type\": \"text/html\" },\n });\n}\n```",
444 },
445 {
458 role: "assistant",
459 content:
460 "```ts\nexport default async function(req: Request): Promise<Response> {\n const apiKey = Deno.env.get(\"METEO_KEY\");\n const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m&current_weather=true&apikey=${apiKey}`;\n\n const response = await fetch(apiUrl);\n const weatherData = await response.json();\n\n return new Response(JSON.stringify(weatherData), { headers: { \"Content-Type\": \"application/json\" } });\n}\n```",
461 },
462 {

getFileEmail4 file matches

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

tuna8 file matches

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