Tuesday, September 22

So a while ago we hired a guy at SparkFun to start doing random desktop support. Help-my-printer-won't-print kinds of things. And then we hired another guy who is way, way smarter about network stuff than me.* And not too long after these events, a really strange thing began to happen: My job where I'm supposed to be a programmer turned into a job where I actually write programs.

Stranger still, I began to find myself enjoying it. And it's starting to cascade into the rest of my life. I wrote code for most of Friday, Saturday, and Sunday, except for the parts I spent reading about code, and the parts I spent installing heavily configurable window managers and text editor extensions. I've been sober almost all of the time for nearly a week and there's no beer in the fridge. My wrists ache from all the typing and my eyes hurt constantly. I'm dabbling in Haskell.

The last time I can remember nerding out like this for any reason other than financial desperation, I was a socially terrified virgin living in a dorm room with Gundam posters on the wall and a music collection comprised entirely of Led Zeppelin albums.

 

XMonad is a window manager. It's really interesting, and configuring it will probably confuse the hell out of you if you don't know Haskell. Here's my first attempt. Sources in the xmonad.hs.

awesome seems to work pretty great out of the box. It is also less intimidating than most of the tiling window managers I've tried.

I'm thinking of putting a fourth computer on or near my desk so that I can run three different window managers at once. (The third computer runs MS-DOS 6.22 right now. I'm going to spend some of tomorrow making it talk to a TTY on some other box, because sometimes I miss the early 1990s.)

If you have more than one computer in front of you all day, Synergy could be your new favorite thing for the ten minutes it takes for you to use it so much you forget it's even there.

Speaking of minimalist interfaces, you can turn off gvim's toolbar display by doing :set guioptions-=T. There turns out to be almost no reason for all those buttons to take up space.

Recent additions to my .vimrc:

" split lines under the cursor
map K i<CR><Esc>g;

" Hit F2 to toggle NERDTree display without losing state
map <F2> :NERDTreeToggle<CR>

Kate now comes with a reasonable vi input model. It still doesn't have all of the Vim-isms I would like, but it's worth looking at.

Here is a way to make your capslock into an extra control key:

xmodmap -e 'keycode 66 = Control_L'
xmodmap -e 'clear Lock'
xmodmap -e 'add Control = Control_L'

The only reason that isn't the best keyboard layout decision I've ever made is that now, every time I do anything on anyone else's computer, I wind up spending most of my time being confused that I've just typed a bunch of capital letters. I'm not sure how people who take Dvorak seriously deal with their version of this problem, but it makes my brain twitch thinking about it.

If you use git for anything collaborative, you should try running gource against your repository. I defy you not to make space battle noises while it's running.

In PHP prior to version 5.3, you can't directly call static methods of a given class using a variable containing the name of the class. You can, however, do

call_user_func("{$classname}::someStaticMethod", $parameter1, $parameter2, ...);

You also can't expect self to refer to anything other than the class where the method containing it is defined, even if (for example) you're instantiating some child class of that method. For all I know, this is perfectly reasonable behavior, but it sure did disgust me when I noticed it.

What you can do, if you want methods defined in some base class to get at static properties of a child class, is combine that call_user_func() hack with some little wrappers that return the right property:


<?php
  ParentClass {
    public function checkSomePropertyForFoo ()
    {
      $classname = get_class($this);
      $someProperty = call_user_func("{$classname}::getSomeProperty");
      if ($someProperty === 'foo') {
        return true;
      }
      return false;
    }
  }

  class ChildClass extends ParentClass {
    private static $someProperty = 'foo';
    public static function getSomeProperty ()
    {
      return self::$someProperty
    }
  }

  $bar = new ChildClass;
  if ($bar->checkSomePropertyForFoo()) {
    print "Got foo.\n";
  }
?>

If you think this is stupid, you are probably correct.

If you are a somewhat opinionated sysadmin, need a spare box sitting on the internet, and have just a little bit of scratch, a Slicehost VPS with a reasonable, no-nonsense operating system is $20/month for the entry level plan. This is only $10 more than DreamHost, and within reasonable limits you can just set it up however you want. There's much to be said for this.

xterm is still the best terminal emulator, but everybody seems to use the vaguely adequate GNOME Terminal (or some other equally mediocre default) instead. On Debian-like systems, you can do

sudo update-alternatives --config x-terminal-emulator

and pick xterm/uxterm.

There doesn't seem to be a reliable, actively developed YAML parser for PHP, which is a shame and I think someone should do something about it because YAML is really cool.** That said, If you're just looking for a simple config file format you could do worse than using the builtin ini_parse(). INI files are one of the few things I wish more people had borrowed from Microsoft. My assumption about the Windows Registry has always been that someone in Redmond became extremely nervous about the simplicity of key-value pairs, decided to do something about it, and succeeded spectacularly.

IBM may or may not have been complicit in the Holocaust, but they sure have made some sweet keyboards. And you can get modern versions of the Model M, complete with USB and such, from these people, who I am guessing don't have much of a corporate history with the Third Reich. (It would make me sad to be wrong about this.)

 

* In fact, Ben gives indications of being smarter than me about everything that my job theoretically entails. If I could figure out where to find half a dozen more guys like this I'd take over the fucking planet.

** I tried Spyc and it seemed to fail quietly a lot. I'd like to be wrong about this, but I didn't have time to figure out how it was breaking. I'll probably revisit this.