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=1370&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 17279 results for "function"(2692ms)

twitterSearchmain.tsx1 match

@danielgmason•Updated 9 months ago
3import { twitterUser } from "https://esm.town/v/stevekrouse/twitterUser";
4
5export async function twitterSearch({
6 query,
7 start_time,

honoWithUnkeyRateLimitingmain.tsx1 match

@dthyresson•Updated 9 months ago
4import type { Context, MiddlewareHandler } from "npm:hono";
5
6export function unkeyRatelimitMiddleware(config: RatelimitConfig): MiddlewareHandler {
7 const ratelimiter = new Ratelimit(config);
8

valleGetValsContextWindowmain.tsx7 matches

@janpaul123•Updated 9 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 {

githubActivityReportmain.tsx1 match

@elliotbraem•Updated 9 months ago
1import { parse } from "npm:parse-github-event";
2
3export default async function(req: Request): Promise<Response> {
4 const url = new URL(req.url);
5 const userName = url.searchParams.get("userName");

switchbotmain.tsx2 matches

@stevekrouse•Updated 9 months ago
18const ValTownOfficeDeviceId = "CD6F3A810848";
19
20async function switchbotRequest(path, args) {
21 const token = Deno.env.get("SWITCHBOT_TOKEN");
22 const secret = Deno.env.get("SWITCHBOT_KEY");
42}
43
44function botPress(device) {
45 return switchbotRequest(`v1.1/devices/${device}/commands`, {
46 method: "POST",

switchbotmain.tsx2 matches

@stevekrouse•Updated 9 months ago
18const ValTownOfficeDeviceId = "CD6F3A810848";
19
20async function switchbotRequest(path, args) {
21 const token = Deno.env.get("SWITCHBOT_TOKEN");
22 const secret = Deno.env.get("SWITCHBOT_KEY");
42}
43
44function botPress(device) {
45 return switchbotRequest(`v1.1/devices/${device}/commands`, {
46 method: "POST",

bbrunmain.tsx2 matches

@dglazkov•Updated 9 months ago
2
3/**
4 * You can supply these options as a second argument to the `proxy` function.
5 * These options are used to configure the frontend.
6 */
135
136export const proxy = (url: string, options?: FrontendOptions) => {
137 return async function(req: Request): Promise<Response> {
138 if (req.method === "GET") {
139 return renderFrontend(url, options);
1export default async function (e: Email) {
2
3}

bbrunREADME.md1 match

@dglazkov•Updated 9 months ago
13must contain your board server API key.
14
15To use, create an HTTP val, then import the `proxy` function from this script and call it like this:
16
17```ts

animemain.tsx3 matches

@tempguy•Updated 9 months ago
125 let streams = []
126
127 function initPlayer() {
128 const video = document.querySelector("media-player");
129 const serverContainer = document.querySelector("#server-select");
142 }
143
144 function loadServer(val) {
145 const player = document.querySelector("media-player");
146 player.src = val
210 `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Video Player</title><style>html,body{color:#DDD;background:#090909;font-family:sans-serif;}#video-player{width:100%;max-width:800px;margin:0 auto;}#video-controls{text-align:center;margin-top:10px;}</style></head><body onload=loadVideo(0)><div id="video-player"><p>Playing ${metaData.title}</p><video id="video" controls width="100%"></video><div id="video-controls">${controls}</div><center><p style="color:#555">A Very Fast Anime Embed, No Ads, No Tracking, Completely Free.</p></center></div><script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script><script>const videoElement=document.getElementById('video');const videoData=${
211 JSON.stringify(results)
212 };function loadVideo(index){const videoStream=videoData[index].stream[0];const quality=videoStream.qualities.unknown;const url=quality.url;if(quality.type==='m3u8'){if(Hls.isSupported()){const hls=new Hls();hls.loadSource(url);hls.attachMedia(videoElement);}else if(videoElement.canPlayType('application/vnd.apple.mpegurl')){videoElement.src=url;}}else if(quality.type==='mp4'){videoElement.src=url;}videoElement.load();videoElement.play();}</script></body></html>`,
213 );
214});

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",