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/$%7Bsuccess?q=function&page=2339&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 29280 results for "function"(2025ms)

tldraw_computer_examplemain.tsx1 match

@ni5k0•Updated 5 months ago
64};
65
66export default async function(req: Request): Promise<Response> {
67 if (req.method === "GET") {
68 // handle a GET request

tldraw_computer_examplemain.tsx1 match

@chini5ko•Updated 5 months ago
64};
65
66export default async function(req: Request): Promise<Response> {
67 if (req.method === "GET") {
68 // handle a GET request

cerebras_codermain.tsx11 matches

@dedicatedstudent•Updated 5 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">

tldraw_computer_examplemain.tsx1 match

@steveruizok•Updated 5 months ago
64};
65
66export default async function(req: Request): Promise<Response> {
67 if (req.method === "GET") {
68 // handle a GET request

obedientLimeOrangutanmain.tsx1 match

@primemeridian•Updated 5 months ago
22 <canvas id="matrixRain"></canvas>
23 <script>
24 (function () {
25 const canvas = document.getElementById("matrixRain");
26 const ctx = canvas.getContext("2d");

incredibleYellowTickmain.tsx1 match

@roadlabs•Updated 5 months ago
42export type Data = BooleanData | TextData | ImageData | SpeechData | WebsiteData;
43
44export default async function(req: Request): Promise<Response> {
45 try {
46 const { version, inputs } = await req.json() as { version: number; inputs: Data[] };

blob_adminmain.tsx8 matches

@kamenxrider•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"));

cerebras_codermain.tsx11 matches

@dno_luigi•Updated 5 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">

notUberMapComponentmain.tsx15 matches

@vawogbemi•Updated 5 months ago
5const GOOGLE_MAPS_API_KEY = "AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U";
6
7function debounce(func, wait) {
8 let timeout;
9 return function executedFunction(...args) {
10 const later = () => {
11 clearTimeout(timeout);
128let googleMapsPromise = null;
129
130// Function to load Google Maps API globally
131function loadGoogleMapsAPI() {
132 if (googleMapsPromise) {
133 return googleMapsPromise;
163}
164
165export function MapComponent(
166 { pickupLocation, dropoffLocation, active, showZoomControl }: {
167 pickupLocation: string | null;
224 }, [active, pickupLocation, dropoffLocation, pathCoordinates, mapFullyLoaded]);
225
226 function initMap() {
227 try {
228 if (!window.google || !window.google.maps) {
266 }
267
268 async function updateMap() {
269 try {
270 if (pickupMarker) pickupMarker.setMap(null);
298 }
299
300 function setMarkerAndCenter(location, type) {
301 return new Promise((resolve, reject) => {
302 if (!window.google || !window.google.maps) {
334 }
335
336 function createCustomMarker(type, size = 24) {
337 const outerColor = "#ffffff";
338 const innerColor = "#121212";
359 }
360
361 function drawRoute(start, end) {
362 return new Promise((resolve, reject) => {
363 if (!directionsServiceRef.current) {
390 }
391
392 function fitRouteBounds() {
393 if (directionsRendererRef.current && directionsRendererRef.current.getDirections()) {
394 const bounds = new window.google.maps.LatLngBounds();
405 }
406
407 function startAnimation() {
408 if (animationRef.current) return;
409 if (!window.google || !window.google.maps || !map) {
430 const numSteps = 200; // You can adjust this for smoother or faster animation
431
432 function animate() {
433 const path = animatedPolylineRef.current.getPath();
434 path.push(pathCoordinates[step]);
448 }
449
450 function stopAnimation() {
451 if (animationRef.current) {
452 window.cancelAnimationFrame(animationRef.current);
468}
469
470export function AutocompleteInput(
471 { value, onChange, placeholder, icon: Icon }: {
472 value: string;

getLatestGitHubRunmain.tsx1 match

@kaleidawave•Updated 5 months ago
1export async function handler(request: Request) {
2 const url = new URL(request.url);
3 const items = url.pathname.slice(1).split("/");
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.