Saturday, September 9

Downloading the New York Times Crossword with Automator

Wordplay got me into doing crosswords. If Jon Stewart, Bill Clinton, and the Indigo Girls are all into something (not to mention Ken Burns) I’d be crazy not to be all up on that. I bought the yearly online subscription to the New York Times puzzle and have been doing (attempting) it pretty much every day.

I made a workflow with Apple’s Automator to download each day’s puzzle from the Times’ website and print it out. If you’re in a similar position as I (you have the subscription, Across Lite, and Mac OS X 10.4) then give it a try: Print Crossword.workflow.

The overall workflow is pretty straightforward:
  1. Start with the New York Times crossword page URL
  2. Download the page, with proper authentication
  3. Find the URL to today’s puzzle
  4. Download today’s puzzle
  5. Open today’s puzzle
  6. Print today’s puzzle
There were two tricky bits at #3 and #6, which I had to solve using shell scripting and AppleScript, respectively.

While Safari scripting does a fair amount (I was happy it took care of using my NYTimes.com cookie for the authentication), it doesn’t handle #3, which actually surprised me. The task I needed is to get the URL linked to with the words “Today’s Puzzle.” Here’s the script I used:
grep -o "<a href=\"[^\"]*\">Today's Puzzle" $1 | sed -n -e "s|<a href=\"\\([^\"]*\\)\".*|http://select.nytimes.com/premium/xword/\\1|p"
rm -rf $1
Yeah, it’s a bit of a hack but it works. (If anyone has a better line, please leave it in the comments.) The grep is there to cut down on the data going in to sed, since sed will print out the unmatched start of the line (and matching the start with a regexp is too slow).

I was impressed with how simple it was to include a shell script in the workflow, given the typing going on. But “Files/Folders” became a path, and the stdout text became “URLs” for the next step. Neat!

Getting Across Lite to print the puzzle was the second tough bit. Across Lite is a reasonable program, but, as is often the case with ported software has no AppleScript support, so I had to fall back on GUI Scripting instead of the standard “print” command. Here’s the code:

on run {input, parameters}
set xfile to item 1 of input

tell application "Finder"
open xfile
end tell

tell application "Across Lite v2.0"
activate
end tell

tell application "System Events"
tell process "Across Lite v2.0"
click menu item "Print" of menu "File" of menu bar 1
keystroke return
keystroke return
keystroke return
end tell
end tell

tell application "Across Lite v2.0"
delay 10
quit
end tell

tell application "Finder"
delete xfile
end tell

return input
end run
Not too much to say here. Three returns to get through the print choices, Page Setup, and Print dialog boxes, and a ten second delay to prevent a crash.

And there you go! I saved this as an iCal plug-in and scheduled it to go off every day at 7AM. Though, to be truthful, I could probably turn it off for Fridays and Saturdays… But now every day when I wake up I have a crossword puzzle to take with me to do on the shuttle.

Monday, September 4

Feed Reader Feature Request

I was reading through maybe the third or fourth article in my feed reader about the MySpace music shop, thinking about how I really didn’t care about this particular story, and I didn’t want to read any more about it. Then, when I saw Tim O’Reilly’s piece on Google’s image-tagging game, I thought that it was interesting, and that I’d like to hear what other people have to say about it.

So I want two new operations in my feed reader. “No More!” would mark all other blog posts on a particular subject as read. “What’s All This, Then?” would dig up blog posts about the same subject from other blogs that I haven’t subscribed to.

“No More!” would help me deal with the incoming volume of news, and maybe put a few echo dampeners in the chamber. If my feed reader quickly cut out stuff I don’t want to see any more of, reading the news each day would be that much more enjoyable, since there would be that much less to wade through.

“What’s All This, Then?” would let me easily dig deeper into cool topics right from my feed reader, and help me find new blogs I might want to subscribe to. When I’m reading, I want to stay in the same app. I don’t want to go trawling through search engines to get more info, when everything I want is probably in the reader’s backend.

These two features come down to looking at one role of a feed reader as a — to coin a phase — canal of topics rather than a firehose of posts. My desire is to #1: hear the latest and #2: hear particular people’s take on such. If I don’t care about the story, then I don’t care what even the most insightful luminaries have to say on it. But if I am interested in the topic, give me anything and everything related to it.

Sunday, August 27

Authenticating to Google Accounts from the Command Line

The beta version of Blogger uses GData for its API and Google Accounts for logins, which means that it requires the GoogleLogin authorization scheme on API requests. This is more secure, but slightly tougher to work with than HTTP Basic authorization.

Sure, there are libraries (Java and C#) for handling this, but where’s the fun in that? Here’s how to do the API using just curl and sed, in a delightful one-liner:

curl -H "`curl -s -d Email=e-mail address -d Passwd=password -d source=your app name -d service=blogger https://www.google.com/accounts/ClientLogin | sed -n -e \"s/Auth=\(.*\)/Authorization: GoogleLogin auth=\1/p\"`" http://beta.blogger.com/feeds/blog id/posts/full

Note that for the e-mail address, you’ll need to replace “@” with “%40” as per URL encoding.

Goldman's Gone


Goldman Bores Biz
Originally uploaded by OldMainstream.
Not to get sappy or anything, but I love this photo of Jason Goldman. It is a rare photo of him that he's not mugging it up, and I think a lamer, more emotional me would go on about how this is the true Goldman, and it's special, and precious just like he is, and no one knows him like I do.

Really, though, I like this photo because I know that, consistently, if Goldman's talking like that, I'm laughing one or more asses off because dude is hilarious.

So it's not so much that I'll miss him now that he's left Blogger, it's more like I welcome the gentle kiss of death so that we can be united again for eternity.

Wait. I think that came out wrong.

Friday, May 5

Greasemonkey Scripts I Want

Thought I’d toss out something just to make sure I didn’t forget how to type. These are Greasemonkey scripts that would be nice to make or find already made:
  • Blogger Blog Link Emblem The deal here would be to add the Blogger icon () to any link that pointed to something at *.blogspot.com. Very useful for harvesting potential Blogs of Note. Extra props if it could do the same for blogs not hosted on Blog*Spot, but the logistics of that get tough.
  • You’re Already Subscribed To This I’m on a boardgaming kick, and as such I’m assembling boardgaming blogs in Reader. I can’t remember which blogs I’ve added, though, so I have tried to add the same ones multiple times. Often I read several posts before I realize that I read them all before. If I go to a blog I already have in Reader I’d like to see a message pop up so I don’t try to add it again. (Update: Mihai whipped it up! Sweet!)
  • Social Bookmark Niagra It would be cool to have a Greasemonkey script that added all the social bookmarking icons to every page I read, cuz sometimes people forget to put them all in. Then I have choices! Will I del.icio.us this one? Or maybe send it to Furl? ONLY THE BEST SITES GET SENT TO GETBOO.