The Wrath of Kon

Dispatches, thoughts, and miscellanea from writer Jon Konrath

October 2009

More kicking of tires

I’m still trying to get used to this new infrastructure, and my actual writing is sapping away any momentum I might have to do this, but I keep thinking of neato ideas I might eventually do on here.

Case in point: I am attempting to write this entire post on the iPhone. Wordpress has an app for that; it lets me enter text, take pictures, and do minor administrative tasks like approve comments, all from my little touchsceen. Yes, I have to type from a glass keyboard, but once you get going, it is not too bad.

It’s weird to think that when I started this journal in early 1997, my cell phone was this analog Sony model with a pull-out antenna that incurred massive roaming charges when I was not in western Washington and could barely store my favorite five speed dial numbers, let alone text message or run apps or browse the web. The most portable computer I had was a Mac Classic, which was luggable, but still required AC power.

The idea of typing away on a machine like this phone and then jetting it across the ether to my web page was completely unfathomable. Cell phones were not even that old then; I think nobody had one five years before. Now in some countries in Europe, there are more cell phones than people.  And I can carry a little Mac in my pocket that’s probably ten times faster than that old luggable mac.

I saved this as a draft, came home, and now it’s the next day and I’m editing it at home in a web browser.  But it’s still exciting that I’ll be able to use this to jot down the occasional note or two, all from a thing smaller than a deck of cards.

Shell scripting will eventually kill me

I spent two hours the other night trying to hack out a shell script to import the archives into this thing. Wordpress doesn’t have a simple way to just suck in a bunch of text files; you need to assemble them into something that resembles an RSS feed, and then import that. This brought up two problems:

  1. All of the posts had to be on a single line in the element. This involved a bit of dicking around with awk and then sed before I finally gave up and realized I could do it faster with tr.

  2. The pubdate element had to be in RFC-822 time format, and the only thing I had to work with was the filename, which was in YYYYMMDD format. It took most of the two hours to figure out the god damned /bin/date program that ships with OS X is fundamentally broken, and ALL date commands in unixes are broken, because instead of curing cancer or stopping wars, about 80% of our world’s brainpower goes to stupid pursuits like “oh, I have philosophical issues with the 87 flags offered in BSD’s date program, so I’m going to write a completely incompatible one with 73 flags of its own, but still fail to address the two or three things people need to do with a time program.”

Case in point, this DOES NOT work in OS X:

date -j -f "%Y%m%d" "20090930" +"%+"

This DOES work:

date -j -f "%Y %m%d" "2009 0930" +"%+"

But my filenames are 20090930.html and not 2009 0930.html. That extra fucking space killed me.

AND YES, I am sure I am just an idiot, and if I sat around all day writing shell scripts, I would KNOW that blah blah blah hidden flag blah blah blah run it through a perl script blah blah blah. But truth of the matter is, I write maybe a half-dozen lines of shell script every three months, and then promptly forget everything. I’m sure if I sat around all day slicing onions into cubes, I would be a god damned onion slicing master, but the truth of it is, I only need to cut up maybe one onion a week tops, and I’m not about to quit my day job just to sit around slicing up onions.

Here’s the script:

for f in ~/website-mirror/oldjournal/html/1997*.html; do
    echo "<item>"
    OLDDATE=`basename -s .html $f`
    THEYEAR=`echo $OLDDATE | cut -c1-4`
    THEREST=`echo $OLDDATE | cut -c5-8`
    SHIT=`echo $THEYEAR $THEREST`
    pubdate=$(    date -j -f "%Y %m%d" "`echo $SHIT`" +"%+")
    echo -n "<pubDate>"
    echo -n $pubdate
    echo "</pubDate>"
    echo "<category></category>"
    echo "<title></title>"
    echo "<content:encoded>`tr '\n' ' ' < $f`</content:encoded>"
    echo "</item>"
done