Jonathan Berger's blog



Jonathan BergerJonathan Berger
NY Stand-up: Gonna Get Down on Friday the 13th
edit Posted by Jonathan Berger on Friday May 13, 2011 at 02:07PM

Interesting

Kris Hicks reassures us that the vim path through git interactive rebases need not lead to maddness. If you'd like to do an interactive rebase in your editor of choice (rather than Textmate, the Pivotal default) you can set the GIT_EDITOR flag. So go ahead to the terminal and

export GIT_EDITOR=vim && git rebase -i origin/master

Vim will launch, changes will be made, commits will be squashed, and all will be right with the world. Until you try to save; after making your changes and :wq-ing, the terminal will admonish you Could not execute editor.

The problem is a vi + Mac OS X + git incompatibility with pathogen (the vim package manager). To fix it, add the following lines to your .vimrc file:

filetype on
filetype off
...pathogen crap...
filetype on

For more on this issue, see http://andrewho.co.uk/weblog/vim-pathogen-with-mutt-and-git

Dangerous

Rayban reminds us that you best yield before you exit the block.

For example:

around_save :check_something, :if => "my_attribute_changed?"

def check_something
  return unless my_attribute == "foo"
  yield
  # do some stuff...
end

will not save unless my_attribute == "foo"— if your condition to run the around filter rarely happens you might not notice this fairly obvious behavior and be confused confused confused.

Jonathan BergerJonathan Berger
NY Standup for Wednesday, May 4: Star Wars Day
edit Posted by Jonathan Berger on Wednesday May 04, 2011 at 07:23AM

Dangerous / Interesting

  • Schubert warns us that Rail's extensions that add to_time method may cast types in unexpected ways: Date#to_time => Time Time#to_time => Time but DateTime#to_time => DateTime

  • Use === when checking equality with DateTime and you don't care about precision (This does not work with Time however)

  • Your humble author cautions that the new Laullon GitX is not ready for prime time. When adding multiple files with a single click, a garbage commit with a long funny name is created without adding the files. Instead, consider Brother Bard's excellent fork of GitX

  • Ian "Waffles" Zabel mentioned that jQuery 1.6 has been released. Notable changes include case-mapping of HTML5 data- attributes, performance improvements, and more.

  • Lee Edwards reminds us "It's Star Wars Day. May the 4th be with you." <⁄rimshot>