Skip to content

Instantly share code, notes, and snippets.

Oliver Nightingale olivernn

  • Cape Town
Block or report user

Report or block olivernn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:350531
Oliver-Nightingales-MacBook-Pro:capybara-envjs olivernightingale$ rake
(in /Users/olivernightingale/code/capybara-envjs)
warning: couldn't activate the debugging plugin, skipping
warning: couldn't activate the doofus plugin, skipping
warning: couldn't activate the git plugin, skipping
/Library/Ruby/Gems/1.8/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:274:in `include_shared_example_group': Shared Example Group 'has_select' can not be found (RuntimeError)
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:66:in `it_should_behave_like'
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:65:in `each'
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:65:in `it_should_behave_like'
from /Library/Ruby/Gems/1.8/gems/capybara-0.3.6/spec/session_spec.rb:58
require 'rubygems'
require 'rack'
require 'snippets'
require 'mongo'
require 'rackjson'
use Rack::JSON::Resource, :collections => [:notes], :db =>"notes")
run lambda { |env| [404, {'Content-Length' => '9', 'Content-Type' => 'text/plain'}, "Not Found"] }
View gist:593354
Post('post', {}, {
validatesPresenceOf: ['title', 'body'],
validatesLengthOf: [{attr: 'title', min: 20}, { attr: 'body', max: 2000 }]
olivernn / user.js
Created Dec 1, 2010
User with validation on presence of name
View user.js
var User = Model('user', {
// class methods
validates: {
presenceOf: ['name']
}, {
// instance methods
o = new User ({name: "oliver"})
olivernn / active_model_errors_patch.rb
Created Jan 27, 2011
stop invalid json after calling to_json on active model errors
View active_model_errors_patch.rb
module ActiveModel
class Errors
def as_json(options=nil)
def to_hash
hash =
each { |k, v| (hash[k] ||= []) << v }
View reports_controller.rb
class Admin::ReportsController < AdminController
respond_to :csv
def trips
View ios_history_bug.rb
require 'rubygems'
require 'sinatra'
get "/" do
erb :index
get "/slow_network" do
View gist:1129339
<script src="" type="text/javascript" charset="utf-8"></script>
<style type="text/css" media="screen">
body {
background-color: black;
color: white;
font-family: helvetica;
#display {
olivernn / bill.js
Created Aug 24, 2011
js model validations
View bill.js
var Bill = Model('bill', function () {
this.validatesPresenceOf(['attribute1', 'attribute2'])
this.validatesPresenceOf('another_attribute', {
'condition': function () {
// some condition if you need it
return true
View Post.js
var Post = Model('post', function () {
this.use(Model.Lunr(function () {
this.field('title', {
'multiplier': 10
You can’t perform that action at this time.