Skip to content

Instantly share code, notes, and snippets.

View nickhammond's full-sized avatar

Nick Hammond nickhammond

View GitHub Profile
# This works with steak 0.3.x and rspec 1.x
# For steak --pre and rspec 2 see this fork: http://gist.github.com/448487
# Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb
Spec::Runner.configure do |config|
config.before(:each) do
Capybara.current_driver = :selenium if options[:js]
end
@dgalarza
dgalarza / session_store_middleware.rb
Created August 23, 2010 22:04
Add the following to config/initializers/session_store.rb to call our FlashSessionCookieMiddleware
Rails.application.config.middleware.insert_before(
ActionDispatch::Session::CookieStore,
FlashSessionCookieMiddleware,
Rails.application.config.session_options[:key]
)
@moklett
moklett / chargify_api_steps.rb
Created September 9, 2010 20:13
A sample of the step definitions used in the Chargify API documentation (i.e. http://docs.chargify.com/api-subscriptions)
Given /^I (?:send and )?accept (.*?)(?: responses)?$/ do |format|
@format = format.downcase.to_sym
header('Content-Type', content_type_for(@format))
http_accept(@format)
end
Given /^the requester accepts (.*) responses$/ do |format|
Given "I accept #{format} responses"
end
@jschoolcraft
jschoolcraft / delayed_job.bluepill
Created April 7, 2011 16:38 — forked from vertis/delayed_job.bluepill
bluepill monitoring multiple delayed_job workers
app_home = "/home/mi/production"
workers = 5
Bluepill.application("mi_delayed_job", :log_file => "#{app_home}/shared/log/bluepill.log") do |app|
(0...workers).each do |i|
app.process("delayed_job.#{i}") do |process|
process.working_dir = "#{app_home}/current"
process.start_grace_time = 10.seconds
process.stop_grace_time = 10.seconds
process.restart_grace_time = 10.seconds
@archan937
archan937 / rvm_git_prompt.sh
Created May 15, 2011 10:02
Current RVM Ruby & Gemset and Git branch in your Bash prompt
function current_rvm_ruby {
color=$(tput setaf 3)
default=$(tput sgr0)
version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
full=${color}${version}${gemset}${default}
[ "$full" != "" ] && echo "$full "
}
@schleg
schleg / 01. Gemfile
Created May 26, 2011 17:26
Setup for Devise + Omniauth
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
@bmarini
bmarini / default.vcl.pl
Created June 30, 2011 18:01
A good varnish config for a Rails app
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
# from the cache for up to 1 hour.
# 2. Varnish will pass X-Forwarded-For headers through to the backend
# 3. Varnish will remove cookies from urls that match static content file
# extensions (jpg, gif, ...)
# config.ru for Pow + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson (patrick@trinity-ai.com)
# added rubygems, replaced script_path with script from path_parts, added to_return to fix return error - Paul Cook
# clearly this could be cleaner, but it does work
require 'rubygems'
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/