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=1405&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 18322 results for "function"(1268ms)

bbruncREADME.md1 match

@dglazkov•Updated 7 months ago
13must contain your board server API key.
14
15To use, create an HTTP val, then import the `proxy` function from this script and call it like this:
16
17```ts

hexmazemain.tsx6 matches

@moe•Updated 7 months ago
14let colorIndex: number
15
16export function setup() {
17 console.log("setup")
18 // variables
77}
78
79function hexagon(x, y, r, c) {
80 let hx = (i) => x + sin((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
81 let hy = (i) => y + cos((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
201}
202
203function drawBorder(border, strokeW = 0) {
204 strokeWeight(0)
205 rect(0, 0, border, height)
216}
217
218export function draw() {}
219
220export function keyPressed() {
221 if (key == "i") {
222 saveCanvas("p5js-" + new Date().getTime(), "png")
226 }
227}
228// export function touchEnded() {
229// saveCanvas("p5js-" + new Date().getTime(), "png");
230// }

exampleP5sketchmain.tsx4 matches

@moe•Updated 7 months ago
5export default sketch(import.meta.url, title)
6
7export function setup() {
8 // console.log("setup", window.innerWidth, window.innerHeight);
9 // createCanvas(window.innerWidth, window.innerHeight);
11}
12
13export function draw() {
14 background(0)
15 if (mouseIsPressed) {
21}
22
23export function keyPressed() {
24 if (key == "i") {
25 saveCanvas("p5js-" + new Date().getTime(), "png")
29 }
30}
31// export function touchEnded() {
32// saveCanvas("p5js-" + new Date().getTime(), "png");
33// }

redditSearchmain.tsx6 matches

@jasperfurniss•Updated 7 months ago
15}
16
17async function redditSearch({
18 query,
19}: RedditSearchOptions): Promise<ThreadResult[]> {
32}
33
34function constructSearchUrl(query: string): string {
35 const encodedQuery = encodeURIComponent(query);
36 return `https://www.reddit.com/search.json?q=${encodedQuery}&sort=new&t=week&limit=25`;
37}
38
39async function processPostData(posts: any[]): Promise<ThreadResult[]> {
40 const processedData: ThreadResult[] = [];
41
57}
58
59function App() {
60 const [query, setQuery] = useState("");
61 const [results, setResults] = useState<ThreadResult[]>([]);
99}
100
101function client() {
102 createRoot(document.getElementById("root")).render(<App />);
103}
107}
108
109export default async function server(request: Request): Promise<Response> {
110 return new Response(`
111 <html>

humansnapmain.tsx5 matches

@ngmi•Updated 7 months ago
4const ADMIN_PASSWORD = Deno.env.get("ADMIN_PASSWORD") || "defaultpassword"; // Set this in your Val Town environment variables
5
6async function initializeDatabase() {
7 await sqlite.execute(`
8 CREATE TABLE IF NOT EXISTS ${KEY}_emails (
14}
15
16async function addEmail(email: string) {
17 await sqlite.execute(`INSERT OR IGNORE INTO ${KEY}_emails (email) VALUES (?)`, [email]);
18}
19
20async function getEmails() {
21 const result = await sqlite.execute(`SELECT * FROM ${KEY}_emails ORDER BY timestamp DESC`);
22 return result.rows;
23}
24
25export default async function server(request: Request): Promise<Response> {
26 await initializeDatabase();
27 const url = new URL(request.url);
290 <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
291 <script>
292 document.getElementById('email-form').addEventListener('submit', async function(e) {
293 e.preventDefault();
294 const email = document.getElementById('email').value;

reMarkableXNYTCrosswordmain.tsx2 matches

@bmalicoat•Updated 7 months ago
3import request from "npm:request";
4
5export default async function(interval: Interval) {
6 // Cookies and Tokens -> use `mitmweb` to navigate to NYTimes.com to grab cookie. Repeat for my.remarkable.com
7
63 },
64 })
65 .then(function(response) {
66 var rmMetadata = { "parent": rmFolderGuid, "file_name": puzzleFriendlyName };
67

waveFormmain.tsx3 matches

@all•Updated 7 months ago
90
91// Main App Component
92function App() {
93 const [synth, setSynth] = useState(null);
94 const [analyser, setAnalyser] = useState(null);
207}
208
209function client() {
210 createRoot(document.getElementById("root")).render(<App />);
211}
213if (typeof document !== "undefined") { client(); }
214
215export default async function server(request: Request): Promise<Response> {
216 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
217 const SCHEMA_VERSION = 2

ssr_react_minimain.tsx1 match

@nicosql•Updated 7 months ago
35
36export const hydrate = (importMetaURL: string) =>
37 async function(req: Request): Promise<Response> {
38 const { author, name } = extractValInfo(importMetaURL);
39 const valURL = `https://www.val.town/v/${author}/${name}`;

assistantHarlequinKangaroomain.tsx10 matches

@nicosql•Updated 7 months ago
15}
16
17export default async function(interval: Interval): Promise<void> {
18 try {
19 await createTable();
38
39// Create an SQLite table
40async function createTable(): Promise<void> {
41 await sqlite.execute(`
42 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
50
51// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53 return hackerNewsSearch({
54 query: topic,
58}
59
60async function fetchTwitterResults(topic: string): Promise<Website[]> {
61 return twitterSearch({
62 query: topic,
67}
68
69async function fetchRedditResults(topic: string): Promise<Website[]> {
70 return redditSearch({ query: topic });
71}
72
73function formatSlackMessage(website: Website): string {
74 const displayTitle = website.title || website.url;
75 return `*<${website.url}|${displayTitle}>*
78}
79
80async function sendSlackMessage(message: string): Promise<Response> {
81 const slackWebhookUrl = Deno.env.get("SLACK_WEBHOOK_URL");
82 if (!slackWebhookUrl) {
104}
105
106async function isURLInTable(url: string): Promise<boolean> {
107 const result = await sqlite.execute({
108 sql: `SELECT 1 FROM ${TABLE_NAME} WHERE url = :url LIMIT 1`,
112}
113
114async function addWebsiteToTable(website: Website): Promise<void> {
115 await sqlite.execute({
116 sql: `INSERT INTO ${TABLE_NAME} (source, url, title, date_published)
120}
121
122async function processResults(results: Website[]): Promise<void> {
123 for (const website of results) {
124 if (!(await isURLInTable(website.url))) {

liquidOrangeFowlmain.tsx10 matches

@nicosql•Updated 7 months ago
15}
16
17export default async function(interval: Interval): Promise<void> {
18 try {
19 await createTable();
38
39// Create an SQLite table
40async function createTable(): Promise<void> {
41 await sqlite.execute(`
42 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
50
51// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53 return hackerNewsSearch({
54 query: topic,
58}
59
60async function fetchTwitterResults(topic: string): Promise<Website[]> {
61 return twitterSearch({
62 query: topic,
67}
68
69async function fetchRedditResults(topic: string): Promise<Website[]> {
70 return redditSearch({ query: topic });
71}
72
73function formatSlackMessage(website: Website): string {
74 const displayTitle = website.title || website.url;
75 return `*<${website.url}|${displayTitle}>*
78}
79
80async function sendSlackMessage(message: string): Promise<Response> {
81 const slackWebhookUrl = Deno.env.get("SLACK_WEBHOOK_URL");
82 if (!slackWebhookUrl) {
104}
105
106async function isURLInTable(url: string): Promise<boolean> {
107 const result = await sqlite.execute({
108 sql: `SELECT 1 FROM ${TABLE_NAME} WHERE url = :url LIMIT 1`,
112}
113
114async function addWebsiteToTable(website: Website): Promise<void> {
115 await sqlite.execute({
116 sql: `INSERT INTO ${TABLE_NAME} (source, url, title, date_published)
120}
121
122async function processResults(results: Website[]): Promise<void> {
123 for (const website of results) {
124 if (!(await isURLInTable(website.url))) {

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks 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.