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.
Block or report user

Report or block whitequark

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@whitequark
whitequark / diff-pci-configs.sh
Created Sep 4, 2011
A script to find differences in PCI configuration space on Linux
View diff-pci-configs.sh
#!/bin/bash
set +e
if ! [ "`id -u`" == '0' ]; then
echo 'This script must be run as root'
exit
fi
mkdir -p diff-pci-configs-data
View ast_quirks.rb
require 'treetop'
Treetop.load 'ast_quirks.treetop'
parser = SimpleExpressionParser.new
ast = parser.parse %q{42}
p ast.to_code
@whitequark
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.new/defs.h
--- strace-4.6.old/defs.h 2011-03-15 20:19:09.000000000 +0300
+++ strace-4.6.new/defs.h 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);
#endif
@whitequark
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]
(ternary
(3560:===
(3558:bit-or
(3555:lshift
(3551:integer 46)
(3553:integer 16))
(3556:integer 14))
(3559:get-local 3))
(3564:integer 0)
@whitequark
whitequark / update-package.sh
Created May 12, 2012
Pure shell update package installer for Android
View update-package.sh
#!/bin/bash
set -e
UPDATE_PKG=$1
if [ "$UPDATE_PKG" == "" ]; then
echo "Usage: $0 <update package>"
echo
exit 1
@whitequark
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!(before=Time.now)
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
whitequark / result.txt
Last active Dec 20, 2015
emacs compatible unicode (c) erikh
View result.txt
$ ruby x.rb <<<"проверка"
"\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"
$ 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
whitequark / swap_escape.ml
Last active Dec 21, 2015
Beautiful tiny FSM encoded with pattern matching
View swap_escape.ml
(* 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
whitequark / README.md
Created Dec 12, 2013
A simple symbolizer for caml-inspect.
View README.md

Caml-inspect symbolizer

Symbolizes closure blocks. Works only on native executables.

Build

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

Use

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.