Skip to content

Instantly share code, notes, and snippets.

View spraints's full-sized avatar
🦦

Matt Burke spraints

🦦
View GitHub Profile
#/ Usage: ruby run.rb [--resume] runlist.txt outdir
#/
#/ --resume picks up after a gracefully shut down previous attempt.
#/
#/ outdir must not exist, but be a path where we can create a directory.
#/
#/ runlist.txt must be a list of the inputs we're going to process, once per line.
require "fileutils"
@spraints
spraints / .gitignore
Last active September 18, 2024 18:28
Miscellanous little test programs
sigset-die
sigset-live
@spraints
spraints / recent-growth.rb
Last active September 27, 2024 13:18
Find which parts of your Git repository are growing the fastest
#/ Usage: ruby recent-growth.rb [OPTIONS]
#/ --git-dir <git_dir>
#/ --since <date>
#/ --until <date>
#/ --max-count <count>
#/ --per tree|extension
#/ --list-all (in the summary, show all trees / extensions, not just the top 10)
#/ --all | --branches | --tags | --remotes | <commit>
#/
#/ Example:
@spraints
spraints / mutexvsatomic_test.go
Created April 12, 2024 15:59
Mutex vs Atomics for read-heavy workload
/*
goos: darwin
goarch: amd64
pkg: github.com/github/gitrpcd/spraints/mutexvsatomic
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkMutex-16 2182556 544.1 ns/op
--- BENCH: BenchmarkMutex-16
compare_test.go:71: maxes: [2 2 2 2 2 2 2 2 2 2]
compare_test.go:71: maxes: [2 2 2 2 2 2 2 2 2 2]
@spraints
spraints / sketch.c
Created September 9, 2023 21:13
cycle through colors on an RGB LED
int red = 11;
int green = 10;
int blue = 9;
long spectrum[] = {
0xff0000, // 0 red
0xffa500, // 1 orange
0xffff00, // 2 yellow
0x00ff00, // 3 green
0x0000ff, // 4 blue
@spraints
spraints / .gitignore
Last active October 21, 2022 17:08
getrusage quirks (on Linux, ru_maxrss is the max for the process, regardless of the exec after a fork)
*.o
show-maxrss
bloat-fe
@spraints
spraints / extract.rb
Created September 26, 2022 12:01
Extract stream blocks from a PDF
# Usage: ruby extract.rb PDF...
#
# Extracts all 'stream' blocks from the PDF. This includes all images embedded
# in it. All of the output files have a '.bin' extension. Sometimes you can see
# what they are by doing something like this:
#
# $ ruby extract.rb example.pdf
# $ file *.bin
def main
@spraints
spraints / code.go
Created April 26, 2022 22:25
Compare locking strategies for generating certs
package sharedcertprovider
import (
"context"
"sync"
"time"
)
type Provider interface {
GetCert() Cert

Hello Mr. Baird,

I've been meaning to write for a while, and your recent mailer provided the motivation I needed.

First of all, I'd like to thank you for representing our district. I realize that it takes a significant amount of effort to keep in touch with your district at home and be involved in Washington, too. I also want to thank you for your military service. It's clear that you are dedicated to our country.

The primary thing that I wanted to write to you about is the ongoing COVID-19 pandemic. Frankly, I'm quite discouraged by the lack of control of the spread of the virus, and the lack of any effective effort by the federal government in this area. I think it's good that there has been significant economic relief. But that's a bandaid. I'll repeat what I said in my May email to you: the economy will not recover as long as coronavirus transmission is still happening. Why hasn't the federal government taken the lead on controlling spread? As a member of Congress and as a representative of our distric

@spraints
spraints / Dockerfile
Last active May 12, 2020 10:59
zerotier
FROM debian:10.2
# This is needed for 'apt-key add'.
RUN apt-get update && apt-get install -y gnupg
COPY zerotier.list /etc/apt/sources.list.d/zerotier.list
COPY zerotier.key /tmp/zerotier.key
RUN apt-key add /tmp/zerotier.key
RUN apt-get update && apt-get install -y zerotier-one