blob_adminREADME.md1 match
9[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
1011It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
1213# TODO
blob_adminREADME.md1 match
9[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
1011It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
1213# TODO
calculateTransitTimeValmain.tsx28 matches
1// This val calculates driving/transit time from given origins to the nearest grocery store, gym, FiDi, Roblox HQ, and Samsara in San Francisco.
2// It uses data from SF_Grocery and SF_Gyms blobs, and the Google Maps Directions API for travel times.
3// It also looks up the neighborhood based on the ZIP code using the SF_Neighborhood_ZIP blob.
4// Results are saved and displayed for each new address added, with options to delete individual results.
219}
220221const apiKey = Deno.env.get("GOOGLE_MAPS_API_KEY");
222if (!apiKey) {
223console.error("API key is missing");
224return new Response(JSON.stringify({ error: "API key is not configured" }), {
225headers: { "Content-Type": "application/json" },
226});
237238console.log("Finding nearest grocery");
239const nearestGrocery = await findNearest(origin, groceries, apiKey);
240console.log("Nearest grocery:", nearestGrocery);
241242console.log("Finding nearest gym");
243const nearestGym = await findNearest(origin, gyms, apiKey);
244console.log("Nearest gym:", nearestGym);
245246console.log("Calculating driving time to FiDi");
247const fidiDestination = "548 Market St, San Francisco, CA 94104";
248const fidiDrivingTime = await getDrivingTime(origin, fidiDestination, apiKey);
249console.log("FiDi driving time:", fidiDrivingTime);
250251console.log("Calculating driving time to Roblox");
252const robloxDestination = "910 Park Pl Ste 300, San Mateo, CA 94403";
253const robloxDrivingTime = await getDrivingTime(origin, robloxDestination, apiKey, "09:00:00", "Tuesday");
254console.log("Roblox driving time:", robloxDrivingTime);
255256console.log("Calculating transit time to Samsara");
257const samsaraDestination = "1 De Haro St, San Francisco, CA 94103";
258const samsaraTransitTime = await getTransitTime(origin, samsaraDestination, apiKey);
259console.log("Samsara transit time:", samsaraTransitTime);
260261console.log("Extracting ZIP code and looking up neighborhood");
262const zipCode = await getZipCode(origin, apiKey);
263const neighborhoodZipMap = await blob.getJSON("SF_Neighborhood_ZIP");
264const neighborhood = neighborhoodZipMap[zipCode] || "Unknown";
315}
316317async function findNearest(origin: string, locations: any[], apiKey: string): Promise<any> {
318console.log(`Finding nearest location among ${locations.length} options`);
319const batchSize = 25; // Google Maps API typically allows up to 25 destinations per request
320let nearestLocation = null;
321let shortestTime = Infinity;
324const batch = locations.slice(i, i + batchSize);
325const destinations = batch.map(location => `${location.gps.lat},${location.gps.lng}`).join("|");
326const distanceMatrixUrl = `https://maps.googleapis.com/maps/api/distancematrix/json?origins=${
327encodeURIComponent(origin)
328}&destinations=${encodeURIComponent(destinations)}&mode=driving&key=${apiKey}`;
329330console.log(`Fetching from Distance Matrix API for batch ${i / batchSize + 1}`);
331const response = await fetch(distanceMatrixUrl);
332const data = await response.json();
333console.log("Distance Matrix API response status:", data.status);
334335if (data.status !== "OK") {
336console.error("Distance Matrix API failed:", data);
337throw new Error(`Distance Matrix API failed. Status: ${data.status}`);
338}
339362origin: string,
363destination: string,
364apiKey: string,
365arrivalTime?: string,
366arrivalDay?: string,
367): Promise<string> {
368let directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${
369encodeURIComponent(origin)
370}&destination=${encodeURIComponent(destination)}&mode=driving&key=${apiKey}`;
371372if (arrivalTime && arrivalDay) {
388}
389390async function getTransitTime(origin: string, destination: string, apiKey: string): Promise<string> {
391const directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${
392encodeURIComponent(origin)
393}&destination=${encodeURIComponent(destination)}&mode=transit&key=${apiKey}`;
394395const directionsResponse = await fetch(directionsUrl);
405}
406407async function getZipCode(address: string, apiKey: string): Promise<string> {
408const geocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${
409encodeURIComponent(address)
410}&key=${apiKey}`;
411const response = await fetch(geocodeUrl);
412const data = await response.json();
blob_adminREADME.md1 match
9[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
1011It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
1213# TODO
free_open_routermain.tsx16 matches
1const COMPLETION = "/api/v1/chat/completions";
2const MODELS = "/api/v1/models";
3const supported_urls = [COMPLETION, MODELS];
4import { blob } from "https://esm.town/v/std/blob";
56const isValTown = Deno.env.get("VALTOWN_API_URL");
7// Define a common set of CORS headers
8const corsHeaders = {
148}
149150// Define the API endpoints and their respective tokens
151const apiEndpoints = [
152{
153url: "https://openrouter.ai/api/v1/models",
154token: Deno.env.get("OPEN_ROUTER_API_KEY"),
155},
156{
157url: "https://api.groq.com/openai/v1/models",
158token: Deno.env.get("GROQ_API_KEY"),
159},
160];
161162// Create fetch promises for each API endpoint
163const fetchPromises = apiEndpoints.map(({ url, token }) =>
164fetch(url, {
165headers: {
262}
263264let bearerToken = Deno.env.get("OPEN_ROUTER_API_KEY");
265266let body: string | ReadableStream<Uint8Array> | null = null;
277provider = "groq";
278model = model.replace("groq/", "");
279bearerToken = Deno.env.get("GROQ_API_KEY");
280}
281// Check if model ends with ':free'
297298if (provider === "groq") {
299url.host = "api.groq.com";
300url.pathname = url.pathname.replace("/api/v1", "/openai/v1");
301url.port = "443";
302url.protocol = "https";
318};
319320// Special handling for /api/v1/models
321if (url.pathname == MODELS) {
322return new Response(JSON.stringify({ object: "list", data: freeModels }), {
celinewaitlistmain.tsx1 match
1/**
2* This Val creates a simple API endpoint that saves an email address for notifications
3* using Val Town's JSON storage. It handles POST requests to save the submitted email
4* and returns a simple confirmation message.
wed18_09_2024main.tsx2 matches
9type Y = Ex<1 | 2 | 3 | "a" | "b" | "c", "a" | "c">;
1011type T = Capitalize<"asdf">;
1213type TT = Uncapitalize<"AAA">;
1415//
axiomNotifierREADME.md1 match
1This webhook handler sends messages in the specificed thread in response to events from [Axiom](https://axiom.co), a log monitoring service,
23Campsite API Documentation: https://campsite.com/docs
openapi_playgroundmain.tsx4 matches
10} from "https://deno.land/x/hono@v4.0.10/jsx/index.ts";
11import { Hono } from "https://deno.land/x/hono@v4.0.10/mod.ts";
12import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
13import { create } from "https://esm.town/v/websandbox/create";
14import * as YAML from "jsr:@std/yaml";
63);
64return (
65<Layout title="OpenAPI Playground">
66<style>
67{String.raw`
231}
232} else {
233code = `# Paste your OpenAPI spec here`;
234}
235}
238});
239function template(code: string) {
240return `import { makeServer } from "https://esm.town/v/stainless_em/openapiPlaygroundServer"\nexport default makeServer(${
241JSON.stringify(YAML.parse(code))
242})`;
1import { getMainExport } from "https://esm.town/v/easrng/oldstyleUtil?v=1";
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { blob } from "https://esm.town/v/std/blob?v=11";
4import { decodeBase64, encodeBase64 } from "jsr:@std/encoding@0.219.1/base64";
28});
29const start = performance.now();
30const res = await fetch(API_URL + "/v1/eval", {
31method: "POST",
32body: JSON.stringify({