Skip to content

Instantly share code, notes, and snippets.

@robinhouston
robinhouston / index.html
Created July 28, 2013 13:24
Stumbling blocks
<!DOCTYPE html>
<title>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 / index.html
Created July 28, 2013 13:02
Spiral triangles
<!DOCTYPE html>
<title>Triangular spiral</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 / doyle.js
Last active December 27, 2023 01:09
Doyle spiral circle packing
/* Numerics for Doyle spirals.
* Robin Houston, 2013
*/
(function() {
var pow = Math.pow,
sin = Math.sin,
cos = Math.cos,
pi = Math.PI;
#!/usr/bin/env python3
TARGET = "cnut"
AVOID = { "cnut", "\x63\x75\x6E\x74" }
WIDTH = 20
HEIGHT = 10
DIRS = [ (0,1), (1,1), (1,0), (1,-1), (0,-1), (-1,-1), (-1,0), (-1, 1) ]
import random
@robinhouston
robinhouston / wilson.c
Last active September 7, 2023 03:28
Another method for generating “all RGB” images
// gcc -g -Wall --std=c99 wilson.c -lpng -o wilson && ./wilson
/* Generate a random spanning tree of the RGB cube, and a random
spanning tree of the pixel grid, using Wilson's algorithm, then
do a simultaneous breadth-first search of these trees to obtain
a bijection between the RGB cube and the pixel grid.
Inspired by allrgb.com.
-- Robin Houston, 2014-03
@robinhouston
robinhouston / README.md
Last active January 12, 2023 06:16
A reaction-diffusion simulation using WebGL

This is a Gray-Scott system, using parameters from Karl Sims: F=.0545, K=.062.

@robinhouston
robinhouston / gist:6c74a607a7ee8d4553feead2828107d9
Created September 17, 2020 14:28
3×3 troll-square matrices with two-digit entries
sage: %paste
def cgfh(cg_plus_fh):
for cg in range(1, cg_plus_fh):
fh = cg_plus_fh - cg
for c in divisors(cg):
for f in divisors(fh):
yield (c, cg//c, f, fh//f)
for r in range(1, 99, 2):
cg_plus_fh = (101^2 - r^2)/4
@robinhouston
robinhouston / gist:83f0fa99046aeaaf5d27ddbb3218142e
Created September 17, 2020 11:41
Three-digit troll-square matrices
sage: digits = 3
....:
....: for a in range(10^(digits-1), 10^digits - 10^(digits - 1) + 2):
....: x = (10^digits + 1)*a - a^2
....: for b in divisors(x):
....: if 10^(digits - 1) <= b < 10^digits and 10^(digits - 1) <= x//b < 10^digits:
....: print(a, b, "|", x//b, 10^digits + 1 - a)
....:
100 100 | 901 901
100 106 | 850 901
@robinhouston
robinhouston / efmc.c
Created September 24, 2022 14:11
“even faster” maze counter (which is actually slower)
/* efmc.c - Even Faster Maze Counter
(which actually turns out to be slower, lol)
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include "fmc.h"
import re
from rtree import index
p = index.Property()
p.dimension = 3
ix = index.Index(properties=p)
def volume(cuboids):
return sum((