Thursday, March 31, 2011

Books: Coders at Work

I just finished reading Coders at Work:
Based on nearly eighty hours of conversations with fifteen all-time great programmers and computer scientists, the Q&A interviews in Coders at Work provide a multifaceted view into how great programmers learn to program, how they practice their craft, and what they think about the future of programming.
In short, I really enjoyed this book. It was relaxing, stimulating, humbling, and enabling all at the same time.

One thing that really stood out was that programmers used to be able to understand systems extremely deeply because they could fit the whole thing in their heads. In contrast, it simply boggles my mind to think of how many lines of code are involved in showing Google Maps to me (think of my laptop, all the routers, Google's servers, the JavaScript, the server-side code, etc.). If you're up for some light technical reading, this book is highly recommended.

Friday, March 25, 2011

The Zen of Testing

Tests that use a style you disagree with are better than no tests at all.

Tests that catch more errors are better than tests that catch fewer errors.

Getting more done with less effort is better than getting less done with more effort.

Tests that are readable are better than tests that are unreadable.

Tests that are easy to update are better than tests that are hard to update.

Tests that fail when appropriate are better than tests that fail when inappropriate.

Tests that test the stuff you care about are better than tests that test stuff you don't care about.

Tests that take little effort and catch a lot are better than tests that take a lot of effort and catch little.

Wednesday, March 23, 2011

Python: Behavioral Driven Development for Telephone Applications Using Lettuce, Flask, and Twilio

I'm going to be giving a talk tomorrow night at BayPiggies called "Behavioral Driven Development for Telephone Applications Using Lettuce, Flask, and Twilio". Here's the description:
Behavioral driven development is a style of programming popular in the Ruby world using tools such as Cucumber and Webrat. In this talk, I'll show how the same tricks can be used in Python too, using a library called Lettuce. I'll also show off Flask which is a new micro web framework. Last of all, I'll cover Twilio which is an API that makes it easy to build telephone-based applications using web technologies.
I'm going to be showing code samples from my demo application PyTeladventure. If you can't make it to the talk, you might way to have a peek at the code.

Monday, March 21, 2011

Hardware: Fixed a Dell Inspiron 1545

My buddy Adam Ulvi loaned me a laptop since I didn't have one. (My last day at Twilio was last Thursday.) He had a Dell Inspiron 1545 lying around, and he was nice enough to mail it to me. The only catch was that there was some breakage around the display near the hinge. Apparently, this is extremely common, so I decided to try to fix it.

I bought a replacement part from The part I bought was the display cover, and it came with replacement hinges. It cost about $50. I went to Dell's site to find the service manual. It was actually a fairly involved repair, but I managed to get it done. My only regret was that I didn't buy a replacement part for the piece of plastic that frames the front side of the screen. I didn't notice that it was broken too, so I had to make due with some carefully applied electrical tape. Fortunate, it doesn't look as ghetto as it sounds.

Anyway, the repair went really well. The laptop looks pretty much brand new, with the exception of one small piece of electrical tape that blends in pretty well anyway. The new lid made a big difference. I've learned two things from this experience: 1) Dell's build quality sucks (which is something that my buddies have been telling me for a while now). 2) Dell's repair manuals are incredibly good. Following the instructions was a piece of cake, even it did take me two hours.

Tuesday, March 15, 2011

Linux: lubuntu

I decided to give lubuntu a try:
lubuntu is a faster, more lightweight and energy saving variant of Ubuntu using LXDE, the Lightweight X11 Desktop Environment.
If you already have Ubuntu installed, trying lubuntu is really easy; just run "sudo apt-get install lubuntu-desktop".

In summary, it's very pretty, super fast, and crazy small. In fact, its memory usage was almost laughable considering I was running it on a 4GB MacBook Pro. I think my total memory usage was something in the 200-300MB range.

The downside is that there are a lot of things that I've grown accustomed to in Ubuntu that I can't live without. Ubuntu has a GUI to swap the capslock key with the control key, and it has a GUI to tweak my touchpad and power management settings. There are probably ways to configure these things by hand under lubuntu, but I've grown mildly impatient in my old age ;)

The biggest challenge for me was that lubuntu doesn't know about encrypted home directories. I have an encrypted home directory, and Ubuntu knows that it has to run ecryptfs-mount-private when I log in; in fact, it doesn't even need to ask me for my password again since it does it as part of the login process. When I ran lubuntu, I had to log in, run ecryptfs-mount-private (typing in my password again), log out, and then log back in.

I have a couple more tips. To access the OpenBox menus, middle click on the desktop. If you decide to install lubuntu, don't tell it to switch to lxdm. Otherwise, if you remove lubuntu, you'll end up with a borked gdm setup. To fix it, you'll need to remove and reinstall gdm.

In summary, I really like lubuntu. It makes my machine feel lightning fast, faster than any other computer I've ever owned--at least until I fire up NetBeans ;) I'm not sure if they'll fix the things I mentioned, but if those things don't affect you, I think lubuntu is worth a try.

Sunday, March 13, 2011

Linux: Awesome is Awesome!

I decided to give Awesome a try. Awesome is a tiling window manager like xmonad. I've been using it for about a month, and I like it a lot.

It integrates with GNOME much better than dwm. Most users of dwm don't use GNOME, but I do. Its default settings are a lot nicer than xmonad's. When I use xmonad, I spend all my time futzing with my .xmonad.hs, but I haven't had to tweak Awesome at all the whole time I've used it. For instance, Awesome comes with a ton of layouts built in.

Getting gvim to work perfectly under xmonad required some tweaking, and I couldn't figure out how to get it to work perfectly under dwm. I know that this is gvim's fault because it doesn't follow the exact size prescribed by the window manager, so the bottom part of the screen gets messed up. I'm sure most dwm users don't use gvim--they probably run vim in a terminal. It worked perfectly under Awesome.

Getting NetBeans to work well took even more work, and even now it sometimes freezes in predictable (and avoidable) ways. I had to "sudo apt-get install suckless-tools", and then I added "xterm -e wmname LG3D" to my startup applications (i.e. my GNOME session). Finally, I switched to JDK 1.7.0 and edited /usr/local/netbeans-6.9.1/etc/netbeans.conf so that "netbeans_jdkhome="/usr/local/jdk-1.7.0".

Since Awesome and GNOME each have their own panels, I did some tweaking to make them get along better. I have Awesome's panel on the top, and one GNOME panel on the bottom. I got rid of things from the GNOME panel that were already provided by the Awesome panel. I'm pretty pleased with the result, and I didn't even have to futz with any configuration files to do it.

I really like the keybindings in Awesome. Since I had already played with xmonad and dwm, I didn't really have to re-learn the keybindings for Awesome since they're so similar. I just had to realize that all the keys were based on the command key (i.e. Mod4) instead of the control key.

I especially like having a different set of tags (i.e. virtual desktops) per monitor. That's exactly the paradigm I like the most. I use a big monitor for most things, and I use a lot of different tags. I use my laptop screen just for instant messaging applications, and I only use a single tag.

Plugging in or unplugging my monitor is a pain, especially since I have to tweak the Nvidia settings every time. I know it's a bit "ghetto", but my solution was to restart X every time I want to plug in or unplug my monitor. I think this actually takes less time than shuffling my windows around and futzing with my Nvidia settings.

I have found one Awesome bug. When I first login, my cursor is a clock, and it doesn't go away. If I play with the menus, it does. It's not a big deal, so I don't care.

The default layout is floating, and each tag has its own layout. This default works well for me. I only have to press Command-space to switch to tiling.

One of these days, I might give Qtile a try since it's written in Python and my buddy really likes it. However, in the meantime, I'm pretty happy with Awesome.

Personal: Should I Leave LinkedIn?

I got email from LinkedIn:
Give your productivity a boost - for free!
Exclusive offer: Try LinkedIn Premium free for 1 month*

Dear Shannon -jj,

Find and manage high quality contacts with LinkedIn Premium. Get started today and get 1 month free!.

LinkedIn Premium helps you be great at what you do, with tools such as:

• InMail: Contact anyone on LinkedIn without an introduction - response guaranteed!**
• Expanded Profile Views: See expanded profiles of everyone on LinkedIn, even people outside of your network
• Who's Viewed My Profile: Get the inside scoop on how you're viewed professionally by accessing the complete list

You'll also get a lot more including up to 700 profiles per search.

Your exclusive offer expires soon so get started today!
This means that LinkedIn is going to be making money off of spammy recruiters at my expense. That is really a violation of my trust. Am I wrong? I'm seriously thinking about deleting my account.

Thursday, March 03, 2011

Humor: Donald Knuth Jokes

At the age of two, Donald Knuth implemented Conway's Game of Life on Babbage's difference engine which was pretty impressive since Conway hadn't been born yet...neither had Babbage.

The next version of TeX will be self hosting...and will run on bare metal.

Skynet is actually an out of control TeX macro.

Knuth can store all integers between 0 and 127 in 4 bits.

Knuth invented binary.

Chuck Norris is actually an android that Donald Knuth created. He was funded by DARPA.

Knuth once wrote, "Email is a wonderful thing for people whose role in life is to be on top of things. But not for me; my role is to be on the bottom of things." He succeeded.

Knuth started to dabble in botany in his backyard. He gave it up, though, when all his trees ended up with squareroots.

Knuth is the last highlander.

Knuth created the Antikythera device when he was a young lad vacationing in Greece.

When Knuth wants to speed up an algorithm, he doesn't code in assembly--he codes in binary.

Donald Knuth enjoys coding in Python, but he prefers to write the .pyc files directly.

One time Knuth decided to crosscompile his algorithms from binary to quaternary. In the process, he invented DNA.

Knuth's brain is the most powerful source of energy known to man. Unfortunately, harnessing it would destroy mankind.

Knuth recently created a new sorting algorithm. Its performance is O(1).

Knuth invented literate programming so that TeX could be compiled by less capable compilers. Knuth's own compiler compiles the English.

If you can think of more, please leave them in the comments below :)