Skip to content

Instantly share code, notes, and snippets.

@matkatmusic
matkatmusic / block-parent-edits.ts
Last active September 18, 2026 10:28
Claude PreToolUse hook that blocks fable from editing files, and forces subagents to do work
#!/usr/bin/env node
import { readFileSync } from "node:fs";
// PreToolUse: blocks file edits from the parent (claude-fable-*) session. Subagents may edit.
// --- regex token vocabulary (jfred's regex_expressions.ts style: named source-string fragments, composed with
// `+`, wrapped in `new RegExp(...)` only at the end) -------------------------------------------------------
const startAnchor = "^"; // matches the start position
const wordBoundary = "\\b"; // a transition between a word char and a non-word char
const wordChar = "\\w"; // one word char: letter, digit, or underscore
const whitespace = "\\s"; // one whitespace char
@matkatmusic
matkatmusic / ask-dont-dump-issues.ts
Last active September 25, 2026 04:43
Claude Hook for preventing dumped issues at end of turn
#!/usr/bin/env node
// import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { readFileSync } from "node:fs";
import { getSessionStatePath, readSessionState, writeSessionState } from "./session-state.ts";
// Stop gate: sends the reminder once per reply, then blocks until the agent writes "done <epoch>" after it.
export const REMINDER =
'If you reported issues, open decisions, open TaskList items, asked a question (?) and gave choices, or wrote "say the word"-style items at the end of your turn, use AskUserQuestion to resolve them now. ' +
'A line like "Task #20 is still open." at the end of your turn drops an issue in front of the user and ends your turn. Do not write it. ' +
"If you left no open items, run: `node ~/.claude/hooks/turn-done.ts` and then end your turn.";
name implement
description Maintain a timestamped implementation-notes.md log while executing a spec or plan file. Captures design decisions, deviations, tradeoffs, and open questions as work proceeds. Use when the user says "implement this plan", "execute the spec", approves a plan for execution, or passes a spec/plan file path.
argument-hint <path-to-specfile>

First, read and internalize <path-to-specfile>.

Then implement it. As you work, maintain a running plans/implementation-notes-.md file that captures,

@matkatmusic
matkatmusic / main.cpp
Created October 7, 2025 20:37
A tutorial on how C++ Tag Dispatch works
/*
We want to design an interface for a function that allows us to pass different types to it.
Templates give us this functionality:
*/
template<typename T>
void function(const T& t)
{
doSomething(t);
}
@matkatmusic
matkatmusic / main.cpp
Last active November 3, 2025 20:56
a complete example project for using the juce::InterprocessConnection and juce::InterprocessConnectionServer classes
/*
==============================================================================
This file contains the basic startup code for a JUCE application.
==============================================================================
*/
#include <JuceHeader.h>
@matkatmusic
matkatmusic / PEMFormatKey.cpp
Created June 9, 2022 04:12
OpenSSL <-> juce::RSAKey
/*
Code that allows conversion of OpenSSL public keys into the juce::RSAKey format.
This may or may not work with private keys.
I have not tested it with private keys from the server, only public keys from the server.
*/
struct PEMHelpers
{
using PEMMemoryBlock = juce::MemoryBlock;
using PEMDataType = juce::uint8;
@matkatmusic
matkatmusic / OpenGLAudioVisualiserComponent.cpp
Created February 7, 2019 22:23 — forked from wtsnz/OpenGLAudioVisualiserComponent.cpp
A hacky version of the JUCE AudioVisualiserComponent that renders the graph OpenGL
/*
==============================================================================
OpenGLAudioVisualiserComponent.cpp
Created: 15 Apr 2017 8:00:56pm
Author: Will Townsend
==============================================================================
*/
@matkatmusic
matkatmusic / sinewaveWriter.cpp
Last active November 10, 2018 21:06
Simple sinewave generator/writer example
/*
replace your initialize() in your juce GUI project with this
*/
void initialise (const String& commandLine) override
{
// This method is where you should put your application's initialisation code..
/*
we're going to write a 2-second long 16-bit wave file to disk.
*/
@matkatmusic
matkatmusic / ScopedValueSaver.h
Last active September 4, 2018 20:49
a wrapper class for Type that tries to behave exactly like a Type, and adds automatically saving the value to a settings file when modified or being destroyed, and executing a lambda when changed.
/*
==============================================================================
ScopedValueSaver.h
Created: 2 Sep 2018 9:46:07pm
Author: MatkatMusic
==============================================================================
*/