Skip to content

Instantly share code, notes, and snippets.

@erithmetic
erithmetic / routes.rb
Created October 24, 2012 19:11 — forked from codeodor/routes.rb
How do I keep all of these routes, but also make them available under a scope?
# I have read http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html#method-i-resources
# and remain clueless.
MyApp::Application.routes.draw do
resources :blogs do
resources :comments
end
# then imagine tons of routing below this
end
@erithmetic
erithmetic / gist:3890301
Created October 15, 2012 00:43
JS Packaging post
---
title: Client-Sdie JavaScript Packaging
author: derek
layout: post
categories: technology
---
One of the joys of Ruby is its package manager, rubygems. With a simple `gem install` you can add a library to your app. There has been an explosion of JavaScript package managers lately. Each one adds the basic ability to gather all of your libraries and application code, resolve the dependencies, and concatenate them into a single application file. They can be grouped into three basic categories:
<!-- more start -->
@erithmetic
erithmetic / gist:3890293
Created October 15, 2012 00:37
Tequila
agave matured 8 years, shipped in hand-blown bottles from the volcanic hills of Jalisco
Blanco
slight vegetals, toasty, cherry
tripled distilled
Reposado
slight caramel smell, tart cherry, vanilla/toasty, slightest peach
aged 11 months in french oak barrels
@erithmetic
erithmetic / rspec.watchr
Created October 14, 2012 23:51
Rspec watchr
# Run me with:
# $ watchr rspec.watchr
# --------------------------------------------------
# Rules
# --------------------------------------------------
watch( '^spec/.*_spec\.rb' ) { |m| rspec m[0] }
watch( '^lib/(.*)\.rb' ) { |m| rspec "spec/#{m[1]}_spec.rb" }
watch( '^spec/spec_helper\.rb' ) { rspec specs }
@erithmetic
erithmetic / gist:2898066
Created June 8, 2012 20:52
RSpec before() filtered by tag
RSpec.configure do |c|
c.filter_run_excluding :database => true
c.include Rack::Test::Methods, :integration => true
c.before(:each, :database => true) do
setup_database
end
end
@erithmetic
erithmetic / browser.js
Created March 26, 2012 15:51
Testling issues
var test = require('testling'),
CM1 = require('./lib/cm1');
test('CM1.impacts', function(t) {
t.plan(3);
CM1.impacts('flight', {
origin_airport: 'IAD',
destination_airport: 'PDX',
airline: 'United',
# mygem/lib/test_support/cucumber/sniff_activity.rb
module Sniff
module Activity
def do_it
run.some_code.that_fails
end
end
end
Started
E
Finished in 1.012821 seconds.
1) Error:
test_0001_underscored_version_of_your_it_statement(CamelizedDescription):
MockExpectationError: expected create, {:retval=>nil, :args=>["foo", "bar", {}]}
test/my_test.rb:25:in `block (2 levels) in <main>'
1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
@erithmetic
erithmetic / git-amend
Created October 26, 2011 19:29
git amend
#!/bin/bash
if [ "$1" == "" ]
then
msg=`git log -n 1 --format=oneline | sed 's/^[0-9a-f]*[ ]//'`
else
msg="$1"
fi
git commit -m "$msg" --amend
info: here is my response
info: {"timeframe":"2011-01-01/2012-01-01","emission":867.7579402033563, ... }
info: undefined