5import { render } from "npm:preact-render-to-string";
6
7export function sendTestEmailNewsletter(interval: Interval) {
8 /*
9 * Since this is a public Val, anyone can run it.
8}
9
10export function generateNewsletterJsx({ webUrl, newsletterContent, emailAddress }) {
11 return (
12 <main>
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");
3import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems";
4
5export async function pollRSSFeeds({ lastRunAt }: Interval) {
6 return Promise.all(
7 Object.entries(rssFeeds).map(async ([name, url]) => {
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(
22const MAX_ROWS_PER_CHUNK = 10000;
23
24export default async function(req: Request): Promise<Response> {
25 console.log("Received request");
26 let requestBody: QueryRequest;
99}
100
101async function executePostgresQuery(url: string, query: string): Promise<any[]> {
102 console.log("Connecting to PostgreSQL");
103 const client = new pg.Client({
136}
137
138async function executeMysqlQuery(url: string, query: string): Promise<any[]> {
139 console.log("Connecting to MySQL");
140 const connection = await mysql.createConnection(url);
163}
164
165async function introspectPostgresSchema(url: string): Promise<any[]> {
166 const query = `
167 SELECT
181}
182
183async function introspectMysqlSchema(url: string): Promise<any[]> {
184 const query = `
185 SELECT
199}
200
201function splitIntoChunks(results: any[], maxRowsPerChunk: number): any[][] {
202 console.log(`Splitting ${results.length} rows into chunks of ${maxRowsPerChunk}`);
203 const chunks = [];
209}
210
211async function createGzipFile(chunk: any[], index: number, shouldGzip: boolean, introspection: boolean): Promise<any> {
212 console.log(`Creating ${shouldGzip ? "gzip" : ""} file for chunk ${index + 1}`);
213 const csv = parse(chunk);
37// });
38
39function parseResultSet<T>(row: ResultSet): T[] {
40 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
41}
51};
52
53function diffCircles(array1: Circle[], array2: Circle[]): Circle[] {
54 const changes: Circle[] = [];
55
74
75 const drag = (() => {
76 function dragstarted() {
77 d3.select(this).attr("stroke", "black");
78 }
79
80 function dragged(event, d) {
81 d3.select(this).raise().attr("cx", d.x = event.x).attr("cy", d.y = event.y);
82 }
83
84 function dragended() {
85 const x = d3.select(this).attr("cx");
86 const y = d3.select(this).attr("cy");
105 .call(drag)
106 .on("click", clicked);
107 function clicked(event, d) {
108 if (event.defaultPrevented) return; // dragged
109
11`);
12
13export function publicKey(data: Uint8Array, offset: number) {
14 return base58.encode(data.subarray(offset, offset + 32));
15}
16
17export function u64(view: DataView, offset: number) {
18 return view.getBigUint64(offset, true);
19}
20
21export function parseSwapEvent(data: Uint8Array) {
22 const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
23 return {
32console.log(parseSwapEvent(input));
33
34function bytes(str: string): Uint8Array {
35 return base16.decode(str.replaceAll(/\s/g, "").toUpperCase());
36}
1import { email } from "https://esm.town/v/std/email?v=11";
2
3export function forwarder(e: {
4 from: string;
5 to: string[];
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 const description = "social meta test";
6 const title = "JGB Test";
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": "*",