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/$%7Bart_info.art.src%7D?q=function&page=1829&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 24500 results for "function"(1914ms)

cerebras_codermain.tsx11 matches

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

codeLearnerProAppmain.tsx6 matches

@mrshorts•Updated 4 months ago
43 advanced: `
44# Decorators
45def log_function(func):
46 def wrapper(*args, **kwargs):
47 print(f"Calling {func.__name__}")
49 return wrapper
50
51@log_function
52def example_function():
53 pass
54 `
56};
57
58function App() {
59 const [activeSection, setActiveSection] = useState('python');
60 const [activeSubSection, setActiveSubSection] = useState('beginner');
259};
260
261function client() {
262 createRoot(document.getElementById("root")).render(<App />);
263}
264if (typeof document !== "undefined") { client(); }
265
266export default async function server(request: Request): Promise<Response> {
267 return new Response(`
268 <html>

onlineGamesAPKmain.tsx4 matches

@nauss21•Updated 4 months ago
24];
25
26function GameCard({ game }) {
27 return (
28 <div style={{
58}
59
60function App() {
61 return (
62 <div style={{
94}
95
96function client() {
97 createRoot(document.getElementById("root")).render(<App />);
98}
99if (typeof document !== "undefined") { client(); }
100
101export default async function server(request: Request): Promise<Response> {
102 return new Response(`
103 <html>

responsiveMagentaBearmain.tsx3 matches

@Pushpam•Updated 4 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function RunningGame() {
6 const [targetDistance, setTargetDistance] = useState(Math.floor(Math.random() * 5) + 1); // 1-5 km
7 const [currentDistance, setCurrentDistance] = useState(0);
119}
120
121function client() {
122 createRoot(document.getElementById("root")).render(<RunningGame />);
123}
124if (typeof document !== "undefined") { client(); }
125
126export default async function server(request: Request): Promise<Response> {
127 return new Response(`
128 <html>

inspiringAquaToadmain.tsx2 matches

@priyanshu•Updated 4 months ago
8
9// Home/Match Screen
10function HomeMatchScreen({ setScreen }) {
11 const [matches, setMatches] = useState([
12 {
138
139// Main App Component
140function App() {
141 const [screen, setScreen] = useState('home');
142 const [profileData, setProfileData] = useState({});

xoGameWithDifficultyLevelsmain.tsx11 matches

@ask0ne•Updated 4 months ago
8type MiniBoard = Board;
9
10function calculateWinner(board: Board): Player | null {
11 const lines = [
12 [0, 1, 2],
28}
29
30function MiniBoard({
31 board,
32 onCellClick,
56}
57
58function App() {
59 const [metaBoard, setMetaBoard] = useState<(Player | null)[]>(Array(9).fill(null));
60 const [miniBoardStates, setMiniBoardStates] = useState<MiniBoard[]>(
78 }, [xIsNext, metaBoard]);
79
80 async function makeAIMove() {
81 setIsAIThinking(true);
82 try {
104 }
105
106 function handleMiniMove(miniBoardIndex: number, cellIndex: number) {
107 if (
108 (currentMiniBoard !== null && currentMiniBoard !== miniBoardIndex) ||
131 }
132
133 function calculateNextAllowedBoard(lastMoveCellIndex: number): number | null {
134 // If the corresponding mini board is already won or full, allow any open board
135 if (metaBoard[lastMoveCellIndex] || miniBoardStates[lastMoveCellIndex].every(cell => cell !== null)) {
141 }
142
143 function resetGame() {
144 setMetaBoard(Array(9).fill(null));
145 setMiniBoardStates(Array(9).fill(null).map(() => Array(9).fill(null)));
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 if (request.method === "POST" && new URL(request.url).pathname === "/ai-move") {
217 const { metaBoard, miniBoardStates, currentMiniBoard, difficulty } = await request.json();
246}
247
248function calculateWinningMoves(board: Board): number[] {
249 const lines = [
250 [0, 1, 2],
267}
268
269async function calculateAIMove(
270 metaBoard: Board,
271 miniBoardStates: MiniBoard[],

ardentTomatoMarmosetmain.tsx3 matches

@sajidhussain•Updated 4 months ago
19};
20
21function App() {
22 const [activeSection, setActiveSection] = useState('history');
23
133};
134
135function client() {
136 createRoot(document.getElementById("root")).render(<App />);
137}
138if (typeof document !== "undefined") { client(); }
139
140export default async function server(request: Request): Promise<Response> {
141 return new Response(`
142 <html>

Wilayatwaymain.tsx3 matches

@sajidhussain•Updated 4 months ago
19};
20
21function App() {
22 const [activeSection, setActiveSection] = useState('history');
23
133};
134
135function client() {
136 createRoot(document.getElementById("root")).render(<App />);
137}
138if (typeof document !== "undefined") { client(); }
139
140export default async function server(request: Request): Promise<Response> {
141 return new Response(`
142 <html>

pythonLearningAppmain.tsx4 matches

@mrshorts•Updated 4 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function PythonLearningApp() {
6 const [topic, setTopic] = useState('');
7 const [explanation, setExplanation] = useState('');
51 value={topic}
52 onChange={(e) => setTopic(e.target.value)}
53 placeholder="Enter Python topic (e.g., lists, functions, classes)"
54 style={styles.input}
55 />
154};
155
156function client() {
157 createRoot(document.getElementById("root")).render(<PythonLearningApp />);
158}
159if (typeof document !== "undefined") { client(); }
160
161export default async function server(request: Request): Promise<Response> {
162 // Log the incoming request for debugging
163 console.log('Incoming request:', request.method, request.url);

imaginativeScarletPikemain.tsx1 match

@Fahad61814•Updated 4 months ago
1export default async function (interval: Interval) {
2
3}

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 month 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.