Skip to content

Instantly share code, notes, and snippets.

# Everything you need to do to get started with Rails 2.3.8
#
# As of June 14th, 2010 @ 2:30 p.m. MST
#
# This gist now features instructions to get Rails 3 up and running with:
# - Ruby 1.8.7-p174
# - Bundler 0.9.26
# - Cucumber 0.8.0
# - Rspec 1.3.0 + Rspec-Rails 1.3.2
# - RVM
@chewbranca
chewbranca / mvfuckit.rb
Created December 15, 2010 02:06
For the times when Rails MVC doesn't cut it... MVFuckit!
module MVFuckit
def cmeth *args
@util_controller ||= ApplicationController.new
@util_controller.send(*args)
end
def hmeth *args
@util_helper ||= MVFuckit::Help.new
@util_helper.send(*args)
end
@chewbranca
chewbranca / trie.rb
Created November 16, 2010 21:28
Find string permutations using a Trie
class Trie
attr_accessor :value, :children
def initialize value = ''
@value = value
@children = {}
end
def [] val
@children[val]
#content
.row
.third
.third
.third.last
.row
.half
.half.last
.row
.fourth
# require 'resque/tasks'
# will give you the resque tasks
namespace :resque do
task :setup
desc "Start Resque Scheduler"
task :scheduler => :scheduler_setup do |t,args|
require 'resque'
require 'resque_scheduler'
set (:stages) { Dir.glob(File.join(File.dirname(__FILE__), "deploy", "*.rb")).map {|s| File.basename(s, ".rb") }.select {|s| not s =~ /sample/} }
namespace :db do
desc "abort rake if using bad memory techniques"
task :safety_migrate => :environment do
path = "#{RAILS_ROOT}/db/migrate/"
migration_directory = Dir.new(path)
proceed = true
migration_directory.each do |file|
if file != "." and file != ".."
migration = File.open("#{path}#{file}")
text = migration.read