Skip to content

Instantly share code, notes, and snippets.

Jacob Swanner jswanner

Block or report user

Report or block jswanner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View add_categories.rb
class AddCategories < ActiveRecord::Migration
def self.up
add_column :tasks, :category, :string
end
def self.down
remove_column :tasks, :category
end
end
View gist:166870
# 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 = Patron::Session.new
COUCH.timeout = 120
View gist:368831
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
View rails_bash_shortcuts
function sc {
if [ -e script/rails ]; then
rails console $@
else
script/console --debugger $@
fi
}
function ss {
if [ -e script/rails ]; then
rails server $@
@jswanner
jswanner / gist:969351
Created May 12, 2011 — forked from Gregg/gist:968534
Code School Screencasting Framework
View gist:969351

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.
View posts_controller.rb
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'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.
@jswanner
jswanner / gist:1073762
Created Jul 9, 2011
Add before_filter to pages controller from refinery engine
View gist:1073762
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
end
@jswanner
jswanner / after_use_192-patched.sh
Created Aug 2, 2011
How to patch ruby for GC tuning and faster requiring
View after_use_192-patched.sh
case "$rvm_ruby_string" in
*ruby-1.9.2*-patched)
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=1000000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000
export RUBY_FREE_MIN=$RUBY_HEAP_FREE_MIN
;;
*)
@jswanner
jswanner / .gitignore.diff
Created Oct 7, 2011
Differences between Rails 3.1.0.beta1 & Rails 3.1.1 generated apps
View .gitignore.diff
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 @@
+.sass-cache/
@jswanner
jswanner / Gemfile.diff
Created Oct 7, 2011
Differences between Rails 3.1.0.rc1 & Rails 3.1.1 generated apps
View Gemfile.diff
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'
You can’t perform that action at this time.