Skip to content

Instantly share code, notes, and snippets.

@npryce
npryce / gist:3840872
Created October 5, 2012 16:35
Two-Dimensional Cucumber Table
|Key Press:
Playback |PAUSE |PLAY |FFWD |REW |STOP
----------+------+-------+--------+--------+------------
paused |paused|fwd x 1|fwd x 2 |rew x 1 |show live tv
fwd x 1 |paused|fwd x 1|fwd x 2 |rew x 1 |show live tv
fwd x 2 |paused|fwd x 1|fwd x 6 |rew x 1 |show live tv
fwd x 6 |paused|fwd x 1|fwd x 12|rew x 1 |show live tv
fwd x 12 |paused|fwd x 1|fwd x 30|rew x 1 |show live tv
fwd x 30 |paused|fwd x 1|fwd x 30|rew x 1 |show live tv
rew x 1 |paused|fwd x 1|fwd x 2 |rew x 2 |show live tv
@npryce
npryce / ZXProportional.lua
Created November 27, 2011 23:24
Proportional Font based on ZX Spectrum font
function ZXProportional()
return BitmapFont {
height = 8,
charSpacing = 1,
lineSpacing = 0,
["!"] = {
" ",
"X",
@npryce
npryce / ZXMonospace.lua
Created November 27, 2011 23:06
Monospace bitmap font for Codea based on ZX Spectrum font (nostalgia!)
function ZXMonospace()
    return BitmapFont {
        height = 8,
        charSpacing = 0,
        lineSpacing = 0,
        
        ["!"] = {
            "        ",
            "   X    ",
@npryce
npryce / trees.lua
Created November 9, 2011 19:45
Random Trees for Codea
function setup()
    seed = 1
end
function draw()
    background(136, 207, 224, 255)
    noStroke()
    fill(61, 109, 31, 255)
    rect(0, 0, WIDTH, 128)
@npryce
npryce / java-generics-hell
Created July 29, 2011 16:57
Java Generics Hell
import java.util.Comparator;
public class GenericsHell {
public static void compareSomeNumbers(Comparator<Integer> numberComparison) {
// ... elided ...
}
public static <T> Comparator<T> arbitraryOrder() {
return new Comparator<T>() {
@Override
@npryce
npryce / wip.py
Created May 28, 2011 20:17
Decorator to mark tests as work in progress for Python's Nose testing framework
from functools import wraps
from nose.plugins.attrib import attr
from nose.plugins.skip import SkipTest
def fail(message):
raise AssertionError(message)
def wip(f):
@wraps(f)
@npryce
npryce / Repeat.java
Created March 1, 2011 14:01
Test to demonstrate search after refresh problem
package acceptance.giraffe.indexing;
import java.util.SortedMap;
import java.util.TreeMap;
import org.junit.rules.MethodRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
public class Repeat implements MethodRule {
@npryce
npryce / ElasticSearch Deadlock Test
Created February 28, 2011 13:46
Demonstrates deadlock when searching an ElasticSearch index immediately after creating it
package acceptance.giraffe.indexing;
import java.io.File;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexMetaData;