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=1067&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 17345 results for "function"(1817ms)

spagUploadmain.tsx1 match

@todepond•Updated 3 months ago
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3
4export default async function(req: Request): Promise<Response> {
5 let json;
6 try {

spagDeletemain.tsx1 match

@todepond•Updated 3 months ago
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3
4export default async function(req: Request): Promise<Response> {
5 let json;
6 try {

spagListmain.tsx1 match

@todepond•Updated 3 months ago
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3export default async function(req: Request): Promise<Response> {
4 // Get all rows from lab_upload_blobs
5 const response = await sqlite.execute(`

seamlessCoffeeCobramain.tsx11 matches

@Eviya•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

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

FetchBasicmain.tsx1 match

@gdm•Updated 3 months ago
1export default async function(req: Request): Promise<Response> {
2 // Setup CORS Headers
3 const headers = new Headers();

aiREADME.md1 match

@wizos•Updated 3 months ago
8
9```
10async function calculateEmbeddings(text) {
11 const url = `https://yawnxyz-ai.web.val.run/generate?embed=true&value=${encodeURIComponent(text)}`;
12

aimain.tsx2 matches

@wizos•Updated 3 months ago
213
214 if (toolResults && toolResults.length > 0) {
215 // we have to do this bc the AI SDK doesn't seem to let you carry over function calling results,
216 // so we pretend to be the user instead of using the official role: tool API, which breaks everything
217 for (const toolResult of toolResults) {
670}
671
672function test() {
673 console.log("test!")
674}

multiplayerCirclesmain.tsx6 matches

@chadwhitacre•Updated 3 months ago
37// });
38
39function parseResultSet<T>(row: ResultSet): T[] {
40 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
41}
51};
52
53function diffCircles(array1: Circle[], array2: Circle[]): Circle[] {
54 const changes: Circle[] = [];
55
74
75 const drag = (() => {
76 function dragstarted() {
77 d3.select(this).attr("stroke", "black");
78 }
79
80 function dragged(event, d) {
81 d3.select(this).raise().attr("cx", d.x = event.x).attr("cy", d.y = event.y);
82 }
83
84 function dragended() {
85 const x = d3.select(this).attr("cx");
86 const y = d3.select(this).attr("cy");
105 .call(drag)
106 .on("click", clicked);
107 function clicked(event, d) {
108 if (event.defaultPrevented) return; // dragged
109

vbloghono-adapter6 matches

@jxnblk•Updated 3 months ago
7const app = new Hono();
8
9function Style() {
10 return <style>{`body{margin:0;padding:32px;font-family:Menlo, monospace}`}</style>;
11}
12
13function Home(data: Data, c: Context) {
14 return (
15 <div>
29}
30
31function Post(data: Data, c: Context) {
32 const name = c.req.param("post");
33 const post = data.posts.find(p => p.name === name);
46}
47
48function NotFound(data: Data, c: Context) {
49 const name = c.req.param("post");
50 return (
59type RouteComponent = (data: Data, context: Context<any, any, {}>) => JSX.Element;
60
61function route(Component: RouteComponent, data: Data) {
62 return async (c) => c.html(Component(data, c));
63}
64
65export default function honoAdapter(data: Data) {
66 app.get("/", route(Home, data));
67 app.get("/posts/:post", route(Post, data));

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