Skip to content

Instantly share code, notes, and snippets.

@mootari
mootari / duckdb-optimizers-description.md
Last active September 25, 2026 14:21
DuckDB 2.0 optimizers (generated with Claude Opus 4.6)

DuckDB 2.0 Optimizers

All optimizers returned by FROM duckdb_optimizers() on the v2.0-cyanoptera branch, sorted alphabetically.

Optimizer Description Examples
aggregate_function_rewriter Decomposes aggregate functions into simpler primitives. AVG(x) → SUM(x)/COUNT(x); SUM(x+5) → SUM(x) + 5*COUNT(x)
aggregate_reuse Reuses aggregate payloads already computed by a filtering SEMI join instead of recomputing them. A SEMI-joined aggregate whose payload columns match the outer aggregate skips the second aggregation.
[build_side_probe_side](https://github.com/duckdb/duckdb/blob/c491d132165f91e492e0feee3d4dbe2b74
@mootari
mootari / queue.ts
Last active September 23, 2026 19:34
Using linked lists for call throttling and pushable async queues.
function deferred<T = void>() {
let resolve: (v: T) => void;
let reject: () => void;
const promise = new Promise<T>((res, rej) => {
resolve = res;
reject = rej;
});
return {promise, resolve: resolve!, reject: reject!};
}
type Deferred<T> = ReturnType<typeof deferred<T>>;
@mootari
mootari / duckdb.ts
Last active September 14, 2026 14:05
Scrappy DuckDB type layer
import * as d from "@duckdb/node-api";
import type * as D from "@duckdb/node-api";
// DECIMAL covers the parameterized case
export const t = {
BOOLEAN: d.DuckDBBooleanType.create,
USMALLINT: d.DuckDBUSmallIntType.create,
UINTEGER: d.DuckDBUIntegerType.create,
VARCHAR: d.DuckDBVarCharType.create,
TIMESTAMP_MS: d.DuckDBTimestampMillisecondsType.create,
@mootari
mootari / packument-props.txt
Last active September 7, 2026 18:26
Property counts in npm packuments (as of 2026-06-05)
┌────────────────┬─────────┬────────────────────────────┬────────────────────────────┐
│ prop │ count │ min_modified │ max_modified │
│ varchar │ int64 │ timestamp with time zone │ timestamp with time zone │
├────────────────┼─────────┼────────────────────────────┼────────────────────────────┤
│ _id │ 4085638 │ 2012-08-21 04:57:30.063+02 │ 2026-06-05 21:11:49.342+02 │
│ name │ 4085638 │ 2012-08-21 04:57:30.063+02 │ 2026-06-05 21:11:49.342+02 │
│ time │ 4085638 │ 2012-08-21 04:57:30.063+02 │ 2026-06-05 21:11:49.342+02 │
│ maintainers │ 4083878 │ 2012-08-21 04:57:30.063+02 │ 2026-06-05 21:11:49.342+02 │
│ versions │ 4083594 │ 2012-08-21 04:57:30.063+02 │ 2026-06-05 21:11:49.342+02 │
│ dist-tags │ 4083594 │ 2012-08-21 04:57:30.063+02 │ 2026-06-05 21:11:49.342+02 │
@mootari
mootari / discord-latest-channels.js
Last active July 30, 2026 15:59
Bookmarklet to show latest channel activity
// Run as content snippet to test and to obtain the bookmarklet URL
function run() {
const stores = ((s = {}) => (webpackChunkdiscord_app.push(
[[Symbol()], {}, r => {
for(const c of Object.values(r.c ?? {})) {
for(const e of Object.values(c?.exports ?? {})) {
if(!e || typeof e !== "object") continue;
if(e[Symbol.toStringTag] === "IntlMessagesProxy") continue;
if(e._dispatchToken) s[e.getName()] = e;
}
@mootari
mootari / discord-stores.js
Last active July 29, 2026 12:58
Getting all Discord Stores from within the web app
// To be run within the web app, via console or a bookmarklet
stores = ((s = {}) => (webpackChunkdiscord_app.push(
[[Symbol()], {}, r => {
for(const c of Object.values(r.c ?? {})) {
for(const e of Object.values(c?.exports ?? {})) {
if(!e || typeof e !== "object") continue;
if(e[Symbol.toStringTag] === "IntlMessagesProxy") continue;
if(e._dispatchToken) s[e.getName()] = e;
}
}
@mootari
mootari / chrome-history-schema.md
Last active April 29, 2026 09:49
Annotated Chrome History SQLite schema. Inferred by Sonnet 4.6 (GitHub Copilot) from the Chromium sources, reviewed and refined in multiple turns. Might still contain errors.

Chrome History Database — Annotated Schema

Chrome's History database is an SQLite file located at <Profile>/History. It is managed by HistoryDatabase, which inherits from several sub-database classes, each owning a group of tables.

Core source files

Class File Tables owned
URLDatabase url_database.cc urls, keyword_search_terms
VisitDatabase visit_database.cc visits, visit_source
@mootari
mootari / bucket-path.mts
Last active July 27, 2025 18:21
Getting the SQLite DB path for a local R2 bucket
#!/usr/bin/env yarn -s tsx
import { createHash, createHmac } from "node:crypto";
import { parseArgs } from "node:util";
const uniqueKey = "miniflare-R2BucketObject";
// Adapted from https://github.com/cloudflare/workers-sdk/blob/2df1d066c/packages/miniflare/src/plugins/shared/index.ts#L236-L249
function durableObjectNamespaceIdFromName(name: string) {
const key = createHash("sha256").update(uniqueKey).digest();
@mootari
mootari / App.tsx
Last active March 8, 2025 16:50
TLDraw - arrow label as range slider
import { createBindingId, createShapeId, Editor, TLArrowShape, Tldraw, UnknownRecord } from 'tldraw'
function updateText(editor: Editor, shape: TLArrowShape) {
const clamp = (a: number, b: number, v: number) => v <= a ? a : v >= b ? b : v;
const rescale = (a: number, b: number, t: number) => (t - a) / (b - a);
const t = shape.props.labelPosition;
const text = (clamp(0, 1, rescale(.1, .9, t)) * 100).toFixed(0) + "%";
editor.updateShape({id: shape.id, type: shape.type, props: {text}});
}
@mootari
mootari / gist:728174a871344cc33ebcb3eaca5d93a0
Last active September 9, 2025 22:29
Container Glossary
APB: Ansible Playbook Bundle (Ansible, Framework)
FCOS: Fedora CoreOS (Red Hat, Host/Container OS)
CRD: Custom Resource Definition (Kubernetes, Concept)
CDK: Red Hat Container Development Kit (Red Hat, Tooling)
DC: DeploymentConfig (Kubernetes, Concept, Tooling)
OKD: Kubernetes distribution that powers Openshift Origin
CNS: Container Native Storage (https://keithtenzer.com/2017/03/29/storage-for-containers-using-container-native-storage-part-iii/)
PVC: PersistentVolumeClaim (https://kubernetes.io/docs/concepts/storage/persistent-volumes/)
CSI: Container Storage Interface (Standard, Concept)
RC: ReplicationController (Kubernetes, Framework)