cmd + 0 in mac :)
If you click the tool icon on the right of the address bar, you can also check the current zoom rate.

cmd + 0 in mac :)
If you click the tool icon on the right of the address bar, you can also check the current zoom rate.

oh-my-zsh is very handy and I’ve been using it for almost a year.
But I found the auto correct is kind of annoying and barely helped me. So I decided to turn if off!
Add this unsetopt to your ~/.zshrc
source $ZSH/oh-my-zsh.sh
unsetopt correct_all
Say if you just want to disable it for git command, you can setup an alias.
alias git=’nocorrect heroku’
I didn’t test out this one :)
CAUTION It’s specific machinist 1.0-maintenance.
Machinist is an alternative for Fixtures or FactoryGirl.
If you want to generate an object without saving it to the database, replace
makewithmake_unsaved
So remember to use make_unsaved.
If you’re interested, here is the source code.
Well if you’re using latest machinist, which is 2.0 at this point, it’s much simpler and cleaner.
make for generating but not saving an object, make! for saving it to database.
Square brackets in zsh have special meanings but in MOST circumstances maybe you just have to escape them by putting \(backslash) before them.
rake new_post["Escape square bracket by default in zsh"]
zsh: no matches found: new_post[Escape square bracket by default in zsh]
rake new_post\["Escape square bracket by default in zsh"\]
mkdir -p source/_posts
Creating new post: source/_posts/2012-07-08-escape-square-bracket-by-default-in-zsh.markdown
Just setup this alias in your .zshrc.
alias rake='noglob rake'
Recently I found this website called Bootswatch, which is really helpful when you want to add color(or say different theme) to your bootstrap project. There is also a marketplace for you to buy/sell themes.
I’ll definetly try one next time I use bootstrap.

If you wanna execute some ruby code in rails environment, say manipulate w/ model or something, you can always try rake task first. But there’re circumstances you don’t want to use it, maybe it’s just a one-time script that you don’t want to save it to git, or whatever.
I’ve found out there’re two simple ways to accomplish it.
# test.rb
require "config/environment"
p User.first
# in terminal
ruby test.rb
Rails Guides about rails runner
runner runs Ruby code in the context of Rails non-interactively. For instance:
rails runner "p User.first"
rails runner some_ruby_script.rb
rails runner -e staging "Model.long_running_method"
rails runner -h
You can also use the alias “r” to invoke the runner:
rails r.
I failed to call rails r on Rails 3.0.10, maybe it’s above 3.1+.
I was wondering why people explicitly specify table name in such a scope definition…
class Answer < ActiveRecord::Base
scope :recent, order('answers.created_at DESC')
end
Until I got this error today.
Mysql2::Error: Column 'created_at' in order clause is ambiguous: SELECT COUNT(DISTINCT `answers`.`id`) AS count_id, question_id AS question_id FROM `answers` LEFT OUTER JOIN `questions` ON `questions`.`id` = `answers`.`question_id` WHERE (`answers`.user_id = 87) GROUP BY question_id ORDER BY created_at DESC LIMIT 10
I have a recent scope defined in both Question and Answer model. And when you chain those two models, rails don’t know the recent is associated to which one.
@answers = @user.answers.recent.group(:question_id).includes(:question).limit(10)