Skip to content

Instantly share code, notes, and snippets.

View brennanMKE's full-sized avatar

Brennan Stehling brennanMKE

View GitHub Profile
@brennanMKE
brennanMKE / photon-architecture.md
Last active December 4, 2026 04:42
PhotonHTTP: request/response architecture and why it's fast

PhotonHTTP: request/response architecture and why it's fast

Photon's request path is one Swift task per connection, running a synchronous parser and serializer between two awaits on raw bytes. It has no actors, no per-request tasks, and no Foundation on that path.

Architecture (HTTP/1.1 request/response cycle)

  1. Transport (NetworkTransport): by default, non-blocking BSD sockets driven by kqueue on macOS and epoll on Linux (BSDEventLoop). On macOS, Network.framework is used for TLS and QUIC; on Linux, OpenSSL. Each kind of transport is wrapped in a small ByteStreamTransport protocol with receive, send, sendFile and close.
  2. Server (HTTPServer): a structured task-group tree (server → listener → connection). Each connection picks its protocol once, from ALPN or the cleartext preface, and hands the transport to that protocol's ConnectionProtocol.run.
  3. Connection loop (HTTP1): one task owns the receive buffer, the parser and the connection state machine as local values
@brennanMKE
brennanMKE / LOW_POWER_ESP32.md
Created November 30, 2026 21:17
Low-Power ESP32 Design: Small Core Waits, Big Core Works

Low-Power ESP32 Design: Small Core Waits, Big Core Works

A guide to the "slow chip watches, fast chip works" architecture and how to use it on ESP32 boards running from a battery.

1. The core idea

A microcontroller that sits in loop() polling millis() is never idle. It runs at full clock and full active current the whole time it waits. On an ESP32 with the radio off, that's tens of milliamps, around the clock.

The fix is to split the work by cost:

@brennanMKE
brennanMKE / claude-code-in-screen.md
Last active November 25, 2026 01:33
Keep a Claude Code session running on a Mac and take it over remotely over SSH with screen 5 and claude-screen

Keep a Claude Code session running on a Mac and take it over remotely with screen

Run Claude Code inside GNU screen 5 on one Mac (the "host"), then SSH in from another machine, take over the same running session, and leave again without stopping Claude.

The claude-screen script in this Gist wraps the whole workflow: it names the session after the current folder, always uses Homebrew's screen 5, and never kills a session.

One-time setup (every Mac)

@brennanMKE
brennanMKE / 0_README.md
Created November 22, 2026 07:18
Laya inference servers benchmark: Go, Swift, Rust and Python on Apple Silicon and Raspberry Pi 5

Laya inference servers: Go, Swift, Rust and Python on Apple Silicon and Raspberry Pi 5

Benchmark of four server implementations of the Laya model on three home machines, November 2026. Every server ran the same checkpoint with its answer cache off, and answered the same captured game requests (Tetris, Frogger, Invaders) from a set of golden fixtures.

Implementation Engine on Mac Engine on Pi 5
laya-go (Go, CGO_ENABLED=0) Metal, fp16 Portable Go loops, no SIMD
laya-swift (Swift) Metal, fp16 —
laya-rust (Rust, gemm crate) — CPU, NEON SIMD, 4 threads
Python (laya 0.3.6, PyTorch) — CPU, PyTorch's ARM kernels
@brennanMKE
brennanMKE / README.md
Created November 21, 2026 00:30
list-recent-issues — a live TUI over a project's markdown issues/ folder

list-recent-issues

A live terminal view of a project's issues/ folder, where each issue is a markdown file (0001.md, 0002.md, …). Run it inside a project and it stays on screen. The list reloads when issue files change, so you see an issue move to resolved without re-running anything.

It's a single Python 3 file that uses only the standard library (curses). glow is optional; if it's installed, issues open rendered in it.

Install

@brennanMKE
brennanMKE / README.md
Created November 20, 2026 05:47
Buzz Desktop on macOS 12 (Monterey): fix for the blank window (block/buzz#3295)

Buzz Desktop on macOS 12 (Monterey): fix for the blank window

Buzz Desktop launches on macOS 12 but shows an empty grey or black window with no error. The log says initial render did not commit before reveal timeout. Upstream issues: block/buzz#3295, #4513 and #8367. This affects both Intel and Apple silicon.

This patch applies to desktop-v0.5.30 (commit dece76e7e), the latest release as

@brennanMKE
brennanMKE / 0002-airplay-reader-skip-unreadable-metadata.patch
Last active November 16, 2026 21:37
Volumio: AirPlay from Apple Music crashes the backend (daap-parser byteLength Received 8) - fix
--- a/app/plugins/music_service/airplay_emulation/shairport-sync-reader/shairport-sync-reader-base.js
+++ b/app/plugins/music_service/airplay_emulation/shairport-sync-reader/shairport-sync-reader-base.js
@@ -86,7 +86,14 @@
this.emit(data.code, data.cont);
}
} else {
- this._meta[data.code] = parser.parseTag(data.code, data.cont);
+ // PATCH(workshop): skip unreadable AirPlay metadata instead of crashing.
+ // daap-parser 0.1.1 throws on 8-byte numbers, which Apple Music sends.
+ try {
@brennanMKE
brennanMKE / open-weight-cad-agent-findings.md
Created November 15, 2026 04:18
Open-weight models driving build123d CAD via MCP: findings

Open-weight models driving CAD: findings

Notes from building a local agent that edits a 3D room model through conversation ("move the sofa a foot closer to the TV"). Goal: run on open-weight models (local via LM Studio, or on OpenRouter) plus a small fast decision model, without a frontier model in the loop.

Stack: build123d through build123d-mcp (0.3.91, HTTP transport), LM Studio 0.4.x on an M4 Pro Mac mini (64 GB), OpenRouter for hosted open models.

Short version: an open model can build CAD parts through build123d-mcp, and checks written in

@brennanMKE
brennanMKE / README.md
Created November 5, 2026 22:55
/costs: a Claude Code slash command that breaks down what a session cost, by model and by prompt

/costs for Claude Code

A Claude Code slash command that estimates what the current session cost at API list prices. It breaks the cost down by model and token type (input, cache writes, cache reads, output, web searches), separates subagent spend, and lists the most expensive prompts.

The built-in /cost shows a total. /costs shows where the money went.

Install

mkdir -p ~/.claude/commands ~/.claude/scripts
@brennanMKE
brennanMKE / opus-low-implementer-results.md
Last active October 20, 2026 03:38
Agent issue workflow: implementing on Opus 5.5 at low effort — results

Implementing on Opus 5.5 at low effort: results

An agent workflow worked through a project's issue tracker. Each issue went through three steps, and each step ran in a fresh subagent:

  1. Plan. Opus 5.5, medium effort. Reads the issue and the code, then writes a concrete plan: files to change, approach, tests by name.
  2. Implement. Follows the plan, writes the code and tests, and runs the test suite.
  3. Review. Opus 5.5, medium effort. Reads the diff, re-runs verification, then resolves the issue or bounces it back.

The change: the Implement step moved from Sonnet 5.5 at medium effort to Opus 5.5 at low effort, stepping up to medium only if an issue bounced. Plan and Review stayed as they were.