Skip to content

Instantly share code, notes, and snippets.

I'm a broken fence in the yard of annoyance.

whitequark whitequark

I'm a broken fence in the yard of annoyance.
View GitHub Profile
whitequark /
Created Sep 4, 2011
A script to find differences in PCI configuration space on Linux
set +e
if ! [ "`id -u`" == '0' ]; then
echo 'This script must be run as root'
mkdir -p diff-pci-configs-data
View ast_quirks.rb
require 'treetop'
Treetop.load 'ast_quirks.treetop'
parser =
ast = parser.parse %q{42}
p ast.to_code
whitequark / strace-4.6-v4l2-ioctls.patch
Created Oct 5, 2011
V4L2 ioctl support for strace
View strace-4.6-v4l2-ioctls.patch
diff -urN strace-4.6.old/defs.h
--- strace-4.6.old/defs.h 2011-03-15 20:19:09.000000000 +0300
+++ 2011-10-05 01:06:42.000000000 +0400
@@ -594,6 +594,7 @@
extern int rtc_ioctl(struct tcb *, long, long);
extern int scsi_ioctl(struct tcb *, long, long);
extern int block_ioctl(struct tcb *, long, long);
+extern int v4l2_ioctl(struct tcb *, long, long);
whitequark / gist:2622705
Created May 6, 2012
a piece of modern art
View gist:2622705
(3995:lookup-switch 3523 [3307, 3307, 3307, 3337, 3337, 3337, 3337, 3337, 3491, 3491, 3491, 3491, 3491, 3491, 3491, 3523]
(3551:integer 46)
(3553:integer 16))
(3556:integer 14))
(3559:get-local 3))
(3564:integer 0)
whitequark /
Created May 12, 2012
Pure shell update package installer for Android
set -e
if [ "$UPDATE_PKG" == "" ]; then
echo "Usage: $0 <update package>"
exit 1
whitequark / gist:4705506
Last active Dec 12, 2015
NoSQL is for those who can't learn SQL.
View gist:4705506
# Convert raw stats into hourly stats.
def self.squash!(
transaction do
range = where(%{
date_trunc('hour', collected_at) < date_trunc('hour', timestamp ?)
}, before)
from_id, to_id = range.minimum(:id), range.maximum('id')
return nil if [from_id, to_id].none?
whitequark / result.txt
Last active Dec 20, 2015
emacs compatible unicode (c) erikh
View result.txt
$ ruby x.rb <<<"проверка"
$ ruby -e 'puts "\M-P\M-?\M-Q\M-\C-@\M-P\M->\M-P\M-2\M-P\M-5\M-Q\M-\C-@\M-P\M-:\M-P\M-0"'
whitequark /
Last active Dec 21, 2015
Beautiful tiny FSM encoded with pattern matching
(* OCaml regular expressions are unusual in that they require
parentheses and pipe symbol to be escaped to *gain* special
meaning. swap_escape converts from (and, incidentally, to)
the usual format. *)
let swap_escape input =
let swap_chr (esc, str) chr =
match esc, chr with
(* Go to escape mode. *)
| false, '\\'
-> true, str
whitequark /
Created Dec 12, 2013
A simple symbolizer for caml-inspect.

Caml-inspect symbolizer

Symbolizes closure blocks. Works only on native executables.


ocamlfind ocamlopt -syntax camlp4o -package lwt -package lwt.syntax -package lwt.unix str.cmxa -linkpkg -o symbolizer
ocamlfind ocamlopt -package inspect -linkpkg -o foo


View gist:8199710
17:08 < whitequark> I once had a home server based on a pentium iii motherboard with makeshift passive cooler
17:09 < whitequark> usually it was around 50°C, but once a night a cron job kicked in and it started gzipping stuff, bringing it up to 110°C
17:09 < whitequark> first time I discovered that, I literally burned myself
17:09 < whitequark> that thing had uptime of about 1.5 years when I finally scrapped it
17:10 < whitequark> oh and that job took about two hours each night... this is quite a testament to reliability.
You can’t perform that action at this time.