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=1121&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 17978 results for "function"(1358ms)

cordialGoldGerbilmain.tsx11 matches

@h123•Updated 3 months ago
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
170 });
171
172 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173 setLoading(true);
174 setTimeout(() => handleSubmit(promptItem.prompt), 0);
175 }
176
177 async function handleSubmit(e: React.FormEvent | string) {
178 if (typeof e !== "string") {
179 e.preventDefault();
226 }
227
228 function handleVersionChange(direction: "back" | "forward") {
229 const { currentVersionIndex, versions } = versionHistory;
230 if (direction === "back" && currentVersionIndex > 0) {
974);
975
976function client() {
977 const path = window.location.pathname;
978 const root = createRoot(document.getElementById("root")!);
1010}
1011
1012function extractCodeFromFence(text: string): string {
1013 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014 return htmlMatch ? htmlMatch[1].trim() : text;
1015}
1016
1017async function generateCode(prompt: string, currentCode: string) {
1018 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019 if (starterPrompt) {
1060}
1061
1062export default async function cerebras_coder(req: Request): Promise<Response> {
1063 // Dynamic import for SQLite to avoid client-side import
1064 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163 <meta property="og:site_name" content="Cerebras Coder">
1164 <meta property="og:url" content="https://cerebrascoder.com"/>
1165 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

cerebrasTemplatemain.tsx3 matches

@h123•Updated 3 months ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [messages, setMessages] = useState([]);
7 const [input, setInput] = useState("");
71}
72
73function client() {
74 createRoot(document.getElementById("root")).render(<App />);
75}
79}
80
81export default async function server(request: Request): Promise<Response> {
82 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
83 const { messages } = await request.json();

cerebras_codermain.tsx11 matches

@h123•Updated 3 months ago
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
170 });
171
172 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173 setLoading(true);
174 setTimeout(() => handleSubmit(promptItem.prompt), 0);
175 }
176
177 async function handleSubmit(e: React.FormEvent | string) {
178 if (typeof e !== "string") {
179 e.preventDefault();
226 }
227
228 function handleVersionChange(direction: "back" | "forward") {
229 const { currentVersionIndex, versions } = versionHistory;
230 if (direction === "back" && currentVersionIndex > 0) {
974);
975
976function client() {
977 const path = window.location.pathname;
978 const root = createRoot(document.getElementById("root")!);
1010}
1011
1012function extractCodeFromFence(text: string): string {
1013 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014 return htmlMatch ? htmlMatch[1].trim() : text;
1015}
1016
1017async function generateCode(prompt: string, currentCode: string) {
1018 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019 if (starterPrompt) {
1060}
1061
1062export default async function cerebras_coder(req: Request): Promise<Response> {
1063 // Dynamic import for SQLite to avoid client-side import
1064 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163 <meta property="og:site_name" content="Cerebras Coder">
1164 <meta property="og:url" content="https://cerebrascoder.com"/>
1165 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

wordcountermain.tsx2 matches

@charmaine•Updated 3 months ago
112 const twitterCount = document.getElementById('twitterCount');
113
114 function updateCounts() {
115 const encoder = new TextEncoder();
116 const utf8 = new Uint8Array(inputText.value.length * 3);
150 }
151
152 function adjustTextareaHeight() {
153 inputText.style.height = 'auto';
154 inputText.style.height = inputText.scrollHeight + 10 + 'px';

karate_classesmain.tsx10 matches

@stevekrouse•Updated 3 months ago
26});
27
28function App({ email, isAdmin }) {
29 return (
30 <BrowserRouter>
70}
71
72function Home() {
73 return (
74 <div className="text-center">
79}
80
81function Login() {
82 return (
83 <div className="max-w-md mx-auto bg-white rounded-lg shadow-md p-8">
93}
94
95function ClassList({ email }) {
96 const [classes, setClasses] = useState([]);
97
125}
126
127function ClassDetails({ email, isAdmin }) {
128 const { id } = useParams();
129 const [classInfo, setClassInfo] = useState(null);
240}
241
242function Admin() {
243 return (
244 <div>
251}
252
253function ClassForm() {
254 const { id } = useParams();
255 const [formData, setFormData] = useState({
405}
406
407function BulkAddUsers() {
408 const { id } = useParams();
409 const [emails, setEmails] = useState("");
455}
456
457function client() {
458 const root = document.getElementById("root");
459 if (root) {
696});
697
698async function handler(request: Request): Promise<Response> {
699 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
700 const KEY = "karate_classes";

URLReceivermainFunctionTest2 matches

@willthereader•Updated 3 months ago
1import { expect } from "jsr:@std/expect";
2import { checkWebsite } from "./mainFunctionURLReciver2";
3
4console.log("Starting Website Checker Tests");
12];
13
14async function runTests() {
15 console.log("\nTesting valid website URL");
16 let result = await checkWebsite(TEST_URLS[0]);

URLReceiversummaryURLReceiverTest7 matches

@willthereader•Updated 3 months ago
47interface TestCase {
48 description: string;
49 function: Function;
50 expectedBehavior: string;
51}
52
53function logTestInfo(message: string) {
54 console.log(` ${message}`);
55}
59 description: "Initialize generator",
60 expectedBehavior: "Should start with empty state",
61 function: () => {
62 console.log("\nTEST: Initialize generator");
63 console.log("Expected: Should start with no URLs processed\n");
83 description: "Process test URLs",
84 expectedBehavior: "Should identify working and broken URLs",
85 function: () => {
86 console.log("\nTEST: Processing multiple URLs");
87 console.log("Expected: Should correctly identify good and bad URLs\n");
124 description: "Test error handling",
125 expectedBehavior: "Should handle different types of errors",
126 function: () => {
127 console.log("\nTEST: Error handling");
128 console.log("Expected: Should identify and explain different errors\n");
182];
183
184async function runTests() {
185 console.log("Starting test run...\n");
186 let passed = 0;
189 for (const test of tests) {
190 try {
191 await test.function();
192 console.log("\nāœ… TEST PASSED");
193 passed++;

cssmain.tsx2 matches

@flymaster•Updated 3 months ago
1export function getBugCSS() {
2 return `
3 body {
67}
68
69export function getCSS() {
70 return `
71 body {

subtleAmaranthWaspmain.tsx5 matches

@gigmx•Updated 3 months ago
3import React, { useCallback, useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function NewTokenDisplay({ data }) {
6 return (
7 <div className="new-token">
34}
35
36function SubscriptionControl({ type, isConnected, isSubscribed, onSubscribe, onUnsubscribe }) {
37 return (
38 <div className="subscription-control">
47}
48
49function App() {
50 const [messages, setMessages] = useState({
51 newToken: [],
158}
159
160function client() {
161 createRoot(document.getElementById("root")).render(<App />);
162}
166}
167
168export default async function server(req: Request): Promise<Response> {
169 return new Response(
170 `

URLReceiverurlCrawlerTests8 matches

@willthereader•Updated 3 months ago
17 inputs: Record<string, unknown>;
18 expectedBehavior: string;
19 function: Function;
20}
21
27 inputs: {},
28 expectedBehavior: "should return initial progress state",
29 function: () => {
30 crawler.reset();
31 const progress = crawler.getProgress();
41 inputs: { url: TEST_URLS[0] },
42 expectedBehavior: "should not crawl beyond specified depth",
43 function: async (inputs) => {
44 // Create mock URLs with known depths
45 const baseUrl = inputs.url;
105 inputs: { url: TEST_URLS[0] },
106 expectedBehavior: "should only crawl URLs from the same domain",
107 function: async (inputs) => {
108 const result = await crawler.crawl(inputs.url);
109
133 },
134 expectedBehavior: "should normalize URLs consistently",
135 function: async (inputs) => {
136 const results = await Promise.all(
137 inputs.testUrls.map(url => crawler.crawl(url)),
157 },
158 expectedBehavior: "should properly categorize different errors",
159 function: async (inputs) => {
160 const results = await Promise.all(
161 inputs.testUrls.map(url => crawler.crawl(url)),
177];
178
179async function runTests() {
180 console.log("\nStarting enhanced test suite...");
181 let passed = 0;
187
188 try {
189 await test.function(test.inputs);
190 console.log("āœ… Test passed\n");
191 passed++;

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