This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# by bryan helmkamp with slight modification by chris wanstrath | |
# from http://www.brynary.com/2008/8/3/our-git-deployment-workflow | |
module GitCommands | |
extend self | |
def diff_staging | |
`git fetch` | |
puts `git diff origin/production origin/staging` | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
project_name = ARGV[0] | |
lib = project_name + "/lib" | |
test = project_name + "/test" | |
rakefile = project_name + '/rakefile.rb' | |
all_tests = test + "/all_tests.rb" | |
main = project_name + "/lib/" + project_name + ".rb" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
car_model_data = {"Acura"=>["MDX","RDX","RL","TL","TSX","Other","CL","Integra","Legend","NSX","RSX","SLX","Vigor"],"Aston Martin"=>["DB9","DBS","Vantage","Other","DB7","Vanquish"],"Audi"=>["A3","A4","A5","A6","A8","Q5","Q7","R8","RS4","RS6","S4","S5","S6","S8","TT","Other","90","100","Allroad","Cabriolet"],"Bentley"=>["Arnage","Azure","Brooklands","Continental Flying Spur","Continental GT","Turbo R","Other"],"BMW"=>["1-Series","3-Series","5-Series","6-Series","7-Series","M3","M5","M6","X3","X5","X6","Z4","Other","2002","8-Series","M Roadster & Coupe","Z3","Z8"],"Buick"=>["Enclave","Lacrosse","Lucerne","Regal","Other","Century","Electra","Grand National","LeSabre","Park Avenue","Rainier","Reatta","Rendezvous","Riviera","Roadmaster","Skylark"],"Bugatti"=>["Veyron","Other"],"Cadillac"=>["CTS","DTS","Escalade","SRX","STS","XLR","Other","Allante","Catera","DeVille","Eldorado","Fleetwood","Seville"],"Chevrolet"=>["Avalanche","Aveo","Camaro","Cobalt","Colorado","Corvette","Equinox","Express","HHR","Impala","Malibu", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws/s3' | |
set :s3_key, "<PUT YOUR KEY HERE>" | |
set :s3_secret, "< PUT YOUR KEY HERE >" | |
set :s3_buckets, { | |
"production" => "<PUT YOUR BUCKET NAME HERE>", | |
"development" => "<PUT YOUR BUCKET NAME HERE>" | |
} | |
set :s3_ignore, ["vendor","backups","coverage"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/php | |
<? | |
function __autoload($className) | |
{ | |
$className = str_replace('_','/', $className); | |
$sFileName = '../vendor/php-ews/' . $className . '.php'; | |
if (file_exists($sFileName) && !class_exists($className)) | |
{ | |
require_once $sFileName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: redis-server | |
# Required-Start: $syslog | |
# Required-Stop: $syslog | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: redis-server - Persistent key-value db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/devise.rb | |
Devise.setup do |config| | |
# ... normal setup options | |
Warden::Manager.before_failure do |env,opts| | |
request = Rack::Request.new(env) | |
request.session[:return_to] = request.env['REQUEST_METHOD']=="GET" ? request.env['action_dispatch.request.path_parameters'] : request.env['HTTP_REFERER'] | |
request.session[:return_params] = request.env['action_dispatch.request.request_parameters'] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book < ActiveRecord::Base | |
scope :category, lambda {|cat| where(:category_id => cat) } | |
scope :author, lambda {|auth| where(:authori_id => auth) } | |
# example of a method to build chainable scope | |
# based on the query parameters | |
def self.query params={} | |
scoped = limit(25) | |
scoped = scoped.category( params[:category_id] ) if params[:category_id].present? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cart | |
has_many :cart_items | |
def add_item item_id, quantity = 1 | |
cart_item = cart_items.find_by_item_id(item_id) || cart_items.create :item_id => item_id | |
cart_item.update_attributes :quantity => cart_item.quantity + quantity | |
end | |
end | |
class CartItem |
OlderNewer