Skip to content

Instantly share code, notes, and snippets.

View imajes's full-sized avatar

James Cox imajes

View GitHub Profile
@imajes
imajes / gist:977587
Created May 17, 2011 22:43
RS deploy error
~/dev/redstamp/redstamp.com-app[master]$ cap production deploy
<snip>
triggering start callbacks for `production'
* executing `require_recipes'
triggering before callbacks for `require_recipes'
* executing `validate_required_variables'
* executing `production'
triggering start callbacks for `deploy'
* executing `multistage:ensure'
* executing `require_recipes'
@imajes
imajes / workers.rake
Created May 3, 2011 20:00 — forked from karmi/workers.rake
Rake taks to launch multiple Resque workers in development/production with simple management included
# Rake task to launch multiple Resque workers in development/production with simple management included
require 'resque/tasks' # Require Resque tasks
namespace :workers do
# = $ rake workers:start
#
# Launch multiple Resque workers with the Rails environment loaded,
# so they have access to your models, etc.
require "stateful"
class Folder < ActiveRecord::Base
include Stateful
# ...
stateful do
state :active
state :inactive
class User
include Mongoid::Document
references_one :best_friend, :class_name => "Person"
references_one :worst_enemy, :class_name => "Person"
end
file = ARGV.shift || "~/Music/iTunes/iTunes Music Library.xml"
albums = []
d = {}
IO.foreach(File.expand_path(file)) do |line|
if line =~ /<dict/
d.clear
elsif line =~ /<key>(Artist|Album)<\/key><.*?>(.*)<\/.*?>/
key = $1.downcase.first.intern
d[key] = $2
@imajes
imajes / url_dsl.rb
Created December 14, 2009 19:21 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
#These all pass the specs in post_create_with_stubble_spec.rb, but not necessarily the other ones
def create
@registration = Registration.new(params[:registration])
if @registration.save
redirect_to registrations_path
else
render :action => 'new'
end
end
@imajes
imajes / gist:49764
Created January 21, 2009 00:13 — forked from peterc/gist:33337
see http://github.com/imajes/rails-template/tree/master