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/image-url.jpg%20%22Image%20title%22?q=function&page=2364&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 30736 results for "function"(4042ms)

InstantQuerygetInstantSchema1 match

@vawogbemi•Updated 4 months ago
1async function getInstantSchema(instantAppId: string, instantAdminToken: string) {
2 const response = await fetch("https://api.instantdb.com/admin/schema", {
3 method: "GET",

translateToEnglishWithOpenAImain.tsx1 match

@Hadarhubara•Updated 4 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function translateToEnglishWithOpenAI(text: string) {
4 const openai = new OpenAI();
5 const completion = await openai.chat.completions.create({

tldraw_computer_examplemain.tsx1 match

@charmaine•Updated 4 months ago
64};
65
66export default async function(req: Request): Promise<Response> {
67 if (req.method === "GET") {
68 // handle a GET request

cerebras_codermain.tsx11 matches

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

digesthelpersmain.tsx6 matches

@joseforonda•Updated 4 months ago
1export function makeDay(days: number) {
2 function makeDate(days: number) {
3 const day = new Date();
4 day.setDate(day.getDate() - days);
9}
10
11export function writeEmailHTML(outline: any) {
12 function composeNoticia(noticia: any) {
13 const textColor = "rgb(54, 55, 55)";
14 const aStyle =
19 }
20
21 function composeTema(tema: any) {
22 const h2Style =
23 `font-family: "SF Pro Display", -apple-system-headline, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; margin:50px 0 25px 0; font-size:24px;`;
34}
35
36export function writeTitle(subject: string, desde: Date, long: Boolean = true) {
37 const locale = "es-BO";
38 let dateFormat;

labLoginLikesmain.tsx1 match

@gaimeri17•Updated 4 months ago
4const SCHEMA_VERSION = 1;
5
6export default async function server(request: Request): Promise<Response> {
7 // Ensure table exists
8 await sqlite.execute(`

humbleCoffeeMoosemain.tsx1 match

@std•Updated 4 months ago
3import process from "node:process";
4
5export async function set(key: string, value: any) {
6 let resp = await fetch(
7 `${API_URL}/v1/vals`,

AviatorGameWithChatGPTmain.tsx3 matches

@Sonu7560•Updated 4 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function AviatorGame() {
6 const [balance, setBalance] = useState(1000);
7 const [betAmount, setBetAmount] = useState(10);
103}
104
105function client() {
106 createRoot(document.getElementById("root")).render(<AviatorGame />);
107}
109if (typeof document !== "undefined") { client(); }
110
111export default async function server(request: Request): Promise<Response> {
112 return new Response(`
113 <html>

IPInfoExamplemain.tsx1 match

@charmaine•Updated 4 months ago
1export default async function(req: Request) {
2 const clientIP = req.headers.get("x-forwarded-for") || "127.0.0.1";
3 const locationURL = new URL(`https://ipinfo.io/${clientIP}`);

FramerAPIWrappermain.tsx1 match

@charmaine•Updated 4 months ago
1export default async function(req: Request) {
2 const data = await fetch("https://api.fetch.tools/status");
3 const status = await data.json();
tuna

tuna9 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.