Skip to content

Instantly share code, notes, and snippets.

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
set (:stages) { Dir.glob(File.join(File.dirname(__FILE__), "deploy", "*.rb")).map {|s| File.basename(s, ".rb") }.select {|s| not s =~ /sample/} }
# 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'
#content
.row
.third
.third
.third.last
.row
.half
.half.last
.row
.fourth
@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]
@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
# 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
# Our own variable where we deploy this app to
deploy_to = "/srv/example.com"
current_path = "#{deploy_to}/current"
shared_path = "#{deploy_to}/shared"
shared_bundler_gems_path = "#{shared_path}/bundler_gems"
# See http://unicorn.bogomips.org/Sandbox.html
# Helps ensure the correct unicorn_rails is used when upgrading with USR2
Unicorn::HttpServer::START_CTX[0] = "#{shared_bundler_gems_path}/bin/unicorn_rails"
<fieldset>
<legend>Add your images here!!</legend>
<ol>
<li>
<label for="foo">FOO</label>
<input name="foo" />
</li>
</ol>
</fieldset>
class ViewObject
include Enumerable
extend Forwardable
def_delegators :@views, :<<, :[], :[]=, :last, :first, :push
def initialize controller
@controller = controller
@views = []
end