Skip to content

Instantly share code, notes, and snippets.

@sbp
sbp / render.py
Last active August 29, 2015 14:23
Simple log renderer
#!/usr/bin/env python3
import codecs
import re
import sys
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
link = r'((ftp|https?)://([^\s<>"\'\[\]),;:.&]|&(?![gl]t;)|[\[\]),;:.](?! ))+)'
print("Content-Type: text/html; charset=utf-8")
@sbp
sbp / log.py
Created June 26, 2015 14:17
saxo logging plugin
import os.path
import time
import saxo
log = None
@saxo.setup
def open_log(irc):
global log
@sbp
sbp / aus.py
Created May 18, 2015 12:33
6 aus 49 generator
#!/usr/bin/env python3
def primegen(n=2):
primes = set()
while True:
for p in primes:
if (n % p) == 0:
break
else:
primes.add(n)
@sbp
sbp / len.rs
Created March 4, 2015 11:48
Fails: Get len of a file, using rustc 1.0.0-dev (built 2015-02-22)
use std::io::prelude::*;
use std::fs::File;
use std::fs::Metadata;
fn main() {
fn len() -> std::io::Result<()> {
let mut f = try!(File::open("len.rs"));
println!("{}", f.metadata().len());
Ok(())
}
@sbp
sbp / diff.py
Last active August 29, 2015 14:12 — forked from tonyg/diff.py
Ukkonen-Myers diff and patch
# Copyright (c) 2015 Tony Garnock-Jones <[email protected]>
# Copyright (c) 2015 Sean B. Palmer <inamidst.com>
# Licensed under the 2-Clause Simplified BSD License
def longest_common_subsequence(xs, ys):
# Uses the Ukkonen-Myers algorithm
t = len(xs) + len(ys)
front = [0] * (2 * t + 1)
candidates = [None] * (2 * t + 1)
for d in range(t + 1):
@sbp
sbp / metasnap.py
Last active August 29, 2015 14:03
import os
import sys
def main():
root = sys.argv[1]
if not os.path.isdir(root):
print("Not a directory:", root)
sys.exit(1)
for (r, d, f) in os.walk(root):
@sbp
sbp / keybase.md
Created March 24, 2014 18:47
keybase.md

Keybase proof

I hereby claim:

  • I am sbp on github.
  • I am sbp (https://keybase.io/sbp) on keybase.
  • I have a public key whose fingerprint is 0894 4399 DB77 C89D 0770 B7B2 ACF4 79DF 7CA8 660D

To claim this, I am signing this object:

@sbp
sbp / bip32.py
Created March 9, 2014 22:41
Parse a BIP32 encoded wallet from stdin
#!/usr/bin/env python3
# Parse a BIP32 encoded wallet from stdin
import sys
import base58
# https://raw.github.com/kylegibson/python-bitcoin-client/master/base58.py
def error(message):
print("E:", message, file=sys.stderr)
sys.exit(1)
@sbp
sbp / 02.make
Created February 22, 2014 22:11
Making install in tools
clang++ -DHAVE_CONFIG_H -I.. -D_REENTRANT -D_REENTRANT -I/usr/local/Cellar/libsigc++/2.3.1/include/sigc++-2.0 -I/usr/local/Cellar/libsigc++/2.3.1/lib/sigc++-2.0/include -I/usr/local/Cellar/glib/2.38.2/include/glib-2.0 -I/usr/local/Cellar/glib/2.38.2/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/glibmm/2.38.1/include/giomm-2.4 -I/usr/local/Cellar/glibmm/2.38.1/lib/giomm-2.4/include -I/usr/local/Cellar/glibmm/2.38.1/include/glibmm-2.4 -I/usr/local/Cellar/glibmm/2.38.1/lib/glibmm-2.4/include -I/usr/local/Cellar/libpng/1.5.17/include/libpng15 -I/usr/local/Cellar/gdk-pixbuf/2.30.4/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/freetype/2.5.2/include/freetype2 -I/usr/local/Cellar/fontconfig/2.11.0/include -I/usr/local/Cellar/freetype/2.5.1/include/freetype2 -I/usr/local/Cellar/pixman/0.32.4/include/pixman-1 -I/usr/local/Cellar/cairo/1.12.16/include/cairo -I/usr/local/Cellar/harfbuzz/0.9.26/include/harfbuzz -I/usr/local/Cellar/pango/1.36.2/include/pango-1.0 -I/usr/l
@sbp
sbp / 02.make
Created February 22, 2014 21:22
Making install in tools
clang++ -DHAVE_CONFIG_H -I.. -D_REENTRANT -D_REENTRANT -I/usr/local/Cellar/libsigc++/2.3.1/include/sigc++-2.0 -I/usr/local/Cellar/libsigc++/2.3.1/lib/sigc++-2.0/include -I/usr/local/Cellar/glib/2.38.2/include/glib-2.0 -I/usr/local/Cellar/glib/2.38.2/lib/glib-2.0/include -I/usr/local/Cellar/glibmm/2.38.1/include/giomm-2.4 -I/usr/local/Cellar/glibmm/2.38.1/lib/giomm-2.4/include -I/usr/local/Cellar/glibmm/2.38.1/include/glibmm-2.4 -I/usr/local/Cellar/glibmm/2.38.1/lib/glibmm-2.4/include -I/usr/local/Cellar/libpng/1.5.17/include/libpng15 -I/usr/local/Cellar/gdk-pixbuf/2.30.4/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/freetype/2.5.2/include/freetype2 -I/usr/local/Cellar/fontconfig/2.11.0/include -I/usr/local/Cellar/freetype/2.5.1/include/freetype2 -I/usr/local/Cellar/pixman/0.32.4/include/pixman-1 -I/usr/local/Cellar/cairo/1.12.16/include/cairo -I/usr/local/Cellar/harfbuzz/0.9.26/include/harfbuzz -I/usr/local/Cellar/pango/1.36.2/include/pango-1.0 -I/usr/local/Cellar/atk/2.10.0/include/at