Skip to content

Instantly share code, notes, and snippets.

# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.
@mislav
mislav / .rspactor
Created March 17, 2009 13:12
RSpec colorized unicode output with Rspactor integration
# this goes in the $HOME dir
# needs mislav-rspactor v0.3.2 and RSpec 1.2
RSpactor::Runner.class_eval do
alias old_formatter_opts formatter_opts
def formatter_opts
# update this path to where you saved unicode_formatter.rb
old_formatter_opts + " -r /Users/mislav/Projects/unicode_formatter -f UnicodeFormatter"
end
end
class BlackHoleStore
def logger
Rails.logger
end
def fetch( *args )
yield
end
def read( *args )
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
# Hi! I'am rack middleware!
# I was born for return to you valid js on json i18n objects
# My author's name was Aleksandr Koss. Mail him at kossnocorp@gmail.com
# Nice to MIT you!
class I18nJs
def initialize app, options = {}
@app = app
@options = options
@lancejpollard
lancejpollard / Rails Nested Forms with belongs_to
Created January 13, 2010 23:09
Rails Nested Forms with belongs_to, doesn't work by default
# user.rb
class User < ActiveRecord::Base
belongs_to :address
accepts_nested_attributes_for :address # can't have allow_destroy
end
# users_controller.rb
class UsersController < ApplicationController
~$ ARCHFLAGS='-arch i386 -arch x86_64'
~$ rvm install 1.8.7 --debug --reconfigure -C --enable-shared=yes
~$ wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.0/RubyCocoa-1.0.0.tar.gz/download
~$ tar xzf RubyCocoa-1.0.0.tar.gz && rm RubyCocoa-1.0.0.tar.gz && cd RubyCocoa-1.0.0
~/RubyCocoa-1.0.0$ ruby install.rb config --build-universal=yes
~/RubyCocoa-1.0.0$ ruby install.rb setup
~/RubyCocoa-1.0.0$ sudo ruby install.rb install
gemcutter => redis downloads spec
=================================
keys
----
downloads => global counter for all gem downloads
downloads:today => sorted set for downloads from today
downloads:rubygem:rails => counter for all rails downloads
downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads
@mislav
mislav / Gemfile.rb
Created February 22, 2010 20:54
Bundler setup for Rails 2.3.x apps
## example Gemfile
source :rubygems
group :rails do
gem 'rake', '< 0.9', :require => nil
gem 'rails', '~> 2.3.5', :require => nil
gem 'builder', '~> 2.1.2'
gem 'memcache-client', '>= 1.7.4', :require => nil
gem 'tzinfo', '~> 0.3.12'
gem 'i18n', '>= 0.1.3'
@vvalgis
vvalgis / Capistrano tasks for starting unicorn.rb
Created May 7, 2010 08:13
Capistrano tasks for starting unicorn
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do