4 * @returns {string} - uploaded image url
5 */
6export async function uploadImage(image: Blob): Promise<string> {
7 const fd = new FormData();
8 fd.append(
23 return data.result.variants[0];
24}
25async function getUploadURL(): Promise<string> {
26 const data = await (await fetch("https://www.val.town/api/trpc/generateImageUploadUrl", {
27 "headers": {
2import { Context, Hono } from "npm:hono";
3
4// Define the route handler function
5export const Time_Blindness_Loud_Calendar_via_iOS_shortcuts = (c: Context) => {
6 console.log("Route accessed: Time_Blindness_Loud_Calendar_via_iOS_shortcuts");
3import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts?v=18";
4
5export const hnFollowApp = function (authors: string[]) {
6 return async function ({ lastRunAt }) {
7 let posts = await hnLatestPosts({
8 authors,
1export function flashBorder(element) {
2 if (!element) return;
3 let flash = true;
1export function animateElement(element, delay) {
2 return new Promise(resolve => {
3 setTimeout(() => {
8}
9
10export async function animateElementsSimultaneously(elements, initialDelay) {
11 const promises = elements.map(element => animateElement(element, initialDelay));
12 await Promise.all(promises);
1const JWT = Deno.env.get("PINATA_JWT");
2
3async function main() {
4 try {
5 console.log("uploading file");
51
52 // Load and render GeoJSON data
53 d3.json("/nyc.geojson").then(function(data) {
54 svg.selectAll("path")
55 .data(data.features)
67 .attr("r", 5)
68 .attr("class", "link")
69 .on("click", function(event, d) {
70 showCamera(d.id);
71 })
72 .on("mouseover", function(event, d) {
73 d3.select(this).transition()
74 .duration(200)
77 d3.select(this).raise();
78 })
79 .on("mouseout", function(event, d) {
80 d3.select(this).transition()
81 .duration(200)
237
238 const source = new EventSource("/camera-text-stream/${c.req.param("id")}");
239 source.onopen = function(e) {
240 loadingInterval = setInterval(() => {
241 loadingBox.textContent = brailleChars[brailleChars.length - charIndex - 1] + ' streaming ' + brailleChars[charIndex];
243 }, 100);
244 }
245 source.onmessage = function(e) {
246 document.querySelector('pre').innerHTML = JSON.parse(e.data);
247 }
248 source.onerror = function(e) {
249 if (loadingInterval) clearInterval(loadingInterval);
250 loadingBox.textContent = 'Error';
29
30// Format an ISO datetime like Sun 06:00 AM
31function fmtDate(d: string): string {
32 return new Date(d).toLocaleString("en-US", { weekday: "short", hour: "numeric", minute: "numeric", hour12: true });
33}
34
35// Format ISO datetime like 06:00 AM
36function fmtTime(d: string): string {
37 return new Date(d).toLocaleString("en-US", { hour: "numeric", minute: "numeric", hour12: true });
38}
39
40// Retry a function n times with exponential backoff.
41async function retry<T>(fn: () => Promise<T>, n: number): Promise<T> {
42 for (let i = 0; i < n; i++) {
43 try {
53
54// Sleep a random amount of seconds (to respect NOAA's API).
55async function sleepRand(seconds: number) {
56 const s = Math.random() * seconds * 1000;
57 await new Promise(r => setTimeout(r, s));
59
60// Find some weather intervals!
61async function run(): Promise<string> {
62 try {
63 await sleepRand(15);
103}
104
105export default async function(interval: Interval) {
106 const msg = await retry(run, 3);
107 await email({ subject: "🚲 Good times to bike!", text: msg });
5await setupSQLiteKV();
6
7export async function set(key, value) {
8 await sqlite.execute({
9 sql: `insert into kv (key, value) values (?, ?)
14}
15
16export async function get(key) {
17 return (await sqlite.execute({
18 sql: `select value from kv where key = ?`,
1import * as THREE from 'https://cdn.skypack.dev/three@0.128.0';
2
3export function create3DEmoji(emoji, width, height) {
4 // canvas element
5 const canvas = document.createElement('canvas');
57
58 // animation loop
59 function animate() {
60 requestAnimationFrame(animate);
61