Callability in Clojure

I’ve been hacking some Clojure code the last couple days and something I’m really coming to love is Clojure’s terse syntax for lambda functions. The basic form is pretty darn short… (map (fn [x] (* x x)) [1 2 3]) => (1 4 9) …but we can make that even shorter with this syntax that doesn’t even require us to name the argument: (map #(* % %) [1 2 3]) => (1 4 9) …or, if we have multiple arguments:

Keyboard Shortcuts for Octopress Sites

Nerds love Octopress. Nerds love keyboard shortcuts. …need I say more? @camdez What a delightful plugin, nice work! — Brandon Mathis (@imathis) March 16, 2012 I added mutt / Gmail-style shortcuts to Octopress and I think it turned out pretty well. Go ahead and try out some of these shortcuts (but be aware that some of them only function within the context of a list of posts–like the homepage):

whiteout - Say 'No' to Whitespace

I recently whipped up a command-line utility / Ruby gem called ‘whiteout’ which removes trailing whitespace from files. As you would imagine, it’s a simple piece of code, but it’s a bit more convenient than the shell script I was using. It also gave me a chance to learn how to cut a gem and how to structure a command-line utility in Ruby. You can use whiteout to remove trailing whitespace from a single file, a directory of files (recursively), or from standard input:

Emacs: transpose-lines

The command transpose-lines, bound to C-x C-t by default, is a standard Emacs workhorse. It exchanges the line point is on with the previous line. Because it also moves point down a line we can invoke it repeatedly to “drag” a line down: one two two two two two< one three three three three --> three< --> one --> four --> four four four four< one five five five five five< one < This is particularly handy for reordering lists.

Pretty JSON in and out of Ruby

Parallel to Ruby’s p and pp methods for quickly printing and pretty-printing, Ruby’s JSON library offers j and jj methods for quickly printing objects in JSON format: > obj = {"foo"=>"bar", "baz"=>[1, 2, 3]} > p obj {"foo"=>"bar", "baz"=>[1, 2, 3]} > j obj {"foo":"bar","baz":[1,2,3]} > jj obj { "foo": "bar", "baz": [ 1, 2, 3 ] } Definitely handy for investigating those large, deeply-nested objects. I’ve not actually looked, but the implementation of jj is probably just something like…

The Five Minute Lisp Environment

Do you want to try Lisp? Do you have a Mac? Do you have $10? Then this is the post for you! (Ok, you don’t need $10 to try Lisp, but this approach is bloody convenient. And it shows off some really cool tools—and no, sadly I’m not making money on any of them.) First we’re going to install the fantastic Homebrew, which is an easy way to install UNIX tools on your Mac.

git: Pushing (Only) Some Commits

Occasionally I’ll find myself deploying to Heroku but for one reason or another I’m not ready to roll out all of the commits I have on master. Maybe I’d like to roll out some of the changes, test, and then roll out the rest later. You don’t want to just run a git push heroku master because that would push (and therefore deploy) everything. Instead, use git log to get hash of the commit you want to push up to (and including), and then run:

GitX Commit Keyboard Shortcut

It took me way too long to figure this out: from the commit view (⌘2) in GitX you can use ⇧⌘⏎to commit.

Moved to Octopress

Well, no fanfare necessary, I switched to Octopress and moved this blog to Github Pages. I’m enjoying the new setup and planning to actually post again (*gasp*).

Decisions are Bullshit

So many new things to say, so many thoughts, so many feelings…I’m not particularly interested in leaving California (70°F as I write this, among other reasons) but I have affairs to settle in Dallas as well as people I’d like to see. Again I’m struck with the feeling that I need to make better use of the time I spend in Dallas. Not only because life is short and I need to always be making the best possible use of the time that I have, but also because of a growing awareness that the sun is setting on my time with that city.