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=873&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 10292 results for "function"(556ms)

perseveringAmaranthChipmunkmain.tsx1 match

@dnakhooda•Updated 5 months ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

uploadImagemain.tsx2 matches

@ajsol•Updated 5 months ago
4 * @returns {string} - uploaded image url
5 */
6export async function uploadImage(image: Blob): Promise<string> {
7 const fd = new FormData();
8 fd.append(
23 return data.result.variants[0];
24}
25async function getUploadURL(): Promise<string> {
26 const data = await (await fetch("https://www.val.town/api/trpc/generateImageUploadUrl", {
27 "headers": {

StripeCheckoutDemomain.tsx8 matches

@vawogbemi•Updated 5 months ago
81`;
82
83function Instructions() {
84 return (
85 <div className="mb-4">
95}
96
97function TipList({ tips, selectedDate, sortOrder, setSortOrder }) {
98 const filteredTips = tips.filter((tip) => {
99 const tipDate = new Date(tip.timestamp);
145}
146
147function DateSelector({ selectedDate, setSelectedDate }) {
148 const [isCalendarOpen, setIsCalendarOpen] = useState(false);
149 const today = new Date();
232}
233
234function App({ initialTips }) {
235 const [amount, setAmount] = useState(20);
236 const [name, setName] = useState("");
354}
355
356function Confetti() {
357 useEffect(() => {
358 confetti({
366}
367
368function SuccessPage({ payments }) {
369 return (
370 <div className="min-h-screen bg-white text-black flex flex-col items-center justify-center p-4">
391}
392
393function client() {
394 const root = document.getElementById("root");
395 if (root.dataset.page === "success") {
406}
407
408export default async function server(req: Request): Promise<Response> {
409 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
410 const SCHEMA_VERSION = 2;

diacomDemomain.tsx4 matches

@vawogbemi•Updated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [imageId, setImageId] = useState(null);
7 const [file, setFile] = useState(null);
12 let cornerstone, cornerstoneWADOImageLoader, dicomParser;
13
14 async function loadLibraries() {
15 cornerstone = (await import("https://esm.sh/cornerstone-core")).default;
16 cornerstoneWADOImageLoader = (await import("https://esm.sh/cornerstone-wado-image-loader")).default;
80}
81
82function client() {
83 createRoot(document.getElementById("root")).render(<App />);
84}
86if (typeof document !== "undefined") { client(); }
87
88export default async function server(request: Request): Promise<Response> {
89 return new Response(`
90 <html>

bricklesGamemain.tsx10 matches

@jamiedubs•Updated 5 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const canvasRef = useRef(null);
7 const [score, setScore] = useState(0);
36 document.addEventListener('keyup', (e) => keys[e.key] = false);
37
38 function drawBall() {
39 ctx.beginPath();
40 ctx.arc(ball.x, ball.y, ball.radius, 0, Math.PI * 2);
44 }
45
46 function drawPaddle() {
47 ctx.beginPath();
48 ctx.rect(paddle.x, paddle.y, paddle.width, paddle.height);
52 }
53
54 function drawBricks() {
55 for (let c = 0; c < brickColumnCount; c++) {
56 for (let r = 0; r < brickRowCount; r++) {
70 }
71
72 function drawParticles() {
73 particles.forEach((particle, index) => {
74 particle.life--;
87 }
88
89 function createParticles(x, y) {
90 for (let i = 0; i < 10; i++) {
91 particles.push({
100 }
101
102 function collisionDetection() {
103 for (let c = 0; c < brickColumnCount; c++) {
104 for (let r = 0; r < brickRowCount; r++) {
118 }
119
120 function draw() {
121 ctx.clearRect(0, 0, canvas.width, canvas.height);
122 drawBricks();
187}
188
189function client() {
190 createRoot(document.getElementById("root")).render(<App />);
191}
192if (typeof document !== "undefined") { client(); }
193
194export default async function server(request: Request): Promise<Response> {
195 return new Response(`
196 <html>

StripeDemomain.tsx4 matches

@vawogbemi•Updated 5 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [tipAmount, setTipAmount] = useState(5);
8 const paymentLinks = {
63}
64
65function Success() {
66 useEffect(() => {
67 confetti({
81}
82
83function client() {
84 const root = document.getElementById("root");
85 if (root) {
94if (typeof document !== "undefined") { client(); }
95
96export default async function server(request: Request): Promise<Response> {
97 const url = new URL(request.url);
98

handleDiscordNewUsermain.tsx1 match

@stevekrouse•Updated 5 months ago
3// # New Val Town User (on Clerk) -> Val Town Discord notification
4// Translates one kind of webhook (Clerk) into another (Discord)
5export async function handleDiscordNewUser(req: Request): Promise<Response> {
6 // check custom auth secret sent from clerk
7 if (req.headers.get("auth") !== Deno.env.get("clerkNonSensitive"))

jokeGeneratorValmain.tsx1 match

@naomizhang•Updated 5 months ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

uptimemain.tsx1 match

@sophie•Updated 5 months ago
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;

statusmain.tsx3 matches

@sophie•Updated 5 months ago
5import { renderToString } from "npm:react-dom/server";
6
7function StatusRow({ rows }) {
8 return (
9 <div className="w-full flex flex-col space-y-2">
28}
29
30function StatusSection({ url, rows }) {
31 const sectionRows = rows.filter(row => row[0] === url);
32 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
45
46export default async function(req: Request): Promise<Response> {
47 const { rows } = await sqlite.execute(
48 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago