Posted by Ed on January 19th, 2012 under Programming, Ruby Tags: Ruby, TIL •
No Comments
I ran into a situation recently where I was writing a library that utilized large files. Specifically a GTFS feed parser. I wanted to cache the files away someplace so I could safely access them for the life of an object, but I didn’t want to leave them hanging around afterwards. I couldn’t do all my work inside a block passed to Dir.mktmpdir because I was planning on accessing the cache when necessary (not just one big up front parsing operation).
This got me wondering: “does Ruby have finalizers?”. It turns out it does in the form of ObjectSpace#define_finalizer. It’s worth mentioning that there are some tricks to using them which are nicely documented on Mike Perham’s blog here.
The gist of it is this: don’t create finalizers which hold a reference to the instance they’re finalizing or it just won’t work. I’m glad I found that blog post before I started coding because I would have certainly fallen into the trap he describes. It probably doesn’t help that the ruby doc examples don’t include any examples of adding a finalizer in a class definition.
So all of this works out pretty nicely and leaves me with code looking something like this:
Posted by Ed on January 17th, 2012 under Uncategorized Tags: development, lion, os x •
No Comments
Currently GitX does some funny things in OS X Lion like opening two windows every time you launch the app. This is easily fixed with the following:
defaults write nl.frim.GitX ApplePersistenceIgnoreState YES
I tweeted about this a while ago with appropriate credit to this tweet. But finding it again in my twitter stream was a pain so here it is for posterity.
Posted by Ed on January 2nd, 2012 under development, vim •
No Comments
When my eyes are tired, or if I want to put my feet up on my desk and relax while still coding I usually bump my VIM font up way high. This is nice and easy with MacVIM because the standard OS X keyboard shortcut applies (Command+Plus). The problem is, when I’m ready to go back to my normal font size I have to hit Command+Minus a bunch of times or source my .gvimrc to get back to the normal font size.
I was in the middle of doing this today when I thought “man, it would be nice if I could hit Command+0 like in other apps and go back to the standard font size”. Then I realized I was using VIM and I could do that. So here ya go:
nnoremap :set guifont=Meslo\ LG\ M\ DZ:h10
Delightful.
Posted by Ed on August 28th, 2011 under Programming, vim Tags: programming, vim •
No Comments
Some people might clean their house on the weekend… I cleaned my ~/.vim directory out. What’s this? Have I ever used that? I must have just downloaded that because someone said it was cool. All is neat and tidy now, but in doing this cleanup I got a reminder of how useful tpope’s work is. His plugins dominate my setup. Not only that, but they are some of the most often used. Thanks, Tim!

Posted by Ed on October 27th, 2010 under OS X, Programming, Tools •
No Comments
GitX shows you stage buttons for chunks of changes in a file it thinks go together which usually works out fine. What’s cool is that it also allows you to select lines with your mouse and stage them too. WIN.
Selecting lines for staging in GitX from Ed Schmalzle on Vimeo.