1import siversRssEmailNotification from "https://esm.town/v/chet/siversRssEmailNotification";
2
3export default async function(interval: Interval) {
4 await siversRssEmailNotification(interval);
5}
4import { parseXML } from "https://esm.town/v/stevekrouse/parseXML";
5
6export default async function(interval: Interval) {
7 // const lastRunAt = new Date(Date.now() - 1000 * 60 * 60 * 24 * 30 * 3);
8 const lastRunAt = interval.lastRunAt;
13 "buttondown.bsky.social",
14 ];
15 const promises = ALERT_STRINGS.map(async function(keyword) {
16 let posts = await fetchJSON(
17 `https://search.bsky.social/search/posts?q=${keyword}`,
1import { im } from "https://esm.town/v/envl/im";
2
3export async function sendMsg(req: Request) {
4 const msg = new URL(req.url).searchParams.get("msg") ?? (await req.json()).msg;
5 await im(msg);
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=42";
3
4export default async function (req: Request) {
5 const url = new URL(req.url);
6 const [, id, action] = url.pathname.split("/");
1let { userCount } = await import("https://esm.town/v/chrisk_7777/userCount");
2
3export function myApi(name) {
4 if (!userCount) {
5 userCount = [];
2import { zip } from "npm:lodash-es";
3
4export async function getDocs() {
5 let { columns, rows } = await sqlite.execute(`select * from DateMeDocs`);
6 return rows.map(row => Object.fromEntries(zip(columns, row.map(d => JSON.parse(d)))));
1import { fetch } from "https://esm.town/v/std/fetch";
2export default async function(req: Request): Promise<Response> {
3 const p = Object.fromEntries(new URL(req.url).searchParams);
4 if (!p.url) return Response.json("missing url");
9const SIMULATIONS = 10000;
10
11function rand_action(state: connect4.State): connect4.Action {
12 const player = state.next_player;
13 while (true) {
20}
21
22function score_action(
23 current_state: connect4.State,
24 action: connect4.Action,
51}
52
53function agent(state: connect4.State): connect4.Action {
54 // For each action we could take, simulate multiple random games from the resulting state.
55 // Keep track of the number of wins for each action.
49export type Action = z.infer<typeof Action>;
50
51export function get(state: State, col: number, row: number): Slot {
52 return state.board[col][row];
53}
54
55export function set(state: State, col: number, row: number, slot: Slot): void {
56 state.board[col][row] = slot;
57}
63 | "column_out_of_bounds";
64
65export function check_action(state: State, action: Action): ActionCheck {
66 if (action.player !== state.next_player) {
67 return "wrong_player";
76}
77
78function check_slots_eq(a: Slot, b: Slot, c: Slot, d: Slot): Slot {
79 if (a === b && b === c && c === d) {
80 return a;
83}
84
85export function status(state: State): Status {
86 // Check Vertical Win
87 for (let col = 0; col < COLS; col++) {
150}
151
152export function apply_action(state: State, action: Action): Status {
153 // Action should be checked before calling this function.
154 // We assert that the action is ok.
155 let check = check_action(state, action);
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",