Skip to content

Instantly share code, notes, and snippets.

@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)
<!DOCTYPE html>
<script src="https://cdn.jsdelivr.net/npm/d3-require@1"></script>
<script>
(async()=>{
/*
Ported from https://observablehq.com/@d3/sankey-diagram@278
Copyright 2018–2020 Observable, Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@mootari
mootari / observable-style.css
Created May 24, 2020 19:49
Monokai for ObservableHQ
/* ==UserStyle==
@name Monokai for Observable
@namespace github.com/openstyles/stylus
@version 1.0.0
@description Overrides the Observable CodeMirror theme with Monokai.
@author -
==/UserStyle== */
@-moz-document domain("observablehq.com") {
/* Based on Sublime Text's Monokai theme */
@mootari
mootari / content-snippet.js
Last active March 17, 2024 14:14
Content Snippet that bundles the current page's stylesheets and assets into a zip file.
(async()=>{
const customCss = `
#title-heading {clear:left}
`;
const asyncArray = (iter, map) => Promise.all(Array.from(iter, map));
const css = (await asyncArray(
document.querySelectorAll('link[rel="stylesheet"][href^="/"]'),
async n => (await fetch(n.href, {mode: 'no-cors'})).text()
)).join("\n").replace(/\/\*.*?\*\//gs, '');
@mootari
mootari / serialize.js
Last active May 4, 2018 18:19
Inlining objects in Javascript.
// Recursively inlines Function, RegExp and undefined.
function serialize(value) {
const type = typeof value;
const json = JSON.stringify;
if(type === 'function') {
return value.toString();
}
if(type === 'object') {
if(value === null) {