Skip to content

Instantly share code, notes, and snippets.

View donnoman's full-sized avatar

Donovan Bray donnoman

View GitHub Profile
#!/bin/bash
# How to exit if any command in a bash subshell fails with piping all output
set -o pipefail
(
set -o errexit;
echo -n "T";
# false;
echo -n "e";
# false;
echo -n "s";
# Helper to execute blocks of shell commands via capistrano run
def run_chunk(cmd,options={})
run cmd.split("\n").map {|l| l.strip }.join(" "), options
end
# Example
task :revision, :roles => [:app] do
run_chunk %Q{
cd #{current_release};
cp REVISION public/REVISION;
#migration to allow nulls for Authlogic Account Activation Tutorial
#http://www.claytonlz.com/index.php/2009/07/authlogic-account-activation-tutorial/
class AllowNullCryptedPassword < ActiveRecord::Migration
def self.up
change_column :users, :crypted_password, :string, :null => true
change_column :users, :password_salt, :string, :null => true
end
def self.down
#!/usr/bin/env ruby
# based on http://gist.github.com/29838
# logging to syslog added
# added killing orphaned procs
# added culling applications to maintain some per application limits
# Find bloating passengers and kill them gracefully. Run from cron every so often.
#
require "rubygems"
require "logging"
namespace :bundler do
task :install do
run("#{sudo} gem install bundler --source=http://gemcutter.org")
end
task :symlink_vendor do
shared_gems = File.join(shared_path, 'vendor/gems')
release_gems = "#{release_path}/vendor/gems/"
%w(cache gems specifications).each do |sub_dir|
shared_sub_dir = File.join(shared_gems, sub_dir)
@donnoman
donnoman / capistrano-filter.rb
Created December 7, 2009 20:29
capistrano skip NoMatchingServers
# Allows Tasks that have no servers to be skipped instead of raising a NoMatchingServersError
module Capistrano
class Configuration
module Connections
def execute_on_servers(options={})
raise ArgumentError, "expected a block" unless block_given?
if task = current_task
servers = find_servers_for_task(task, options)
@donnoman
donnoman / Gemfile
Created July 24, 2010 00:50
causing script/server and rake db:migrate to hang with bundler 0.9.24, 1.0.0.beta.9, and 1.0.0.rc.1
# bundle update vendor/bundler_gems
# Sources
source "http://gemcutter.org"
source "http://gems.github.com"
# Stack
gem "rails", "2.3.4"
gem "rack", "1.0.1"
gem 'mysql', "2.7"
@donnoman
donnoman / api_controller_spec.rb
Created July 29, 2010 22:43
post bundler upgrade with 1.0.0.rc.1 getting seemingly random segfaults, see http://gist.github.com/488261 for config
describe Api::ApiController, "base controller" do
integrate_views
before(:all) do
$api_token = User.first.single_access_token
end
after(:all) do
ApplicationGlobals.subscriber = subscriber = Subscriber.find(0)
subscriber.create_default_preferences! unless subscriber.preferences_set?
@donnoman
donnoman / explanation issue with logging 1.2.2
Created July 30, 2010 21:23
Discovered Issue with Bundler with Logging 1.2.2
boot.rb patches the initialzer to memoize the Bundler.require
the preinitializer runs
The environment.rb is loaded
logging is required before the Rails::Initializer.run
group :development, :test do
gem 'ruby-debug'
gem "rspec-rails", ">= 2.0.0.beta.17"
end