Skip to content

Instantly share code, notes, and snippets.

@robinhouston
robinhouston / index.html
Created July 28, 2013 14:16
Double stumbling blocks
<!DOCTYPE html>
<meta charset="utf-8">
<title>Double stumbling blocks</title>
<script src="http://bl.ocks.org/robinhouston/raw/6096562/rAF.js" charset="utf-8"></script>
<script src="http://bl.ocks.org/robinhouston/raw/6096562/doyle.js" charset="utf-8"></script>
<canvas width=960 height=500></canvas>
<script>
// Initialisation
var canvas = document.getElementsByTagName("canvas")[0],
context = canvas.getContext("2d");
@robinhouston
robinhouston / README.md
Created August 4, 2013 17:49
Experiments in flow

An experiment in flow visualisation and the mathematical transformation of vector fields. Visual style obviously influenced by the classic http://hint.fm/wind/

@robinhouston
robinhouston / README.md
Created August 4, 2013 19:39
Flow experiment II

The velocity at point z in the complex plane is proportional to z^2 - z + c for a constant c.

@robinhouston
robinhouston / README.md
Last active December 20, 2015 21:49
A family of equal-area projections

There is a family of pseudocylindrical equal-area projections that starts with the cylindrical equal area and ends with the sinusoidal, parameterised by t ∈ [0,1].

The formulas are:

x = λ cos^t φ

y = ∫_0^φ cos^(1-t) φ

@robinhouston
robinhouston / bangbang_counter.py
Last active December 21, 2015 04:48
Compute the Bang Bang numbers
#!/usr/bin/python
# -*- encoding: utf-8 -*-
# See http://shadabahmed.com/blog/2013/08/16/bang-bang for context.
# A string of single and double quotes may be interpreted as an element
# of the symmetric group S3, since there are three quotation states when
# lexing a shell command: unquoted, single-quoted, and double-quoted,
# and each string permutes the quotation state. A single quote mark
# switches between unquoted and single-quoted, and a double quote mark
@robinhouston
robinhouston / question2_brian_meyer.c
Created September 12, 2013 23:52
Solve a variant of the “Question 2” homework exercise from a previous iteration of the Coursera _Cryptography I_ course, proposed by Brian Meyer: https://class.coursera.org/crypto-008/forum/thread?thread_id=59#post-445
/* Solve a variant of the “Question 2” homework exercise from a previous
* iteration of the course, proposed by Brian Meyer:
*
* https://class.coursera.org/crypto-008/forum/thread?thread_id=59#post-445
*/
#include <stdio.h>
#include <stdbool.h>
#define N 9
#!/usr/bin/python2.7
# -*- encoding: utf-8 -*-
from __future__ import division
import sys
P = 0xFFFFFFFFFFFFFFC5 # The largest 64-bit prime
def f(n):
return (2*n) ^ ((3*n + 7) % P)

Emacs is a text editor that is installed on most Unix-like computers. It has a long history and a devoted following, and contains unusually many bizarre jokes for a piece of ostensibly serious software.

One of these is the doctor command, which implements the famous ELIZA algorithm: a primitive but surprisingly convincing simulation of a Rogerian psychotherapist.

Another used to be the yow command, which would print a quotation from the 70s underground comic strip Zippy the Pinhead. These quotations are typically strange non-sequiturs.

So perhaps it is inevitable that someone had the idea of combining the two, creating the command psychoanalyze-pinhead, which runs the yow command and feeds its output to the doctor command, creating an unending stream of random nonsense alternating with formulaic responses that appear to be taking the nonsense seriously. This is amusing

with n as (
select a.state_name a, b.state_name b
from usa_state_shapefile a
, usa_state_shapefile b
where ST_Dimension(ST_Intersection(a.the_geom, b.the_geom)) > 0
)
select w.a w, x.a x, y.a y, z.a z
from n w
join n x on x.a = w.b
join n y on y.a = x.b
@robinhouston
robinhouston / universal-tartan.py
Created March 4, 2014 21:01
A 4096×4096 image containing each RGB value once (h/t allrgb.com). Z-order traversal of RGB cube mapped to z-order traversal of 4096×4096 square.
from PIL import Image
def splitnum(k, x):
parts = [0] * k
for n in range(24):
parts[n % k] |= ((x >> n) & 1) << (n // k)
return tuple(parts)
im = Image.new("RGB", (4096, 4096))
pix = im.load()