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=1018&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 16864 results for "function"(1092ms)

tidyLimeRoundwormmain.tsx3 matches

@stevekrouse•Updated 2 months ago
14} from "https://esm.sh/recharts@2.7.2?deps=react@18.2.0,react-dom@18.2.0";
15
16function App({ tweetData }) {
17 const [selectedTweetId, setSelectedTweetId] = useState("1852746483306492004");
18 const [filteredData, setFilteredData] = useState([]);
125}
126
127function client() {
128 const tweetData = JSON.parse(document.getElementById("tweet-data").textContent);
129 createRoot(document.getElementById("root")).render(<App tweetData={tweetData} />);
131if (typeof document !== "undefined") { client(); }
132
133export default async function server(request: Request): Promise<Response> {
134 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
135

brightSalmonHoverflymain.tsx3 matches

@maxm•Updated 2 months ago
14} from "https://esm.sh/recharts@2.7.2?deps=react@18.2.0,react-dom@18.2.0";
15
16function App({ tweetData }) {
17 const [selectedTweetId, setSelectedTweetId] = useState("1852746483306492004");
18 const [filteredData, setFilteredData] = useState([]);
125}
126
127function client() {
128 const tweetData = JSON.parse(document.getElementById("tweet-data").textContent);
129 createRoot(document.getElementById("root")).render(<App tweetData={tweetData} />);
131if (typeof document !== "undefined") { client(); }
132
133export default async function server(request: Request): Promise<Response> {
134 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
135

httpCachemain.tsx4 matches

@stainless_em•Updated 2 months ago
1/**
2 * Wraps a server function to add ETag-based caching
3 * @param serverFn The original server function to be wrapped
4 * @returns A new server function with caching logic
5 */
6export default function httpCache(
7 serverFn: (request: Request) => Promise<Response>,
8 valUrl: string,

regexToBrainrotmain.tsx6 matches

@stainless_em•Updated 2 months ago
13const { Children, toChildArray, cloneElement, useMemo, useReducer, useState, useEffect } = React;
14
15function hydrateReactElements(obj: any): any {
16 if (obj == null || typeof obj !== "object") {
17 return obj;
34
35// Reducer to handle JSON patch updates
36function brainrotReducer(state: Object, action: { type: "PATCH"; patch: any[] } | { type: "SET"; value: any }) {
37 switch (action.type) {
38 case "PATCH":
70};
71
72function Spinner() {
73 return (
74 <div
113};
114
115function App({ state: { share } }: { state: State }) {
116 const [regex, setRegex] = useState(share?.regex ?? "");
117 const [brainrotExplanation, dispatch] = useReducer(
285}
286
287function client() {
288 React.hydrate(
289 <App state={JSON.parse(document.getElementById("_state_")!.textContent!)} />,
293if (typeof document !== "undefined") { client(); }
294
295export default async function server(request: Request): Promise<Response> {
296 const url = new URL(request.url);
297 const route = url.pathname.match(/^\/(?:share\/([^\/]+))?$/);

DualLangWebSpeechAPImain.tsx3 matches

@AIWB•Updated 2 months ago
3import React, { useCallback, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [isRecording, setIsRecording] = useState(false);
7 const [currentLanguage, setCurrentLanguage] = useState<"korean" | "english">("english");
210}
211
212function client() {
213 createRoot(document.getElementById("root")).render(<App />);
214}
215if (typeof document !== "undefined") { client(); }
216
217export default async function server(request: Request): Promise<Response> {
218 return new Response(
219 `

cerebras_codermain.tsx11 matches

@HArS•Updated 2 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">

uiComponentPlaygroundmain.tsx12 matches

@aazad•Updated 2 months ago
4
5// Accordion Component
6function Accordion() {
7 const [activeIndex, setActiveIndex] = useState<number | null>(null);
8
14 {
15 title: "Advanced Features",
16 content: "Explore advanced functionalities and tips for power users."
17 }
18 ];
43
44// Dialog Component
45function Dialog() {
46 const [isOpen, setIsOpen] = useState(false);
47
74
75// Checkbox Component
76function Checkbox() {
77 const [isChecked, setIsChecked] = useState(false);
78
96
97// Switch Component
98function Switch() {
99 const [isOn, setIsOn] = useState(false);
100
118
119// Tabs Component
120function Tabs() {
121 const [activeTab, setActiveTab] = useState(0);
122
153
154// Tooltip Component
155function Tooltip() {
156 const [isVisible, setIsVisible] = useState(false);
157
175
176// Progress Bar Component
177function ProgressBar() {
178 const [progress, setProgress] = useState(0);
179
201
202// Radio Button Group Component
203function RadioButtonGroup() {
204 const [selectedOption, setSelectedOption] = useState('');
205
232
233// Main App Component
234function App() {
235 return (
236 <div className="app-container">
275
276// Client-side rendering
277function client() {
278 createRoot(document.getElementById("root")).render(<App />);
279}
281
282// Server-side rendering
283export default async function server(request: Request): Promise<Response> {
284 return new Response(`
285 <html>

checkMixcloudIsLivemain.tsx5 matches

@kailhus•Updated 2 months ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [isLive, setIsLive] = useState(false);
7 const [channelName, setChannelName] = useState("");
9 const [submittedChannel, setSubmittedChannel] = React.useState<string | null>(null);
10
11 async function checkLiveStatus(channel: string) {
12 try {
13 setIsLoading(true);
83}
84
85function client() {
86 createRoot(document.getElementById("root")).render(<App />);
87}
88if (typeof document !== "undefined") { client(); }
89
90export default async function server(request: Request): Promise<Response> {
91 const url = new URL(request.url);
92
182}
183
184async function checkMixcloudLiveStatus(
185 channelName: string,
186 sqlite?: any,

textToImagePlaygroundmain.tsx2 matches

@AIWB•Updated 2 months ago
59 <script type="module" src="https://esm.town/v/iamseeley/realtimeFormLogic"></script>
60 <script>
61 document.getElementById('generationType').addEventListener('change', function() {
62 const type = this.value;
63 if (type === 'regular') {
81`;
82
83export default async function handler(req: Request): Promise<Response> {
84 const url = new URL(req.url);
85

cerebras_codermain.tsx11 matches

@Bne44•Updated 2 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">

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