- Smarter completion:
- cd tab completion -- directories only
- bash can do this, but needs the bash-completion package, usually comes separately
- zsh always comes with completions, why doesn't bash?
- Filename correction during completion
- if dir1/x exists and dir2 exists, then "dir/x<TAB>" completes to dir1/x
- if name1 is a file and name2 is a directory with files in it, "name/<TAB>" completes to "name2/"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Users::OauthCallbacksController, "handle facebook authentication callback" do | |
describe "#annonymous user" do | |
context "when facebook email doesn't exist in the system" do | |
before(:each) do | |
stub_env_for_omniauth | |
get :facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin` | |
# Be sure to have rails and thin installed. | |
require "rubygems" | |
# We are not loading Active Record, nor the Assets Pipeline, etc. | |
# This could also be in your Gemfile. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
require "rails" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version | |
# see https://github.com/defunkt/resque/issues/49 | |
# see http://redis.io/commands - new commands | |
namespace :resque do | |
desc "Clear pending tasks" | |
task :clear => :environment do | |
queues = Resque.queues | |
queues.each do |queue_name| | |
puts "Clearing #{queue_name}..." |
by Jonathan Rochkind, http://bibwild.wordpress.com
Capistrano automates pushing out a new version of your application to a deployment location.
I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".
These commands are good as of 2010-11-18.
Homebrew http://mxcl.github.com/homebrew/
ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"
http://developer.apple.com/technology/xcode.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class S;def initialize *w;@s=w;end;def method_missing *w;@s<<w;self ########### | |
end;def to_ary;[@s.map{|e|e=~/[\,\.\:\-\(\)\/\'\"]/?[e]:[" ",e]}.join.strip] ## | |
end;end;def Object.const_missing(c);S.new c;end ####### gist.github.com/2354740 | |
puts This.is.a.sentence.represented.by.a.Ruby.expression(".") ################# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionDispatch::Routing::Mapper | |
def draw(routes_name) | |
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
end | |
end | |
BCX::Application.routes.draw do | |
draw :api | |
draw :account | |
draw :session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This way we re-query the app itself in order to avoid sequential execution for CPU-intensive tasks | |
# that can (and should) be executed in parallel. | |
# | |
# Pros: decent scalability can be achieved by assigning path=some.load.balancer.com (i.e. Amazon ELB) | |
# and putting a bunch of multicore machines behind it. | |
# | |
# Cons: we lose some fraction of time on JSON encoding/decoding and HTTP traffic. | |
# Load-balanced fault-tolerant DRb could be a better choice, but would require more work and provide only | |
# minor performance improvement in situation where JSON/HTTP aren't the main CPU consumers. |
- Jim Weirich: The Building Blocks of Modularity – http://goo.gl/g4Nk
- Jim Weirich: SOLID Ruby – http://goo.gl/z3jd
- Sandi Metz: SOLID Object-Oriented Design – http://goo.gl/PDn6T
- Sandi Metz: Less – The Path to Better Design – http://goo.gl/VuTl4
- Demeter is for Encapsulation – http://is.gd/eeyLx
- Opinionated Modular Code – http://is.gd/eeyXm
- Scaling to Hundreds of Millions of Requests – http://vimeo.com/12814529
- Confident Code – http://goo.gl/VFLX
- Destroy All Software Screencasts – https://www.destroyallsoftware.com/screencasts
- Corey Haines: Fast Rails Tests – http://goo.gl/Va2gb