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=812&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 8331 results for "function"(528ms)

sqlite_admin_tablesmain.tsx1 match

@stevekrouse•Updated 1 year ago
2import { blob } from "https://esm.town/v/std/blob?v=10";
3
4export async function sqlite_admin_tables() {
5 let blobs = await blob.list();
6 return (

dailyDadJokemain.tsx1 match

@stevekrouse•Updated 1 year ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

valTownBlogRSSmain.tsx1 match

@stevekrouse•Updated 1 year ago
2import { valTownBlogJSON } from "https://esm.town/v/stevekrouse/valTownBlogJSON";
3
4export async function valTownBlogRSS() {
5 return Response.redirect("https://blog.val.town/rss.xml", 301);
6}

sqlite_admin_tablemain.tsx1 match

@stevekrouse•Updated 1 year ago
3import { css } from "https://esm.town/v/stevekrouse/sqlite_admin_css";
4
5export async function sqlite_admin_table(name: string) {
6 if (!name.match(/^[A-Za-z_][A-Za-z0-9_]*$/)) return <>Invalid table name</>;
7 let data = await sqlite.execute(`SELECT * FROM ${name}`);

untitled_limeBeetlemain.tsx1 match

@stevekrouse•Updated 1 year ago
1import { refs } from "https://esm.town/v/stevekrouse/refs";
2
3function a() {
4 console.log(refs());
5}

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).

untitled_moccasinHeronmain.tsx1 match

@stevekrouse•Updated 1 year ago
1export const str = "hello world";
2
3export default function handler(request: Request) {
4 return Response.json({ ok: true });
5}

gpt4FunctionCallingExamplemain.tsx10 matches

@stevekrouse•Updated 1 year ago
2
3const openai = new OpenAI();
4const functionExpression = await openai.chat.completions.create({
5 "messages": [
6 { "role": "user", "content": "What is the weather like in Boston?" },
7 ],
8 "functions": [
9 {
10 "name": "get_current_weather",
29 max_tokens: 30,
30});
31console.log(functionExpression);
32
33// TODO pull out function call and initial message
34let args = functionExpression.choices[0].message.function_call.arguments;
35let functionCallResult = { "temperature": "22", "unit": "celsius", "description": "Sunny" };
36
37const result = await openai.chat.completions.create({
41 "role": "assistant",
42 "content": null,
43 "function_call": { "name": "get_current_weather", "arguments": "{ \"location\": \"Boston, MA\"}" },
44 },
45 {
46 "role": "function",
47 "name": "get_current_weather",
48 "content": JSON.stringify(functionCallResult),
49 },
50 ],
51 "functions": [
52 {
53 "name": "get_current_weather",

gpt4FunctionCallingExampleREADME.md1 match

@stevekrouse•Updated 1 year ago
1Migrated from folder: External_APIs/openai/function_calling/gpt4FunctionCallingExample

oldfashionedmain.tsx9 matches

@tmcw•Updated 1 year ago
23const { styleRoute, StyleTag } = styleSystem();
24
25function MaterialsList() {
26 const c = useContext(RequestContext);
27 const mats = getMaterialIds(c);
76}
77
78function RecipesList() {
79 const c = useContext(RequestContext);
80 const s = c?.req.param("slug");
131} as const;
132
133function Units() {
134 const requestContext = useContext(RequestContext);
135 let unit = getCookie(requestContext!, "units") || "";
162});
163
164function getTitle(recipe: Recipe | undefined): string {
165 if (!recipe) {
166 return "Old Fashioned";
169}
170
171function parseUnit(unit: string | undefined): Fmt {
172 if (unit === "CL" || unit === "Ml" || unit === "Oz") {
173 return unit;
176}
177
178function WelcomeMessage() {
179 return (
180 <plank id="recipe-detail" hx-swap-oob="true">
203}
204
205function RecipeDetail() {
206 const c = useContext(RequestContext);
207 const s = c?.req.param("slug") || "";
257}
258
259function IngredientDisplay({ ingredient, unit }: {
260 ingredient: Ingredient;
261 unit: keyof typeof units;
292}
293
294function Index() {
295 const requestContext = useContext(RequestContext);
296 const s = requestContext?.req.param("slug") || "";

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago