Skip to content

Instantly share code, notes, and snippets.

View postspectacular's full-sized avatar
🎉
Celebrating 25 years of building open source tools

Karsten Schmidt postspectacular

🎉
Celebrating 25 years of building open source tools
View GitHub Profile
@postspectacular
postspectacular / delete-bookmarks.js
Last active September 17, 2025 10:24
Configurable batch deletion of Mastodon bookmarks (using Mastodon API). MIT Licensed.
// your account domain
const DOMAIN = "mastodon.social";
// your registered mastodon app's access token
// (might need to first create an app via mastodon preferences and
// assign scopes: read:bookmarks and write:bookmarks)
const ACCESS_TOKEN = "TODO";
// only remove bookmarks older than this date
const THRESHOLD_DATE = "2025-06-01";
@postspectacular
postspectacular / swizzle.zig
Created September 15, 2025 12:54
Comptime enum-based 1D-4D vector swizzling
fn swizzleEnum(comptime N: usize, comptime T: type, a: @Vector(N, T), comptime id: Swizzle) @Vector(swizzleLength(id), T) {
comptime var code = @intFromEnum(id);
comptime var i = 0;
comptime var offset = 0;
comptime var count = 4;
inline while (code >= offset + count) {
offset += count;
count <<= 2;
i += 1;
}
@postspectacular
postspectacular / lsys-fizzbuzz.ts
Created March 16, 2025 13:10
L-System based FizzBuzz implementations (using https://thi.ng/lsys)
import type { Fn2 } from "@thi.ng/api";
import {
DEFAULT,
expand,
interpret,
type LSysSymbol,
type RuleImplementations,
} from "@thi.ng/lsys";
// iterative rule expansion
@postspectacular
postspectacular / svg-gauge.html
Last active November 28, 2024 08:21
Pure SVG based ASCII/UTF art gauge using patterns & symbols to define dither pattern "characters" based on ░▒▓█ (2KB minified, 616 bytes gzipped for entire doc, but only needs around 660 chars (uncompressed) per 24h gauge...)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>svg-gauge</title>
<style>
:root {
--gauge-col: #0c9;
@postspectacular
postspectacular / ffmpeg-xfade.ts
Last active August 3, 2024 12:41
TypeScript & ffmpeg-based crossfading & looping slideshow generator. Supports GIF or MP4 output. Configure options at the end of the file, then run via https://bun.sh
import { Z4, type Stringer } from "@thi.ng/strings";
import {
comp,
iterator,
map,
mapcat,
partition,
range,
wrapSides,
} from "@thi.ng/transducers";
import {
asSvg,
bounds,
circleFrom2Points,
group,
GroupAttribs,
line,
Polygon,
starWithCentroid,
svgDoc,
@postspectacular
postspectacular / ANSI.md
Created February 19, 2024 10:34 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@postspectacular
postspectacular / 018.ts
Created September 28, 2023 06:51
#HowToThing #018 — Topological sorting, creating and visualizing a task dependency graph
import { identity } from "@thi.ng/api";
import { topoSort } from "@thi.ng/arrays";
import { defDGraph } from "@thi.ng/dgraph";
import { toDot } from "@thi.ng/dgraph-dot";
import { comp, filter, map, mapcat, pairs, run, trace } from "@thi.ng/transducers";
interface Task {
title: string;
done?: boolean;
// IDs of other tasks this task depends on (aka is blocked by)
@postspectacular
postspectacular / 01_main.zig
Last active August 29, 2023 22:12
#HowToThing #010 — Creating a basic web app with Zig/WebAssembly and the extensible https://thi.ng/wasm-api and its https://thi.ng/wasm-api-dom add-on module
const std = @import("std");
const wasm = @import("wasm-api");
const dom = @import("wasm-api-dom");
// expose thi.ng/wasm-api core API (incl. panic handler & allocation fns)
pub usingnamespace wasm;
// main entry point
export fn start() void {
init() catch |e| @panic(@errorName(e));
@postspectacular
postspectacular / 008.ts
Last active August 28, 2023 12:29
#HowToThing #008 — Multi-plot COVID data visualization via https://thi.ng/csv and https://thi.ng/viz
import { epoch, int, parseCSV, type CSVRecord, type ColumnSpecs } from "@thi.ng/csv";
import { defFormat, months } from "@thi.ng/date";
import { readText, writeText } from "@thi.ng/file-io";
import { serialize } from "@thi.ng/hiccup";
import { svg } from "@thi.ng/hiccup-svg";
import { closedOpen } from "@thi.ng/intervals";
import { split } from "@thi.ng/strings";
import { comp, filter, push, transduce } from "@thi.ng/transducers";
import {
barPlot, dataBounds, dataMaxLog,