Skip to content

Instantly share code, notes, and snippets.

@hwayne
hwayne / requirements.md
Last active October 26, 2026 14:06
PBT / Example Testing comparison problem

You are writing simple budgeting softare. A Budget consists of a total limit, represented as a positive integer, and a dictionary of category limits, represented as a map from strings to integers. For example:

{
  "total_limit": 50,
  "category_limits": {
    "food": 10,
    "rent": 11,
    "candles": 49
 }
@hwayne
hwayne / ghstats.py
Last active September 17, 2026 02:34
Vibeslopped github PR stats collector
#!/usr/bin/env python3
"""Collect, store, graph, and print GitHub pull-request search counts."""
from __future__ import annotations
import argparse
import calendar
import datetime as dt
import json
import os
@hwayne
hwayne / foo.tla
Created June 9, 2026 15:41
How to override a spec operator with itself and something else
---- MODULE foo ----
EXTENDS Integers
VARIABLE x
\* ...
Init == x \in 1..1000
\* ...
====
@hwayne
hwayne / expand_version.py
Created March 11, 2024 20:51
expand_version.py
import xml.etree.ElementTree as ET
from xml.etree.ElementTree import Element
from copy import deepcopy
from argparse import ArgumentParser
from dataclasses import dataclass
from string import Template
from pathlib import Path
import typing as t
#Common issue is that I need to have multiple slightly different versions of the same spec, this is a helper to do that.
@hwayne
hwayne / linkedinqueens.py
Last active January 19, 2026 21:41
LI queens in z3
# Associated newsletter: https://buttondown.com/hillelwayne/archive/solving-linkedin-queens-with-smt/
# See also: https://ryanberger.me/posts/queens/
# And: https://github.com/ryan-berger/queens/blob/master/main.py
from z3 import * # type: ignore
from itertools import combinations, chain, product
solver = Solver()
size = 9
# queens[n] = col of queen on row n
@hwayne
hwayne / rainbow-sort.js
Created December 4, 2023 17:54
Rainbow sort
// put in https://editor.p5js.org/
// generated (mostly) with GPT4
let cols, rows;
let w = 2;
let colors = [];
let i = 0;
let j = 0;
let sorted = false;
@hwayne
hwayne / README.md
Created August 15, 2025 19:58
p99 Sample TLA+ code
@hwayne
hwayne / maxgag.py
Created June 24, 2025 16:10
Finding a polynomial that looks like `max`
from z3 import * # type: ignore
s1, s2 = Solver(), Solver()
a0, a, b, c, d, e, f = Consts('a0 a b c d e f', IntSort())
x, y, z = Ints('x y z')
t = "a*x+b*y+c*z+d*x*y+e*x*z+f*y*z+a0"
lambdamax = lambda x, y, z: eval(t)
z3max = Function('z3max', IntSort(), IntSort(), IntSort(), IntSort())
@hwayne
hwayne / threads.cfg
Last active May 30, 2025 18:23
TLA+ Threads example
SPECIFICATION Spec
PROPERTY Liveness
CHECK_DEADLOCK FALSE
@hwayne
hwayne / filelinks.lua
Created April 22, 2025 20:13
Neovim Filelinks Plugin