Skip to content

Instantly share code, notes, and snippets.

Feature: Anaphora
Scenario: Dog barks at cat
Given there is a dog
And there is a cat
When the dog barks at the cat
Then the cat should run away
@joshski
joshski / patterns.js
Created July 8, 2011 14:16 — forked from jcleveley-zz/patterns.js
Javascript patterns
// namespace - single global variable for all news JS
var news = news || {};
// Example of a singleton as a revealing module
// When you only need one of something
news.preferences = (function (app, global) {
// Private variables
var persistent = true;
Sprint 2
Evaluate unit test framework options (some are unlikely to work on all devices)
Make unit tests run under node.js and in-browser
Make unit tests run in headless browser in hudson (when code is committed)
Sprint 3
Make spassky tool (runs tests on physical devices) usable by dev team
Improve spassky output: summarise passes/fails/devices and stack traces
Sprint 4
function EbnfDiagram(gc) {
this.gc = gc;
this.styles = STYLES;
this.style = this.styles["DIAGRAM"];
this.init();
}
EbnfDiagram.prototype.getGC = function() {
return this.gc;
@joshski
joshski / concat.pogo
Created January 7, 2013 08:27
concatenative pogo
async = require 'async'
one ! = 1
two ! = 2
plus ! (x, y) = x + y
log ! (x) = console.log (x)
concat (memo, item, callback) =
done = @(err, result)
callback (err, memo.concat(result))
@joshski
joshski / gist:4596443
Created January 22, 2013 17:22
capybara mechanize headers
# capybara '1.1.2
require 'capybara'
require 'capybara/dsl'
require 'capybara/mechanize'
Capybara.default_driver = :mechanize
Capybara.app_host = 'http://httpbin.org'
include Capybara::DSL
@joshski
joshski / flame.lua
Created April 21, 2013 10:52
Generates a little flame. Works in Codea.
-- a little flame in a functional style
function particle(step, style, t)
local newStyle = step(style, t)
return {
style = newStyle,
next = function()
return particle(step, newStyle, t + 1)
end
}
echo
echo "DELETE INDEX"
echo
curl -w "\r\n" -X DELETE http://localhost:9200/temp-index
echo
echo "CREATE MAPPINGS"
echo
curl -w "\r\n" -X POST http://localhost:9200/temp-index -d '{"mappings":{"product":{"properties":{"name":{"type":"string","analyzer":"snowball"},"tags":{"type":"string","index":"not_analyzed"},"url":{"type":"string","index":"not_analyzed"},"image":{"type":"string","index":"not_analyzed"},"class":{"type":"string","index":"not_analyzed"},"publisher":{"type":"string","index":"not_analyzed"}}}},"settings":{}}'
@joshski
joshski / gist:8207912
Created January 1, 2014 13:06
bug in npm 'xpath'?
require 'nokogiri'
Nokogiri::HTML('<z><a /><b /><a /><b /><b /><b /><a /><c><a /><b /></c></z>').css("a + b")
=> [#<Nokogiri::XML::Element:0x3fdf7d0c0a34 name="b">, #<Nokogiri::XML::Element:0x3fdf7d0c0688 name="b">, #<Nokogiri::XML::Element:0x3fdf7d0c046c name="b">]
Nokogiri::HTML('<z><a /><b /><a /><b /><b /><b /><a /><c><a /><b /></c></z>').xpath("//a/following-sibling::*[1]/self::b")
=> [#<Nokogiri::XML::Element:0x3fdf7d0cc294 name="b">, #<Nokogiri::XML::Element:0x3fdf7d0cc08c name="b">, #<Nokogiri::XML::Element:0x3fdf7d0cbe70 name="b">]
$('<z><a /><b /><a /><b /><b /><b /><a /><c><a /><b /></c></z>').find('a + b');
Object[b, b, b]
import minecraft
import block
import time
mc = minecraft.Minecraft.create()
direction = 'none'
playerTilePos = mc.player.getTilePos()
mc.setBlocks(playerTilePos.x - 25, playerTilePos.y, playerTilePos.z - 25, playerTilePos.x + 25, playerTilePos.y + 2, playerTilePos.z + 25, block.AIR)