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=1164&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 17970 results for "function"(1806ms)

brilliantChocolateElkmain.tsx11 matches

@sh66n•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">

cerebras_codermain.tsx11 matches

@sh66n•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">

cerebras_codermain.tsx11 matches

@nopatad188•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">

routineTrackerAppmain.tsx5 matches

@ashryanio•Updated 3 months ago
34};
35
36// Simple hash function for the password
37const simpleHash = (str) => {
38 let hash = 0;
143};
144
145function App({ tasks }) {
146 const [completedTasks, setCompletedTasks] = useState([]);
147 const [timerStates, setTimerStates] = useState(tasks.map(task => ({
162 };
163
164 function fire(particleRatio, opts) {
165 confetti({
166 ...defaults,
378}
379
380function client() {
381 // Detect which user from query param in the script URL
382 const url = new URL(import.meta.url);
390}
391
392async function server(request: Request): Promise<Response> {
393 console.log(import.meta.url);
394

birthdayAlertsAppmain.tsx3 matches

@abidiqrar•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [birthdays, setBirthdays] = useState([]);
7 const [name, setName] = useState('');
80}
81
82function client() {
83 createRoot(document.getElementById("root")).render(<App />);
84}
85if (typeof document !== "undefined") { client(); }
86
87export default async function server(request: Request): Promise<Response> {
88 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
89 const KEY = "birthdayAlertsApp";

zSTYLES_elatedOrangeMonkeymain.tsx9 matches

@arfan•Updated 3 months ago
22`;
23
24function parseCSV(csv) {
25 const result = Papa.parse(csv, {
26 header: true,
35}
36
37function App() {
38 const [darkMode, setDarkMode] = useState(false);
39 const [linkData, setLinkData] = useState([]);
50 const toggleSettings = () => setShowSettings(!showSettings);
51
52 function updateLinkList() {
53 const linkList = document.getElementById('link-list');
54 linkList.innerHTML = '';
102 }
103
104 function saveToLocalStorage() {
105 localStorage.setItem('linkData', JSON.stringify(linkData));
106 localStorage.setItem('csvData', csvData);
108 }
109
110 function loadFromLocalStorage() {
111 const savedLinkData = localStorage.getItem('linkData');
112 const savedCsvData = localStorage.getItem('csvData');
126 }
127
128 function updateLineCount() {
129 const lines = csvData.split('\n').length;
130 return `Lines: ${lines}`;
131 }
132
133 function showUpdateMessage(message, type) {
134 // Implementation depends on how you want to show messages in React
135 console.log(`${type}: ${message}`);
282}
283
284function client() {
285 createRoot(document.getElementById("root")).render(<App />);
286}
290}
291
292export default async function server(request: Request): Promise<Response> {
293 return new Response(`
294 <!DOCTYPE html>

loanCalculatorAppmain.tsx4 matches

@thecybergenius•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function LoanCalculator() {
6 const [principal, setPrincipal] = useState('');
7 const [rate, setRate] = useState('');
102}
103
104function App() {
105 return <LoanCalculator />;
106}
107
108function client() {
109 createRoot(document.getElementById("root")).render(<App />);
110}
111if (typeof document !== "undefined") { client(); }
112
113export default async function server(request: Request): Promise<Response> {
114 return new Response(`
115 <html>
8const DISCORD_NOT_PLAYED_URL = process.env.DISCORD_NOT_PLAYED_URL;
9
10export default async function(interval: Interval) {
11 if (!STEAM_WEB_API_KEY || !STEAM_ID || !DISCORD_WEBSOCKET_URL || !DISCORD_NOT_PLAYED_URL) {
12 throw new Error("STEAM_WEB_API_KEY, STEAM_ID or DISCORD_WEBSOCKET_URL not set");

carRaceGame1main.tsx3 matches

@Salmannadaf1•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function CarRaceGame() {
6 const [carPosition, setCarPosition] = useState(50);
7 const [obstacles, setObstacles] = useState([]);
149};
150
151function client() {
152 createRoot(document.getElementById("root")).render(<CarRaceGame />);
153}
155if (typeof document !== "undefined") { client(); }
156
157export default async function server(request: Request): Promise<Response> {
158 return new Response(`
159 <html>

realMiningAppsmain.tsx4 matches

@Sagar445•Updated 3 months ago
4
5// Cryptocurrency Mining Simulator
6function CryptoMiningApp() {
7 const [miners, setMiners] = useState([
8 { name: "Bitcoin", hashRate: 0, power: 0, isActive: false },
130}
131
132function App() {
133 return <CryptoMiningApp />;
134}
135
136function client() {
137 createRoot(document.getElementById("root")).render(<App />);
138}
139if (typeof document !== "undefined") { client(); }
140
141export default async function server(request: Request) {
142 return new Response(`
143 <html>

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