Skip to content

Instantly share code, notes, and snippets.

View wjt's full-sized avatar

Will Thompson wjt

View GitHub Profile
@wjt
wjt / Makefile
Last active August 29, 2015 14:07
Calling C functions which accept UTF-16 as a 0-terminated array of int16 using ctypes
all: csa.so
csa.so: csa.c csa.h
gcc -fPIC -shared -Wall -Werror -o $@ $<
@wjt
wjt / gist:ed20f635818652bb02dc
Created November 26, 2014 23:51
A Scandal in Bohermia
To Sherlock Holmes he is always THE man. I have seldom heard her
mention hress|his|him under any other name. In hers|her eyes he
eclipses and predominates the whole of hress|his|him sex. It was not
that she felt any emotion akin to love for Irene Adler. All emotions
and that one particularly were abhorrent to hers|her cold precise but
admirably balanced mind. She was I take it the most perfect reasoning
and observing machine that the world has seen but as a lovress she
would have placed herself in a false position. She never spoke of the
softer passions save with a gibe and a sneress. They were admirable
things for the observress excellent for drawing the veil from men ' s

Keybase proof

I hereby claim:

  • I am wjt on github.
  • I am wjt (https://keybase.io/wjt) on keybase.
  • I have a public key whose fingerprint is 1E68 E58C F255 8883 0164 5B56 3422 DC0D 7AD4 82A7

To claim this, I am signing this object:

@wjt
wjt / reticulator.py
Created July 9, 2015 16:49
I've written essentially this many times in the last 18 months.
class Reticulator(object):
def __init__(self, n):
self.n = n
self.i = 0
def tick(self):
self.i += 1
if (self.i - 1) % 100 == 0 or self.i + 1 >= self.n:
sys.stderr.write('[{}/{}]\r'.format(self.i, self.n))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wjt
wjt / gist:6412403
Last active December 22, 2015 03:48
How to Good-bye Passwords: If You Upgrade Node 100 Times Everyday. Malarkey? or Effective Way?
  1. Looked up the pre-upgrade version of nodejs in /var/log/dpkg.log, which was 0.6.19~dfsd1-7
  2. Grabbed it from snapshot.debian.org and installed it
  3. Ran vault --export vault.json, which worked perfectly
  4. Re-ran apt-get dist-upgrade to move back to Node v0.10.17
  5. Upgraded npm from 1.1.4~dfsg-2 – the current version in unstable, which is incompatible with nodejs 0.10.17~dfsg1-2 in unstable – to 1.2.18~dfsg-3 from experimental
  6. Installed vault@0.3.0 using npm
  7. Deleted my old .vault
  8. Ran vault --import vault.json
  9. Joy and kittens
@wjt
wjt / Output
Last active December 25, 2015 06:38
I'm trying to make a JavaScript subclass of GtkTreeStore, overriding the row_draggable() method on the GtkTreeDragSource interface. This crashes gjs. My hypothesis is that this is because GtkTreeStore already implements GtkTreeDragSource, but I haven't looked into it yet. gjs version 1.36.1-2 from Debian.
% gjs subclass-GtkTreeStore-override-row_draggable.js
** (gjs:14866): CRITICAL **: g_object_info_get_class_struct: assertion `GI_IS_OBJECT_INFO (info)' failed
zsh: segmentation fault gjs subclass-GtkTreeStore-override-row_draggable.js
<html>
<head>
<link rel='stylesheet' href='css/drop-theme-basic.css'>
<script src='js/tether.js'></script>
<script src='js/drop.js'></script>
<script>
window.addEventListener('load', function onload() {
var b = document.querySelector('button');
var drop;
function InterruptingCowsocket(...args) {
var ws = new WebSocket(...args);
f();
return ws;
function g() {
ws.send("moo!");
f();
}
ntfsextents: fix incorrect handling of merged runs
After the filesystem is defragmented, ntfsextents produced suspicious output
like the following:
...
47934664704 292540416
47934664704 930017280
47934664704 2045247488
...