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=1608&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 18949 results for "function"(2205ms)

aqimain.tsx1 match

@chen•Updated 11 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "narberth, pa"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

upload_jsonmain.tsx1 match

@stevedylandev•Updated 11 months ago
1const JWT = Deno.env.get("PINATA_JWT");
2async function pinJSONToIPFS() {
3 try {
4 const data = JSON.stringify({

twitterAlertmain.tsx2 matches

@chen•Updated 11 months ago
29const openai = new OpenAI();
30
31export async function twitterAlert({ lastRunAt }: Interval) {
32 let results = [];
33 for (const username of usernames) {
38 }
39
40 async function filterTweets(tweets) {
41 const completion = await openai.chat.completions.create({
42 messages: [

getTeamsmain.tsx1 match

@brianleroux•Updated 11 months ago
1import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
2
3export default async function getTeams() {
4 let url = "https://www.capfriendly.com";
5 let res = await fetch(url);

scrapecapfriendlymain.tsx1 match

@brianleroux•Updated 11 months ago
1import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
2
3export async function handler(request: Request) {
4 let url = "https://www.capfriendly.com/";
5 let res = await fetch(url);

sqliteExplorerAppREADME.md1 match

@kamek•Updated 11 months ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query

password_authmain.tsx7 matches

@kamek•Updated 11 months ago
11};
12
13async function createSessionTable(tableName: string) {
14 await sqlite.execute(`CREATE TABLE ${tableName} (
15 id TEXT NOT NULL PRIMARY KEY,
19}
20
21async function createSession(tableName: string, valSlug: string): Promise<Session> {
22 try {
23 const expires_at = new Date();
39}
40
41async function getSession(tableName: string, sessionID: string, valSlug: string): Promise<Session> {
42 try {
43 const { rows, columns } = await sqlite.execute({
60}
61
62async function fetchUser(token: string): Promise<{ id: string }> {
63 const resp = await fetch("https://api.val.town/v1/me", {
64 headers: {
74}
75
76async function verifyApiToken(token: string) {
77 try {
78 const [currentUser, requestUser] = await Promise.all([fetchUser(Deno.env.get("valtown")), fetchUser(token)]);
106</html>`;
107
108export function redirect(location: string): Response {
109 return new Response(null, {
110 headers: {
124const cookieName = "auth_session";
125
126export function passwordAuth(next, options?: PasswordAuthOptions) {
127 let passwords: string[];
128 if (!options?.password) {

multiplayerCirclesmain.tsx6 matches

@maxm•Updated 11 months ago
37// });
38
39function parseResultSet<T>(row: ResultSet): T[] {
40 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
41}
51};
52
53function diffCircles(array1: Circle[], array2: Circle[]): Circle[] {
54 const changes: Circle[] = [];
55
74
75 const drag = (() => {
76 function dragstarted() {
77 d3.select(this).attr("stroke", "black");
78 }
79
80 function dragged(event, d) {
81 d3.select(this).raise().attr("cx", d.x = event.x).attr("cy", d.y = event.y);
82 }
83
84 function dragended() {
85 const x = d3.select(this).attr("cx");
86 const y = d3.select(this).attr("cy");
105 .call(drag)
106 .on("click", clicked);
107 function clicked(event, d) {
108 if (event.defaultPrevented) return; // dragged
109

reportBodySizemain.tsx1 match

@maxm•Updated 11 months ago
1export default async function(req: Request): Promise<Response> {
2 if (req.method !== "POST") {
3 return new Response("Method not allowed", { status: 405 });

twitterAlertmain.tsx2 matches

@rkartzman•Updated 11 months ago
27const openai = new OpenAI();
28
29export async function twitterAlert({ lastRunAt }: Interval) {
30 let results = [];
31 for (const username of usernames) {
36 }
37
38 async function filterTweets(tweets) {
39 const completion = await openai.chat.completions.create({
40 messages: [

getFileEmail4 file matches

@shouser•Updated 2 weeks 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
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",