Skip to content

Instantly share code, notes, and snippets.

@captivus
captivus / INSTRUMENTATION.md
Created May 28, 2026 19:31
Handy memory leak bugfix instrumentation

Mapping Handy's End-to-End Execution Flow

This document is a standalone, validated procedure for instrumenting Handy and producing a complete, cross-correlated trace of one or more transcription cycles — from process boot, through trigger, through the recording steady state, through VAD finalization and Whisper inference, through paste, back to idle.

It is written without assuming prior context. Every environment variable, flag, and structural decision in this document is one that has been

@captivus
captivus / METHODOLOGY.md
Created May 28, 2026 19:31
Handy memory leak bugfix methodology

A Methodology for Identifying and Fixing Hard Bugs in Complex Multi-Process Software

A reproducible procedure for diagnosing bugs that resist normal debugging: bugs that span process boundaries, manifest over hours, or have no obvious cause from logs alone. Worked example throughout: a sustained memory leak in WebKitWebProcess on Linux in a Tauri 2 desktop application (issue #1279 in the cjpais/Handy repository), eventually narrowed to WebKit C++ allocations driven by high-frequency JS event traffic, then fixed with a three-part patch validated by bisect.

@captivus
captivus / webkit_eval_leak_test_v2.py
Created April 12, 2026 16:35
Standalone WebKitGTK evaluate_javascript leak test (multi-variant)
"""
WebKitGTK evaluate_javascript leak test -- v2.
Fixes from v1:
- Properly calls evaluate_javascript_finish() via a GAsyncReadyCallback
(v1 passed None, which left GTask results unconsumed)
- Supports --static-js flag to test with identical JS each eval
(v1 embedded a unique ID in each eval, polluting JSC bytecode cache)
Tests four combinations to isolate the cause:
@captivus
captivus / README.md
Last active April 7, 2026 15:44
Must-have modification to Claude Code statusline for effective context engineering.

Claude Code Context Window Monitor

Two-file setup that surfaces Claude Code's context window usage as a status line in your terminal and writes it to /tmp so the agent itself can read it.

Files

File Location
~/.claude/settings.json Claude Code settings — enables the status line
~/.claude/statusline-command.sh Script that parses and renders context usage
@captivus
captivus / claude_3.5_sonnet_artifacts.xml
Created September 18, 2024 19:48 — forked from dedlim/claude_3.5_sonnet_artifacts.xml
Claude 3.5 Sonnet, Full Artifacts System Prompt
<artifacts_info>
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity.
# Good artifacts are...
- Substantial content (>15 lines)
- Content that the user is likely to modify, iterate on, or take ownership of
- Self-contained, complex content that can be understood on its own, without context from the conversation
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations)
- Content likely to be referenced or reused multiple times
@captivus
captivus / meta.yaml
Created February 27, 2021 19:28
Edit the meta.yaml file to reflect minimum python versions in both the host and run sections of requirements
requirements:
host:
- pip
- python >=3.6
run:
- python >=3.6
- requests >=2.20.0
- six >=1.10.0
@captivus
captivus / meta.yaml
Created February 27, 2021 19:23
Final, pull request-ready meta.yaml recipe for the spotipy package
{% set name = "spotipy" %}
{% set version = "2.16.1" %}
package:
name: {{ name|lower }}
version: {{ version }}
source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/spotipy-{{ version }}.tar.gz
sha256: 4564a6b05959deb82acc96a3fe6883db1ad9f8c73b7ff3b9f1f44db43feba0b8
@captivus
captivus / meta.yaml
Created February 27, 2021 19:14
Example meta.yaml recipe file for Conda Forge packaging
# Note: there are many handy hints in comments in this example -- remove them when you've finalized your recipe
# Jinja variables help maintain the recipe as you'll update the version only here.
# Using the name variable with the URL in line 14 is convenient
# when copying and pasting from another recipe, but not really needed.
{% set name = "simplejson" %}
{% set version = "3.8.2" %}
package:
name: {{ name|lower }}
@captivus
captivus / meta.yaml
Created February 27, 2021 19:17
grayskull-generated meta.yaml recipe for the spotipy package from PyPI
{% set name = "spotipy" %}
{% set version = "2.16.1" %}
package:
name: {{ name|lower }}
version: {{ version }}
source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/spotipy-{{ version }}.tar.gz
@captivus
captivus / audible_matchmaker_scraping.py
Created April 26, 2020 17:31
Audible Matchmaker scraping in Python
import requests
from bs4 import BeautifulSoup
# open Audible Matchmaker page locally
# (see accompanying Jupyter notebook for details)
infile = open(file='audible_matchmaker.html', mode='r')
# parse the page with BeautifulSoup
soup = BeautifulSoup(markup=infile, features='html.parser')