Skip to content

Instantly share code, notes, and snippets.

View woodrow's full-sized avatar

Steve Woodrow woodrow

View GitHub Profile
match_latencies = c(
7.47978949546814, 6.318617582321167, 6.1188719272613525, 7.745437145233154,
...,
2.361427068710327, 3.1125471591949463)
nomatch_latencies = c(
1.8395578861236572, 1.9002978801727295, 2.7614076137542725, 4.611708402633667,
...,
2.752995729446411, 5.312501907348633)
@woodrow
woodrow / gist:6347926
Created August 26, 2013 23:25
Passport MRZ check digit algorithm
def compute_check_digit(str)
str = str.strip.upcase
values = str.chars.map do |char|
case char
when '<'
0
when 'A'..'Z'
char.ord - 65 + 10
when '0'..'9'
char.ord - 48
require 'benchmark'
NUM_TRIALS = 10_000_000
Benchmark.bm(20) do |x|
x.report('no concatenation') do
NUM_TRIALS.times do
y = "onetwothree"
end
end
@woodrow
woodrow / demo_conn.py
Created January 23, 2012 05:52
Reproducing Unhandled Errors with txpostgres
# based on fist example at http://wulczer.github.com/txpostgres/usage.html
import socket
import sys
from txpostgres import txpostgres
from twisted.internet import reactor, stdio
from twisted.python import log, util
from twisted.protocols import basic
@woodrow
woodrow / get_gmail_recipients.py
Created January 15, 2012 10:12
Determine who you sent mail to from an expiring/expired email addresss
#!/usr/bin/env python
import imaplib
import email.parser
import pickle
import pprint
GMAIL_USERNAME = 'yourname@gmail.com'
GMAIL_PASSWORD = 'yourgmailpassword'
OLD_SENDER_ADDRESS = 'defuntaccount@mit.edu'
woodrow@woodrow-x200:~/tmp$ cat sort_test
1.2.3.4
2.3.4.5
12.3.2.4
12.2.3.4
12.2.3.5
11.2.3.4
1.12.3.4
20.2.3.4
21.2.3.4