Skip to content

Drupal Case Study on MCR: FeedAPI, SimplePie Parser, and Cron

Last week at WBR, we re-launched the website for My Chemical Romance. The site’s built on Drupal 6.x and showcases blogs, photos, and tweets directly from the band members.

My Chemical Romance

To aggregate the Twitter feed, we used the FeedAPI module and associated SimplePie parser. Cron runs every 10 minutes to ensure the content stays fresh.

We hit a few bumps getting this all to work.

Feeds rarely updating
Initially, the feeds were scarcely refreshing. The problem was caused by SimplePie doing its own feed caching, with FeedAPI blissfully unaware. To fix this, I wrote a simple patch for parser_simplepie.module (under review as of this writing): http://drupal.org/node/341410

Cron not refreshing feeds
Cron, when invoked from a command-line PHP script, was failing to refresh the feeds. The cause was a default PHP setting of max_execution_time = 0.

FeedAPI uses max_execution_time to calculate its allowed time during a cron run. This value is always set when invoking PHP through the web, but it needs to be explicitly defined in any command line PHP script. This is solved with the following line of code:

ini_set('max_execution_time', 300); // Set to 5 minutes

Cron refresh rate set too high
FeedAPI sets a default cron refresh rate value of 1800 seconds. This prevents cron from refreshing the feeds twice within 30 minutes. For us this was too high (cron runs every 10 minutes). Lowering this to a more reasonable setting did the trick.

feedapi.module (lines 14-15):

// Minimum time that must elapse before a feed can be refreshed again on cron.
define('FEEDAPI_CRON_MIN_REFRESH_TIME', 300);

Everything is now running smoothly!

Tagged , , , ,

BADCamp Slides and Code

My BADCamp slides and code are available below.

Database Syncronization
http://badcamp.net/session/database-synchronization

Core Crazy
http://badcamp.net/session/core-crazy

Tagged , ,

Quick Look from the command line!

For all you Leopard users out there, here’s a handy trick to use Quick Look from the command line.

Leopard ships with a command called ‘qlmanage’. The -p option shows a preview of the file passed to the command. In the terminal, type the following:

qlmanage -p thefile

You can extend this by creating the following shell script:

#!/bin/bash
qlmanage -p $1 >& /dev/null &

The >& /dev/null prevents output from displaying, and the & runs the process in the background so a new prompt displays on the terminal.

Download it here.

Save this script as an executable file and store it somewhere in your PATH. I recommend naming it something short like ‘ql’.

(Note: I stored mine in a home bin folder used for custom-made scripts).

You can close the Quick Look window with the mouse (the conventional way), or close it in the terminal by getting the pid from the ps command and using kill [pid].

ql_on

Using the ql command in Terminal

ql_off

Closing the Quick Look window using the kill command

This feature is really handy for me because I spend a lot time in the Terminal. Many times I encounter a file such as an image, pdf, word doc, etc. that I’d like to briefly preview.

Before I discovered this, I would resort to opening Finder and navigating to the same directory to preview the file. Being able to do this all from Terminal is a real time saver!

[UPDATE]
A better solution is to use “$@” (with quotes) instead of $1 in the script. This will allow multiple arguments and wrap quotes around each one to account for spaces or other odd characters in the filename. Additionally, providing multiple arguments creates a slideshow in Quicklook.


#!/bin/bash
qlmanage -p “$@” >& /dev/null &

Spinwatch: Southwest (Finally) Apologizes To Mini-Skirted Customer

Spinwatch: Southwest (Finally) Apologizes To Mini-Skirted Customer: This is yet one more reason why I love Southwest Airlines. They admit to their mistakes and are “somehow” able to spin them into good PR opps.

My favorite personal Southwest experience earlier this year:

I was on a flight from San Diego to Oakland on Februrary 14. Halfway thru the flight, one of the flight attendants announces on the P.A. that Valentine’s Day is the Southwest’s favorite holiday and they have a special treat for us. Soon afterwards, another attendant starts walking down the aisle carrying a basket of chocolate hearts, handing one out for each customer.

A simple gesture, but a big one… especially considering they were (probably) doing that on every flight that day.

Favorite 2nd experience last year:

Our plane was late arriving to the gate, so to speed up the boarding time the attendants put a race clock by the gate ticking down from 14min. Our goal was to completely board the plane, stow away our luggage in under 14min. If we succeeded, one person picked at random wins a $50 voucher. We succeeded. Somebody one (it wasn’t me). Quite amusing.

Other moments include attendants singing Proud Mary when taking off from LAX, replace “rolling down the river” with “rolling down the runway”, and also landing in San Diego with the attendant pretending to be a jockey slowing down her horse. I think the more kids on a flight, the goofier the attendants get, but in a very respectable manner… if that makes sense.

Now if only they had satellite TV with a flight-tracker channel like Jet Blue. Oh, and WiFi.

How I Improved My Feed Reader, 2 Simple Hints

I use NetNewsWire as my main RSS reader on the Mac. Until recently, I had a hard time keeping up on all my feeds. However, I recently employed 2 tricks to greatly improve my productivity for perusing my feeds and finding the gems.

Tip #1: Flatten the Feeds

For the longest time, I tried hard to keep my feeds categorized: Apple, Tech, Blogs, Flickr, etc. Ultimately, this required too much cognitive overhead.

Where should I place a new feed? Does it need a new category? Where was that other feed I want to read? Under Tech? Blogs? etc…

The solution: Flatten the feeds!

Having one long list of feeds sorted alphabetically has been a huge help. Now I don’t have to think twice when I add a new feed, and I can easily scroll up or down to find a particular feed I want to read.

Tip #2: Create a hot key on the mouse for “Mark All As Read”

NetNewsWire has the Cmd-K hotkey for the “Mark All As Read” feature. This is useful for quickly committing RSS suicide. Additionally, it prevents you from having to increment through each story one-by-one to mark them as read.

I took this one step further by mapping my middle click mouse button to Cmd-K for the NewNewsWire app. I did this using the SteerMouse driver for the Logitech VX Revolution mouse.

Now I never need to lift my hand off the mouse. I can quickly scan through and mark off all my feeds at an olympic gold-medal pace.

Bonus Tip

I use the Combined View layout in my feed reader. The left column shows all the feeds, the right columns shows all the stories and the body text. This is in contrast to the Traditional and Widescreen Views, which require an extra click on the story headline to read the actual text. Not really a tip, but I thought it was worth mentioning.

My NewNewsWire Setup

[tags]NetNewsWire, rss, feed reader[/tags]

Rangers’ 30 runs sets AL record in rout of Orioles

ESPN - Rangers’ 30 runs sets AL record in rout of Orioles - MLB: The Texas Rangers beat the Orioles 30-3 today… and that was just game 1 of a doubleheader. My god!

They also won game 2 by a measley score of 9-7 (which is still high for San Diego standards).

By contrast, the Houston Texans didn’t manage to score 30 points in a single NFL game all last season.

PETA ranks Petco 10th most ‘vegetarian friendly park in MLB

San Diego Metro News | SignOnSanDiego.com — PETA ranks Petco 10th most ‘vegetarian friendly park in MLB: I find this story slightly ironic, considering this.

Google Street View Car Hit San Diego in March ‘07

This one’s for all of you UCSD’ers.

First, the smoking gun: La Jolla Village Theatres

Notice the show dates for the upcoming Saturday Night Movie Madness shows:
Mar 31 - Donnie Darko
Apr 7 - Star Trek IV
Apr 14 - Army of Darkness

It is likely this image was captured during the last week of March: tinyurl.com/yswydb

Google Street View - La Jolla Village Theatres

Additionally, those familiar with the area know that students are always waiting at UCSD shuttle stops. However, all of the stops (I’ve checked so far) are empty. This yields two conclusions:

  • These were taken during the weekend
  • These were taken during spring break.

I opt for the latter.

Finally, a couple fun things…

Rebecca, I found your car: http://tinyurl.com/2cohxv
Rebecca's car on google maps

Spence, I found your car: http://tinyurl.com/yrd292
Spence's car on google maps
I’m really bummed my car didn’t make the cut! I was usually working from home during this time. My guess is I was at ETech. Otherwise, I might have just been out.

Cool or creepy, you gotta love Google Maps. :-)

Voldemort and Kif

The new trailer is out for Harry Potter and the Order of the Phoenix.

While watching this, I immediately thought that Voldemort looks exactly like Kif from Futurama. Has nobody else noticed this?… Or cared?

I tried searching the blogosphere (technorati, google blogs, etc.) for any related posts and was surprised to no one else mentioning this. Am I completely off here?

Left: Voldemort (screenshot from trailer)
Right: Kif

Voldemort and Kif

Recent Reads

I just finished reading a couple of great books.

  • Freakonomics is an insightful look inside the social trends in America, involving crime rates, drug trafficking, and racial discrimination. Steven D. Lewitt thinks of provocative questions (e.g. why did crime rates drop in the ’90s?) and comes up with answers generally ignored and dismissed by the media. It’s a fascinating read, offering a different slant from conventional economics (which I know very little about).
  • Ultramarathon Man is a collection of memoirs from Dean Karnazes. This guy is a beast, making a 26.2 mile marathon look like child’s play. He runs in excess of 100 miles at a time, including the Western States Endurance Run, Badwater Ultramarathon (Death Valley), and even a marathon at the South Pole. Yet he’s humble and passionate, an ordinary family man with a day job… an incredible inspiration. I usually average about 5 miles per run, but I know I can go much longer. :-)