Skip to content

Instantly share code, notes, and snippets.

View semipermeable's full-sized avatar

Jay Moorthi semipermeable

View GitHub Profile
@semipermeable
semipermeable / delayed_job
Created August 1, 2011 04:14
Sys-V init script for delayed job that plays well with capistrano and rvm
#! /bin/sh
### BEGIN INIT INFO
# Provides: delayed_job
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
### END INIT INFO
@semipermeable
semipermeable / pre-commit
Created July 18, 2011 02:14
tddium schema capture and load example
#!/bin/sh
set -e
bundle exec rake tddium:db:capture
@semipermeable
semipermeable / data_migration_and_test.rb
Created July 14, 2011 19:18
Rails3 Data Migration and RSpec Test
# db/migrate/20110714024435_split_author.rb
class SplitAuthor < ActiveRecord::Migration
def self.up
Post.where(:author=>nil).each do |p|
author = Author.create!(:name => p.author_name,
:account_id => p.account_id)
p.author = author
p.save!
end
end
@semipermeable
semipermeable / tddium.rake
Created June 23, 2011 06:17
tddium:db_hook example
# lib/tasks/tddium.rake
namespace :tddium do
desc "tddium environment db setup task"
task :db_hook do
ENV['RAILS_ENV'] = 'test'
Rake::Task["db:create"].invoke
if File.exists?(File.join(Rails.root, "db", "schema.rb"))
Rake::Task['db:schema:load'].invoke
else
Rake::Task['db:migrate'].invoke