Skip to content

Instantly share code, notes, and snippets.

View tantalor's full-sized avatar

John Tantalo tantalor

View GitHub Profile
@tantalor
tantalor / quine.pl
Created January 27, 2011 01:04
A perl quine.
#!/usr/bin/perl
my ($q, $n) = ("'", chr(10));
my $s = '#!/usr/bin/perl%smy ($q, $n) = ("%s", chr(10));%smy $s = %s%s%s;%sprintf $s, $n, $q, $n, $q, $s, $q, $n, $n;%s';
printf $s, $n, $q, $n, $q, $s, $q, $n, $n;
@tantalor
tantalor / counters.js
Created February 15, 2011 00:03
Starcraft 2 counters for basic units (node)
var
ZERGLING = 'Zergling',
ROACH = 'Roach',
HYDRALISK = 'Hydralisk',
BANELING = 'Baneling',
MARINE = 'Marine',
HELLION = 'Hellion',
MARAUDER = 'Marauder',
REAPER = 'Reaper',
TANK = 'Siege Tank',
@tantalor
tantalor / bliff.pl
Created March 12, 2011 03:07
Combines svn blame and diff.
#!/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;
{"html": "line<br>break"}
@tantalor
tantalor / generator.js
Created April 20, 2011 23:43
buffering asynchronous iterator pattern
// 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) {
@tantalor
tantalor / javascript_bookmarklet_builder.pl
Created October 3, 2011 16:09
Perl script to URI-escape JavaScript for bookmarklets
#!/usr/bin/env perl
#
# Written by John Gruber, taken with permission from:
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder
use strict;
use warnings;
use URI::Escape qw(uri_escape_utf8);
use open IO => ":utf8", # UTF8 by default
":std"; # Apply to STDIN/STDOUT/STDERR
@tantalor
tantalor / go.js
Created October 10, 2011 03:40
Prime sieve in Go-flavored JavaScript
#!/usr/bin/env node
var sys = require('sys');
function go (fn) {
setTimeout(fn, 0);
};
var chan = function () {
this.readers = []; // [cb, ...]
@tantalor
tantalor / Custom.css
Created January 18, 2012 05:32
Wikipedia Blackout Blocker
#mw-page-base, #mw-head-base, #content,
#mw-head, #mw-panel, #footer {
display: block !important;
}
#mw-sopaOverlay {
display: none !important;
}
import thor
thor.ssh()
@tantalor
tantalor / moon.html
Created March 12, 2012 22:25
Moon in px
<body style="background: black">
<a href="http://inamidst.com/stuff/notes/csspx">
<img src="http://upload.wikimedia.org/wikipedia/en/thumb/c/c9/Moon_nearside_LRO.jpg/170px-Moon_nearside_LRO.jpg" style="width:24.3px;height:24.3px">
</a>