Skip to content

Instantly share code, notes, and snippets.

# change name for generated routes
map.resources :posts, :as => 'articles'
# manually update any custom routes that use the old name
map.post_draft '/article/:id/:token', :controller => 'posts', :action => 'show', :conditions => { :method => :get }
# model:
def to_param
login.parameterize
end
# for controllers (the User controller and all the controllers that are
# nested under it, or in other namespaces): replace User.find(params[:id]) with
User.find_by_login(params[:id])
def current_object
User.find_by_login(params[:id])
end
# if you used the more general
get :edit, :id => @user.to_param
# instead of the specific
# get :edit, :id => @user.id
# ack
alias ack="ack-grep -i -a"
jack() {
ack $1 --ignore-dir=vendor --ignore-dir=cache --ignore-dir=stubs public/javascripts
}
sack() {
ack $1 public/stylesheets/sass
}
@dira
dira / ro.yml
Created April 25, 2009 00:10
rails - translation/localization for time_ago_in_words - Romanian
# rails - translation/localization for time_ago_in_words - Romanian
ro-RO:
datetime:
distance_in_words:
less_than_x_minutes:
one: 'mai putin de un minut'
other: 'mai putin de {{count}} minute'
x_minutes:
one: 'un minut'
other: '{{count}} minute'
@dira
dira / vimmish-input.txt
Created May 7, 2009 16:34
a sequence of input for vim - for vimmish
iDon't know vim :(.<ESC>^2WBc2wbetter now<ESC><RIGHT>Da.<ESC>II can understan<ESC><RIGHT>~dE
@dira
dira / vimmish-output.txt
Created May 7, 2009 16:35
vimmish translation of input stream
i => insert before cursor:
Don't know vim :(. => type Don't know vim :(.
<ESC> => go to normal mode
^ => move to the begining of the line (not blank character)
2W => move to the begining of the next space-separated word, 2 times
B => move backwards one space-separated-word
c2w => change to the begining of the next word, 2 times
better now => type better now
<ESC> => go to normal mode
<RIGHT> => move one character to the right
# bash: kill the process that occupies <port>
kill $(lsof -t -i :4567)
@dira
dira / gist:163186
Created August 6, 2009 08:03
Kill a firefox profile - for testing with Selenium
# kill [firefox, profile]
ps aux | grep [f]irefox | grep ***profilename*** | awk '{print $2 }' | xargs kill -9