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=2390&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 29319 results for "function"(8752ms)

embedVideoWebPagemain.tsx3 matches

@eligosmlytics•Updated 6 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [youtubeUrl, setYoutubeUrl] = useState("https://www.youtube.com/embed/QskiaNqaqlc?si=MvD_ydotKgovS9pC");
8 const [postVideoImages, setPostVideoImages] = useState<string[]>([]);
218}
219
220function client() {
221 createRoot(document.getElementById("root")).render(<App />);
222}
223if (typeof document !== "undefined") { client(); }
224
225export default async function server(request: Request): Promise<Response> {
226 // Image proxy endpoint
227 const url = new URL(request.url);

p5_latest_starterkitmain.tsx3 matches

@ff6347•Updated 6 months ago
15};
16
17export default async function server(request: Request): Promise<Response> {
18 // Default modules to include
19 const defaultModules = [
172 `
173
174function setup(){
175 const canvas = createCanvas(100,100);
176 canvas.parent("sketch");
178}
179
180function draw() {}
181`,
182 );

blob_adminmain.tsx8 matches

@caseyg•Updated 6 months ago
13}
14
15function Tooltip({ children, content }: TooltipProps) {
16 const [isVisible, setIsVisible] = useState(false);
17 const tooltipRef = useRef<HTMLDivElement>(null);
52}
53
54function formatBytes(bytes: number, decimals = 2) {
55 if (bytes === 0) return "0 Bytes";
56 const k = 1024;
61}
62
63function copyToClipboard(text: string) {
64 navigator.clipboard.writeText(text).then(() => {
65 console.log("Text copied to clipboard");
69}
70
71function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72 const [isOpen, setIsOpen] = useState(false);
73 const menuRef = useRef(null);
76
77 useEffect(() => {
78 function handleClickOutside(event) {
79 if (menuRef.current && !menuRef.current.contains(event.target)) {
80 event.stopPropagation();
158}
159
160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161 const [isLoading, setIsLoading] = useState(false);
162 const decodedKey = decodeURIComponent(blob.key);
219}
220
221function App({ initialEmail, initialProfile }) {
222 const encodeKey = (key: string) => encodeURIComponent(key);
223 const decodeKey = (key: string) => decodeURIComponent(key);
645}
646
647function client() {
648 const initialEmail = document.getElementById("root").getAttribute("data-email");
649 const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));

superbAzureSharkmain.tsx8 matches

@thesolarmonk•Updated 6 months ago
13}
14
15function Tooltip({ children, content }: TooltipProps) {
16 const [isVisible, setIsVisible] = useState(false);
17 const tooltipRef = useRef<HTMLDivElement>(null);
52}
53
54function formatBytes(bytes: number, decimals = 2) {
55 if (bytes === 0) return "0 Bytes";
56 const k = 1024;
61}
62
63function copyToClipboard(text: string) {
64 navigator.clipboard.writeText(text).then(() => {
65 console.log("Text copied to clipboard");
69}
70
71function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72 const [isOpen, setIsOpen] = useState(false);
73 const menuRef = useRef(null);
76
77 useEffect(() => {
78 function handleClickOutside(event) {
79 if (menuRef.current && !menuRef.current.contains(event.target)) {
80 event.stopPropagation();
158}
159
160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161 const [isLoading, setIsLoading] = useState(false);
162 const decodedKey = decodeURIComponent(blob.key);
219}
220
221function App({ initialEmail, initialProfile }) {
222 const encodeKey = (key: string) => encodeURIComponent(key);
223 const decodeKey = (key: string) => decodeURIComponent(key);
645}
646
647function client() {
648 const initialEmail = document.getElementById("root").getAttribute("data-email");
649 const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));

cerebras_codermain.tsx10 matches

@binaco•Updated 6 months ago
15 "recipe ingredient converter and scaler",
16 "morse code translator with audio output",
17 "random quote generator with tweet functionality",
18 "personal finance tracker with basic charts",
19 "multiplayer rock-paper-scissors game",
20];
21
22function Dashboard() {
23 const [stats, setStats] = useState<{
24 totalGenerations: number;
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
97}
98
99function App() {
100 const [prompt, setPrompt] = useState(
101 STARTER_PROMPTS[Math.floor(Math.random() * STARTER_PROMPTS.length)],
128
129 useEffect(() => {
130 async function fetchUsageStats() {
131 const response = await fetch("/usage-stats");
132 const data = await response.json();
136 }, []);
137
138 async function handleSubmit(e: React.FormEvent) {
139 e.preventDefault();
140 setLoading(true);
170 }
171
172 function handleVersionChange(direction: "back" | "forward") {
173 const { currentVersionIndex, versions } = versionHistory;
174
271}
272
273function client() {
274 const path = window.location.pathname;
275 const root = createRoot(document.getElementById("root")!);
286}
287
288function extractCodeFromFence(text: string): string {
289 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
290 return htmlMatch ? htmlMatch[1].trim() : text;
291}
292
293export default async function server(req: Request): Promise<Response> {
294 // Dynamic import for SQLite to avoid client-side import
295 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");

test_on_applesmain.tsx1 match

@dcm31•Updated 6 months ago
1export function main() {
2 return `# Test on Apples\n\n1. What color are most ripe apples?\n a) Blue\n b) Red\n c) Yellow\n d) Purple\n\n2. Which part of the apple tree is edible?\n a) Root\n b) Trunk\n c) Fruit\n d) Leaves\n\n3. Apples are a rich source of:\n a) Vitamin C\n b) Vitamin D\n c) Protein\n d) Calcium\n\n4. What is the scientific name of the apple tree?\n a) Malus domestica\n b) Prunus avium\n c) Citrus limon\n d) Musa acuminata`;
3}

trustworthyEmeraldFlamingomain.tsx1 match

@dcm31•Updated 6 months ago
1export function handler() { return "Hello, Val Town!"; }

smartGoldMarlinmain.tsx1 match

@dcm31•Updated 6 months ago
1export function run() {
2 return "Hello, Val Town!";
3}

gif_uploadmain.tsx4 matches

@mozzius•Updated 6 months ago
9} from "https://esm.sh/@atproto/api";
10
11function App() {
12 const [result, setResult] = useState("");
13 const [progress, setProgress] = useState(0);
105}
106
107function client() {
108 createRoot(document.getElementById("root")).render(<App />);
109}
110if (typeof document !== "undefined") { client(); }
111
112export default async function server(request: Request): Promise<Response> {
113 if (request.method === "POST" && new URL(request.url).pathname === "/submit") {
114 const formData = await request.formData();
170}
171
172async function processGifUpload(
173 serviceUrl: string,
174 username: string,

blueskyPostButtonmain.tsx3 matches

@jdan•Updated 6 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [message, setMessage] = useState("");
8 const [status, setStatus] = useState("");
82}
83
84function client() {
85 createRoot(document.getElementById("root")).render(<App />);
86}
87if (typeof document !== "undefined") { client(); }
88
89export default async function server(request: Request): Promise<Response> {
90 if (request.method === "POST" && new URL(request.url).pathname === "/post-bluesky") {
91 try {
tuna

tuna9 file matches

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