Skip to content

Instantly share code, notes, and snippets.

View codeprimate's full-sized avatar

Patrick Morgan codeprimate

  • Bellingham, WA
  • 08:15 (UTC -07:00)
View GitHub Profile
@codeprimate
codeprimate / _readme.md
Last active August 29, 2015 14:06 — forked from shime/_readme.md

Having trouble installing the latest stable version of tmux?

Save yourself some time and run this little fellow!

Prerequisities

  • gcc
  • wget
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#

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

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

# 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
git diff $1 | grep "^\+[^+]\{3\}" | grep -v "^\+[\t ]*$" | wc -l
@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
@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 / 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 / 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'"