mahiwaga

I'm not really all that mysterious

itunes_playlist

What I did on my birthday weekend (besides the requisite alcoholic binging) was write a script to list the last 5 songs I’ve listened to on iTunes. (I guess I’m just an irresolute geek.)

In the process, I managed to learn how to use XML::LibXML. So my XPath skills aren’t going to go to waste.

My first attempt involved trying to parse the iTunes Music Library XML file. Unfortunately, this is a rather large file (5.2M with over 4,000 songs) and Apple’s plist format is a pretty bad implementation of XML (you have use some rather arcane XPath to get the value of the key you’re interested in, because the key name and the value are siblings instead of parent-child, which would make more sense), and maybe I wasn’t using the most efficient way to do it (with two XSL transforms), but it was taking forever to pull a playlist out.

So I went with Applescript. (Applescript for extracting playlists by Kimbra Staken) Even this is a little slow, but nowhere near as horribly so as my Perl script. I ended up embedding the Applescript in Perl anyway (using Mac::Applescript) because I wanted to use XML::LibXML.

The Applescript just parses a smart playlist I set up to give back the last five songs I’ve played.

Now, what I wanted as output was an HTML fragment that I could include into my template with Blosxom’s file plugin. I wanted a link to lyrics (via Google), a link to search the iTunes Music Store, and a link to Amazon.com.

For the Google link, all I did was escape the artist name and the song name, concatenate them together with the word “lyrics” and then stick it all into a URI that will feed it to Google’s “I’m Feeling Lucky” mode.

For the iTMS link, I formatted the escaped parameters to adhere to the iTMS search URI syntax

The trickiest part was getting the Amazon links. You have to figure out the ASIN identifier for whatever you’re looking for in order to have a usable URI. Luckily, Amazon.com has exposed their API for public consumption. You have to register as a developer, and then you can send queries to Amazon’s database. Amazon.com will send back an XML file, which you can then parse for the ASIN.

So basically I execute this perl script before I generate static pages with Blosxom and rsync with my webhost.

[Source code for itunes_playlist]

posted by Author's profile picture mahiwaga

scattered thoughts

Random things I found on the web:

—Jakob Nielsen

</figure> The quote is from a page of quotes about XML. It’s kind of interesting. It’s somewhat philosophical, and definitely touches upon epistemology. Knowing how we know what we know should define how we structure information, just because it would be the path of least resistance, I think.

posted by Author's profile picture mahiwaga

retrograde consolidation revisited

Yeah, maybe I need a better name. I really didn’t give it much thought. Hell, maybe there’s already a name for it. I’m trying to think of a term for the phenomenon of returning to an older technology because it’s actually better than whatever we got. And it’s not mere regression into the past. The old technology gets adapted to whatever new challenges we face. Often times, the old technology is merely a shell, a vehicle, for what really is new technlogy. It looks like an Apollo Command Module, but it’s designed with 21st century technology. Sometimes the “old” technology only continues to exist in an abstract (though still palpable) sense, although the real nitty-gritty is all new stuff. (I am thinking of UNIX, which, on one hand doesn’t really exist, but on the other hand, is proliferating everywhere.)

Probably because I’m using Blosxom, the power of plain-text is on my mind, as I mentioned previously. And so I spotted this quote:

The problem is, once we store data in a non-transparent, inaccessible format, then we need code to read it, and that code disappears. Code is disappearing all the time. You probably can’t go to a store and ask for a copy of Word 1, or whatever the first version of Word was called. So we are losing vast quantities of information, because we can no longer read the files.

One of the reasons we advocate using plain text is so information doesn’t get lost when the program goes away. Even though a program has gone away, you can still extract information from a plain text document. You may not be able to make the information look like the original program would, but you can get the information out. The process is made even easier if the format of the plain text file is self-describing, such that you have metadata inside the file that you can use to extract out the actual semantic meaning of the data in the file. XML is not a particularly good way to do this, but it’s currently the plain text transmission medium du jour.

Another reason for using plain text is it allows you to write individual chunks of code that cooperate with each other. One of the classic examples of this is the Unix toolset: a set of small sharp tools that you can join together. You join them by feeding the plain text output of one into the plain text input of the next. There’s no concept of trying to make sure the word count program outputs things in a format that’s compatible with the next tool in the chain. It’s just plain text to plain text, and that’s a very powerful way to do it.

—Dave Thomas Plain Text and XML

The mention of UNIX has me thinking about the evolution of operating systems, too. UNIX as a concept has been present for 30+ years. Maybe because I went to UC Berkeley, in the mid-to-late ’90s, most of the computers still ran some variant of UNIX. (Although, ironically, they didn’t run BSD.) I remember the sense of incredulity I had when Windows 3.0 came out in 1990, and everyone was excited, as if a windowing system had never existed before, when I had known for a fact that they were already deployed and quite powerful (I ran GEOS on a Commodore 64, and I remember playing around with Workbench on my friend’s dad’s Amiga. I never saw a Macintosh until I was in college, and that was when I was already an x86 chauvinist. Although, I did run Linux briefly even before Windows 95 came out.) Obviously, Microsoft had much at stake with trying to spread the FUD that UNIX was dead, despite the fact that it or some of its genetic and symbolic offspring ran almost all of the Internet. But in the past few years, the OS world seems to have come full-circle, with Apple deciding to build Mac OS X on top of BSD. The only remaining (quite significant) hold-out is the Microsoft World, and even there, UNIX toolsets have established a foothold.

One OS to rule them all.

posted by Author's profile picture mahiwaga

gorillaz "m1 a1"

I’m not the only one, apparently, but the beginning of this song totally makes me think of the opening sequences of “28 Days Later.” I mean, the lyrics do talk about zombies.

posted by Author's profile picture mahiwaga

27 – third time pays for all

It really sucks that after 25, birthdays aren’t nearly as good. The big 3-0 just looms a little too close, and you’re not old, but you’re a little too old for the club (to steal a line from Chris Rock.) When the age difference between you and a Playboy centerfold approaches a decade, you know things have got to change.

I am a bitter, bitter man.

But at least i have energy. (‘cause once you get tired, you will get sucked down into the vortex of hopelessness. It’s like a treadmill. Or trying to outrun a crumbling bridge, Indiana Jones-style. You’ve just got to keep moving even if all your muscles are turning your blood into battery acid.

I will not bitch too much about the fact that (despite the sincere apologies and excuses) three different women declined the invitation to hang out on my birthday.

I give up. There is no use swimming against the current. I might as well enjoy the ride.

I must say that dinner was pretty good. You can’t really go wrong with sangria. But we hit the liquor a little too early, and by 1:00 a.m. we were mostly non-functional. It was a good thing that we went home when we did, because the remainder of the evening included a good number of blank spots. Like, I don’t remember how i got into bed. The last thing I remember clearly is throwing down a throwpillow onto my hard wood floors and lying down because the floor was so cool and I felt like I was burning up. Oh, and drinking out of a Pyrex measuring cup. I think I was honestly trying to read Perl documentation in my drunken stupor. When I woke up this morning, I found at least thirty webpages open in my browser.

To help me get to sleep, I do remember putting “Piggy (Nothing Can Stop Me Now)” by Nine Inch Nails on repeat. “Nothing can stop me now, ‘cause I don’t care anymore.”

The red hot anger and bitterness has dissolved into morbid apathy and brooding self-loathing. None of this matters, really, and all I’m doing is torturing myself.

As my oldest friend once advised me: Fuck it.

There are things I need to take care of, and while, it’s true, my future does rest upon me getting these things done, if I don’t, I don’t.

I feel all stretched and thin, and there ain’t any more slack left to pull on. Times like this, if you don’t want to snap in half, something has got to give. You’ve got to let go, and fall, and pray to God that you’ll hit the ground running.

Only hope can keep me together. Love can mend your life, but love can break your heart. (Thank you, Gordon Sumner.)

Whatever. There are worse things in life than being alone. I guess.

posted by Author's profile picture mahiwaga