Skip to content

Instantly share code, notes, and snippets.

@creachadair
creachadair / recommended-reading.md
Created November 9, 2019 15:46
Recommended reading
@creachadair
creachadair / shell-notes.md
Created August 27, 2020 15:58
Notes on the POSIX Shell Language
@creachadair
creachadair / timed-mute.lua
Created August 27, 2020 16:00
Hammerspoon script for "timed mute"
do
local log = hs.logger.new('mutation', 'info')
local cmd_shift = {"cmd", "shift"}
-- Mute or unmute the speaker according to the truth of t.
local function mute(t)
return string.format("set volume %s output muted",
t and "with" or "without")
end
@creachadair
creachadair / install-go.sh
Last active April 17, 2025 04:22
Install Go from source at a tagged version
#!/usr/bin/env bash
##
## Usage: install-go.sh [<version>]
## e.g.: install-go.sh 1.22.3
##
## If a version is omitted, the latest available release is installed.
##
## By default, the script installs a precompiled toolchain for the specified OS
## and architecture. Set SOURCE=1 to build from source instead. Source builds
## require a bootstrap toolchain, which the script will fetch if needed.
@creachadair
creachadair / bookmarklet.md
Last active August 26, 2023 18:13
Notes on browser bookmarklets

Bookmarklet Notes

Broadly speaking, a bookmarklet is just a bookmark containing a javascript: URL, e.g.,

javascript:void%28alert%28%22test%22%29%29

Note that the contents of the URL need to be escaped in the Usual Way™.

@creachadair
creachadair / chrome-encrypted-cookies.md
Last active January 12, 2026 16:01
Encryption format for Chrome browser cookies

Google Chrome Encrypted Cookies

Google Chrome stores browser cookies in an SQLite database. The database has two tables, meta containing format and version metadata, and cookies with the contents of the cookies. The cookies table uses this schema:

-- To reproduce: sqlite path/to/Cookies .schema
CREATE TABLE cookies (
   creation_utc     INTEGER  NOT NULL,  -- microseconds since epoch
   host_key         TEXT     NOT NULL,  -- domain
   name             TEXT     NOT NULL,
@creachadair
creachadair / ilof-queries.md
Last active December 5, 2021 17:25
Metadata queries for ILoF

Metadata Queries for ILoF

These queries require curl and jq.

  • Twitter handles for all guests who have them:

    curl -s https://inlieuof.fun/guests.json | jq -r '[.guests[].twitter|select(.)]|sort[]'
@creachadair
creachadair / binary-cookies.md
Last active November 7, 2023 16:21
macOS Binary cookies file format

Binary cookies file format

Browsers and other macOS applications use the NSHTTPCookieStorage API to store cookies. The API writes .binarycookies files in a specialized binary format. The binary file format has the following structure:

Bytes Format Description
4 text magic number ('cook')
4 uint32 BE page count (np)
*4 [i] uint32 BE page i data size S, bytes; *repeat np times
*S [i] bytes page i contents; *repeat np times
@creachadair
creachadair / interfaces-and-tests.md
Last active October 8, 2021 22:23
Interfaces and satisfaction checks in Go packages

Interfaces and Satisfaction Checks in Go Packages

When a Go package defines a concrete type to implement some interface, it is common to ask the compiler to verify that your type satisfies the desired interface, e.g.,

package mything

import "some/other/pkg"

// Concrete implements pkg.Interface using a pellucid ammonite in
@creachadair
creachadair / fuse-ref.md
Last active September 11, 2021 14:03
References on FUSE