Interesting email from Barnes & Noble.

Interesting email from Barnes & Noble.

My iPhone home screen.

My iPhone home screen.

Matt Gemmell:

Good SEO is a by-product of not being a dick on the internet.

How to Make Yourself Use Python 3

Python 3 is the future. Since I don’t have any kind of massive legacy codebase to support, there’s really no reason I shouldn’t be using it. If you, too, would like to force yourself to use Python 3, here are three simple steps you can follow that won’t screw with the system Python installed by Apple.

  1. Download and install Python 3 from Python.org.
  2. Open Terminal.
  3. Type the following command:
    echo "alias python='/usr/local/bin/python3'" >> ~/.bash_profile; source ~/.bash_profile

Now every time you type python at the command line, whether it’s to run a script or enter the interactive interpreter, you’ll be using Python 3.

Weekend Project: Steal This Book (Cover)

Disclaimer: Let’s get this out of the way up front. The gist of what I describe in this post is probably against Amazon’s terms of service. So don’t be an idiot.

I own about 1,000 books. For years I’ve used Delicious Library on my Mac to catalogue them all. If you’re unfamiliar with Delicious Library, it’s the best cataloguing app you can buy for the platform. To my knowledge, it was the first to let you scan the barcode of a book and then automatically download all the information, including the cover image, from Amazon. You can do the same for movies, video games and even tools.

When the iPhone was released, I waited patiently for a mobile version and Wil delivered. There was much rejoicing. But the dream was over almost as soon as it began. Amazon changed their terms of service to disallow using their information in mobile applications, the app went away, and the ability to sync to the iPhone client was removed from the desktop version.

Since then I’ve been trying to find a solution that would allow me to have access to my entire library on my iPhone. For a long time, I lived in a state of denial and kept the Delicious Library app on my phone, but it was pretty useless without the ability to add new information to it. I tried exporting flat html files from Delicious Library to Dropbox and then syncing with Good Reader. It worked, but it was impossible to search so I found myself tapping repeatedly to manually find the information I was looking for.

The ideal solution (besides a working Delicious Library app) would be to create a database on my Mac that I could sync with my iDevices. It would also allow me to add new books on the device and then sync the updates back. Bento seemed perfect for the job, since I have it everywhere, I just thought actually creating the database would be a huge pain so I never bothered. But it’s amazing the things you’ll do when you’re completely bored on a weekend. Step one was to export a .csv file from Delicious Library with just the basic information (title, author, ISBN, publisher) and then import it into a new Bento library. Easy. That wasn’t enough though. I also wanted to have the cover images and you can’t export those from Delicious Library.

So the question became how to easily obtain the cover images for almost 1,000 books. Obviously searching Google Images wasn’t going to cut it. But Google did lead me to this excellent Abusing Amazon images article by Nat Gertler that describes in awesome detail the various URLs that Amazon uses for its cover images. With that information in hand, all I needed was the Amazon item IDs for all of my books. And it turns out that the item ID is one of the many things that Delicious Library keeps in its database. Exporting a file with just that field was trivial.

Now I had all the pieces: a generic image URL and a file with all of the Amazon item IDs. The Unix utility curl comes with OS X so I could use that to download the files. All that remained was to find some glue to put it all together. And my glue of choice is Python (you could do it in perl or Ruby and probably even AppleScript, but I stick with what I know best).

After reading a little documentation and experimenting with a subset of my item ID file, my little script was ready. I let ‘er rip and after about an hour I had a folder full of book cover images. I still had to add the images to Bento manually (since it appears that AppleScript support is not a high priority for the developers), but it sure beat having to download them all manually too. It also didn’t work for every book, and the image quality varied, but all in all it saved me a lot of time. The final script, cleaned up and with some features added, can be found on my GitHub.

Another thing I found while I was working on this is Delicious Library’s Scanned UPCs Log file. It basically keeps a record of the ISBNs for the books you’ve scanned into the application. I could see eventually modifying my script to read the most recent entry in the log and automatically download the cover. That would take some time to figure out Amazon’s API and the various Python libraries for working with it.May make for another fun installment in the Weekend Project Series.

In the end, this entire process could have been avoided if Amazon would just let us use their data in mobile applications. But since they won’t, I don’t feel entirely guilty about “stealing” it. Wouldn’t it be nice if they gave us some kind of library functionality, similar to what they’re doing with Cloud Drive or even extending the current Wish List? Why couldn’t we just upload a file with a bunch of ISBNs and then have a nicely formatted list show up in say Amazon’s iOS apps? It would be awesome, but I won’t hold my breath.

Now With 100% More GitHub

I’ve had a GitHub account for years and never used it for anything other than casually following a few projects (mostly because I think mercurial is a better solution than git). Since I’ve started posting some code here, and discovered GitHub’s gists, I’ve decided to try making more use of the site. My main page is here and my Open in Marked AppleScript now lives here.

The Storm’s Aftermath

As I’ve mentioned before, my basement gets water when it rains. Two weeks before anybody even suspected hurricane Irene, we were getting estimates for waterproofers. Due to our procrastination and indecision, we didn’t choose a company until the week of the hurricane and unfortunately they weren’t able to get to us until the following week. So I had plenty to keep me occupied down there in the days after the storm. But they came as scheduled and fixed everything. We’ve had a bit of rain since then and not a drop of water in the basement.

Here are a few poorly lit iPhone photos of the process.

Before:
before

During:
during

After:
after

Evolution of Apple’s Laptop Packaging

If you follow me on Twitter, you may have seen that I had some water troubles due to hurricane Irene. My basement basically takes on water like the Titanic after it hit the iceberg, so in preparation for the storm’s onslaught, I went down and did some strategic rearranging. Amongst the things I decided to take out of the basement permanently are the boxes from every new laptop I’ve bought from Apple since I switched in 2003/2004 (yes, I’ve kept them all now stop looking at me like that):

laptops

From bottom to top:
  • 12” PowerBook G4 (9/04)
  • 15” MacBook Pro (5/06)
  • 13” Black MacBook (5/08)
  • 13” MacBook Pro (8/09)
  • 13” MacBook Air (8/11)

Based on my purely unscientific measurements, you can fit three 13” MacBook Air boxes in one 12” PowerBook box. The width difference between the 13” MacBook in 2008 and the 13” MacBook Pro just a little over a year later is also noticeable; the MacBook is closer in size to the 15” MacBook Pro.

I don’t have any earth shattering or novel conclusions to draw from this. In fact I’m sure other more capable writers have pointed this out. And we all know Apple has been on a quest to make everything smaller and thinner. They don’t include any of the fancy adapters or other accessories that they used to, for example. I just thought it was neat to see the changes up close and personal in my living room.

2011 Won’t Be Like 1985

I’ve had two days to digest both the news that Steve Jobs was resigning as CEO of Apple and the torrent of news articles and blog posts that followed. Two days to contemplate what the post-Jobsian landscape might look like for the company and the world. Two days to hone a fitting tribute to a monumental man.

But I’ve got nothing.

Maybe it’s because I don’t think anything is really going to change. Don’t get me wrong, we’re probably not going to see another leader like Steve Jobs in a very long time. I’m going to miss his genuine enthusiastic wonder at the “awesome” and “magical” products he unveiled at every keynote. We’ll have no more apocryphal stories about anonymous Apple employees getting on an elevator with him, only to be fired for the sin of working in a department he happened to hate that day. But those are small concerns, ancillary to the real reasons I love Apple and its products: they’re beautiful and they work. That’s why I left Linux for the Mac.

Sure Steve probably had a lot to do with why Apple’s products were so attractive to me, but this is not going to be in any way similar to the last time he left the company. The culture at Apple has undergone a complete transformation over the past fourteen years and they are not going to shit the bed just because the letters CEO are on Tim Cook’s business cards instead of Steve Jobs’. The company is significantly more profitable than it was in 1985 and has a gazillion dollars just sitting in the bank. Steve is not a vice-president being forced out of the company because Mac sales are slumping, he’s stepping aside willingly as a CEO at the top of his game. The man is not dead, and also, he’s not really leaving. He’s just moving upstairs.

The Voice of Jobs will still be heard in the hallways at Infinite Loop and his vision will shine through in every product that Apple releases in the foreseeable future.

What’s your hardware/software setup look like?

A brand new, specced-out MacBook Air, an iPad 2, and an iPhone 4.

I do 95% of my writing on the Air using Byword and MarsEdit. I do most of my reading on the iPad using Instapaper and Reeder. And I do most of my Twitter checking on my iPhone with Tweetbot.

This is pretty much my exact setup (excepting of course that Shawn writes a hell of a lot more than I do). Glad to see I’m in good company.

Speaking of AppleScript

While I was writing the previous post, Gabe at Macdrifter posted a link to this AppleScript for Python Programmers guide. I immediately Evernoted it.

I also found this nifty little command line utility to convert an AppleScript to HTML. Adding the CSS to Tumblr was easy, but I’m still working on an automated solution for creating the HTML and then getting it into MarsEdit. For now I have two shell script services set up in the Finder to make it a little more efficient. Of course I’m probably expending more effort trying to find a solution than the amount of AppleScript code I post justifies.

Byword and Marked: Perfect Together

I love me some Markdown. If I’m writing it on my iPhone/iPad, it’s in Elements. But on the Mac, I like Byword. It’s simple, effective and visually striking. And while it does have a nicely done preview mode, you can’t view it concurrently with the marked up document. That’s mildly annoying.

Enter Marked by the always awesome Brett Terpstra. Marked is an application that lets you preview what a Markdown file will look like when it’s all prettified (amongst other things like exporting the html or making a PDF). So problem solved, right? Just open the document for writing in Byword and previewing in Marked and I’m done. Yes, well, mostly. It’s not quite as streamlined as I’d like it be.

The standard way to view a document in Marked is to either

  1. drag the document’s icon (from the Finder or, if it’s open in an editor, the title bar) to Marked’s icon in the Dock or

  2. launch Marked and do a File → Open.

This is probably fine if I’m going to be working on an existing document and set everything up before getting to work. But if I’m in the middle of a furious writing spree on a new document, I don’t want to take my hands off the keyboard. And thanks to the magic of a stupidly simple AppleScript and Red Sweater’s FastScripts I don’t have to.

So without further ado, here’s the script:

tell application “Byword”

set theDocument to file of document of window 1

end tell


tell application “Marked”

open theDocument

end tell


Stupidly simple. I just saved the script as ~/Library/Scripts/Applications/Byword/Open in Marked.scpt and set a keyboard shortcut in FastScripts. Now when I’m in the middle of writing, I just hit ⌘S to save the document (otherwise Marked has no file to open) then ⌘⇧M to activate the script and I’m all set.

Update: The folks behind Byword released a css style sheet specifically for Marked at almost the exact time I posted this. Nifty.

Update 19 Sept 2011: Brett has released the Marked Bonus Pack. It probably does a lot better of a job than my silly little script.

Patrick Rhone on what companies (like HP) should be doing instead of trying to copy the iPad:

Create. A. New. Option.

Make the iPad as irrelevant as the iPad seems to be doing to the consumer PC.

Spot on.

Evolution of the Hipster. (via Laughing Squid)

Not something I see myself using regularly, but a nice little tip by Matt Gemmell.