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=1321&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 16278 results for "function"(1361ms)

sqliteExplorerAppREADME.md1 match

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

pinkEgretmain.tsx1 match

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

stitchValmain.tsx9 matches

@yawnxyz•Updated 9 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
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
41
42// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
46
83 const writer = writable.getWriter();
84 const textEncoder = new TextEncoder();
85 function write(text) {
86 writer.write(textEncoder.encode(text));
87 }
149 </div>
150 <script>
151 function updateValName(valName) {
152 const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
153 const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
157 document.getElementById('open-link').href = previewUrl;
158 }
159 function saveVal() {
160 if (window.codeMirrorEditor) {
161 document.getElementById("save-icon").classList.remove("hidden");
177 return false;
178 })
179 function openTab(tab) {
180 const tabButtonCode = document.getElementById("tab-button-code");
181 const tabButtonPreview = document.getElementById("tab-button-preview");
197 }
198 }
199 function toggleTab() {
200 openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
201 }
255 (() => {
256 const scrollingElement = document.getElementById("conversation-container");
257 const callback = function (mutationsList, observer) {
258 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
259 };
328 window.setCodeMirrorContent({ doc: '', old: ''});
329 let fullStr = "";
330 window.addToken = function(str) {
331 fullStr += str;
332 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
41
42// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
46
84 const writer = writable.getWriter();
85 const textEncoder = new TextEncoder();
86 function write(text) {
87 writer.write(textEncoder.encode(text));
88 }
164 </div>
165 <script>
166 function updateValName(valName) {
167 const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
168 const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
172 document.getElementById('open-link').href = previewUrl;
173 }
174 function saveVal() {
175 if (window.codeMirrorEditor) {
176 document.getElementById("save-icon").classList.remove("hidden");
192 return false;
193 })
194 function openTab(tab) {
195 const tabButtonCode = document.getElementById("tab-button-code");
196 const tabButtonPreview = document.getElementById("tab-button-preview");
212 }
213 }
214 function toggleTab() {
215 openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
216 }
270 (() => {
271 const scrollingElement = document.getElementById("conversation-container");
272 const callback = function (mutationsList, observer) {
273 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
274 };
343 window.setCodeMirrorContent({ doc: '', old: ''});
344 let fullStr = "";
345 window.addToken = function(str) {
346 fullStr += str;
347 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
31the simplest way to achieve the goal, though you can add some inline comments to explain your
32reasoning (not for every line, but for major groups of lines). Don't use any environment variables
33unless strictly necessary, for example use APIs that don't require a key, prefer internal function
34imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
35functions where possible. Unless specified, don't add error handling,
36make sure that errors bubble up to the caller.
37There should be no comments like "more content here", it should be complete and directly runnable.
38The val should create a "export default async function main" which is the main function that gets
39executed on every HTTP request.
40`.replace("\n", " ");
41
42// Your response should start with \`\`\`ts and end with \`\`\`.
43// The val should create a "export default async function main() {" which
44// is the main function that gets executed, without any arguments. Don't return a Response object,
45// just return a plain Javascript object, array, or string.
46
83 const writer = writable.getWriter();
84 const textEncoder = new TextEncoder();
85 function write(text) {
86 writer.write(textEncoder.encode(text));
87 }
174 </div>
175 <script>
176 function updateValName(valName) {
177 const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
178 const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
182 document.getElementById('open-link').href = previewUrl;
183 }
184 function saveVal() {
185 if (window.codeMirrorEditor) {
186 document.getElementById("save-icon").classList.remove("hidden");
202 return false;
203 })
204 function openTab(tab) {
205 const tabButtonCode = document.getElementById("tab-button-code");
206 const tabButtonPreview = document.getElementById("tab-button-preview");
222 }
223 }
224 function toggleTab() {
225 openTab(document.getElementById("tab-panel-code").style.visibility === "visible" ? "preview" : "code");
226 }
280 (() => {
281 const scrollingElement = document.getElementById("conversation-container");
282 const callback = function (mutationsList, observer) {
283 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "smooth" });
284 };
32the simplest way to achieve the goal, though you can add some inline comments to explain your
33reasoning (not for every line, but for major groups of lines). Don't use any environment variables
34unless strictly necessary, for example use APIs that don't require a key, prefer internal function
35imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
36functions where possible. Unless specified, don't add error handling,
37make sure that errors bubble up to the caller.
38There should be no comments like "more content here", it should be complete and directly runnable.
39The val should create a "export default async function main() {" which
40is the main function that gets executed on every HTTP request.
41`.replace("\n", " ");
42
79 const writer = writable.getWriter();
80 const textEncoder = new TextEncoder();
81 function write(text) {
82 writer.write(textEncoder.encode(text));
83 }
143 </div>
144 <script>
145 function updateValName(valName) {
146 const valUrl = valName ? \`https://val.town/v/${username}/\${valName}\` : "";
147 const previewUrl = valName ? \`https://${username}-\${valName}.web.val.run\` : "";
151 document.getElementById('open-link').href = previewUrl;
152 }
153 function saveVal() {
154 if (window.codeMirrorEditor) {
155 document.getElementById("save-icon").classList.remove("hidden");
171 return false;
172 })
173 function openTab(tab) {
174 const tabButtonCode = document.getElementById("tab-button-code");
175 const tabButtonPreview = document.getElementById("tab-button-preview");
191 }
192 }
193 function toggleTab() {
194 openTab(document.getElementById("tab-panel-code").classList.contains("hidden") ? "code" : "preview");
195 }
250 (() => {
251 const scrollingElement = document.getElementById("conversation-container");
252 const callback = function (mutationsList, observer) {
253 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
254 };
322 window.setCodeMirrorContent({ doc: '', old: ''});
323 let fullStr = "";
324 window.addToken = function(str) {
325 fullStr += str;
326 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");

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": "*",