Latest links on Pinboard

My Pinboard RSS Feed

I have fixed my MP3 blog unzipper python script from the 30 Days of Python, so now it works under Windows as well as under Ubuntu. I’ve also made it so it automatically unzips any zip files in the same folder as it, so you don’t have to manually change the script whenever you drop in a new file. (Note: it doesn’t do any detection of whether or not the zip file is in the format that Caitlyn uses. Using it on other zip files will produce unpredictable results.)

0number of comments:

30 Days of Python: Days 20-30 » 0number of comments:

And we’re done! I have created 30 python scripts this month (only three of which were too lame to post). It’s been a lot of fun, and now I feel much more comfortable with using Python.

It’s amazing how easy python is to work with, really. Some of these tasks I expected to be pretty hard, but there are python modules to help you solve just about any problem.

Here are the last 11 scripts:

Day 20: Unpickled the object saved in Day 19.

Day 21: Created and tested a custom exception.

Day 22: One last lame script, sorry.

Day 23: Played a bit with the Twitter API.

Day 24: Parsed a file from the Metafilter Infodump to see who had the most deleted Ask Metafilter questions.

Day 25: Created an Metafilter Data Dump parser that loads most of the data into python classes (excluding comment data, favorites data, and contacts data).

Day 26: Created a script that uses the Google Maps API to determine which of several addresses is closest to a given addresses. (I’m hunting for an apartment.)

Day 27: Revised Day 25 and converted it into a module for easy use in scripts (like this one).

Day 28: Tried out a really easy to use python twitter module.

Day 29: Used python-markdown to convert markdown text into HTML.

Day 30: Revised 29; now it posts a markdown-encoded text file like this one to my blog as a draft using xmlrpclib.

Thanks to all the hard-working folks who make python and python modules available for everyone to use for free.

30 Days of Python: Days 13-19 » 0number of comments:

As you may have gathered, a lot of these scripts don’t do too much useful stuff. I’m using them as a teaching tool, trying things. Later, when I need to use one of these techniques, I can look through these scripts and get a brief reminder of how to parse an XML file or use regex in python or whatever.

Day 13: Figured out how to construct XML with ElementTree.

Day 14: Used regex to search a list of presidents for how many used middle initials in their names.

Days 15 and 16: Extremely lame scripts, not uploaded

Day 17: Download today’s transcript of a room in Campfire; not uploaded because on…

Day 18: Updated Day 17′s script to look up user names from the userid’s Campfire provides.

Day 19: Saved an Object using Pickle

30 Days of Python: Days 6-12 » 0number of comments:

Day 6: Wrote a disemvoweler to teach myself about how to accept command line arguments and how to use those nifty one-line for statements.

Day 7: Wrote a program that reverses the case of a block of text, to teach myself the basics of Python GUI programming using Tkinter.

Day 8: Wrote a Commute Cost Calculator to reinforce Tkinter stuff. Also tried out py2exe: verdict is Pretty Spiffy.

Day 9: Wrote a really basic counter class to make sure I understood how classes work.

Day 10: Wrote a script that converts all the pictures in a directory to 800px high/wide (saving the originals in a separate directory) and uploads these thumbnails to my server via FTP

Day 11: Wrote a script that converts a string to a QR Code (using the Google Charts API).

Day 12: Installed ElementTree and did some extremely basic XML parsing (using this XML file).

30 Days of Python: Days 4 and 5 » 0number of comments:

I’m subscribed to an excellent MP3 Blog. Every few days, she collects a bunch of music, writes some notes about each song, and puts it all into a big zip file. I usually find at least a couple of songs I like in each post.

I had been downloading the zip file, unzipping it, adding it to iTunes, then manually adding the notes about each song to the lyrics tab in iTunes so I could see them on my iPhone as I’m listening to them. This sort of repetitive task is what python is built for!

Day 4: A script that opens a zip file, finds the title for the album from the text file inside, collects the notes and track numbers for each song, and extracts only the MP3′s from the zip file. Not uploaded, because on Day 5…

Day 5: Updated Day 4′s script to assign the album artist, album title, lyrics, and track numbers to the song’s ID3 tags. (Note: you’ll need to install the mutagen library for this to work.)

That’ll save me ten or fifteen minutes a week.

EDIT: Oddly, this script seems to have worked under Kubuntu but not on my windows PC. I think something went wrong with the zip extraction process. All the MP3′s extracted on my windows machine with this script sound like they’re being played under water and with bursts of static. Weird.

30 Days of Python » 0number of comments:

A bunch of my friends are participating in a Thirty Days project this month: Every day in June, they’re doing something creative, like writing fiction, drawing dead astronauts, or taking photos.

I wanted to play too! My plan is to write 30 python scripts this month. It’s already helped me learn new things about the language. So far:

30 Days of Python:

  • Day 1: Wrote a quick-and-dirty tax calculator (input taxable income, get tax bill)
  • Day 2: Installed Python3 and got a python script to run on my server at JDHarper.com. (Not linked: it was basically a “Hello World” script. The trick was that my web host, a2hosting.com, only displays the output of python scripts if they are in the cgi-bin folder, if they have as their first line a shebang indicating where the python interpreter is, and if they print “Content-type: text/html” as their first line of output.)
  • Day 3: Set up a python script to process emails sent to a private email address: this one records their subject lines in a text file.

Hopefully, I will be able to come up with 30 different things to write this month!

Python Script: Auto Add to Instapaper » 0number of comments:

I like the Instapaper iPhone app for saving stuff to read from the Internet. It strips out everything but the content I want to read and makes it look really good on the iPhone.

It makes it a lot easier to actually read the content instead of just skimming through like I tend to do in Google Reader. There are some sites I read pretty much exclusively through Instapaper, like 365Tomorrows and A Guide to Moral Living in Examples.

Before, I had been selecting the Add to Instapaper option in Google Reader or using the Instapaper bookmarklet on each entry. But now, I’ve written a Python1 script that automatically adds each entry from an RSS feed to Instapaper.

If that sounds like something useful to you, feel free to download the AutoAddToInstapaper script. There are setup instructions in the zip file.

[1] I have been teaching myself Python lately; it is just a joy to work with. There are libraries for just about everything, and it’s a simple language to work with. Love it.