Ah, glorious Thursday. Not even close to the end of the week and I’m writing a wrap-up of my week so far. Want to know why?
My project is broken.
Yup, absolutely broken. Well, it works up to a certain point (and was really fun writing!) but there’s no logical way to finish it.
Recapping
This week, I was spending the majority of my days getting myself setup on Python and writing a script that accesses the Last.FM API to grab all of my scrobbles throughout the years, categorize them into genre, and present the data by year to visualize the change in my musical tastes over the years.
Everything went well until the “categorizing into genres” part, because… trying to pin a single genre to an artist is apparently very difficult. Last.FM doesn’t use “genres,” they have tags that are user applied and include a high level of variance. MusicBrainz, which Last.FM utilizes (I believe) also uses tags. Scraping Wikipedia and AllMusic resulted in gigantic piles of genre for each artist, so I’ve resorted to a more manual version: I tag them all as a specific genre by hand.
It hurts. Right in the wrists. (And the feels.)
However, this week has been a really fun experience and only makes me look forward to the next project. Before I talk about that, there are some important lessons I learned throughout the week.
1) Homebrew and pip are your best friends.
Writing basic scripts in Python? Yeah, that’s no sweat.
Want to write more complex scripts that might require external libraries? Yeah, have fun compiling and installing that stuff.
Well, okay, in actuality, it’s still relatively simple. But compared to typing ‘pip pymongo‘ into the terminal? It’s quite a bit more complex!
With homebrew and pip, I managed to get MongoDB onto my development machine, install the PyMongo driver, and install the unidecode library. In a matter of seconds.
Sa-weet!
2) Unicode can burn in hell.
I spent the better part of today and yesterday figuring out how to wrangle with unicode. A few of the artists from my scrobble list have Asian characters in their name on Last.FM, and Python (or MongoDB) automatically turns them into their unicode representations.
That’s all good and well, but turning them back (and using them in functions) is an absolute nightmare. Thank goodness for unidecode for (temporarily) solving that nightmare.
3) MongoDB is pretty awesome.
During the project, I was able to pull my scrobbles down from Last.FM but I wanted to insert them into a database.
I’m used to working with MySQL so I attempted to get that up and running. Well, after half an hour of yelling at my computer, I decided to take the lazy route and check out my alternatives that might be quicker. The suggested alternatives were SQLite or some sort of NoSQL solution. I figured it would also be a good opportunity to try out those fancy datastores I kept seeing on Hacker News and settled on MongoDB.
Got it up and running within minutes on default settings, and it’s been pretty smooth sailing so far. Inserting and retrieving data has been a breeze (my dataset is only 50,000 items) and I have enjoyed the experience.
I’m not skilled enough (yet) to really grasp the differences between the different types of datastores, and I make no attempt at doing so. I was just enamoured by the incredibly short amount of time it took for me to get up and running on Mongo.
4) I took breaks by learning Spanish.
I’ve been experimenting with the Pomodoro technique (25 minute sprints, 5 minute breaks) and it’s been a really good way of creating hard deadlines and stop-points for work.
However, I generally surf during breaks and get carried away for more than 5 minutes, so I wanted to do something that allowed for shorter bursts.
Enter Duolingo.
It turns out, doing one or two lessons on Duolingo were perfect – I would sit here shouting Spanish phrases and words at my computer and laughing all the while, and my alarm would go off and I would get right back into the work.
As a result, I’ve familiarized myself with basic Spanish words and phrases, and I am working my way through as much of the Spanish portion of Duolingo as I can. It’s a win-win situation, as far as I can tell!
Want to follow my Spanish-learning progress? Check out my profile on Duolingo.
Here comes week 2!
I haven’t decided exactly what project I’ll be working on next week, but I would really like to focus on starting to incorporate tests into my code. I’ve been ignoring them for now because I figured it would be beneficial to familiarize myself with syntax over anything else.
However, if I want to get any better at this, I’ll have to learn to write code that isn’t complete crap and I think tests would be a good place to start.
In the mean time, I’m going to try to categorize my music and complete my musical visualization. Thanks for reading my weekly brain dump!