Skip to content

Instantly share code, notes, and snippets.


John Tantalo tantalor

View GitHub Profile
tantalor /
Created May 5, 2014
Merge Algorithm
def merge(streams):
# Keep track of the least value in each stream.
head = [ for stream in streams]
while len(head):
# Yield the least value of all streams.
next = min(head)
yield next
index = head.index(next)
# Get next value from that stream.
def bin(x, k=0):
d = {0:'000', 1:'001', 2:'010', 3:'011', 4:'100', 5:'101', 6:'110', 7:'111'}
return ''.join([d[int(dig)] for dig in oct(x)]).lstrip('0').zfill(k)
View ipa.bookmarklet.js
View chain.jquery.js
// John Tantalo
jQuery.fn.chain = function (fn)
var self = this;
return function ()
if (!self.size()) return;
fn(self.eq(0), self.slice(1).chain(fn));
View svnclean
alias svnclean="for i in \$(svn st | grep \? | cut -c 9-); do echo \$i && rm \$i; done"
View .screenrc_ssh
escape ``
screen -t "host 1" ssh host1
screen -t "host 1" ssh host1
screen -t "host 2" ssh host2
screen -t "host 2" ssh host2
screen -t "host 3" ssh host3
screen -t "host 3" ssh host3
View slideshow.html
<div id="slideshow">
<img src="">
<img src="" style="display:none">
<img src="" style="display:none">
<img src="" style="display:none">
<img src="" style="display:none">
<script type="text/javascript">
var ims = document.getElementById('slideshow').children;
tantalor /
Created Mar 12, 2011
Combines svn blame and diff.
use strict;
use List::Util 'max';
my ($from, $to) = @ARGV
or die "usage: $0 OLD-URL[\@OLDREV] NEW-URL[\@NEWREV]\n";
my @diff = `svn diff $from $to` or die;
my @blame = map {/^\s*(\d+)/} `svn blame $to` or die;
View html.js
{"html": "line<br>break"}
tantalor / generator.js
Created Apr 20, 2011
buffering asynchronous iterator pattern
View generator.js
// produce: accepts a cb which is called with an array of items
// initial: initial array of results to return
// returns a function which accepts a cb which is called with one item
// each time it is called
function generator(produce, initial) {
var items;
var waiting = [];
var next = function (cb) {
if (items && items.length) {