Skip to content

Instantly share code, notes, and snippets.

import collections
horiz_edges = [
[">", "<", ">", ">"],
["<", " ", "<", ">"],
[">", ">", "<", " "],
["<", " ", ">", "<"],
[" ", " ", ">", ">"],
]
assert len(horiz_edges) == 5
cmake_minimum_required(VERSION 3.12)
# A reproduction of the example given in
# https://cmake.org/cmake/help/latest/command/target_link_libraries.html#linking-object-libraries
project(CMakeTest)
# Object Libraries may be used as the <target> (first) argument of target_link_libraries to specify dependencies of their sources on other libraries. For example, the code
add_library(A SHARED a.c)
target_compile_definitions(A PUBLIC A)
@jthemphill
jthemphill / bisect_react_compiler_vite.py
Last active October 30, 2024 17:39
Figure out which files are causing `babel-plugin-react-compiler` to output bad code and crash Vite's Rollup build
import asyncio
import sys
import typing
"""
vite.config.ts has these lines:
function djb2Hash(str: string): number {
let hash = 5381
@jthemphill
jthemphill / bisect_for_multiple_files.py
Last active June 9, 2025 23:46
Version of bisect for if an E2E test passes as long as at least one of multiple affected files is not compiled
import asyncio
import json
import pathlib
import random
import signal
import typing
"""
vite.config.ts has these lines:
@jthemphill
jthemphill / getReactRerenderReasonStack.js
Last active July 8, 2025 21:09
Set a breakpoint in React's source code, then load this function into the debugger. Call this function on a rendering `fiberNode` to see why the fiber is rerendering!
getReactRerenderReasonStack = (fiberNode) => {
const NoFlags = 0;
const PerformedWork = 1;
const Placement = 2;
const Update = 4;
const ChildDeletion = 16;
const ContentReset = 32;
const Callback = 64;
const DidCapture = 128;
const ForceClientRender = 256;
@jthemphill
jthemphill / find_oldest_todo.py
Created November 18, 2025 20:01
Find the oldest TODO in a Git codebase
#!/usr/bin/env python3
"""
Find the oldest TODO comment that still exists in the codebase.
This script traverses git history commit-by-commit, finds commits that add TODOs,
and checks whether each TODO still exists in the current version of the code.
"""
import asyncio
import re