Avatar

@generatecoll

2 likes3 public vals
Joined June 7, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
export const generative_ascii_pattern = (async () => {
// a - pattern character 1, b - pattern character 2, n = horizontal char,
// m = vertical char, mod - initial modulus, patt_freq - pattern frequency change
const char_feat = ["|", "-", "*", "~", "#", ">", "_"];
const clen = char_feat.length;
const R = () => Math.random();
const F = (x) => Math.floor(x);
let param = {
a: char_feat[F(R() * clen)],
b: char_feat[F(R() * clen)],
n: 100,
m: 20,
mod: 2,
patt_freq: 0.001,
};
let fin = "";
for (let i = 0; i < param.m; i++) {
for (let k = 0; k < param.n; k++) {
fin += k % param.mod == 0 ? param.a : param.b;
if (R() < param.patt_freq) {
param.mod = 1 + F(R() * 10);
}
}
fin += "\n";
}
fin += "\n\ngenerative.substack.com";
return fin;
})();
Output

Random Creativity Quotes

The following call will bring back random creativity quotes

Readme
1
2
3
4
5
6
7
8
9
10
import process from "node:process";
export let testPostgres = (async () => {
const postgres = await import("https://deno.land/x/postgres/mod.ts");
const client = new postgres.Client(process.env.neon_url);
await client.connect();
let res = await client.queryObject`select quote_text, author FROM quotes ORDER BY RANDOM() LIMIT 1;`;
let quote = res.rows[0].quote_text;
return Response.json({ quote: quote }); // Response.json({ res: rest });
})();
Exports

An example of how to render an invoice using @vtdocs.generateInvoicePDF

Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { generateInvoicePDF } from "https://esm.town/v/vtdocs/generateInvoicePDF";
// View me at https://vtdocs-examplePDF.express.val.run!
export const examplePDF = async (req: express.Request, res: express.Response) => {
const invoicePDF = generateInvoicePDF({
invoiceNumber: "001",
date: new Date().toDateString(),
customerName: "Alice Bar",
customerEmail: "alice@bar.com",
items: [{ description: "Arabica Beans 500g", quantity: 2, price: 10 }, {
description: "Robusta Beans 500g",
quantity: 1,
price: 11,
}],
currencySymbol: "$",
});
res.set("Content-Type", "application/pdf");
res.send(invoicePDF);
};