Skip to content

Instantly share code, notes, and snippets.

View the-mikedavis's full-sized avatar
🏛️
Busy at work

Michael Davis the-mikedavis

🏛️
Busy at work
View GitHub Profile
/* The property, in one monitor: GC must never reap an object whose stream is
committed.
It tracks the committed streams (from the DB) and each object's stream (from
S3), both from announced events only. On every delete it asserts the reaped
object does not belong to a committed stream. That assert is the whole
invariant, and it fires when GC reaps the fragment of a stream that committed
after GC read the committed set. */
spec NoReapLive observes eStreamCommitted, eObjectPut, eGcDelete {
var committed: set[int];
@the-mikedavis
the-mikedavis / README.md
Created May 28, 2026 18:04
Script to reproduce rabbitmq-server#14137
@the-mikedavis
the-mikedavis / README.md
Last active May 5, 2026 22:06
AMQP 1.0 vs. 0-9-1 connection memory impact script

amqp-memory-compare

A small Go tool that opens a gradually growing number of idle connections against two single-instance RabbitMQ brokers — AMQP 0-9-1 to one, AMQP 1.0 to the other — and samples node memory via the RabbitMQ HTTP API into a CSV for side-by-side comparison.

It is intentionally minimal: no publishing, no consuming, one channel (0-9-1) or one session (1.0) per connection, all idle.

-module(shipit).
-define(REGION, "us-east-2").
-define(AWS_ACCESS_KEY_ID, "A11111111...11111111").
-define(AWS_SECRET_ACCESS_KEY, "011111111111111111...1111111111111111111").
-define(HOST, "s3.us-east-2.amazonaws.com").
-include_lib("kernel/include/file.hrl").

Nominal types are new in Erlang/OTP 28: https://www.erlang.org/eeps/eep-0069

Previously the dialyzer considered two types to be the same only if they were structurally equal. For example {number(), number()} created in one place is equivalent to any other {number(), number()} with structural typing. With nominal typing two types are considered the same only if their type has the same name. In Erlang this means that you have functions with specs that say they return a type defined with -nominal Type :: Definition..

Nominal types have slightly worse ergonomics since you need to have APIs for producing and modifying the type. For example even though nom_index is a non_neg_integer(), we can't say Index + 1 in nom.erl. Instead we would need a function nom_index:next/1 which returns a nom_index:t().

Nominal typing is very powerful, however, and a really great addition to the Erlang type system, because the dialyzer can now distinguish between two types which are structurally equivalent bu

@the-mikedavis
the-mikedavis / jaro.erl
Last active January 6, 2025 22:32
-module(jaro).
-export([distance/2]).
%% This is an Erlang translation of Elixir's `String.jaro_distance/2'.
%% Upstream: https://github.com/elixir-lang/elixir/blob/v1.15.7/lib/elixir/lib/string.ex#L2784-L2879.
%% Jaro Distance is relatively simple - only transpositions of grapheme
%% clusters are allowed which is much simpler than other edit distance
%% measurements like Damerau–Levenshtein (insertion, deletion, substitution
@the-mikedavis
the-mikedavis / BUILD
Created January 19, 2023 16:14
Bazel resize exit MWE
load("//:defs.bzl", "build_run", "build_test")
build_run(name = "hello-run")
build_test(name = "hello-test")
@the-mikedavis
the-mikedavis / erlang.kak
Last active January 6, 2025 22:31 — forked from subsetpark/erlang.kak
A half-baked kakoune language file for erlang.
# Detection
# ---------
hook global BufCreate .*[.](erl|hrl|app\.src) %{
set-option buffer filetype erlang
}
hook global BufCreate .*/rebar.config %{
set-option buffer filetype erlang
}