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).
From a Tom’s Hardware story about Foxconn, the company that builds Apple’s products (my emphasis):
Foxconn has been in the press a lot over the last few weeks because of a bout of suicides at one of its factories. The company has given raises; put nets up around the buildings to stop jumpers; hired councilors and exorcists; given more raises; and issued workers with a ‘no-suicide’ contract (though they took that one back because it was a little insensitive).
Employees committing suicide has become enough of a problem that management had to put nets up around their factory. What on earth goes on in those factories? Steve Jobs goes on about how magical the iPad is, but he failed to mention that it was some sort of dark blood magic that involved human sacrifices.
Someone with cameras and satellite feeds ought to investigate.
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.
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!
I mentioned the awesomeness of QR codes a couple of posts ago. I’ve found a pretty good iPhone QR scanner called iRobin, and it’s free for the next couple of weeks. It doesn’t appear to be routing the URL’s through it’s own server like NeoReader was, and it can automatically follow links it finds, which is nice.
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.
I’ve just discovered something neat: QR Codes. These are basically 2D bar codes which embed data, usually URLs. So, for example, this is the QR Code for JDHarper.com:
Most Japanese phones (and apparently Android phones) can decode these QR codes natively; they’re used all over the place in Japanese advertising. There are a number of free iPhone apps that decode QR codes. I use NeoReader. [1] There’s probably a reader that works with your phone.
So, what can we do with QR codes, other than respond to Japanese advertising? Let’s say you’re looking at a link you want to pass to your phone. You can use the QRLink Firefox Add On or this bookmarklet to generate a QR code. Then read it using your phone’s decoding program. Way faster than email.
Semapedia suggests making stickers that link physical objects to wikipedia entries.
And you can store any text in these, not just URL’s, up to 4,296 alphanumeric characters. One suggestion I’ve seen is encoding your contact info into a QR code and putting onto your business card, although I have my doubts about that idea.
I feel like there’s a lot of potential in these things, but I don’t quite know what they might be good for yet. Any ideas?
[1]. Although I’m not thrilled that NeoReader redirects the URL’s through their website, presumably to track your usage for advertising. There are other options which I haven’t explored yet.
This is fascinating: These scientists are growing new organs and implanting them in people.
Prediction: Someone is going to use this for some really interesting crimes too. Fake your own death by planting an exact replica of your own heart in your enemy’s office.
If you run a blog using WordPress, you owe it to yourself to install the Hotlink Image Cacher Plugin. It’s my favorite kind of plugin: it automates a tedious task.
When you want to display an image that you find on the internet, there are two ways of going about it. First, you can just put the url for that image into an image tag (e.g. <img src="[URL]">). This is called “hotlinking,” and it’s considered bad manners, as you’re stealing someone else’s bandwidth, and it’s a bad idea since the person who’s hosting the image might change or delete it.
The right way to deal with images is to download the image to your computer, upload it to your own server, and link it from there. This way, you have control over the image and you’re not stealing bandwidth. But it’s kind of a pain, especially if you want to use several pictures.
This plugin automates good behavior: You set up your blog post using hotlinking. It automatically copies the image to your server and changes the img tag to point to your copy, and it does it without getting in the way at all. Awesome!
I just saw this fascinating TED talk about how an organization called Aravind is providing high quality, low cost eye care to India.
Let me spoil the punchline: They provide eyecare approximately equal to the United Kingdom’s National Health Service in terms of volume. Statistically, the quality is superior to the NHS in terms of complications. And they do it, profitably, at 1% of the cost of the NHS.
Their mission is to eliminate needless blindness. Instead of viewing eyecare as a business, Aravind seems to view it as a religious calling. From the video, their founder says:
When we grow in spiritual consciousness, we identify with all that is in the world, so there is no exploitation. It is ourselves we are helping. It is ourselves we are healing.
I think this has some implications for the health care debate in the United States.
In the US, health care is big business. At every step, everyone is trying to make a lot of money. Drug companies, hospitals, insurance companies–at each step, everyone is trying to grab their share of the profit, rather than focusing on healing patients.
Income is vital, of course. Doctors, nurses, technicians, researchers, ambulances, and all that need to be paid for. But I wonder what the system would look like if everyone in the health care supply chain, from drug companies and ambulance manufacturers to doctors and hospitals, did their work as non-profits instead of as companies.
What would it look like if health care providers in the US viewed patients as people to help instead of as profit centers to be exploited? How many lives and livelihoods could they save if they viewed health care not as a business opportunity, but as a moral obligation?