Skip to content

Instantly share code, notes, and snippets.

View akiellor's full-sized avatar

Andrew Kiellor akiellor

View GitHub Profile
@akiellor
akiellor / gist:3288126
Created August 7, 2012 18:33
WebDriver Traffic
POST /session HTTP/1.1
GET /session/ad69c299769a6a219f10173073210387 HTTP/1.1
POST /session/ad69c299769a6a219f10173073210387/element/:wdc:1344363770883/elements HTTP/1.1
POST /session/ad69c299769a6a219f10173073210387/elements HTTP/1.1
GET /session/ad69c299769a6a219f10173073210387/element/:wdc:1344363775379/displayed HTTP/1.1
POST /session/ad69c299769a6a219f10173073210387/elements HTTP/1.1
GET /session/ad69c299769a6a219f10173073210387/element/:wdc:1344363775380/displayed HTTP/1.1
POST /session/ad69c299769a6a219f10173073210387/element/:wdc:1344363775380/elements HTTP/1.1
GET /session/ad69c299769a6a219f10173073210387/element/:wdc:1344363775381/displayed HTTP/1.1
GET /session/ad69c299769a6a219f10173073210387/element/:wdc:1344363775381/selected HTTP/1.1
@akiellor
akiellor / build.gradle
Created July 25, 2012 07:39
Sample Gradle Project using GemJars
repositories {
ivy {
ivyPattern "http://repository.gemjars.org/ivys/[organisation]/ivy-[module]-[revision].xml"
artifactPattern "http://repository.gemjars.org/jars/[organisation]/[module]-[revision].jar"
}
}
configurations {
rspec.extendsFrom runtime
}
@akiellor
akiellor / step_invocation.rb
Created April 7, 2012 23:08
Platform sniffing...grrrr
class Cucumber::Ast::StepInvocation
def failed(configuration, e, clear_backtrace)
if Cucumber::JRUBY && e.class.name == 'NativeException'
# JRuby's NativeException ignores #set_backtrace.
# We're fixing it.
e.instance_eval do
def set_backtrace(backtrace)
@backtrace = backtrace
end
@akiellor
akiellor / document_spec.rb
Created January 2, 2012 05:20
XPath matcher using nokogiri.
require 'nokogiri'
RSpec::Matchers.define :have_xpath do |*paths|
match do |doc|
!doc.xpath(*paths).empty?
end
end
def within *paths, &block
describe "within #{paths.inspect}" do
@akiellor
akiellor / servlet.js
Created November 14, 2011 04:37
The best servlet I have ever seen :)
exports.woot = new javax.servlet.http.HttpServlet({
doGet: function(req, res){
res.getWriter().print("woot from JS");
}
})
@akiellor
akiellor / main.js
Created November 14, 2011 02:19
CommonJS implementation of Polyglot for Rhino.
var polyglot = require('polyglot');
polyglot.register('coffee', require('coffee-script').CoffeeScript.compile);
polyglot.require('math').square(2);
@akiellor
akiellor / coffee.loader.js
Created October 24, 2011 23:06
CoffeeScript Loader for rhino.
load("coffee-script.js");
var eval = (function(scope){
var __context__ = Packages.org.mozilla.javascript.Context.getCurrentContext();
function __eval(scope, source, name){
__context__.evaluateString(
scope,
source,
name,
@akiellor
akiellor / Tap.scala
Created October 24, 2011 01:40
An implementation of Ruby's Tap in Scala.
import collection.mutable.MutableList
import Tap._
class Tap[A](any: A) {
def tap(f: (A) => Unit): A = {
f(any)
any
}
}
@akiellor
akiellor / ArrayListTest.java
Created September 6, 2011 08:59
RSpec Style Runner for JUnit
@RunWith(BehaviourRunner.class)
@ItBehavesLike(ListBehaviours.class)
public class ArrayListTest {
@Subject ArrayList<String> list(){
return new ArrayList<String>();
}
}
@akiellor
akiellor / build.gradle
Created August 19, 2011 01:50
Gradle which supports rspec :-)
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse'
import org.rubygems.repository.GemResolver;
buildscript {
repositories {
mavenCentral()
}