10}
11
12export default function MapboxComponent({ city }: MapboxProps) {
13 const mapContainer = <div id="map" style={{ width: '100%', height: '400px' }}></div>;
14
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);
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 });
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,
1import { postToMastodon } from "https://esm.town/v/sebdd/postToMastodon";
2
3export function testPostToMastodon() {
4 let response = postToMastodon(
5 "https://floss.social/api/v1",
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.
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 }) => {
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.
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">,
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(