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/$%7Bsuccess?q=function&page=1709&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 19696 results for "function"(1734ms)

MapUsermain.tsx1 match

@iamseeley•Updated 12 months ago
10}
11
12export default function MapboxComponent({ city }: MapboxProps) {
13 const mapContainer = <div id="map" style={{ width: '100%', height: '400px' }}></div>;
14

pipedreamREADME.md3 matches

@stevekrouse•Updated 12 months ago
3Pipedream offers an Accounts API to handle OAuth for you, automatically, and for free. [How to do it is covered in this guide](https://docs.val.town/integrations/google-sheets/#use-pipedreams-accounts-api).
4
5The helper functions below can make it easier to work with various Google API. For example, I used them like so to get all my free/busy times for this week from all my google calendars:
6
7```ts
11const calendar = await pipeDreamGoogle("calendar", accountId);
12
13// Function to get free/busy information
14async function getFreeBusyTimes(calendarId: string) {
15 const now = new Date();
16 const startOfWeek = new Date(now);

aqimain.tsx1 match

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

gptApiSchemaBuildermain.tsx3 matches

@xkonti•Updated 12 months ago
3import { zodToJsonSchema } from "npm:zod-to-json-schema";
4
5export function getSchemaDesc(schema: z.Schema) {
6 return zodToJsonSchema(schema, {
7 name: "schema",
24}
25
26export function getPathsDesc(endpoints: EndpointDefinition[]) {
27 const paths: any = {};
28 for (const endpoint of endpoints) {
61}
62
63export function getOpenApiSpec(
64 url: string,
65 title: string,

testPostToMastodonmain.tsx1 match

@geraldo•Updated 12 months ago
1import { postToMastodon } from "https://esm.town/v/sebdd/postToMastodon";
2
3export function testPostToMastodon() {
4 let response = postToMastodon(
5 "https://floss.social/api/v1",

staticChessREADME.md1 match

@avkv•Updated 12 months ago
6Plain, brutalist, no bloat chess. Every page is only html and css. Every chess move is made by clicking a link. Send a link to your friend and they'll send you one back to make your move. No silly animations or slick interactivity to trip up your gameplay. When Google indexes this site will we successfully compute all possible chess moves?
7
8Functionality is quite limited, and things might be broken. Please let me know if you find bugs!
9
10Inspired by [this HN discussion](https://news.ycombinator.com/item?id=39456467) about sites that have all possible game states of tic-tac-toe.

decorator_routermain.tsx4 matches

@yieldray•Updated 12 months ago
18}
19
20export function get(path: string) {
21 return (
22 target: (query: Record<string, string>, ctx: Context) => unknown,
37}
38
39export function post(path: string) {
40 return (target: (body: any, ctx: Context) => unknown, _context: ClassMethodDecoratorContext) => {
41 _registered.push({ method: "POST", path });
49}
50
51export function all(path: string) {
52 return (target: (ctx: Context) => unknown, _context: ClassMethodDecoratorContext) => {
53 _registered.push({ method: "*", path });
61}
62
63export function use(path: string) {
64 return (target: (ctx: Context) => unknown, _context: ClassMethodDecoratorContext) => {
65 app.use(path, async (request: Request, { params, next }) => {

chatREADME.md1 match

@onixoni•Updated 12 months ago
1# OpenAI ChatGPT helper function
2
3This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free.

chatmain.tsx3 matches

@onixoni•Updated 12 months ago
1import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
2
3async function getOpenAI() {
4 // if you don't have a key, use our std library version
5 if (Deno.env.get("OPENAI_API_KEY") === undefined) {
14/**
15 * Initiates a chat conversation with OpenAI's GPT model and retrieves the content of the first response.
16 * This function can handle both single string inputs and arrays of message objects.
17 * It supports various GPT models, allowing for flexibility in choosing the model based on the application's needs.
18 *
21 * @returns {Promise<string>} A promise that resolves to the content of the first response from the completion.
22 */
23export async function chat(
24 input: string | Message[],
25 options?: Omit<ChatCompletionCreateParamsNonStreaming, "messages">,

whiteMongoosemain.tsx1 match

@tfayyaz•Updated 12 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

getFileEmail4 file matches

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

tuna8 file matches

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