Skip to content

Instantly share code, notes, and snippets.

@jlevy
jlevy / README.md
Last active September 10, 2026 04:18
memory_guard.py - a dependency-free macOS memory watchdog for process trees that fan out (agent CLIs, parallel builds). Sheds proportionally before the host wedges.

memory_guard.py

A last-resort supervisor that watches a process tree on macOS and sheds it before the host becomes unusable. Standard library only, no dependencies, one file.

For workloads that fan out into many short-lived, memory-hungry child processes — agent CLIs, parallel builds, batch jobs — where nothing upstream bounds how many run at once. Where a pool offers real admission control, that pool should do this job and this tool should never fire.

@jlevy
jlevy / logical-word-count.md
Last active August 13, 2026 05:57
Logical word count: a cheap, tokenizer-free measure of text length that tracks LLM token counts across languages, code, and mixed content

Logical Word Count

Logical word count is a cheap, deterministic, tokenizer-free measure of text length that stays stable across natural languages, code, math, and mixed content, and stays roughly proportional to LLM token counts — while remaining equal to ordinary word count for plain English prose.

It is defined in two rules:

  1. Wide (East Asian) characters count as ½ logical word each. This covers Chinese
@jlevy
jlevy / research-2026-06-06-portable-concurrent-sqlite.md
Created June 6, 2026 22:29
Portable, server-free, concurrent SQLite — research doc (snaplog)
title Portable, Server-Free, Concurrent SQLite for Local Applications
description A domain-agnostic reference on building a locally-friendly, portable, thread-safe, NFS-safe, data-loss-safe usage pattern (package/wrapper/adapter) around SQLite — covering the locking/journaling/filesystem background, the session/changeset extension, source-grounded node:sqlite findings, the prior-art landscape, and a validated snapshot-publish and transaction-envelope design with a working prototype.
author Claude Code agent (finterm), with prior survey work by Joshua Levy and LLM agents

Research: Portable, Server-Free, Concurrent SQLite for Local Applications

@jlevy
jlevy / research-2026-06-06-sqlite-file-coordination.md
Last active June 6, 2026 22:30
Research doc from codex-gpt-5.5: SQLite File Coordination for Portable Server-Free Databases [codex-gpt-5.5]

title: "Research: SQLite File Coordination for Portable Server-Free Databases" description: Consolidated research on using ordinary SQLite database files as durable, portable, server-free archives with cooperative WAL-free concurrency, safe backup, and cross-platform file coordination. author: Levy + Codex status: "Complete: background consolidated; recommendations tentative" related:

  • ../specs/active/plan-2026-06-06-sqlite-session-safe-package.md
  • research-2026-05-15-secure-file-backed-tool-access.md
  • research-2026-04-19-filestore-mount-alternatives.md
  • research-2026-04-09-large-tree-and-nfs-browser-monitoring.md

Standard Documentation Guidelines

Version: v0.3 (last update 2026-05-05)
Joshua Levy (github.com/jlevy)

Purpose

Both agents and humans benefit from accurate, maintained documentation. These are brief and general guidelines for humans and agents when writing and organizing code, text files, and documentation.

@jlevy
jlevy / fetch_rejected_prs.py
Created December 3, 2025 04:54
Fetch rejected PRs and maintainer feedback from GitHub repos
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = []
# ///
"""
Fetch rejected PRs and maintainer comments from a GitHub repo.
Uses `gh` CLI for authentication (must be logged in via `gh auth login`).
@jlevy
jlevy / fetch_rejected_prs.py
Created December 3, 2025 04:51
Fetch rejected PRs and maintainer feedback from GitHub repos
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = []
# ///
"""
Fetch rejected PRs and maintainer comments from a GitHub repo.
Uses `gh` CLI for authentication (must be logged in via `gh auth login`).
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = "==3.13"
# dependencies = [
# "requests>=2.32.3",
# "rich>=14.0.0",
# "markdownify>=1.1.0",
# "readabilipy>=0.3.0",
# ]
# ///
@jlevy
jlevy / fnm.py
Last active January 8, 2025 09:49
xonsh xontrib for fnm (for node version management)
"""
xontrib for fnm (Fast Node Manager) integration with xonsh shell.
Fnm is a good replacement for nvm and is compatible with .nvmrc.
Currently fnm doesn't support xonsh directly. This parses the bash output
of fnm and uses it within xonsh.
"""
import subprocess
@jlevy
jlevy / uniquifier.py
Last active May 6, 2024 21:18
Tiny class that saves you effort when maintaining a set of unique names.
from typing import Set
from typing import NamedTuple
class Key(NamedTuple):
name: str
group: str
class Uniquifier: