Author Archive

Fun with the Last.fm API, python and Wordle

Monday, May 11th, 2009

I’ve been looking for a reason to hack around with python. Recently, my friend @smbrown published a post on his The Monkey Represents Sharing blog entitled Wordle visualization of my Tweetstream where he used a python script to archive his Twitter stream which he then used to create a Wordle, or a visual representation of the frequency of terms used in a collection of words. Words that you use most often are relatively larger than words used less often. Tag Clouds such as these have been around for quite some time, but what sets Wordle apart is its ability to arrange words both vertically and horizontally and even nest small words inside the actually letters of larger words. This got me thinking… “I wonder if I could do the same with data I have scrobbled to my last.fm account”

I started by reading up on the Last.FM API and getting myself an API key so that I could access the data held on Last.FM’s servers. I targeted the user.getTopArtists API call because I thought that would make for an interesting Wordle. Looking over the script used to archive your tweetstream I noticed a python library called Beautiful Soup was used to parse the XML returned from Twitter’s servers. I used Beautiful Soup to parse the top 50 artists from my Last.FM account and their respective playcounts returned from the API call. I looped over that data and exported it to a text file which I then Wordled. The results are below:

lastfm-artists-total-20090511

Click the image to enlarge

Here is the python code:

Notes

I wasn’t sure how Wordle would handle phrases. At first, I noticed that Artist Names like The Flaming Lips were broken up when Wordled. I tried wrapping the artist’s names in quotes but Wordle removed the quotes. I also tried joining the individual words of the phrases with + (plus) signs. This approach kept the words together, but Wordle rendered the plus signs. I eventually found that non-breaking spaces (%nbsp;) would work.

Here is another Wordle I created by making an API call for user.getWeeklyArtistChart which shows who I have listened to so far this week:

lastfm-artists-recent-20090511

Click the image to enlarge

Wordles

Here is a sample of all of my Wordles to date#.

The Sadecki’s are moving!

Monday, May 5th, 2008

We have decided to move closer to our work in an effort to cut down on time spent commuting so that we can spend MORE time with Ruby.
We accepted an offer on our home just last week and have picked out a
new place to live in Jamaica Plain. The new place in JP is just 2 miles
from Nancy’s office, and 5 miles from Mark’s.

The new place is much smaller than our old one, so we have a lot of stuff to liberate.
We have started a new website for everything related to this move. You
should check it out! We have posted some pictures of the new space (as
well as the old.)

http://moving.sadecki.com

Hiking with Ruby

Sunday, December 30th, 2007



Hiking with Ruby

Taking tumblr for a ride

Sunday, December 30th, 2007

Looking for more convenient ways to make posts to this blog. I’m mainly looking at twitter, jaiku, and now tumblr. They all have their pros and cons. Now I have to play with integrating them into sadecki.com

Using scp to copy files/directories with spaces in their names

Friday, September 7th, 2007

While trying to copy a directory recursively from one machine to another on a network using the scp command I ran into a problem I have never encountered before. I suspected that the spaces in the directory name were causing the problem so I tried the usual escaping options. First I tried escaping with quotes:

$ scp -r user@ip1:~/tmp/"The Office Season 3"/ user@ip2:~/tmp/

That didn’t work, so I tried escaping with escape characters:

$ scp -r user@ip1:~/tmp/The\ Office\ Season\ 3/ user@ip2:~/tmp/

Same result. After searching online I found a post that suggested trying both at the same time:

$ scp -r user@ip1:~/tmp/"The\ Office\ Season\ 3"/ user@ip2:~/tmp/

That did it! Check out the scp man page for more on using scp.