Friday, June 03, 2011

Mac Pro Tip: Preferences .plist files

I love my new MacBook Air 11". Used it for most of my flight from Atlanta to Chicago today (about 1.5 hours flying time), and for once didn't have to worry about the guy in front of me leaning his seat back all the way into my lap. Also had a reported ~5.5 hours of battery time left when I had to shut down. The only thing I would do differently next time is get maximum RAM (currently sporting 2GB versus a potential max of 4GB).

When I'm at home, I run the MB Air in clamshell mode connected to a 20" cinema display (old school, baby; that's how I roll). Works great, everything displays where it should in either mode.

Except ...

There's this one app, RSA SecurID, that I occasionally need to connect to ThoughtWorks' sites. And it is decidedly not smart about repositioning itself. I usually have it dragged down out of the way, to the bottom right corner of the cinema display, but today while traveling I found out it always stays off the screen, even without the cinema display connected. Exposé will show it to me when I switch to the app and Show Application Windows, but when I click on it, it zips back off to the (now non-existent) bottom right corner of the cinema display. Restarting does not help, nor does gathering windows nor detecting displays in the Displays settings panel.

Bummer.

So I had to resort to opening the .plist file for the app (located for me at ~/Library/Preferences/com.rsa.Software Token\Desktop.plist) and manually updating its two properties: LastXPosition and LastYPosition. Supposedly, .plist files can be edited with any text editor (e.g., TextEdit), but this one seems to be in some binary format; I ended up have to use Xcode's plist editor to be able to make my changes.

Further Pro Tip: Make sure to tab or click out each field that you've edited. If you just type your change in place and save, it will not take.

Thursday, April 07, 2011

First App: TreadCalc!

My first app for iPhone -- TreadCalc -- is live in the iTunes store! It's a little utility I developed for when I have to run on a treadmill and want to know what speed to set to run a given distance in a given time. There are other apps in the store that do this, of course, but I think mine is the only one that does it all on one screen -- no settings, no info; nothing but you, a few buttons (for switching between miles, kilometers, and time entry), and a couple of dials. As a bonus, you can use it as miles-to-kilometers conversion calculator, at least for distances up to 26.9 miles (just over the length of a marathon).

Wednesday, March 16, 2011

Mac Tech Tip: chflags

I'm in the throes of my very-nearly-annual clean install of Mac OS X to my MacBook Pro (just to generally de-gunk; no other pressing reason). Of course this means I have to reinstall a lot of software (note to self: Hey self! You still need to restore World of Warcraft from your backup, stat!). Dropbox is helping me a lot this year; this time I don't have to recreate e.g., all of my password manager entries. That would be bad.

One of the more obscure things that I take for granted, always lose when I reinstall, and immediately miss is my symlink to /usr, which I like to create so I can use Finder to browse it. This year I decided to see if there was some better, native way to expose /usr to the Finder, and it turns out there is: chflags. One quick call to sudo chflags nohidden /usr, and I'm happily browsing. No muss, no fuss, no stretchmarks.

Monday, October 25, 2010

First Clojure Patch (ding)!

In celebration of the awesomeness that was ClojureConj The First, I just submitted my first patch to the Clojure core codebase! Still waiting for the Lumbering Wheels of Bureaucracy to turn the Massive Gears of Pending Assembla Membership to open the Gates to the Kingdom of Those Who Have Had a Patch Accepted. But the hardest part is done!

I'm just giddy with excitement. Or sleep deprivation. Or both. Probably both.

Sunday, May 02, 2010

Using Haml with Rails 3.0

One of the things I [heart] about being a Ruby/Rails developer for ThoughtWorks is that I occasionally get asked to do something really cool on the side, like being a technical reviewer for an upcoming book on Rails 3.0.

In this particular book, the author uses Haml instead of Erb for templating views in the sample code. When I'm reviewing a book, I like to actually exercise as much of the sample code as I reasonably can, as it tends to be among the hardest stuff to get right, and among the easiest ways to discourage a reader when it's not right. But Rails defaults to Erb for templating, and I'm not exactly Haml-enabled.

What's a geek to do?

Well, my friend Google had a thing or two to suggest, but the process is slightly non-trivial so I thought I'd collate it here, thusly:

  • NB: All commands are entered from your Rails 3.0 application's root directory.

  • Edit [your_app]/Gemfile, and add the line gem 'haml' somewhere convenient.

  • Edit [your_app]/config/application.rb, and add the line g.template_engine :haml to the config.generators block (uncommenting the block if necessary).

  • gem install haml

  • bundle install

  • haml --rails .

  • git clone git://github.com/psynix/rails3_haml_scaffold_generator.git lib/generators/haml


That last bit is particularly important for allowing Rails' scaffold generators to Do The Haml Thang(TM) when generating view templates.

Now back to my regularly scheduled tech review ...

P.S.: The book is going to be awesome. Reserve your copy now!

Saturday, May 01, 2010

Enter the Lich!

So I've finally spent a little bit of time unpacking and bookshelving my trove of geek books from my move last summer. Among many that I want/need to read Real Soon Now (TM), the book "Lisp in Small Pieces" by Christian Queinnec caught my eye and reminded me that I need to actually do something about learning Clojure.

So I've set out to implement Lisp in Clojure, following Queinnec's book. I've put the shell of the project -- featuring 100% test coverage; go me! -- on GitHub, at http://github.com/davidrupp/lich. For some reason I haven't taken the time to obsess about (yet), lein repl doesn't include the project's src directory on the CLASSPATH, so you can't really require your code and play with it in the REPL. So I've included my own in script/repl. I suspect that once I really get the hang of unit testing I won't need/want to rely on it so much, but at least it's there for now.

This should be fun ...

Sunday, March 21, 2010

Review: Pragmatic Clojure Studio

Executive Summary: If you are a developer looking to get into Clojure programming, attend this studio.

Executive Summary (for executives): If a developer who reports to you wants to attend this studio -- let him.

Even if you're at a shop that doesn't allow development in anything as exotic as Clojure -- yet -- you will benefit from this view of a language that embraces the JVM-as-a-platform as richly and effectively as Clojure does. You will learn what Java-the-language could (should?) have been capable of. You will even learn what Java-the-language actually *is* capable of. Much of Clojure is implemented in Clojure itself (homoiconicity FTW!), but a good chunk of it is implemented in Java.

The value of this studio is not the standard nuts-'n'-bolts / grammar / syntax / now-do-some-labs dance of most technical training. The value of this studio is that it's co-taught by Rich Hickey, the creator of Clojure. You will get to hear him talk about the design decisions he made in the evolution of Clojure. More importantly, you will get to hear him talk about the design decisions he *avoided*. You may not agree with all of those decisions, but you have to respect the man's process. Language philosophy aside, Rich's talks on "State and Identity", "Modeling State and Time", and "Protocols, Reify, and Datatypes" will blow your mind, and cause you to think differently about the act of programming whether or not you ever write a line of Clojure outside the studio.

Other not-quite-as-mind-blowing-but-still-pretty-cool topics include functional programming, web development with Compojure, Java interoperability, macros, and method dispatch.

And it's not just Rich who is fun to watch. The studio is co-taught by Stuart Halloway, owner of Relevance, LLC -- a working Clojure shop -- and author of the Pragmatic Programmers' "Programming Clojure". The two complement each other nicely. Stuart is very impassioned, a bundle of energy when it's his turn at the projector. Rich is much more laid back (though still impassioned), and expresses volumes with the arch of an eyebrow or a quirky half-smile at Stuart's antics. Both are eminently accessible and happy to answer questions and interact with students during breaks.

Remember Java in 1995? Ruby in 2005? I went into this studio a skeptic, and I came out convinced that Clojure is going to have a place -- and ultimately a prominent one -- in the landscape of our profession.

Go to this studio. Spend a few days learning from the masters. You'll be glad you did.