Archive for June 2009


Updating Rails on OS X

June 23rd, 2009 — 5:04pm

If you install XCode for OS X 10.5, it automatically comes with a version of rails. This is (generally) not the latest version however, and you must take a few steps to update it. First you need to update rubygems with the following:

macintosh$ sudo gem install rubygems-update
macintosh$ sudo update_rubygems

After updating rubygems, you should be able to update the rest of your gems without a problem (including rails) via the following:

macintosh$ sudo gem update

After that you should be ready to build a rails app.

Comment » | Coding

Scripting Languages

June 22nd, 2009 — 1:02pm

I just thought I’d share with you Random thoughts on scripting languages by Brian Kernighan.

After reading this, I looked up the source code to the unix utility wc. The GNU wc program was written in C, and amounted to about 800 lines with comments. A similar program written in awk is a mere 2 lines long:

{ nc += length($0) + 1; nw += NF }
END { print NR, "lines", nw, "words", nc, "characters" }

I know you are probably thinking that I just made an unfair comparison. Yes, I did.

Comment » | Coding, Unix

Replace Text Recursively with sed

June 17th, 2009 — 11:53am

Here is a quick little trick I discovered today when I needed to replace text in multiple files recursively:

grep -rl -e <searchterm> * | xargs sed -i .bak 's/searchterm/newterm/i'

There might be a problem with files that have spaces in the names (because xargs will take a space as the start of a new argument). To solve this problem, you should be able to do something like this:

grep -rl --null -e <searchterm> * |
xargs -0 sed -i .bak 's/searchterm/newterm/i'

If you are using GNU grep, you could also use -Z instead of –null. I happen to be using the BSD version of grep, so -Z isn’t an alias for –null.

Comment » | Coding, Unix

New Tattoo

June 14th, 2009 — 3:59pm

Yesterday I got my tattoo extended. Have a look :)

tattoo front

tattoo front

And my girlfriend also got a new tattoo, a birthday present… I think it’s nice.photo

2 comments » | Uncategorized

Back to top