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=2658&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 28726 results for "function"(5730ms)

btcPriceAlertmain.tsx1 match

@dantaeyoung•Updated 1 year ago
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8

staleGithubPRsEmailmain.tsx2 matches

@andreterron•Updated 1 year ago
5// Sends an email with all the open PRs that have not had any activity
6// for specified period of days
7// Set up this function to run every day (or any interval)
8export async function staleGithubPRsEmail() {
9 // Set up a secret named githubRepos with all the repos you want to analyze (comma separated)
10 let repos = Deno.env.get("githubRepos")?.split(",").filter((r) => r.trim()) ?? [];

cdnmain.tsx2 matches

@pomdtr•Updated 1 year ago
3import { readmeToHtmlResponse } from "https://esm.town/v/pomdtr/readme";
4
5async function createScreenshot(code: string) {
6 const apiUrl = "https://sourcecodeshots.com/api/image";
7 const resp = await fetch(apiUrl, {
19}
20
21export default async function(req: Request) {
22 const url = new URL(req.url);
23 const [author, file] = url.pathname.slice(1).split("/");

htmlExamplemain.tsx1 match

@andreterron•Updated 1 year ago
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4

getValREADME.md1 match

@pomdtr•Updated 1 year ago
2Gets information about a specific val.
3
4To access private vals, pass your API token as a secret to the function. Read more about [authentication](https://docs.val.town/api/authentication) to understand how to generate a token and save it as a secret.

hnFollowAppmain.tsx1 match

@bentossell•Updated 1 year ago
3import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts?v=18";
4
5export default async function({ lastRunAt }) {
6 let posts = await hnLatestPosts({
7 query: "AI, LLM",

hnFollowAppmain.tsx1 match

@maggieappleton•Updated 1 year ago
3import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts?v=18";
4
5export default async function({ lastRunAt }) {
6 let posts = await hnLatestPosts({
7 query: "maggieappleton",

ntfyReqmain.tsx1 match

@arrudaricardo•Updated 1 year ago
151}
152
153export async function sendNotification(baseURL: string, body: NtfyJSONBody): Promise<Response> {
154 return await fetch(baseURL, {
155 method: "POST",

vtTypesmain.tsx1 match

@easrng•Updated 1 year ago
1export default async function(req: Request): Promise<Response> {
2 const urls = [
3 "https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.d.ts",

encryptionmain.tsx5 matches

@easrng•Updated 1 year ago
6// $SECRET should be high quality random base64
7const baseKey = decodeBase64(Deno.env.get("SECRET"));
8function deriveKey(usage: string) {
9 const tag = encoder.encode(usage);
10 const hash = nacl.hash(concat([tag, baseKey]));
11 return hash;
12}
13export function encrypt(usage: string, data: Uint8Array): Uint8Array {
14 const nonce = nacl.randomBytes(nacl.secretbox.nonceLength);
15 const key = deriveKey(usage).slice(0, nacl.secretbox.keyLength);
16 return concat([nonce, nacl.secretbox(data, nonce, key)]);
17}
18export function decrypt(usage: string, encrypted: Uint8Array): Uint8Array {
19 const box = encrypted.slice(nacl.secretbox.nonceLength);
20 const nonce = encrypted.slice(0, nacl.secretbox.nonceLength);
24 return data;
25}
26export function encryptString(usage: string, data: string) {
27 return encodeBase64(encrypt(usage, encoder.encode(data)));
28}
29export function decryptString(usage: string, encrypted: string) {
30 return decoder.decode(decrypt(usage, decodeBase64(encrypted)));
31}

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.