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/image-url.jpg?q=function&page=2482&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 28467 results for "function"(5714ms)

infiniteSVGGraphmain.tsx6 matches

@ttodosi•Updated 9 months ago
35// Database querying.
36
37function parseResultSet<T>(row: ResultSet): T[] {
38 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
39}
67};
68
69// Client side javascript and template functions.
70
71const clientJavascript = async () => {
135 });
136
137 function createHeartBurst(event) {
138 const button = event.currentTarget;
139 const buttonContainer = button.closest(".heart-button-container");
174};
175
176function escapeHTML(html: string): string {
177 const escapeChars: { [char: string]: string } = {
178 "&": "&amp;",
408 let encoder = new TextEncoder();
409
410 function isValidSVG(svgString) {
411 const parser = new DOMParser({
412 errorHandler: {
488
489app.get("/:id/img.svg", async (c) => {
490 function addSVGNamespace(svgString) {
491 if (!/^<\?xml/.test(svgString)) svgString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + svgString;
492 if (!/xmlns="http:\/\/www.w3.org\/2000\/svg"/.test(svgString))

valTownBlogRSSmain.tsx1 match

@ttodosi•Updated 9 months ago
2import { valTownBlogJSON } from "https://esm.town/v/stevekrouse/valTownBlogJSON";
3
4export async function valTownBlogRSS() {
5 const json = await valTownBlogJSON();
6 return new Response(dataToRSS(

poisedOrangeJellyfishmain.tsx2 matches

@jeffreyyoung•Updated 9 months ago
133`;
134console.log(EventSource);
135async function* forward(query: QueryRequest, botName: string, accessKey: string) {
136 console.log(query, botName, accessKey);
137 const req = new Request(`https://api.poe.com/bot/${botName}`, {
149}
150
151async function* fetchEventSource(request: Request) {
152 const response = await fetch(request);
153 console.log(response.status, response.statusText);

spotifymain.tsx3 matches

@ejfox•Updated 9 months ago
40 window.location.href = url;
41 });
42 window.onerror = function(message, source, lineno, colno, error) {
43 console.error('An error occurred:', error);
44 errorDiv.textContent = 'An error occurred: ' + message;
83 console.log('Access token received');
84
85 async function fetchPlaylists() {
86 try {
87 const response = await axios.get('https://api.spotify.com/v1/me/playlists', {
111 }
112
113 async function fetchTracks(playlistId, playlistName) {
114 try {
115 const response = await axios.get(\`https://api.spotify.com/v1/playlists/\${playlistId}/tracks\`, {

grotesqueAquamarineShrewmain.tsx1 match

@slowchaz•Updated 9 months ago
7}
8
9export default async function handler(req: Request): Promise<Response> {
10 const headers = new Headers({
11 "Access-Control-Allow-Origin": "*",

friendmain.tsx1 match

@robh3•Updated 9 months ago
9});
10
11export default async function(req: Request): Promise<Response> {
12 let currentDate = new Date().toISOString(); // Otherwise, we take the current date
13 await cloudflareR2client.putObject("transcription-" + currentDate + ".json", req.body);

mastodonmain.tsx1 match

@ejfox•Updated 9 months ago
4import axios from "npm:axios";
5
6export default async function main(req: Request): Promise<Response> {
7 const token = Deno.env.get("MASTODON_TOKEN");
8 const instance = "mastodon.social"; // Replace with your Mastodon instance if different

recentpinboardmain.tsx1 match

@ejfox•Updated 9 months ago
4import axios from "npm:axios";
5
6export default async function main(req: Request): Promise<Response> {
7 const token = Deno.env.get("PINBOARD_TOKEN");
8

githubcollabgenmain.tsx4 matches

@ejfox•Updated 9 months ago
3const OPENAI_API_KEY = "your_openai_api_key"; // Replace with your actual OpenAI API key
4
5export default async function main(req: Request): Promise<Response> {
6 const url = new URL(req.url);
7 const user1 = url.searchParams.get("user1") || "ejfox";
8 const user2 = url.searchParams.get("user2") || "stevekrouse";
9
10 async function fetchUserActivity(username: string) {
11 const threeMonthsAgo = new Date(Date.now() - 90 * 24 * 60 * 60 * 1000).toISOString();
12 const response = await fetch(
20 }
21
22 function summarizeActivity(data: any[]): string {
23 const summary = [];
24 const repoSet = new Set<string>();
96 });
97 } catch (error) {
98 console.error("Error in main function:", error);
99 return new Response(`Error: ${error.message}. Please check the logs for more details.`, { status: 500 });
100 }

githubactivitysummarizermain.tsx3 matches

@ejfox•Updated 9 months ago
10const OPENAI_API_KEY = "your_openai_api_key"; // Replace with your actual OpenAI API key
11
12export default async function main(req: Request): Promise<Response> {
13 const url = new URL(req.url);
14 const user1 = url.searchParams.get('user1') || 'ejfox';
15 const user2 = url.searchParams.get('user2') || 'octocat';
16
17 async function fetchUserActivity(username: string) {
18 const oneYearAgo = new Date(Date.now() - 365 * 24 * 60 * 60 * 1000).toISOString();
19 const response = await fetch(`https://api.github.com/users/${username}/events?per_page=100&since=${oneYearAgo}`);
31 ]);
32
33 function summarizeActivity(data: any[]) {
34 const repoSet = new Set();
35 const languageSet = new Set();

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.