How to remove duplicate entries in Finder menu

posted by Arkham on April 10th, 2013

Type in console:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister \
-kill -r -domain local -domain system -domain user

and then:

killall Finder

Tags:

iTerm2 on Mac OSX: add alt-left, alt-right and alt-backspace behaviour

posted by Arkham on January 9th, 2013

If you want iTerm2 to behave like the other Mac OSX applications, so that alt + left moves the previous word, alt + right moves to the next word and alt + backspace deletes the whole word, add these keyboard shortcuts from iTerm > Preferences > Profiles > Keys:

  • Alt + left: Send Escape Sequence, Esc + b
  • Alt + right: Send Escape Sequence, Esc + f
  • Alt + backspace: Send Hex Code, 0×17

Tags: , , , ,

Ruby 1.9 – Tap my Object

posted by Arkham on October 28th, 2011

Let’ say you need to debug this piece of code:

very_cool_method(egg, sausage)

What would you do? I guess something along the lines of:

spam = very_cool_method(egg, sausage)
p spam

Well, Ruby 1.9 let you do something cooler instead:

very_cool_method(egg, sausage).tap{ |s| p s }

The cool thing about tap is that you can use it to eavesdrop method chains:

very_cool_method(egg, sausage).tap{ |s| p s }.now_make_sandwich_from(bacon)

Hooray! :)

Tags: , , , ,

Rails: how to show SQL logs in console

posted by Arkham on September 2nd, 2011

Simply type in rails console:

ActiveRecord::Base.logger = Logger.new(STDOUT)

Tags: , , ,

Ruby: disable documentation when installing gems

posted by Arkham on July 29th, 2011

If you want to install gems quickly without waiting for ri and rdoc documentation files, run this command:

echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

Your new gems won’t include documentation at all. Hooray!

Tags: ,