Skip to content

Instantly share code, notes, and snippets.

@robinhouston
robinhouston / sleepsort.coffee
Created September 26, 2011 21:56
A Sleep sort implementation for http://visualsort.appspot.com/
pos = [0 ... VA.length]
rpos = [0 ... VA.length]
swap = (i, j) ->
VA.swap i, j
tmp = rpos[j]; rpos[j] = rpos[i]; rpos[i] = tmp
pos[rpos[i]] = i; pos[rpos[j]] = j
j = 0
@robinhouston
robinhouston / pdftk.patch
Created December 9, 2011 14:53
A patch for pdftk 1.44 that fixes an infinite-loop bug
diff -ru -x '*.class' pdftk-1.44-dist/java/com/lowagie/text/pdf/PdfReader.java pdftk-1.44-patched/java/com/lowagie/text/pdf/PdfReader.java
--- pdftk-1.44-dist/java/com/lowagie/text/pdf/PdfReader.java 2010-10-28 21:07:44.000000000 +0000
+++ pdftk-1.44-patched/java/com/lowagie/text/pdf/PdfReader.java 2011-12-08 17:07:23.000000000 +0000
@@ -1421,18 +1421,18 @@
// ssteward - 6/21/10
// stream should be followed by a LF or a CRLF, but not just a CR, per the PDF spec.
// however, I have encountered a generated PDF (Microsoft Reporting Services 10.0.0.0)
- // that added a space after "stream" but before the CR; so gobble up unexpected chars
- // until we find a LF
+ // that added a space after "stream" but before the CR; and also one (HP Digital
@robinhouston
robinhouston / gist:1746349
Created February 5, 2012 16:22
lvalue subroutine behaviour changes
# In days of yore, this would print ONCE UPON A TIME.
# In bleadperl, it prints BUT NOWADAYS
#
# Can anyone point me to what has changed?
use strict; use feature 'say';
my $x = "ONCE UPON A TIME";
sub foo :lvalue { $x; }
my $r = \(scalar foo());
@robinhouston
robinhouston / gist:1771478
Created February 8, 2012 17:29
what happens when I run a script (bug in survey branch of whatdotheyknow-theme)
Robin-Houstons-MacBook-Pro:alaveteli robin$ script/alert-new-response-reminders
<
<=
<=>
==
===
=~
>
>=
N_
@robinhouston
robinhouston / unholy.cc
Created February 16, 2012 23:10
Test case for throwing an exception in Java and catching it in C++
/* Derived from the example at
* http://gcc.gnu.org/onlinedocs/gcj/Invocation.html
*
* Compile using:
* /usr/local/bin/g++ -c unholy.cc
* /usr/local/bin/gcj -lstdc++ unholy.o -o unholy
*/
#pragma GCC java_exceptions
Robin-Houstons-MacBook-Pro:pdftk robin$ /usr/local/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin11.2.0/4.6.2/lto-wrapper
Target: x86_64-apple-darwin11.2.0
Configured with: ./configure
Thread model: posix
gcc version 4.6.2 (GCC)
Robin-Houstons-MacBook-Pro:pdftk robin$ /usr/local/bin/gcj -v
@robinhouston
robinhouston / README.md
Created December 14, 2012 01:26 — forked from mbostock/.block

A central challenge of projecting geography is that the globe is spherical while the display is planar. Projecting the globe onto the screen thus requires cutting the globe at least once. Most commonly, world maps are horizontally cented at the prime meridian and cut the globe along ±180° longitude, which is called the antemeridian.

But what happens to shapes that cross the antemeridian, such as the Eastern tip of Russia? When projecting Russia using a normal cylindrical projection, for example, the Western part of Russia appears on the right edge, while the Eastern part appears on the left edge. A naïve projection of lines that cross the antemeridian would also cross the map, leading to distracting visual artifacts!

To avoid this problem, many freely-available shapefiles are already cut along the antemeridian. This enables geographic software to ignore the topologi

@robinhouston
robinhouston / gist:4284890
Created December 14, 2012 11:52
Simple color animation
function animateColor(element, property, start_hex, end_hex, duration) {
var start = parseHexColor(start_hex),
end = parseHexColor(end_hex);
var start_time = new Date().getTime();
var timer = setInterval(function() {
var elapsed_millis = new Date().getTime() - start_time;
if (elapsed_millis >= duration) {
clearInterval(timer);
element.css(property, end_hex);
return;
@robinhouston
robinhouston / README.md
Last active December 12, 2015 08:18
Head & Shoulders

A little audio-synchronised animation using Kiln’s Talkie library.

@robinhouston
robinhouston / README.md
Last active December 12, 2015 08:18
Countdown – Talkie demo

A simple demonstration of how to use Kiln’s Talkie animation library.