Skip to content

Instantly share code, notes, and snippets.

View codeprimate's full-sized avatar

Patrick Morgan codeprimate

  • Bellingham, WA
  • 17:32 (UTC -07:00)
View GitHub Profile
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@codeprimate
codeprimate / how_to_install_qcachegrind_on_osx.txt
Created January 23, 2012 22:59 — forked from justfalter/how_to_install_qcachegrind_on_osx.txt
How to install qcachegrind (kcachegrind) on OSX Snow Leopard
SUMMARY
I like to use kcachegrind for doing profiling on my ruby code. Most of my development
is done on OSX, and while you can install kcachegrind via macports, it takes forever
because it has to build KDE, as well. Much to my surprise, the fine folks who
wrote kcachegrind also made a QT version, qcachegrind. I was able to build this on
OSX without too much effort, only having to install QT and GraphViz. Yippie!
I'm running OSX 10.6.7, with Xcode 4. My default gcc/g++ version is 4.2. I'm sure
it will build just fine on earlier versions of Xcode, but I haven't tested it.
@codeprimate
codeprimate / gist:2258839
Created March 31, 2012 02:51 — forked from jrochkind/gist:2161449
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@codeprimate
codeprimate / gist:2340890
Created April 9, 2012 02:24 — forked from german/gist:1237902
god config for delayed_job
# run with: god -c /path/to/config.god [add -D if you want to not-deamonize god]
# This is the actual config file used to keep the delayed_job running
APPLICATION_ROOT = "/var/www/application"
RAILS_ENV = "production"
God.watch do |w|
w.name = "delayed_job_production"
w.interval = 15.seconds
w.start = "/bin/bash -c 'cd #{APPLICATION_ROOT}/current; /usr/bin/env RAILS_ENV=#{RAILS_ENV} #{APPLICATION_ROOT}/current/script/delayed_job start > /tmp/delay_job.out'"
@codeprimate
codeprimate / deploy.rb
Created May 10, 2012 22:21 — forked from bkutil/deploy.rb
Start and Stop tasks for resque workers and resque scheduler with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
after "deploy:restart_workers", "deploy:restart_scheduler"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
@codeprimate
codeprimate / resque_workers.rake
Created May 10, 2012 22:22 — forked from karmi/resque_workers.rake
Our Rake task for running multiple Resque workers in production
namespace :queues do
desc "Run Resque workers with options and job classes loaded"
# Run with & appended to daemonize
task :workers => :environment do
def pid_directory
Rails.root.join('tmp', 'pids')
end
@codeprimate
codeprimate / cooks.rb
Created August 7, 2012 07:03 — forked from shime/cooks.rb
overriding instance method with module, ultimate solution
module Prepending
def append_features(base)
prepend = self
base.extend Module.new { define_method(:new) { |*args,&block| super(*args,&block).extend(prepend) }}
end
end
module CanCook
extend Prepending
git diff $1 | grep "^\+[^+]\{3\}" | grep -v "^\+[\t ]*$" | wc -l
# Forked to get it working with Rails 3 and RSpec 2
#
# From http://github.com/jaymcgavren
#
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
#
# Use rcov:rspec or rcov:cucumber
# to get non-aggregated coverage reports for rspec or cucumber separately

Ruby, RVM and Mountain Lion

Key problems

Mountain Lion (10.8) has three main difference compared to Lion (10.7):

  • XCode 4.4 does not install Command Line Tools by default
  • X11 isn't available anymore
  • The installed version of OpenSSL has some bugs

How to work around