Skip to content

Instantly share code, notes, and snippets.

View codeprimate's full-sized avatar

Patrick Morgan codeprimate

  • Bellingham, WA
  • 19:41 (UTC -07:00)
View GitHub Profile
@codeprimate
codeprimate / .gitignore
Created October 9, 2010 20:13
.gitignore for Visual Studio projects
# .gitignore for Visual Studio projects
#ignore outputs of project
build*/
src/SharpArch/CommonAssemblyInfo.cs
#ignore thumbnails created by windows
Thumbs.db
#Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
" ~/.vimrc
set autoindent
set bs=2
set cindent
set cursorline
set expandtab
set ignorecase
set laststatus=2
set mat=5
set nocompatible
@codeprimate
codeprimate / .vimrc
Created June 29, 2011 17:50
My VIM configuration
set nocompatible
set laststatus=2
set bs=2
set cursorline
set ignorecase
set showmatch
set mat=5
set nu
set ruler
set autoindent
@codeprimate
codeprimate / ctags.rake
Created October 22, 2011 16:29
Rake task to create ctags for a Rails application
# ctags.rake - Rake task to create ctags for a Rails application
# and also including Ruby and Gem signatures
#
# Requires exuberant-ctags to be in $PATH
desc "Regenerate tags (CTAGS)"
task :ctags do
puts " * Regenerating Tags"
excludes = %w{
.git
@codeprimate
codeprimate / index.rake
Created October 25, 2011 19:36
Rails Rake task to add indexes on columns that are foreign keys
# Rails Rake task to search all database tables and add indexes on columns that are foreign keys, or match the "indexed_columns" variable
desc 'Add missing indexes'
task :index_tables => :environment do
indexed_columns = ['code', 'name', 'updated_at', 'created_at']
tables = ActiveRecord::Base.connection.select_values('show tables')
tables.each do |t|
columns = ActiveRecord::Base.connection.select_values("describe #{t}")
keys = columns.select{|k| k.match(/_id$/) || indexed_columns.include?(k)}
indexes = []
# 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 / rvm_passenger_path_fix.rb
Created January 20, 2012 18:49
Passenger Standalone running on RVM Ruby
# config/initializers/rvm_passenger_path_fix.rb
#
# This configuration is necessary for Passenger Standalone and RVM running under the development environment
#
if ENV['RAILS_ENV'] == 'development' && ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
@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'"