Skip to content

Instantly share code, notes, and snippets.

View jacobat's full-sized avatar

Jacob Atzen jacobat

  • Copenhagen, Denmark
View GitHub Profile
group :development do
platforms :ruby do
gem 'rb-fsevent', :require => nil
gem 'growl', :require => nil
gem 'libnotify', :require => nil
gem 'rb-inotify', :require => nil
end
platforms :mswin do
gem 'rb-fchange', :require => nil
Parameters: {... "role_ids"=>[""]} ...}
@jacobat
jacobat / application_controller.rb
Created December 8, 2011 12:09
Swapping database on running instance
class ApplicationController < ActionController::Base
before_filter :swap_db
def swap_db
if(params[:swap_db])
ActiveRecord::Base.class_eval('establish_connection YAML.load_file("#{Rails.root}/config/database.yml")["' + params[:swap_db] + '"].symbolize_keys')
end
end
end
@jacobat
jacobat / gist:1240695
Created September 25, 2011 15:06
Comments for Cory Haines fast tests talk

Introduction

Corey Haines gave his Fast Tests talk at the Golden Gate Ruby Conference 2011 (http://confreaks.net/videos/641-gogaruco2011-fast-rails-tests), here's my feedback on it.

So first up, I think it's very interesting to see another take on how to speed up Rails testing. There's been a focus on it for a couple of years now with various solutions coming for it. From running tests in parallel, to tweaking the filesystem for faster access. Corey Haines take on it is that we should isolate ourselves from the framework that Rails provides and do as much as possible in plain Ruby objects and modules. In his talk he shows how he has been able to massively improve the runtime of his tests by implementing this.

I think it is a logical next step to the current that has been in the community for a while where we have been debating how to improve the design of Rails applications.

Objections

[cijoe]
runner = sh `pwd`/../joes/project.joe
source 'http://rubygems.org'
gem 'rake', '~> 0.8.7'
gem 'rails', '3.0.6'
group :development do
gem "awesome_gem"
end
group :test_gem do
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
unbind %
unbind '"'
bind | split-window -h
bind - split-window -v
describe 'Location', ->
it 'should create a location', ->
new Location()
[1,2,3,5,7,8].inject([]) { |array_of_arrays, number|
if array_of_arrays.empty? || array_of_arrays.last.last != number - 1
array_of_arrays << [number]
else
array_of_arrays.last << number
end
array_of_arrays
}.map{ |array|
(array.count == 1 ? array.to_s : "#{array.first}-#{array.last}")
}.join(',')
[alias]
ci = commit -v
st = status -sb
br = branch
co = checkout
ru = remote update
dif = diff
ap = add -p
la = log --pretty=\"%C(yellow)%ad %Cred%h%Cblue (%an)%Cgreen%d%Creset %s\" --date=short
lg = log --pretty=\"* %Cred%h %C(blue)(%an)%Cgreen%d%Creset %s %C(magenta)(%cr)\"