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/$%7Bsuccess?q=function&page=1684&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 20274 results for "function"(2912ms)

violetFerretmain.tsx1 match

@tempguy•Updated 10 months ago
1import { blob } from "https://esm.town/v/std/blob?v=12";
2export default async function(interval: Interval) {
3 await fetch("https://tempguy-scarletsole.web.val.run/refresh");
4 const date = new Date();

fizzFussmain.tsx1 match

@iamseeley•Updated 10 months ago
82
83// FizzBuzz Microservice
84export default async function(req) {
85 Logger.log("FizzBuzz request received");
86 const startTime = PerformanceTracker.start();

beigeMandrillmain.tsx1 match

@iamseeley•Updated 10 months ago
1export default async function (req: Request): Promise<Response> {
2 const { searchParams } = new URL(req.url);
3

upgradeHTTPPreviewValsmain.tsx4 matches

@stevekrouse•Updated 10 months ago
3import OpenAI from "npm:openai";
4
5async function getVals(username, type, limit) {
6 const res = await db.execute({
7 sql: `
21}
22
23async function checkHTTPPreviewUpgrade(code) {
24 const openai = new OpenAI();
25 const completion = await openai.chat.completions.create({
53 content: `const number = Math.random();
54
55 export default function(req: Request) {
56 return Response.json(number);
57 }`,
80
81/* This example will return the contents of a documentID passed in as the path as JSON. */
82export default async function(req: Request): Promise<Response> {
83 const docId = new URL(req.url).pathname.substring(1);
84

upgradeHTTPPreviewValsREADME.md5 matches

@stevekrouse•Updated 10 months ago
16 "name": "harlequinChickadee",
17 "probabilityUpgradeNeeded": true,
18 "reason": "The current code structure has several functions and program logic outside the main handler, including word selection, game state management, and SVG generation. These parts would not re-run with the new runtime, potentially affecting functionality. They need to be moved inside the handler to ensure consistent behavior across requests."
19 },
20 {
31 "name": "untitled_pinkRoundworm",
32 "probabilityUpgradeNeeded": true,
33 "reason": "The functions `addComment` and `getComments` as well as the initialization \nof the KEY variable perform actions that are intended to be run per request. These need to be moved \ninside the relevant HTTP handler to ensure the behavior remains consistent in the new runtime."
34 },
35 {
46 "name": "untitled_maroonSwallow",
47 "probabilityUpgradeNeeded": false,
48 "reason": "All the code, including the check for authentication,\n is inside the handler function. This means the behavior will stay \n the same with the new runtime."
49 },
50 {
51 "name": "wikiOG",
52 "probabilityUpgradeNeeded": true,
53 "reason": "The function `getWikipediaInfo` defined outside of the handler makes network requests and processes data for each request. In the new runtime, this function would only be executed once and cached. To ensure the same behavior in the new runtime, this function should be moved into the handler."
54 },
55 {
61 "name": "discordEventReceiver",
62 "probabilityUpgradeNeeded": false,
63 "reason": "All the relevant code for handling requests and logging input is inside the handler.\n No code needs to be moved for the new runtime to function correctly."
64 }
65]

sqliteExplorerAppREADME.md1 match

@alongwill•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

pinkEgretmain.tsx1 match

@maxm•Updated 10 months ago
1// import { Request, Response } from "./node_modules/express/index.js";
2export default async function(req: Request): Promise<Response> {
3 console.log("Request received:", req);
4

stitchValmain.tsx9 matches

@smca•Updated 10 months ago
89 <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
90 <script>
91 document.addEventListener('DOMContentLoaded', function () {
92 if (typeof THREE === 'undefined') {
93 console.error('THREE is not defined. Make sure Three.js is loaded correctly.');
106 const debugElement = document.getElementById('debug');
107
108 function createTextureCanvas() {
109 const canvas = document.createElement('canvas');
110 const ctx = canvas.getContext('2d');
130 }
131
132 function init() {
133 scene = new THREE.Scene();
134 camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
163 }
164
165 function onMouseMove(event) {
166 currentPoint.set(event.clientX, window.innerHeight - event.clientY);
167 if (isPressed) {
172 }
173
174 function onMouseDown(event) {
175 isPressed = true;
176 clickPoint.set(event.clientX, window.innerHeight - event.clientY);
181 }
182
183 function onMouseUp() {
184 isPressed = false;
185 }
186
187 function updateUniforms() {
188 if (material) {
189 material.uniforms.uClickPoint.value = clickPoint;
194 }
195
196 function onWindowResize() {
197 const width = window.innerWidth;
198 const height = window.innerHeight;
204 }
205
206 function animate() {
207 requestAnimationFrame(animate);
208

SagaImmoScrapermain.tsx2 matches

@matthiasraimann•Updated 10 months ago
3import { JSDOM } from "npm:jsdom";
4
5export async function scrapeSAGA(
6 areas: Area[],
7 maxPrice: number,
59}
60
61function parsePriceToNumber(priceString: string): number {
62 const val = +priceString.replace(/[^0-9,]/g, "").replace(",", ".");
63 return isNaN(val) ? 0 : val;

videoStoragemain.tsx6 matches

@mux•Updated 10 months ago
22)`);
23
24export function rowObjects(data) {
25 return data.rows.map(row => {
26 return data.columns.reduce((obj, column, index) => {
37}
38
39export async function createVideo(webhook: Mux.Webhooks.VideoUploadCreatedWebhookEvent) {
40 const {
41 environment,
65}
66
67export async function updateVideoCreated(webhook: Mux.Webhooks.VideoUploadAssetCreatedWebhookEvent) {
68 const sql = `
69 UPDATE videos
89
90// Just returns the sql statement itself so that we can use `batch` in our backfill script.
91export function backfillVideo(asset: Mux.Video.Asset) {
92 const sql = `
93 INSERT OR IGNORE INTO videos (
156// This is just an upsert in case somehow we get an asset created webhook from something other
157// than our direct upload process.
158export async function updateVideoReady(webhook: Mux.Webhooks.VideoAssetReadyWebhookEvent) {
159 const sql = `
160 INSERT INTO videos (
243}
244
245export async function getAllVideos() {
246 const data = await sqlite.execute(`select * from videos`);
247

getFileEmail4 file matches

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