Skip to content

Instantly share code, notes, and snippets.

View tokenrove's full-sized avatar
💭
Ill; I may be slow to respond.

Julian Squires tokenrove

💭
Ill; I may be slow to respond.
View GitHub Profile

Keybase proof

I hereby claim:

  • I am tokenrove on github.
  • I am tokenrove (https://keybase.io/tokenrove) on keybase.
  • I have a public key whose fingerprint is 2066 CB72 11CE F88D 6DD2 2B6A 3657 CDF8 0FD4 092C

To claim this, I am signing this object:

@tokenrove
tokenrove / parse.ur
Last active August 29, 2015 14:21
Attempted minimal example of unification failure problem
datatype result a = Success of a*string | Failure
type t a = string -> result a
fun mreturn [a] (x:a) : t a = fn s => Success (x, s)
fun mbind [a] [b] (p: t a) (f: a -> t b) : t b =
fn s => case p s of
Failure => Failure
| Success (x, s') => f x s'
val monad_parse : monad t = mkMonad {Bind=@@mbind, Return=@@mreturn}

Keybase proof

I hereby claim:

  • I am tokenrove on github.
  • I am tokenrove (https://keybase.io/tokenrove) on keybase.
  • I have a public key whose fingerprint is CC8C C599 9DEB 3428 5859 A966 E66D 2011 DA6D 1862

To claim this, I am signing this object:

/// Murmur3 x86-64 128-bit hash; pretty much a direct port of Austin Appleby's murmur3 x86-64 128-bit hash.
/// A simpler conversion than some others.
/// NB: the endianness/ordering here can be very confusing; caveat scriptor
pub fn hash(bytes: &[u8]) -> u128
{
let (mut h1, mut h2) = (0_u64, 0_u64);
let (c1, c2) = (0x87c37b91114253d5_u64, 0x4cf5ad432745937f_u64);
let n = bytes.len();
let lower_round = |h, k: u64| h ^ k.wrapping_mul(c1).rotate_left(31).wrapping_mul(c2);
let upper_round = |h, k: u64| h ^ k.wrapping_mul(c2).rotate_left(33).wrapping_mul(c1);
@tokenrove
tokenrove / catfd.c
Last active July 12, 2017 22:42
sending fds over unix domain sockets
/*
* Opens a Unix domain socket and cats any fds passed over it.
*/
#include <err.h>
#include <stdbool.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
@tokenrove
tokenrove / minimal-tap.tcl
Created July 14, 2017 16:35
Minimal TAP output from expect/tcl
proc ok {string body} {
if {![[proc {} {} $body]]} { send_user "not " }
puts "ok - $string"
}
proc plan {n} {
puts "1..$n"
}
@tokenrove
tokenrove / zhang-shasha.lisp
Last active November 2, 2017 19:57
Code from PWLMTL 2017/09 talk on the Zhang-Shasha paper
(defpackage #:zhang-shasha
(:use :cl))
(in-package :zhang-shasha)
(defun postorder-numbering-of-sexp (sexp)
(let ((nodes (make-array 0 :adjustable t :fill-pointer t))
(keyroots (make-hash-table)))
(labels
((dfs (node)
(let ((leaf