Skip to content

Instantly share code, notes, and snippets.

@pete
pete / causes-icd.awk
Last active March 15, 2018 08:42
Fact-checking the New Yorker
BEGIN {
# X40-X44 is accidental overdose.
# X60-X64 is intentional (i.e., suicide)
# Y10-Y14 is unknown intent.
for(i = 0; i < 5; i++) {
cs["X4" i]++
cs["X6" i]++
cs["Y1" i]++
}
for(i in cs)
@pete
pete / Makefile
Last active October 7, 2017 01:23
# This gives you the ability to do
# git tag -a -m '1.0' 1.0
# make upload-release-1.0
# Written off the top of my head and not tested.
# Use at your own peril.
.PHONY: release
release:
mkdir -p release
@pete
pete / gist:dffed6d4c513c3877a1ab4cc9b8b6c30
Created August 1, 2016 00:28
Basic no-op version of Rack Middleware
class SomeMiddleware
attr_accessor :app
def initialize app
# The arguments passed to use() will end up here.
self.app = app
end
def call env
# This gets called when there's a request. It
#!/dis/sh
load std regex
drx = '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
cfn = `{ls tw-days|sort -r|sed 1q}
dn = `{basename $cfn .log}
echo -n > $cfn
sed -n (
'/^! day changed, ' ^ $dn ^ '/,$ { s///g; s/$/\n/; p; }'
implement A;
include "sys.m"; sys: Sys;
include "draw.m";
A: module {
init: fn(nil: ref Draw->Context, nil: list of string);
};
init(nil: ref Draw->Context, nil: list of string)
@pete
pete / 0readme
Created August 23, 2013 03:50
Numbers that mean absolutely nothing.
I was waiting for a Linux kernel to build. It seems to take
longer to configure a new kernel every time, like the number
of options have been steadily increasing. I thought I might
be hallucinating, you know? Maybe I have just gotten
impatient and the bloat wasn't that bad. Or maybe it is
the case that the options have gotten horribly numerous and
increasingly arcane. In any case, I did this:
for m in $list_of_linux_machines_here; do
ssh $m wc -l '/usr/src/linux-*/.config'
@pete
pete / 0README
Created March 11, 2013 21:34
See 0README. Power management.
These change the background color in X (and I think they don't work if you are
using a desktop system, so the `xset` command ought to be changed for whatever
Gnome/KDE/LXDE/XFCE/ASDFJKLSEMICOLON thing you are using if you are using such a
thing) based on battery power remaining. The Lua one requires luaposix to be
installed.
The reason there are two versions is that Ruby was, when it ought to have been
sleeping, doing some select() loop. I figured Lua would not do that to me, and
it does not. (Porting is usually more fun than fighting the language.)
@pete
pete / gist:4694295
Created February 1, 2013 21:31
Ridiculous nonsense.
#!/usr/bin/env ruby
# Hey, wanna see something fun?
#
# My disk broke. Thinking quickly, I decided to harness the unlimited power of
# User Error, and partially wreck my backup.
#
# Don't ask.
#
# md0 had most of the data. But the filesystem and partition table were
# wrecked, and some unknown amount of data had been exchanged between it and
@pete
pete / tac.b
Created October 8, 2012 20:38
"tac", ported to Limbo as an example.
implement Tac;
include "sys.m"; sys: Sys;
include "bufio.m"; bufio: Bufio; Iobuf: import bufio;
include "draw.m";
Tac: module {
init: fn(nil: ref Draw->Context, args: list of string);
};
#!/bin/sh
dropdb thedb
createdb thedb
ssh root@host5 /usr/local/pgsql/bin/pg_dump \
gzip -c \| \
tee prod.db.gz | \
gunzip | \
tee prod-without-audits.sql | \
psql thedb