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=1219&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 18363 results for "function"(2218ms)

zyloxAIChatAppmain.tsx3 matches

@gigmx•Updated 4 months ago
4import OpenAI from "https://esm.sh/openai@4.28.4";
5
6function App() {
7 const [messages, setMessages] = useState([]);
8 const [inputMessage, setInputMessage] = useState("");
177}
178
179function client() {
180 createRoot(document.getElementById("root")).render(<App />);
181}
182if (typeof document !== "undefined") { client(); }
183
184export default async function server(request: Request): Promise<Response> {
185 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
186 const { OpenAI } = await import("https://esm.town/v/std/openai");

compassionateBlackCatfishmain.tsx7 matches

@gigmx•Updated 4 months ago
1import OpenAI from "https://esm.sh/openai@4.28.4";
2
3export default async function(req: Request): Promise<Response> {
4 const LEPTON_API_TOKEN = Deno.env.get('LEPTON_API_TOKEN') || '';
5
83 const audioInput = document.getElementById('audio-input');
84
85 function createMatrixBackground() {
86 const canvas = document.createElement('canvas');
87 const ctx = canvas.getContext('2d');
106 }
107
108 function draw() {
109 ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
110 ctx.fillRect(0, 0, canvas.width, canvas.height);
129 createMatrixBackground();
130
131 function addMessage(role, content, isTyping = false, contentType = 'text') {
132 const msgParent = document.createElement("div");
133 msgParent.className = "mb-4 " + (role === 'user' ? 'text-right' : 'text-left');
158 if (file) {
159 const reader = new FileReader();
160 reader.onload = async function(e) {
161 const base64Audio = e.target.result.split(',')[1];
162 addMessage('user', file.name, false, 'audio');
218 });
219
220 document.getElementById("input").addEventListener("submit", async function(event) {
221 event.preventDefault();
222 const userMessage = event.target.message.value;
302
303// Add a separate API route handler for chat
304export async function handler(req: Request) {
305 if (req.method !== 'POST') {
306 return new Response('Method Not Allowed', { status: 405 });

stellarCrimsonPandamain.tsx11 matches

@myy•Updated 4 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

@myy•Updated 4 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">

calculateRequiredQuantityAppmain.tsx4 matches

@kalawaja•Updated 4 months ago
3import React, { useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function PriceQuantityCalculator() {
6 const [calculation, setCalculation] = useState({
7 item: "",
204}
205
206function App() {
207 return <PriceQuantityCalculator />;
208}
209
210function client() {
211 createRoot(document.getElementById("root")).render(<App />);
212}
213if (typeof document !== "undefined") { client(); }
214
215export default async function server(request: Request): Promise<Response> {
216 return new Response(
217 `

gistFetchermain.tsx1 match

@tgrecojs•Updated 4 months ago
38 });
39
40 function transformData(data) {
41 // Implement your data transformation logic here
42 return getFileContents("accounts.json")(data); // Modify as needed

cerebras_codermain.tsx11 matches

@Twosteptv•Updated 4 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">

googleMapsTravelTimeBetweenAirportsmain.tsx6 matches

@nulo•Updated 4 months ago
293].map(pair => ({ origin: `${pair.orig}`, destination: `${pair.arpt}` }));
294
295// Function to parse duration string into seconds
296function parseDurationToSeconds(duration: string): number {
297 const parts = duration.split(" ");
298 let seconds = 0;
322}
323
324// Function to get travel time between two airports
325async function getTravelTime(
326 origin: string,
327 destination: string,
355}
356
357// Main function to calculate travel times for all airport pairs
358export async function calculateAirportTravelTimes(): Promise<string> {
359 const results: Array<
360 { origin: string; destination: string; duration: string | null; durationSeconds: number | null; error?: string }

compassionateFuchsiaXerinaemain.tsx3 matches

@davidho123•Updated 4 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [todos, setTodos] = useState([]);
7 const [newTodo, setNewTodo] = useState("");
91}
92
93function client() {
94 createRoot(document.getElementById("root")).render(<App />);
95}
96if (typeof document !== "undefined") { client(); }
97
98export default async function server(request: Request): Promise<Response> {
99 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
100 const KEY = "compassionateFuchsiaXerinae";

settingWebAppWithUserModelInterfacemain.tsx3 matches

@davidho123•Updated 4 months ago
9};
10
11function ModelBuilder() {
12 const [modelName, setModelName] = useState('');
13 const [fields, setFields] = useState<ModelField[]>([]);
178}
179
180function client() {
181 createRoot(document.getElementById("root")).render(<ModelBuilder />);
182}
183if (typeof document !== "undefined") { client(); }
184
185export default async function server(request: Request): Promise<Response> {
186 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
187 const KEY = "settingWebAppWithUserModelInterface";

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.