Archive for the 'Computers' Category

Wednesday, January 9th, 2008
» Testing App::Cmd

As I mentioned last week, I’ve been working on a little reading list management tool. I’m using App::Cmd as the framework, which has been a somewhat frustrating but ultimately worthwhile choice.

I first learned of App::Cmd at the Pittsburgh Perl Workshop, through a talk given by the module’s author Ricardo Signes. The slides from that talk are about the best App::Cmd documentation out there, although App::Cmd::Tutorial also has some useful bits, and the module documentation itself isn’t bad by any means, just a little light on example code.

For BookList I didn’t do a lot of up-front design work — I was basically designing as I went and learning App::Cmd at the same time. As a result, I ended up implementing several commands with only the most rudimentary tests — basically, if the command module loaded, I was happy. Since BookList is getting towards a 0.1 level of functionality and I’d like to release it, I spent the past couple days renewing my appreciation of “test first” development by going back and writing all the tests I skipped over the first time through.

Because of the way the framework works, testing App::Cmd code is a bit different than testing library-level routines. The talk I pointed to above has a section on testing (around slide 115, for those of you who want to check it out), which references a nifty looking module called Test::App::Cmd. Unfortunately, the module doesn’t appear to be publicly available yet. (This might have been mentioned at the talk; I don’t recall. Any status updates are welcomed.)

After poking around on CPAN, trying to find something to provide some scaffolding for my tests, I ended up finding a module called Test::Output. I used that and the sample test code in the talk to write a bunch of tests that looked like this:


use Test::More     qw/ no_plan /;
use Test::Output   qw/ stdout_from /;

use Booklist::Cmd;

my $error;
my $stdout = do {
  local @ARGV = ( 'authors' );
  stdout_from( sub {
    eval { Booklist::Cmd->run ; 1 } or $error = $@;
  } );
};

like $stdout , qr/^###  #bk  author/ , 'see expected header';
ok ! $error;

and while that mostly worked out okay, I ran into trouble with some of my error-handling code. When writing libraries, especially for my personal use, I tend towards the low-budget “croak() and let the caller deal” method of exception handling. But for something that’s going to be more application-level, I wanted to print messages to STDERR and then exit() with a non-zero status. This doesn’t play well with Test::More or Test::Output, neither of which trap calls to exit().

After a bit more CPAN searching, I found Test::Trap which is excellent for testing App::Cmd code. The above code rewritten to use Test::Trap looks like this:


use Test::More    qw/ no_plan /;
use Test::Trap    qw/ trap $trap /;

use Booklist::Cmd;

trap {
  local @ARGV = ( 'authors' );
  Booklist::Cmd->run;
};

$trap->leaveby_is( 'return' , 'exit normally' );
$trap->stdout_like( qr/^###  #bk  author/ , 'see expected header' );
$trap->stderr_nok( 'nothing on stderr' );

That second code block is a lot cleaner and easier to understand than the first one (not to mention being fewer LOC while doing an additional test), and the accessor/comparison methods (leaveby_is, stdout_like, etc.) from Test::Trap are both easy to write and (if you know anything at all about idiomatic Perl testing code) trivial to understand.

I’m going back now and rewriting all my previous Test::Output tests to use Test::Trap — but I’ve also learned another lesson here: my last test is currently failing, because I wrote it beforeimplementing the command it tests.

Tuesday, November 20th, 2007
» grrrrrrr.

Dear LazyWeb –

I need a terminal emulator for MacOS X. I’m an Emacs user, and my forearms think that the key immediately to the left of the space bar is the Meta key. One of the frequent key combinations I use is ‘M-Q’, to reflow paragraphs and other text. The silly Mac persists in thinking this keystroke means “quit the current program”.

I used to run X11.app and just use xterms. Leopard apparently got the eff’d up juice all over the X11.app, so that currently doesn’t seem like a good option. I just quit iTerm for the last time before starting to type this post. I won’t get into the details at the moment, but suffice it to say that it also makes the baby Jesus cry big tears of pain. (Randomly garbling control characters is not an acceptable behavior.)

Is there anything else that’s going to suck less than Terminal.app? (Ideally, something that doesn’t involve the phrase “and then I installed Ubuntu”).

Thank you O Great Lazyweb. May your surfing always be free of content filters.

Wednesday, September 5th, 2007
» Mail-centric tab dump

Mailing List Management Software

I needed to set up some mailing list management software recently. I considered Mailman. JWZ’s Mailman Considered Harmful walked me back away from that and got me pointed towards SmartList. While trying to find out if anybody other than JWZ was actually using SmartList, I ran across an advogato diary from 2003 which got me pointed to Minimalist. Happiness ensued.

A couple other mail-related links

I set up the mailing list software on a new VPS I have at Slicehost (who I highly recommend, by the way). I don’t really have anything terribly important migrated over to that server yet; part of the mixed joy and curse of a VPS is that you end up doing a lot of stuff that gets taken care of for you in a shared hosting environment, and doing that stuff properly takes time. Mail for some of my domains is routing through there now, however, which means that spam is getting routed there too. I was having a fairly bad time of it until I added Postgrey to the mix. At that point the amount of spam making it into inboxes slowed to a trickle — most days, I get none at all and usually what little makes it past Postgrey is flagged by SpamAssassin.

I also wanted some visual check on what the mail server was doing, so I installed Mailgraph. I had to tweak the code a bit to get it to look like I wanted, but eventually I ended up with some nice graphs.

Friday, June 22nd, 2007
» emacs tab dump
Thursday, May 31st, 2007
» You can’t spell “disintermediate” without “me”

So, SixApart made some incredibly stupidunfortunate business decisions about Certain Types of content yesterday. Lots of blowback all over the place; I first saw stuff on Warren Ellis’s site (this is his final word as I write this) and then Elf Sternberg posted (and there have been subsequent posts from Elf on the same topic). From what I can see standing on the edge of the community, seems like a lot of people are poised to up and move elsewhere.

Here’s the thing: this is the downside of the “user-generated content” “revolution” — it’s way too easy for somebody else to pull the plug on you with little to no notice. It has its own set of issues, but the next step up the Internet food chain — buying your own domain and getting it hosted somewhere — is a lot more resilient to this particular type of disruption. The problem is that the feature set of LJ isn’t, as far as I know, really available in a form you can use in a “hosted” fashion.

That’s where we come to the idea. It seems to me like, given that OpenID is mature and getting some traction, it should be possible to come up with some reasonably simple CGI that ties together some basic blogging functionality, some RSS pull/display capability, and a bit of access management, and bicketyBAM, instant distributed LiveJournal-ish-like thingy. The key here is that there aren’t any centralized servers where this runs, you’ve just got a whole bunch of people with CGIs on their own hosted domains and all the community interaction happens from the CGIs talking to each other, using OpenID to handle all the authentication/authorization issues. The real beauty is that, since LiveJournal supports OpenID, taking your existing LiveJournal community with you shouldn’t be a big deal — which was a concern for Elf and I bet for a lot of other people. Pair this with a tool that scrapes your old content out of your LiveJournal and dumps it into the new system, and you’ve just made it possible for people to jump off the LJ wagon.

One of you crazy college kids that just got out of school for the summer pick this up and run with it, okay? First version doesn’t have to be all that pretty, just has to be good enough to spread around and demo the idea for people; once that happens I don’t think you’ll have a big problem with contributors.

Thursday, March 22nd, 2007
» Twitter tweet

After mentioning it a month-or-so ago, I’m actually twittering semi-regularly, if you’re interested. My theory about the appeal of Twitter? It seems like everybody idealizes some earlier stage of their life — high school, college, grad school, whatever. As a group (and this is a massive generalization, but bear with me), the geek/digerati/hipster crowd tends to idealize their college days and that dorm-life/hang-out/group-of-friends collective experience, where there’s almost always a like-minded individual close to hand regardless of what time of day it is. (After all, what is SXSW or ETech but a repeat of Frosh Week with more money and shinier toys?) Twitter seems to tap into the same sort of communal living vein that dorm life had, where you get a group bonding effect because of the sharing of life’s inevitable minutia rather than any larger commonality.

(I’m not trying to imply there’s anything wrong with idealizing college, or hell, even high school — and obviously I’m using Twitter enough to be thinking and writing about it, so please don’t read any of the above in a negative way. It’s a cool toy, maybe with a limited shelf life, but I’ve been pondering why it seems to be catching on with the groups that it’s catching on with, and this is what popped out of my noggin.)

Tuesday, February 6th, 2007
» ROFLMAO

Maybe it’s just the tail end of a long, not-yet-over day, but UselessAccount.com is the funniest damn thing I’ve seen in a while. I especially love the “slightly more useful than twitter” banner.

Monday, February 5th, 2007
» Here’s an idea for you to … disregard

This is probably something with too small a target market to be viable, but I know that I’d pay for it, and I imagine a number of people I know would too, so I’m throwing it out here. If somebody happens to run with this, please let me know where to sign up.

I want a web site that lets me put in all my demographic information, set up a series of preferred usernames, and provide a default password. Then I want the people who run that site to watch — nay, scour — the online world for new and upcoming services, and I want them to register me for those services, using my preferred username(s) and password(s). I don’t want to have to worry about finding out about things in time to get my preferred handle, I don’t care that all the sites will be using the same password (because I’m already using the same password when I register for them myself), and I don’t particularly care what the master registration site does with my demographic info as long as my spam load doesn’t go up appreciably and as long as nobody, you know, jacks my credit card or something.

Oh, and I’ll pay money for this service. I’ll quite happily take the money I was giving Flickr for a Pro account and give it to whoever sets this up. Please.

(And yeah, yeah, OpenID blah blah blah, but until that gets to be part of the landscape, it’s not doing me any real good. I’m not looking to do the Right Thing here, I’m looking for a cheap technological fix for this particular pain in my ass.)

In related news, stalkers may wish to know that twitter.com/genehack is now active. Shiny.

Wednesday, January 24th, 2007
» <sfx:BLOOP>

That sound was me unsubscribing from all my tag-based del.icio.us feeds. (I’m still keeping the person-based ones.)

Noted as yet another medium being overcome and/or failing to deal with the spam problem; I don’t need to hunt through dozens of pr0n and health care links in the ‘lifehack’ category, thanks much.

Friday, January 19th, 2007
» Grrrr…

Reason number 934058049 why having a case-insensitive filesystem on a *nix-like machine is stupid (and yes, Apple, I’m looking right at you and sharpening a Leatherman as I say this…): I just found out that I’d managed to replace the command that shows you the first few lines of a file (normally at /usr/bin/head on *nix-y OSen) with a script that submits a URL to a web server using the HTTP command HEAD (normally found at /usr/bin/HEAD) — because the computer I’m using is too damn stupid to realize that /usr/bin/head and /usr/bin/HEAD should be different!

I’d wipe the thing and put Ubuntu on it, but the last time I tried, it refused to boot off the CD. I suspect it was aware I was trying to kill it and was refusing to cooperate.