Skip to content

Instantly share code, notes, and snippets.

class AddCategories < ActiveRecord::Migration
def self.up
add_column :tasks, :category, :string
def self.down
remove_column :tasks, :category
# last version had a bug:
# instead of inserting 1 million docs,
# it inserted 8000 docs then updated them 125 times
require 'rubygems'
require 'patron'
require 'json'
COUCH.timeout = 120
This example shows how to setup an environment running Rails 3 beta under 1.9.2-head with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.2-head
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.2-head@rails3
function sc {
if [ -e script/rails ]; then
rails console $@
script/console --debugger $@
function ss {
if [ -e script/rails ]; then
rails server $@
jswanner / gist:969351
Created May 12, 2011 20:18 — forked from Gregg/gist:968534
Code School Screencasting Framework

Screencasting Framework

The following document is a written account of the Code School screencasting framework. It should be used as a refernce of the accompanying screencast on the topic.

Why you should care about screencasting?

You're probably aren't going to take the time to read this document if you're not interested, but there are a lot of nice side effects caused by learning how to create quality screencasts.

  1. Communicating more effectively - At Envy Labs we produce screencasts for our clients all the time. Whether it's demoing a new feature or for a presentation for an invester, they're often much more effective and pleasent than a phone call or screen sharing.
1) Error:
test: Blog::PostsController should get the blog index. (Blog::PostsControllerTest):
ActionController::RoutingError: No route matches {:controller=>"blog/posts"}
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:424:in `raise_routing_error'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:406:in `rescue in generate'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:395:in `generate'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:453:in `generate'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:449:in `generate_extras'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:445:in `extra_keys'
jswanner / gist:1073762
Created July 9, 2011 17:16
Add before_filter to pages controller from refinery engine
require 'refinerycms'
module Refinery
module MyEngine
class Engine < Rails::Engine
refinery.after_inclusion do
::PagesController.class_eval do
before_filter :check_some_stuff, :only => :show
def check_some_stuff
jswanner /
Created August 2, 2011 17:46
How to patch ruby for GC tuning and faster requiring
case "$rvm_ruby_string" in
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000
jswanner / .gitignore.diff
Created October 7, 2011 17:50
Differences between Rails 3.1.0.beta1 & Rails 3.1.1 generated apps
diff -U 0 -r rails-3.1.0.beta1/.gitignore rails-3.1.1/.gitignore
--- rails-3.1.0.beta1/.gitignore 2011-10-07 11:56:15.000000000 -0400
+++ rails-3.1.1/.gitignore 2011-10-07 12:59:12.000000000 -0400
@@ -4,0 +5 @@
jswanner / Gemfile.diff
Created October 7, 2011 19:17
Differences between Rails 3.1.0.rc1 & Rails 3.1.1 generated apps
diff -U 0 -r rails-3.1.0.rc1/Gemfile rails-3.1.1/Gemfile
--- rails-3.1.0.rc1/Gemfile 2011-10-07 11:57:59.000000000 -0400
+++ rails-3.1.1/Gemfile 2011-10-07 12:59:13.000000000 -0400
@@ -3 +3 @@
-gem 'rails', '3.1.0.rc1'
+gem 'rails', '3.1.1'
@@ -10,4 +10,8 @@
-# Asset template engines
-gem 'sass'
-gem 'coffee-script'