Things I Learned
Short, dated notes on things I’ve learned. Longer write-ups live in Writing.
SecretSpec
SecretSpec declares secrets once in
secretspec.toml(names + descriptions, never values) and resolves them from any of 11 backends: keyring, 1Password, Vault, AWS, GCP, .env. Same command everywhere:secretspec run --profile production -- npm start. Per-secret fallback chains (providers = ["vault", "keyring", "env"]) and aref = { item, field }form points at a secret you already have elsewhere, no renaming. Sharpest bit: agents get held to a stricter bar by default.require_reason = "agents"forcessecretspec run --reason "..."before an AI agent can read a secret, appended to a local audit log; humans running interactively are unaffected. Rust core, SDKs for Python/Go/Node/Ruby/PHP/Haskell. Worth piloting on a project drowning in.envsprawl.Recordly
Recordly does video recording, screenshots, and demo editing in one open-source Electron app. Not in Homebrew core, but easy to ship via a personal tap:
brew install --cask theskumar/tap/recordly. Replacing my previous screenshot/recording workflow with this as the single default (see Default Apps 2025).import datetime as dt
Python 3.15 datetime docs now officially recommend
import datetime as dtin a Tip block, to disambiguate the module from thedatetime.datetimeclass. The tip cites Adam Johnson’s 2019 post — 6 years from community convention to CPython docs. Fixes both traps:from datetime import datetimeshadows the module, andimport datetimereads ambiguously asdatetime.datetime.now(). viaPostgreSQL UNLOGGED tables as a cache
PostgreSQL
UNLOGGEDtables skip the write-ahead log, making writes considerably faster than ordinary tables. Trade-off: they are truncated after a crash or unclean shutdown and are not replicated to standbys. hynek/psycache exploits this as a PostgreSQL-native cache replacing Redis — crash truncation is acceptable since it’s a cache anyway, and you reuse existing Postgres connections. Interesting idea: port this to Django as a customBaseCachebackend — swapDatabaseCache’s regular table forCREATE UNLOGGED TABLE, reuse Django’s existing DB connections, and skip Redis entirely. ~200 lines.baidu/Unlimited-OCR
baidu/Unlimited-OCR (paper) parses dozens of pages in one forward pass by fixing the real bottleneck in end-to-end OCR.
- The problem: an OCR decoder types out the page token-by-token, and its KV cache grows unbounded with output length — so memory climbs and speed decays the longer the doc, forcing page-by-page loops that wipe memory each step.
- The trick (Reference Sliding Window Attention): split context into two zones with different retention. Vision/prompt tokens stay fully visible and pinned forever (the “source book”); each token attends to only the last 128 of its own outputs (the “last few words you wrote”). KV cache becomes a fixed-size queue, so memory and TPS stay flat regardless of output length.
- The non-obvious part: discarding history improves accuracy (+6% on OmniDocBench, beating Qwen2.5-VL-72B at 3B/0.5B-active) — full attention can diverge on long dense output, and pinned vision tokens never blur.
- Cheap to build: freeze DeepSeek-OCR’s encoder, fine-tune only the decoder with the swapped attention.
- Generalizes past OCR: separate what you reference from what you remember.
- Ran it on an M1 Mac (32GB) with R-SWA intact, no NVIDIA. The official HF model (
trust_remote_code) already ships R-SWA as a pure-PyTorch eager ring buffer (SlidingWindowLlamaAttention, picked viaattn_implementation="eager") — not buried in a CUDA/FlashAttention kernel. So the “port” was just stripping.cuda()/torch.autocast("cuda")and running bf16 on MPS; zero MPS op-gaps hit. bf16 works on MPS in torch 2.12. - Proof R-SWA is live: instrument the KV cache during decode — on a 540-token page it plateaus at
prefill(277) + window(128) = 405and never grows (full MHA would hit 817). That constant-cache assertion + Distinct-35≈1.0 are the decisive signals, not edit distance (too noisy vs a single reference). - Gotcha: feeding all pages to one
generate()(infer_multi) loops at the document level — the 128-token decode window forgets the doc was already transcribed while the vision prefix still shows every page, so it restarts from page 1. Fix = onegenerate()per page (matches officialinfer.pyPAGE_SIZE=1). Accuracy then lands at/below gemini-vs-docai inter-annotator noise (~0.31 mean edit). ~35–55 s/page on M1.
Many asymmetric embedding models need task prefixes on inputs, and skipping…
Many asymmetric embedding models need task prefixes on inputs, and skipping them quietly degrades relevance. Each model has its own scheme: nomic (
search_query:/search_document:), E5 (query:/passage:), BGE (a query instruction sentence, bare docs) — not interchangeable. OpenAItext-embedding-3-*andall-MiniLM-L6-v2need none. Whether you add the prefix depends on the serving layer, not the model: raw endpoints (llama.cpp/v1/embeddings, HF TEI, Ollama) send bare text so it’s on you, while sentence-transformers (prompt_name="query") and vendor SDKs inject it for you. Addingsearch_query:/search_document:to a nomic-v1.5 call lifted cosine similarity on a real query/doc pair from 0.54 to 0.60 at zero cost.Vim motion tips for Zed
Vim motion tips for Zed. Turn on relative line numbers, and let vim mode switch them to absolute in Insert mode, so you get jump distances in Normal mode and context while typing.
{ "relative_line_numbers": true, "vim": { "toggle_relative_line_numbers": true } }[[/]]jump between function definitions in a large Django or FastAPI file.f:moves to the end of anif,deforclassline.
Moshi
Moshi is the best SSH client I’ve found for iPhone — connects to your laptop’s tmux sessions over Mosh, making it rock-solid on mobile networks with roaming support. Perfect for an agent view on the go; I use it to monitor and interact with running pi/Claude sessions from my iPhone without losing the session on network switches.
fabric
faberic is a crowd-sourced collection of prompts bundeled with a cli to use them via piped interfaces.