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=1325&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 18322 results for "function"(1360ms)

statusmain.tsx3 matches

@sophie•Updated 5 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",

labLoginUpdateStatusmain.tsx1 match

@svenlaa•Updated 5 months ago
3import { sqlite } from "https://esm.town/v/std/sqlite";
4
5export default async function(req: Request): Promise<Response> {
6 const TABLE_NAME = "lab_login_users_with_times";
7 const body = await req.json();

labLoginDeleteAccountmain.tsx1 match

@svenlaa•Updated 5 months ago
2import { sqlite } from "https://esm.town/v/std/sqlite";
3
4export default async function(req: Request): Promise<Response> {
5 const TABLE_NAME = "lab_login_users_with_times";
6 const body = await req.json();

CDS_Countermain.tsx9 matches

@toowired•Updated 5 months ago
33let model;
34
35async function loadModel() {
36 model = await cocoSsd.load();
37}
39loadModel();
40
41self.onmessage = async function(e) {
42 if (!model) {
43 await loadModel();
56const worker = new Worker(workerUrl);
57
58export default async function server(request: Request): Promise<Response> {
59 if (request.method === "POST") {
60 try {
139}
140
141// Helper function to map detected objects to acceptable container types
142function mapToAcceptableContainer(detectedClass) {
143 const lowerClass = detectedClass.toLowerCase();
144 if (lowerClass.includes("bottle")) return "plastic bottle";
149}
150
151// Cleanup function to revoke the worker URL when the val is unloaded
152globalThis.addEventListener("unload", () => {
153 URL.revokeObjectURL(workerUrl);
155
156// Implementation of sendNotification
157async function sendNotification(message) {
158 try {
159 // Using Val Town's email functionality:
160 await email.send({
161 to: 'your_email@example.com', // Replace with your email
172
173// Implementation of logDetection
174async function logDetection(containers) {
175 try {
176 const timestamp = new Date().toISOString();

rss_feed_ai_analysismain.tsx3 matches

@vip•Updated 5 months ago
28}
29
30function App() {
31 const [keys, setKeys] = useState<string[]>([]);
32 const [selectedFeed, setSelectedFeed] = useState<RSSFeed | null>(null);
143}
144
145function client() {
146 createRoot(document.getElementById("root")).render(<App />);
147}
151}
152
153export default async function server(request: Request): Promise<Response> {
154 const { blob } = await import("https://esm.town/v/std/blob");
155 const url = new URL(request.url);

LSDisolatedCodemain.tsx1 match

@willthereader•Updated 5 months ago
1export async function extractLinksFromUrl(url) {
2 const query = `SELECT a AS title, a@href AS url FROM ${url} GROUP BY a`;
3 try {

adaptableAmberDonkeymain.tsx7 matches

@Gcoxy•Updated 5 months ago
195};
196
197function PrintableLabel({ label }: { label: LabelResponse['label'] }) {
198 if (!label) return null;
199
240}
241
242function PrintModal({ label, onClose }: { label: LabelResponse['label']; onClose: () => void }) {
243 const printRef = React.useRef<HTMLDivElement>(null);
244
291}
292
293function LandingPage({ onNavigate }: { onNavigate: (page: string) => void }) {
294 return (
295 <Card.Root className="landing-card">
317}
318
319function CSVUploadPage() {
320 const [file, setFile] = React.useState<File | null>(null);
321 const [uploadStatus, setUploadStatus] = React.useState<string | null>(null);
411}
412
413function App() {
414 const [currentPage, setCurrentPage] = React.useState('landing');
415
436}
437
438function client() {
439 createRoot(document.getElementById("root")).render(<App />);
440}
441if (typeof document !== "undefined") { client(); }
442
443export default async function server(request: Request): Promise<Response> {
444 return new Response(`
445 <html>

sqliteExplorerAppREADME.md1 match

@mixer•Updated 5 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

evanescentMagentaThrushmain.tsx1 match

@adagradschool•Updated 5 months ago
1
2 export default function handler(req) {
3 return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n </style>\n </head>\n <body>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">How can we use the capture mark recapture method to estimate bugs in a software</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">I'll create a Python implementation of the capture-mark-recapture method adapted for software bug estimation. This statistical technique, originally used in ecology, can help estimate the total number of bugs in a system.\nSoftware Bug Estimation using Capture-Mark-RecaptureClick to open code\nThis implementation provides a statistical approach to estimating the total number of bugs in a software system. Here's how it works:\n\nTwo independent testing sessions are conducted\nThe Lincoln-Petersen estimator is used to estimate the total number of bugs based on:\n\nNumber of bugs found in first session (n1)\nNumber of bugs found in second session (n2)\nNumber of bugs that were found in both sessions (m2)\n\n\n\nThe formula used is: N = (n1 * n2) / m2\nKey features of the implementation:\n\nIncludes standard error calculation\nProvides confidence intervals\nIncludes simulation capabilities for testing\nHandles edge cases like zero recaptures\n\nTo use this in practice:\n\nTrack bugs found in two separate testing sessions\nRecord which bugs were found in both sessions\nUse the estimator to calculate the likely total number of bugs\n\nWould you like me to explain any part of the implementation in more detail or add additional features like multiple estimation methods?</div>\n </div>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">Explain how it works to me in simple english</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">Let me break down the capture-mark-recapture method in simple terms, using a real-world analogy.\nImagine you're trying to count fish in a large pond, but you can't see all the fish at once. Here's how you'd do it:\n\nFirst Capture (First Testing Session)\n\nYou catch some fish (find some bugs)\nCount how many you caught (let's say 40 bugs)\nMark them (in software, we remember which bugs we found)\nRelease them back (in software, we keep a list)\n\n\nSecond Capture (Second Testing Session)\n\nYou catch fish again (find bugs again in another testing session)\nCount how many you caught this time (let's say 50 bugs)\nCount how many have marks from the first time (overlapping bugs - let's say 20 bugs were found in both sessions)\n\n\nThe Math Behind It\n\nIf you found 20 marked bugs out of 50 total bugs in the second session\nThis means about 40% of the bugs you found were from the first session\nIf 40% of all bugs were from the first session where you found 40 bugs\nThen the total number of bugs can be estimated as: (40 × 50) ÷ 20 = 100 bugs\n\n\n\nThe formula works because:\n\nIf there's a lot of overlap between sessions (many bugs found twice), the total number is probably small\nIf there's little overlap (few bugs found twice), the total number is probably large\n\nFor example:\nCopyFirst session: Found 40 bugs\nSecond session: Found 50 bugs\nOverlapping bugs (found in both): 20 bugs\n\nEstimated total = (40 × 50) ÷ 20 = 100 bugs\nThis means even though we only found maybe 70 unique bugs total (40 + 50 - 20 overlapping), we can estimate there are about 100 bugs total in the system.\nThe method assumes:\n\nThe system isn't changing (no new bugs being introduced)\nEach bug has roughly the same chance of being found\nFinding a bug once doesn't change the chances of finding it again\n\nWould you like me to explain any part of this in more detail?</div>\n </div>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">How did we estimate this?</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">Let me explain the estimation logic step by step, again using simple terms:\n\nBasic Ratio Logic\nThe core idea is based on a proportion. Let's break it down:\n\n\nIf you know there were 40 bugs in your first test\nAnd in your second test, you found that 20 out of 50 bugs were from the first test\nThis means 40% (20/50) of the bugs you found in the second test were from the first test\nTherefore, we can assume that those 40 bugs from the first test represent about 40% of ALL bugs\n\n\nThe Math\nLet's solve this like a simple proportion:\n\nCopyIf 20 overlapping bugs are 40% of first session (40 bugs)\nThen 40 bugs must be 40% of total bugs\n\nTo find 100%: (40 × 50) ÷ 20 = 100 bugs\nLet's verify this makes sense:\n\nIf there really are 100 bugs total, and you found 40 in first session\nThen you found 40% of all bugs in first session\nWhen you do second session and find 50 bugs\nYou'd expect about 40% of them (20 bugs) to be from the first session\nAnd that's exactly what happened!\n\n\nReal Example\nLet's say you're testing a program:\n\nCopyFirst test session: \n- You find 30 bugs\n- You document their IDs (like #1, #2, etc.)\n\nSecond test session:\n- You find 40 bugs\n- You check their IDs and see 15 were from first session\n\nCalculation:\nTotal estimated bugs = (30 × 40) ÷ 15 = 80 bugs\nThis means:\n\nEven though you only found 55 unique bugs (30 + 40 - 15 overlapping)\nStatistics suggest there are probably around 80 bugs total\nSo there might be 25 bugs you haven't found yet!\n\nThe formula (n1 × n2) ÷ m2 comes from this where:\n\nn1 = first session count (30)\nn2 = second session count (40)\nm2 = overlapping bugs (15)\n\nThe beauty of this method is that it can give you an estimate of bugs you haven't even found yet. Would you like me to explain how we calculate the confidence intervals to know how reliable this estimate is?</div>\n </div>\n \n </body>\n </html>\n"`, {
4 headers: {
1
2 export default function handler(req) {
3 return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n </style>\n </head>\n <body>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">Tell me about how Buddhism and Hinduism coexisted for a thousand years in India but there's barely any traces of Buddhism left in modern day India. What happened?</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">The decline of Buddhism in India is a complex historical phenomenon that unfolded over several centuries. Let me break down the key factors:\n\nHistorical Coexistence (3rd century BCE - 12th century CE):\n\n\nBuddhism emerged in India around 5th century BCE and initially flourished alongside Hinduism\nUnder Emperor Ashoka (3rd century BCE), Buddhism spread widely across the subcontinent\nMany Hindu kings patronized both religions, building temples and monasteries\n\n\nGradual Decline Factors:\n\nReligious/Philosophical:\n\nBuddhism was gradually absorbed into Hinduism, with Buddha being incorporated as an avatar of Vishnu\nHindu philosophers like Adi Shankara (8th century CE) effectively challenged Buddhist philosophical positions\nMany Buddhist practices and ideas were incorporated into Hindu traditions\n\nSocial/Economic:\n\nBuddhism relied heavily on monastery systems and urban centers for support\nAs trade routes shifted and urban centers declined, monasteries lost patronage\nHinduism's caste system remained deeply entrenched in rural society\nBuddhism had less appeal among rural populations compared to devotional Hindu movements\n\nPolitical:\n\nDecline of Buddhist-supporting dynasties\nIslamic invasions (particularly 12th-13th centuries) destroyed many Buddhist institutions and monasteries\nBuddhist centers of learning like Nalanda were destroyed\nMany Buddhists fled to Nepal, Tibet, and Southeast Asia\n\n\nRegional Survival:\n\n\nBuddhism did survive in some pockets like Ladakh and the Northeast\nIt saw a revival in the 20th century through Dr. Ambedkar's neo-Buddhist movement\nNepal maintained a continuous Buddhist tradition\n\nThe end result wasn't so much a sudden disappearance as a gradual absorption into Hinduism combined with institutional collapse. Many Buddhist concepts and practices were preserved within Hindu traditions, while institutional Buddhism largely shifted to other parts of Asia.\nWould you like me to elaborate on any particular aspect of this historical process?</div>\n </div>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">So was it the Islamic invasions? Why did Hinduism persist then?</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">The Islamic invasions were a significant factor but not the sole reason. Here's why:\n\nDifferent Organizational Structures:\n\n\nBuddhism was centralized around monasteries and universities (like Nalanda, Taxila, Vikramshila)\nThese institutions were obvious targets, and their destruction severely disrupted Buddhist networks\nHinduism was more decentralized with countless local temples, household shrines, and practices\nEven when temples were destroyed, Hindu practices could continue in homes and small communities\n\n\nSocial Integration:\n\n\nBuddhism relied more on urban patronage and trade networks\nHinduism was deeply woven into rural social fabric through:\n\nCaste system\nVillage temples\nFamily traditions\nLocal festivals\nMarriage customs\n\n\nThis made Hinduism more resilient to institutional disruption\n\n\nAdaptability:\n\n\nHinduism had already absorbed many Buddhist elements\nIt could go \"underground\" during periods of persecution\nHindu practices could be maintained privately\nBuddhism required more institutional support for sanghas (monastic communities)\n\n\nGeographic Distribution:\n\n\nBuddhist centers were concentrated in specific regions (especially North India)\nHinduism was more evenly spread across the subcontinent\nSouth India, less affected by invasions, remained strongly Hindu\n\n\nPre-existing Decline:\n\n\nBuddhism was already weakening in India before the Islamic invasions\nMany Buddhists had already converted to Hinduism\nBuddhist patronage had decreased under Hindu dynasties\nPhilosophical challenges from Hindu thinkers had undermined some Buddhist positions\n\nSo while Islamic invasions definitely accelerated Buddhism's decline by destroying its institutional base, Hinduism's survival wasn't just about resisting invasion - it was about having a more resilient, decentralized structure that could weather persecution and maintain continuity through family and village-level practices.\nWould you like me to elaborate on any of these aspects?</div>\n </div>\n \n </body>\n </html>\n"`, {
4 headers: {

getFileEmail4 file matches

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

tuna8 file matches

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