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=2082&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 22445 results for "function"(2934ms)

get_random_bilibili_videomain.tsx2 matches

@rebelpotato•Updated 1 year ago
1import { get_bilibili } from "https://esm.town/v/rebelpotato/bilibili_methods";
2
3function randint(x) {
4 return Math.floor(Math.random() * x);
5}
7const video_url = "https://api.bilibili.com/x/web-interface/dynamic/region?ps=6&rid=1";
8
9export async function get_random_video(cookie) {
10 let videos = (await get_bilibili(video_url, cookie)).archives;
11 let video = videos[randint(videos.length)];

bilibili_methodsmain.tsx5 matches

@rebelpotato•Updated 1 year ago
1function getBilibiliHeaders(cookie) {
2 return new Headers({
3 "connection": "keep-alive",
9}
10
11function postBilibiliHeaders(cookie) {
12 return new Headers({
13 "connection": "keep-alive",
22}
23
24export function get_bilibili(url, cookie) {
25 return fetch(url, {
26 method: "GET",
39}
40
41function post_encode(params) {
42 return Object.keys(params).map(key => encodeURIComponent(key) + "=" + encodeURIComponent(params[key])).join("&");
43}
44
45export function post_bilibili(url, post_data, cookie) {
46 return fetch(url, {
47 method: "POST",

untitled_blushLobstermain.tsx1 match

@anniepeak•Updated 1 year ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

dbToAPIREADME.md1 match

@nbbaier•Updated 1 year ago
1## Create an API from a [lowdb blob](https://www.val.town/v/pomdtr/lowdb)
2
3This val exports a function that takes a lowdb instance and returns a [Hono](https://hono.dev) router that can be used to interact with the data. This is the beginning of an implementation of something like [json-server](https://github.com/typicode/json-server) for Val Town.
4
5The resulting server also comes with a frontend at `/`. The code for the frontend can be found [here](https://www.val.town/v/nbbaier/dbToAPIFrontend).

weatherGPTmain.tsx1 match

@treb0r•Updated 1 year ago
32console.log(text);
33
34export async function weatherGPT() {
35 await email({ subject: "Weather Today", text });
36}

untitled_coffeeMacawmain.tsx1 match

@shaniehurvitz•Updated 1 year ago
8// Fetches a random joke.
9// Fetches a random joke.
10async function fetchRandomJoke() {
11 const response = await fetch(
12 "https://official-joke-api.appspot.com/random_joke",

aoc15_05main.tsx1 match

@karfau•Updated 1 year ago
1049console.log("solution *2:", secondStar(input));
1050
1051function debug<T>(value: T, msg = "debug"): T {
1052 console.log(msg, value);
1053 return value;

weatherGPTmain.tsx1 match

@ellenchisa•Updated 1 year ago
32console.log(text);
33
34export async function weatherGPT() {
35 await email({ subject: "Weather Today", text });
36}

emailRandomJokemain.tsx1 match

@liu_david3•Updated 1 year ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

aocXX_00README.md2 matches

@karfau•Updated 1 year ago
1This is a great template if you want to solve the <https://adventofcode.com> puzzles in a TDD style:
21. dump your puzzle input into the `input` function
32. copy/paste sample input and output from the page
43. once all assertions pass, the solution is calculated
5
6There is one function for each star that can be achieved.
7
8Some helpers for common tasks are defined at the end of code: `debug`, `toInt`, `exctractNumbers`, `sum`, ... ?

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.