From 22e0b3b9677cfbb416880cd6cccd4d0713a55249 Mon Sep 17 00:00:00 2001 From: mehbark Date: Sat, 30 Dec 2023 01:39:37 -0500 Subject: [PATCH] moby dick -> hyde --- html/read-more.tsx | 19 +++++++ html/webark-countdown-negative.tsx | 88 ++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 html/read-more.tsx create mode 100644 html/webark-countdown-negative.tsx diff --git a/html/read-more.tsx b/html/read-more.tsx new file mode 100644 index 0000000..bb7dbf9 --- /dev/null +++ b/html/read-more.tsx @@ -0,0 +1,19 @@ +import { render_and_copy } from "./common.tsx"; + +const DICK_URL = "https://www.gutenberg.org/files/2701/old/moby10b.txt"; + +const text = await fetch(DICK_URL).then(r => r.text()); +render_and_copy( +
+ {text + .split(/CHAPTER|Epilogue/) + .slice(1) + .map(c => ( + <> + {...c + .split("\r\n\r\n") + .map(p =>

{p.replaceAll("\r\n", " ")}

)} + + ))} +
+); diff --git a/html/webark-countdown-negative.tsx b/html/webark-countdown-negative.tsx new file mode 100644 index 0000000..a6b6b85 --- /dev/null +++ b/html/webark-countdown-negative.tsx @@ -0,0 +1,88 @@ +import { render_and_copy } from "./common.tsx"; + +const Digit = ({ + length_per_s, + digits, +}: { + length_per_s: number; + digits: (number | string)[]; +}) => ( +
+
+ {...digits.map(d => ( +
+ {d} +
+ ))} +
+
+); + +// silly +const make_digits = ({ + up, + cycle_up, + cycle_down, +}: { + up: number[]; + cycle_up: number; + cycle_down: number; +}) => [ + ...new Array(cycle_up).flatMap(() => up), + ...new Array(cycle_down).flatMap((_, i) => + i == 0 ? up.toReversed().slice(1) : up.toReversed() + ), +]; +console.log( + make_digits({ + up: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + cycle_up: 6, + cycle_down: 10, + }) +); + +render_and_copy( + + + (i < 10 ? 10 - i : -(i - 10)) + .toString() + .replace(/-([0-9])$/, "-0$1") + .replace(/^([0-9])$/, "0$1") + )} + /> + : + + (i < 30 * 60 ? 59 - (i % 60) : i % 60) + .toString() + .padStart(2, "0") + )} + /> + +);