View merge.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def merge(streams): | |
# Keep track of the least value in each stream. | |
head = [stream.next() for stream in streams] | |
while len(head): | |
# Yield the least value of all streams. | |
next = min(head) | |
yield next | |
index = head.index(next) | |
try: | |
# Get next value from that stream. |
View decimal_to_binary.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function%20()%20{var%20selection%20=%20window.getSelection%20?%20window.getSelection()%20:document.getSelection%20?%20document.getSelection()%20:document.selection%20?%20document.selection.createRange().text%20:%20%27%27;if%20(selection)%20{selection%20=%20String(selection);}if%20(selection)%20{var%20match%20=%20selection.match(%27\/(.*)\/%27);var%20ipa;if%20(match%20&&%20match[1])%20{ipa%20=%20match[1];}if%20(!ipa)%20{ipa%20=%20prompt(%22Couldn%27t%20find%20any%20IPA.%20Type%20it%20in%20instead?%22);}if%20(ipa)%20{ipa%20=%20ipa.replace(/./g,%20function%20(c)%20{if%20(/%u0(...)/.test(escape(c)))%20{return%20escape(c).replace(/%u0(...)/g,%20%27&#x$1;%27);}%20else%20{return%20c;}});var%20request%20=%20{txt:%20%27<phoneme%20alphabet=%22ipa%22%20ph=%22%27+ipa+%27%22>%20</phoneme>%27,voice:%20%27crystal%27};var%20iframe%20=%20document.createElement(%27iframe%27);iframe.name%20=%20iframe.id%20=%20%22iframe%22+new%20Date().getTime();document.body.appendChild(iframe);var%20form%20=%20document.createElemen |
View chain.jquery.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias svnclean="for i in \$(svn st | grep \? | cut -c 9-); do echo \$i && rm \$i; done" |
View .screenrc_ssh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="slideshow"> | |
<img src="http://farm6.static.flickr.com/5243/5373962623_0e23ed169b_t.jpg"> | |
<img src="http://farm6.static.flickr.com/5007/5374562138_30e01a767f_t.jpg" style="display:none"> | |
<img src="http://farm6.static.flickr.com/5288/5374562162_d48ca16567_t.jpg" style="display:none"> | |
<img src="http://farm6.static.flickr.com/5084/5374562208_3e1bbe58cc_t.jpg" style="display:none"> | |
<img src="http://farm6.static.flickr.com/5086/5374562182_5ec5c14403_t.jpg" style="display:none"> | |
</div> | |
<script type="text/javascript"> | |
var ims = document.getElementById('slideshow').children; |
View bliff.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"html": "line<br>break"} |
View generator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
OlderNewer