This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple app that implements a naive session-based login, to demonstrate the problems with testing sessions in Sinatra. | |
require 'rubygems' | |
require 'sinatra/base' | |
class LoginApp < Sinatra::Base | |
enable :sessions | |
get '/' do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cloudmadeOptions = { | |
getTileUrl: function(coord, zoom) { | |
return "http://a.tile.cloudmade.com/<API KEY HERE>/<CLOUDMADE CUSTOM TILE ID>/256/" + | |
+ zoom + "/" + coord.x + "/" + coord.y + ".png"; | |
}, | |
tileSize: new google.maps.Size(256, 256), | |
isPng: true | |
}; | |
var cloudmadeType = new google.maps.ImageMapType(cloudmadeOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# features/support/configuration.rb | |
Before do | |
Neo4j::Transaction.run do | |
Neo4j._all_nodes.each { |n| n.del unless n.neo_id == 0 } | |
end | |
end | |
# spec/support/configuration.rb | |
def delete_all | |
Neo4j::Transaction.run do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Active Model North American Telephone Number Validator | |
# http://en.wikipedia.org/wiki/North_American_Numbering_Plan#Current_system | |
# [Author] Roger Rohrbach (roger@ecstatic.com) | |
class NanpValidator < ActiveModel::EachValidator | |
def self.matcher(require_area_code) # :nodoc: | |
%r{ | |
(?<country_code> \+1 ){0} | |
(?<trunk_prefix> 1 ){0} | |
(?<delimiter> ([-\.]|\ +) ){0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested on: Rails 3.1.x, Heroku Cedar stack | |
1. Generate/develop local Rails app, add mongoid gem, bundle install etc. | |
2. Git the App | |
3. Generate Heroku Cedar App: | |
heroku create --stack cedar | |
4. Rename app | |
heroku rename <newname> | |
5. Install heroku mongoHQ or mongolab: | |
heroku addons:add mongohq:free |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json_expressions' | |
RSpec::Matchers.define :match_json do |expected| | |
unless JsonExpressions::Matcher === expected | |
expected = JsonExpressions::Matcher.new(expected) | |
end | |
match do |actual| | |
actual = JSON.parse(actual) if String === actual | |
expected =~ actual |