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=2417&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 28348 results for "function"(4230ms)

githubreposearchmain.tsx1 match

@toowired•Updated 8 months ago
1export default async function fetchNewPublicGitHubRepos() {
2 // Generate today's date in YYYY-MM-DD format
3 const today = new Date().toISOString().split("T")[0];

mosaiclipsemain.tsx4 matches

@moe•Updated 8 months ago
36let colorPalette: any
37
38export function setup() {
39 tileCount = Math.floor(random(5, 9))
40 tileSize = canvasSize / tileCount
45}
46
47export function draw() {
48 let colorindex = Math.floor(random(colorPalette.length))
49 background(colorPalette[colorindex % colorPalette.length])
70}
71
72export function keyPressed() {
73 if (key == "i") {
74 saveCanvas("p5js-" + new Date().getTime(), "png")
78 }
79}
80// export function touchEnded() {
81// saveCanvas("p5js-" + new Date().getTime(), "png");
82// }

computeScheduleREADME.md1 match

@toowired•Updated 8 months ago
1# `computeSchedule` function
2Combines several schedule segments together to form a complete schedule for a 24-hour period.
3

statusmain.tsx4 matches

@overengineered•Updated 8 months ago
4import { render } from "npm:preact-render-to-string";
5
6export const sha256 = async function digestMessage(message) {
7 const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
8 const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8); // hash the message
18);
19
20function BasicLayout(props) {
21 return (
22 <html>
33}
34
35export default async function(req: Request): Promise<Response> {
36 const url = new URL(req.url);
37 if (req.method === "POST") {
94 {` var cookies = document.getElementById('cookies');
95 var login = document.getElementById('login');
96 cookies.onchange = function () {
97 login.disabled = false;//!this.checked;
98 }`}

lightGrayCrowmain.tsx4 matches

@jeffreyyoung•Updated 8 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
15}
16
17function createStoryHTML(story: any) {
18 return `
19 <li>
28}
29
30function createEmailContent(
31 topStories: any[],
32 newStories: any[],
118}
119
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);

hackerNewsDigestmain.tsx4 matches

@jeffreyyoung•Updated 8 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
15}
16
17function createStoryHTML(story: any) {
18 return `
19 <li>
28}
29
30function createEmailContent(
31 topStories: any[],
32 newStories: any[],
118}
119
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);

audio03main.tsx8 matches

@all•Updated 8 months ago
4import * as d3 from "https://esm.sh/d3";
5
6function App() {
7 const svgRef = useRef();
8 const [cables, setCables] = useState([]);
34 .text("INSTRUO");
35
36 // Function to create a knob
37 function createKnob(x, y, radius, label, labelY) {
38 const knob = svg.append("g")
39 .attr("transform", `translate(${x}, ${y})`);
95 createKnob(340, 450, 25, "SUB", 45);
96
97 // Function to create a jack input
98 function createJack(x, y, label) {
99 const jack = svg.append("g")
100 .attr("transform", `translate(${x}, ${y})`);
160 const cableGroup = svg.append("g").attr("class", "cables");
161
162 function updateCables() {
163 const cableElements = cableGroup.selectAll("path")
164 .data(cables);
200}
201
202function client() {
203 createRoot(document.getElementById("root")).render(<App />);
204}
206if (typeof document !== "undefined") { client(); }
207
208export default async function server(req: Request): Promise<Response> {
209 return new Response(`
210 <html>

laserCutterSimulatormain.tsx3 matches

@all•Updated 8 months ago
76};
77
78function App() {
79 const [position, setPosition] = useState({ x: 0, y: 0 });
80 const [isLaserOn, setIsLaserOn] = useState(false);
199}
200
201function client() {
202 createRoot(document.getElementById("root")).render(<App />);
203}
205if (typeof document !== "undefined") { client(); }
206
207async function server(request: Request): Promise<Response> {
208 return new Response(`
209 <html>

v2FanFicScrapermain.tsx10 matches

@willthereader•Updated 8 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4// last stable version is 47
5function App() {
6 const [url, setUrl] = useState("");
7 const [result, setResult] = useState(null);
104}
105
106function client() {
107 console.log("Initializing client-side React application");
108 createRoot(document.getElementById("root")).render(<App />);
116const _REGEX_POST_URL = /posts\/(?<id>\d+)/;
117
118function normalizeUrl(url) {
119 const threadMatch = url.match(_REGEX_THREAD_URL);
120 const postMatch = url.match(_REGEX_POST_URL);
128}
129
130async function scrapePage(url) {
131 console.log(`Starting to scrape page: ${url}`);
132 const apiKey = await getApiKey();
165}
166
167function processThreadmarks(threadmarks) {
168 return threadmarks.map(tm => {
169 let category = "1";
201}
202
203async function scrapePageWithRules(url, apiKey, extractRules) {
204 console.log(`Sending request to ScrapingBee API for URL: ${url}`);
205 try {
245}
246
247function processResults(results) {
248 console.log("Processing results:", JSON.stringify(results, null, 2));
249 if (!results || results.length === 0) {
275}
276
277function processPost(post) {
278 return {
279 id: post.id,
286}
287
288async function getApiKey() {
289 const apiKey = Deno.env.get("ScrapingBeeAPIkey");
290 if (!apiKey) {
295}
296
297export default async function server(request) {
298 console.log(`Received ${request.method} request for path: ${new URL(request.url).pathname}`);
299 if (request.method === "POST" && new URL(request.url).pathname === "/scrape") {

count_visitsmain.tsx4 matches

@muhammad_owais_warsi•Updated 8 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [websiteUrl, setWebsiteUrl] = useState("");
7 const [embedCode, setEmbedCode] = useState("");
61}
62
63function client() {
64 createRoot(document.getElementById("root")).render(<App />);
65}
69}
70
71async function server(request: Request): Promise<Response> {
72 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
73 const SCHEMA_VERSION = 1;
92import { useState, useEffect } from 'react';
93
94function VisitorCounter() {
95 const [count, setCount] = useState(0);
96

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.