Skip to content

Instantly share code, notes, and snippets.

View tijmenb's full-sized avatar

Tijmen Brommet tijmenb

  • CaptionHub
  • Amsterdam, NL
  • 00:11 (UTC +02:00)
View GitHub Profile
require "timeout"
module WaitSteps
extend RSpec::Matchers::DSL
matcher :become_true do
match do |block|
begin
Timeout.timeout(Capybara.default_wait_time) do
sleep(0.1) until value = block.call
@michaelcox
michaelcox / SpecRunner.js
Last active January 11, 2024 06:05
Browser Unit Testing with Backbone Mocha Chai and RequireJS
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'
@bdurand
bdurand / benchmark_bundle.rb
Created May 10, 2012 16:15
Benchmark Your Bundle
#!/usr/bin/env ruby
require 'bundler'
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
/^Missing API definition file in (.+)$/i,
/^cannot load such file -- (.+)$/i,
@ddemaree
ddemaree / application.js.coffee
Created June 12, 2011 21:54
Simple Google Maps API v3 integration in CoffeeScript, with non-JS Static Maps fallback
#= require jquery
#= require jquery_ujs
#= require lib/modernizr
#= require lib/jquery.lettering
#= require_tree .
$ ->
$('*[data-googlemap]').googleMap()
true
@ohrite
ohrite / router.js
Created March 19, 2011 20:33
Route resolver for Rails3 into Backbone-style routes
// Router.js 0.1.0
// (c) 2011 Doc Ritezel
// Freely distributable under the MIT license.
//
// Load this before rails_routes.js (generated by routes_to_javascript.rb)
// Enables:
// var c = new Backbone.Controller({ routes: { Routes.root(): 'index' } });
// $('a.delete').attr('href', Routes.delete_item(3));
(function(){
@georgebrock
georgebrock / Rakefile
Created February 18, 2010 23:32
Rake tasks to manage Heroku deploys
namespace :deploy do
PRODUCTION_APP = 'myapp'
STAGING_APP = 'myapp-staging'
def run(*cmd)
system(*cmd)
raise "Command #{cmd.inspect} failed!" unless $?.success?
end
def confirm(message)
@tylerhunt
tylerhunt / gist:206213
Created October 9, 2009 18:03
Rack middleware that redirects requests to a canonical host.
class CanonicalHost
def initialize(app, host=nil, &block)
@app = app
@host = (block_given? && block.call) || host
end
def call(env)
if url = url(env)
[301, { 'Location' => url }, ['Redirecting...']]
else