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/$%7Burl%7D?q=function&page=1792&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 23483 results for "function"(3204ms)

pythonHTTPValmain.tsx1 match

@iamseeley•Updated 5 months ago
1import { runPythonCode } from "https://deno.land/x/py_town@v0.0.8/mod.ts";
2
3export default async function handler(req: Request): Promise<Response> {
4 const pythonCode = `
5import numpy as np

postMessageButtonGamemain.tsx3 matches

@edenh•Updated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const handlePostMessage = () => {
7 window.parent.postMessage('{"data": "foo", "field": "expected", "type": "update"}', '*');
29}
30
31function client() {
32 createRoot(document.getElementById("root")).render(<App />);
33}
34if (typeof document !== "undefined") { client(); }
35
36export default async function server(request: Request): Promise<Response> {
37 return new Response(`
38 <html>

wholeFoodsRSSmain.tsx1 match

@Glench•Updated 5 months ago
2import { wholefoodssales } from "https://esm.town/v/Glench/wholefoodssales";
3
4export default async function(req: Request): Promise<Response> {
5 return new Response(dataToRSS(await wholefoodssales(), {
6 title: "Whole Foods Sales — Personal",

tvshowsmain.tsx2 matches

@Glench•Updated 5 months ago
3import process from "node:process";
4
5export const tvshows = async function() {
6 const TV_SHOWS_WATCHED = [
7 // Ted Lasso
28 data.push(show);
29 }
30 data.sort(function(a, b) {
31 if (a.last_air_date > b.last_air_date)
32 return -1;

blob_adminmain.tsx8 matches

@stevekrouse1•Updated 5 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"));

pyodideSetupmain.tsx1 match

@iamseeley•Updated 5 months ago
1const pyodideUrl = "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/";
2
3export async function initializePyodide() {
4 // Set up the global objects that Pyodide expects
5 (globalThis as any).window = globalThis;

marpmain.tsx1 match

@pomdtr•Updated 5 months ago
3import { Marp } from "npm:@marp-team/marp-core";
4
5export default async function() {
6 const { author, name } = extractValInfo(import.meta.url);
7 const { readme } = await api(`/v1/alias/${author}/${name}`);

weatherGPTmain.tsx1 match

@rohanchoudhary15•Updated 5 months ago
31console.log(text);
32
33export async function weatherGPT() {
34 await email({ subject: "Weather Today", text });
35}

devstatsmain.tsx3 matches

@carburo•Updated 5 months ago
113}).toString().split("\n").slice(1).slice(0, -1).join("\n")
114
115async function getRows() {
116 const result = await sqlite.execute(`SELECT * FROM ${TABLE_NAME}`)
117 const rows = result.rows.map(r => ({
126type Rows = Awaited<ReturnType<typeof getRows>>
127
128app.get("/api", async function apiRoute(c) {
129 try {
130 return c.json(await getRows())
160})
161
162export default async function(req: Request): Promise<Response> {
163 await sqlite.execute(`
164 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (

notUberHomemain.tsx1 match

@vawogbemi•Updated 5 months ago
117};
118
119export function Home() {
120 return (
121 <div className="p-0 md:p-4">

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.