September 30, 2007

More grepping - mp3’s this time!

So my personal laptop’s hard drive recently bit the dust, or so I think. I haven’t had time to bring it in and get it checked out…but it doesn’t boot and it makes a strange, repeating sound that doesn’t sound so good when I try to boot it up. It’s not a clicking, per-say, but more of what seems like a failure of the actuator arm trying to move across the platter. …but what do I know?

In any case, I’ve been managing my music libraries across a couple different computers but since my personal one went down I’ve been looking for a way to re-populate some of my smart playlists that were based on comments. One of the most common ways I use these is for categorizing dance music. For example, if I’m listening a song and I think it’s a good swing song I’ll update the comment to include “Dance, Swing”. And then I just have a Smart Playlist that looks for comments with Swing in them.

The problem is, many of these songs weren’t in my other library. I keep most of my music on a shared server, so luckily I didn’t lose it. But what I wanted to do was go through my music library (several thousand songs as of this writing) and figure out which songs I had tagged with those specific Dance comments. The UNIX command-line to the rescue!

There’s a tool out there called id3v2 that reads ID3 information from mp3 files (the majority of my collection). Using that and the wonders of find and grep, I was able to list out which files contained the Dance comment:

find /mp3/ -name "*.mp3" -exec sh -c 'id3v2 -l "$1" | egrep "COMM.*Dance.*" && echo $1' '{}' '{}' \; | tee dance_mp3.txt

I had to do a little fu to be able to use pipes in the exec command, but I found out how to do that on this useful article.

I wish I had been syncing playlists (among other useful things…:-() before the drive failure, but alas…

*zoom*

Life goes by pretty fast. If you don’t stop and look around once in a while, you could miss it.” — Ferris Bueller

It’s been two weeks since I last posted. What the heck have I been up to? Well let’s see. I worked most of the weekend of the 15th on a visualization project I’ve been working on at work. We had a little conference on the 20th where I presented the results of my work and research. I spent the days (and nights) leading up to the 20th also working on the presentation and supporting tool. It was worth it, though, as I think the presentation was pretty well received.

I then spent the weekend of the 22nd spending time with two awesome friends and standing at the groom’s side at their marriage. I, unfortunately, didn’t take many pictures but I posted a few pictures of my weekend in SLC on Flickr.

I was originally supposed to be in San Francisco this past week, but I got an email Friday morning (just before I left for Salt Lake) saying I was supposed to be at a client in Seattle at 9am on Monday morning. This made for an interesting Monday as I was leaving SLC at 7am. But I made it on time, and then spent the rest of the week pulling some long nights for that client.

I’ve been able to slow down a little bit this weekend but I’m still crazy busy. We had a company event Friday night that kept me out until the wee hours of the morning and I hung out with some friends last night. Today, I’m chilling in the coffee shop and trying to code but lacking some motivation. Later this week, I fly down to Dallas and then out to Toledo for a wedding this weekend. And then I’ve got a little family vacation coming up on the east coast as well. Me? Slow down? Not anytime soon. I’m enjoying myself, but don’t worry if you don’t see me posting for a while. ;o)

September 14, 2007

Grepping emails

And people wonder why I love Unix/Bash. I had to combine a few different files yesterday that had email addresses, but with different delimiters and a bunch of dupes. This basically goes through those files, standardizes the delimiters, sorts it in a fashion to get find the emails with the most info, uniq’s out the dupes, and then reorders it into a csv file.

Schwag.

sed 's/:/,/g' Email\ List.txt | tr -d "'" | sort -r | awk -F, '{print $2"\t__"$3"\t__"$1}' | sed 's/^[ ^t]*//;s/[ ^]*$//' | uniq -f2 | tr -d "__" | sort | tr "\t" "," > Emails.csv

September 6, 2007

Quick Comparison of Numbers vs. Excel/Google Spreadsheet

Being the Apple neophyte that I am, I’m always looking to compare my ability to achieve things in the Mac world as opposed to other worlds. My challenge this evening - creating a spreadsheet in iWork ’08’s Numbers application from an HTML table.

Source Data: Music sources from episodes of This American Life. I love the background music on TAL and was in search of some of the songs. I this metafilter post, which ultimately led me to the Wayback Machine as the TAL site has been updated since that post. I then wanted to get the list into a format I could use for some scripting goodness in the future.

This is a stunningly simple task in Microsoft Office.

  1. Open the web page in your browser of choice.
  2. Highlight the table in question.
  3. Open Microsoft Excel.
  4. Paste - the table is automatically formatted into two columns

It doesn’t get much easier than that.

I tried the same thing in Numbers tonight, figuring it would be no more difficult. Well, it was. Instead of pasting a table, it just pasted the two columns as one, each column one under the other. I looked around for a way to convert data to columns. No luck. I tried to paste it into Pages, do some find/replace magic and export to a csv file. Too much trouble. I tried copying the HTML source. Definitely the wrong thing to try. I tried searching the help. Yea right!

I finally got so frustrated (and I don’t have Parallels reinstalled yet as I reinstalled my MacBook today), that I opened Google Spreadsheets and decided to see if I would have any luck there. Using the same process as in Excel, I instantly had exactly what I needed in Google Docs. Color me impressed! Not only that, I was able to extract the data I wanted using the provided formulas. This really makes me want to implement that Firefox Google Docs encryption plugin I’ve been thinking about…

In any case, for the curious - here’s the finished product. Now I just need to work on that script. ;-)

I’m somewhat disappointed in Numbers. There was another simple task I was recently trying to accomplish where Numbers just wasn’t up to the task. It’s a great app, but it definitely needs a few more features before I can use nothing else.

September 4, 2007

dig verbosity

One of the things that’s always bugged me about the dig command is the standard verbosity when used with its default invocation. This has kept me using the host command for a while for generic lookups, but today I figured I should emerge myself into the greatness that is the dig command. After a brief google for something actually unrelated, I came across this great DiG HOWTO that answered all my questions and addressed all my misgivings. Now I can go forth and query the Internet as it should be.

September 1, 2007

Congratulations

Congratulations to the happy couple!

The Happy Couple

It was a beautiful day for a beautiful couple. It was even better to see all my friends again, some of whom I hadn’t seen since November of last year. It had been far too long and I regret not going back to Chicago more often to see my friends!