Archive for the ‘media’ Category
What’s wrong with Roger Ebert’s blog
March 9th, 2010 at 12:21 pm
It’s not the content, of course, it’s the formatting. Have you tried to read his RSS feed on an iPhone?
I started reading Roger’s latest blog entry this morning and ran into the same problem I always do when reading him on my iPhone.

The screenshot above is from the MobileRSS feed reader, but I get basically the same horrible formatting when reading it through NetNewsWire

and through the Google Reader mobile page.

Everything past the first couple of paragraphs gets squeezed down to pass through a narrow chute.
Grabbing the feed via
curl http://blogs.suntimes.com/ebert/atom.xml > ebert.rss
and isolating the area where the formatting goes crazy, we get
<p> Todd McCarthy reviewed films for Variety for 31 years.
He was the ideal critic for the paper -- better, we now
realize, than it deserved. His reviews and the reviews of
Kirk Honeycutt at the Hollywood Reporter were frequently the
first reviews of a new film to see print. Honeycutt
fortunately continues. <br /> </p>]]>
<
and here’s the page for the latest entry

Each entry on main page has an image and a paragraph or two of text. You’ll note that the length of the text matches the height of the image almost exactly, a feat that probably comes easily to a guy who’s been writing newspaper copy for five decades, but which seems amazing to me.
The triple <blockquote> comes right after those lead paragraphs and is what gives the subsequent text its left indentation. And turns that text into a thin trickle running down the center of my iPhone.
(The indentation also appears when I read his feed on my computer, of course, but it’s not as annoying on a full-sized screen.)
I don’t know whether it’s Roger himself that’s putting in those <blockquote>s or whether it’s some blogging program he’s using, but whatever the source, it’s the old problem of using HTML for formatting instead of semantics. I wish one of Roger’s web-savvy friends—Andy Ihnatko, say—would step in and give him a little CSS assistance.
-
I call him Roger instead of Mr. Ebert not just because his persona in print and on TV makes everyone feel like his friend. And not just because we share an alma mater and happy memories of Champaign-Urbana. No, there’s a deeper bond.
Back in the late 80s, my wife and I were driving down through the center of Illinois on I-57. We pulled into a rest stop and noticed a BMW with the license plate ROSEBUD (or maybe ROSEBD) in the parking lot. As I went into the men’s room, I passed familiar-looking portly guy with big glasses coming out the door. It wasn’t until I got back to my car that I realized I’d just had a brush with greatness.
It’s the intimate relationship that comes from nearly sharing a rest room that puts Roger and me on a first name basis. ↩
Headline Fallows
February 27th, 2010 at 9:27 pm
The Atlantic rolled out some big changes to its website a couple of days ago. Normally, I wouldn’t notice something like this, because even though I’m a regular reader of James Fallows’ blog, I almost never visit the site itself. As I do with all my favorite blogs, I subscribe to his RSS feed and read his posts in Google Reader. But since the redesign, I can’t do that anymore.
Oh, there’s still a feed, but it provides only the headlines of Fallows’ posts, nothing more. Not even the first paragraph or two to give a you a decent sense of the post’s topic. I assume the idea behind this change is to force us to go to the main site, pumping up the pageviews for The Atlantic’s advertisers. It won’t work; you can’t force someone to follow a link, and readers who’ve jumped on the RSS train will not be jumping off.
Merlin Mann has written a couple of tart posts today about the stupidity of this change. I’m more disappointed than angry, but the source of our displeasure is the same: we like reading Fallows, and we will read much less of him because of the anemic new feed. I sent this email to Fallows:
Is there some way you can prevail upon the Atlantic’s webmasters (and their masters) to return the RSS feed to providing the full text of your posts? I understand the need to make money and would not complain if the feed included ads. Many of the feeds I subscribe to have ads (Talking Points Memo, for example), and I stay subscribed to them. But I won’t continue to subscribe to a feed that provides only headlines.
I’m sure I’m not alone in this. People who do a lot of reading online have gotten used to using RSS and will not go back to the old way of clicking back and forth between dozens of sites. Especially since much of our blog reading is now done on our smartphones.
I mentioned Talking Points Memo because I know it’s a site Fallows is familiar with. I could just as easily have mentioned Daring Fireball or TidBITS. They’ve all figured out ways to get ads in their feeds, meeting the advertising requirements necessary to keep their businesses going while still providing articles in a form their readers want.
Update 2/28/10
Fallows sent me (and, apparently, about 800 other people) a polite response, agreeing with our complaints. Later came this post, acknowledging the RSS feed problem, and this one, telling us that it’s been fixed. I’m not sure that it has been fixed just yet—the “fixed” post still hasn’t appeared in my RSS reader—but it’s clear that a fix is at least on the way.
Interestingly, the headline-only feeds were not a bad commercial decision; they were just bad programming. Never attribute to malice that which can be explained by incompetence.
BBC iPlayer site-specific browser
February 24th, 2010 at 10:00 am
As I’ve mentioned at great length in earlier posts, I use Audio Hijack Pro to record BBC Radio shows that are streamed over the internet but don’t come in podcast form. Until recently, I’d been using Safari to open the stream URL. Generally, this worked out fine, but if I wanted to browse while recording something in the background, I had to follow two rules
- Don’t open any sites that play sounds, as these will be recorded on top of the show.
- Don’t quit Safari when I was done browsing, as that will kill the recording.
Sometimes I’d forget to follow these rules and ruin a hour or more of recording. Whenever this happened, I’d try to fix the problem by swearing at myself, but that never seemed to work.
What has worked is creating a site-specific browser (SSB) for recording. I used Fluid1 to create an SSB, called BBC iPlayer, that opens a generic BBC page.

BBC iPlayer, then, is the application whose sound output gets hijacked by AHP.

AHP tells BBC iPlayer to navigate away from the generic page to the URL for the stream. Now I can browse in Safari without worrying that something I do will screw up the recording.
Luckily, the various scripts I wrote for getting the streaming URL from the BBC—all collected in this GitHub repository—are browser-agnostic, so they didn’t have to be edited at all. Only the settings in AHP itself needed updating.
I was going to use the current BBC logo as the icon for the BBC iPlayer SSB, but its horizontal layout doesn’t work well as an icon. So I found a screenshot of the old spinning blue globe logo (the one you’d always see during Monty Python’s Flying Circus) on this BBC logo history page and did a bit of editing.

It doesn’t look great at a small size, but it’s instantly recognizable to me.
One more thing: As you can see in the AHP screenshot, one of my upcoming recordings is of an episode of Radio 2’s semi-regular show, The Record Producers. The subject of this Saturday’s show will be Todd Rundgren. Obviously, I have no idea if the show will be any good (personally, I’m hoping they don’t spend too much time on Bat Out of Hell), but Todd fans will probably want to listen regardless.
Unintended Consequences of Math
February 17th, 2010 at 11:30 pm
I thought last week’s episode of In Our Time was particularly good, even though I already knew most of the facts presented and disagreed with much of the discussion of those facts. Actually, maybe I liked it because I disagreed with it. It gave me a lot to think about, which thinking I will now inflict on you.
In Our Time is a weekly radio show broadcast on BBC Radio 4, the hifalutin BBC station. People outside the UK can get the podcast. Each episode covers a fairly restricted topic, with panel discussion moderated and prodded by the host, Melvyn Bragg. Unlike most American shows of this type, In Our Time puts real experts on its panels, not journalists hawking their latest books. Each show’s panel is usually made up of professors of the subject from various British universities. The scope of the show is immense, as you can see from looking at its archive. The most recent three shows, for example, covered
- George Eliot’s Silas Marner;
- the 14th-century philosopher Ibn Khaldun; and
- the unintended consequences of pure math.
It’s this last one that got me thinking.
Most of the show was given over to stories, told in the style of James Burkes’ Connections series, of concepts developed purely for their own mathematical beauty (that’s the pure math of the episode’s title) that suddenly became useful for practical purposes decades or centuries later.
The first of these stories, told by the delightfully-named Colva Roney-Dougal of the University of St. Andrews, purportedly explains how the solution of cubic equations led to the electric chair. In the 16th century, while investigating the solution of cubic equations, Cardano found square roots of negative numbers in his solutions. This led to the use of complex numbers. It turned out, hundreds of years later, that complex numbers were very convenient in the analysis of alternating current.
(Phasor image blatantly stolen from here.)
If you know anything about the competition between Thomas Edison and George Westinghouse over use of DC and AC, you can see where this is going. As part of his campaign against AC, Edison touted its use in electrocution.1 Therefore, we’re supposed to think, the electric chair was an unintended consequence of complex numbers.
But, and this is pointed out in the show, while complex numbers make the analysis of AC easier, they’re not required. In fact, the electric chair was first designed before anyone used complex numbers to analyze AC. So yes, it’s interesting that complex numbers can be used in AC analysis (as they can be used similarly to analyze mechanical vibrations and problems in plane elasticity), but it really isn’t right to call the connection a consequence.
The use of the term consequence is even less apt in the second example: the application of conic sections to celestial orbits and the trajectories of projectiles. There’s no question this is an interesting connection. The Greeks studied conic sections for their intrinsic beauty, and it was definitely an exercise in pure math. There’s no particular reason to believe they’d be applicable to gravity-controlled motions. But again, this isn’t a consequence, it’s a discovery. Planets didn’t start orbiting in ellipses because Kepler said so.
(Image from Duk at Wikipedia.)
The third story eventually works its way (via Cardano and de Moivre) to Gauss’s use of the normal distribution to predict the position of an asteroid. The asteroid had been observed for only a short time before the view of it was blocked by the sun. Gauss recognized that the observations prior to its disappearance had errors that followed the normal distribution and was able to give the best prediction of where it would be after it reappeared.
The normal distribution had been described by previous mathematicians—de Moivre and Laplace, in particular—studying games of chance and other random phenomena, and Gauss’s use of it to analyze observational errors was definitely a consequence of that earlier work. But here I would disagree with the characterization of that earlier work as pure math. Early studies of probability were intensely practical because of their connection to gambling. There was nothing pure about it.
I would classify the fourth connection, between non-Euclidean geometry and relativity, as I did the conic section/orbit connection: interesting but not a consequence because there’s no cause and effect relation.
The last story, finally, does what all the stories were supposed to do: it describes how the study of prime numbers, once thought of as the purest of pure math topics, now has a very practical and thoroughly unexpected application in cryptography, keeping our credit card numbers safe as we shop online. The historical connection between the pure math and the practical application wasn’t made very strongly—it was basically some hand-waving about Alan Turing—but the story may have been rushed because the show was nearly over.
I was amazed that the show finished without a single mention of “The Unreasonable Effectiveness of Mathematics in the Natural Sciences,” a famous paper written in 1960 by a physicist, Eugene Wigner. (How famous is this paper? Type “unreasonable” into your browser’s Google search field and see what comes up. It was the seventh suggestion when I tried it.)

The theme of the paper, as you can guess from the title, is how amazing it is that mathematics—often developed for completely different purposes—works so well to describe the physical world. While the In Our Time episode’s theme is not exactly the same as this, it’s damned close. Even the episode’s title is an echo of the paper’s title.
Fairly early in the show, one of the guests,2 John Barrow of the University of Cambridge, dives right into the main topic of “Unreasonable Effectiveness,” giving a very reasonable explanation of why many topics in math have applicability beyond their original conception. In his view, the whole of math is a collection of patterns, with the number of patterns increasing as math has progressed. It is, therefore, not surprising that some of these patterns match the patterns found in nature. How Barrow manages to go through this explanation without mentioning Wigner’s paper, I’ll never understand, but this was my favorite part of the show.
I doubt I’ll have as much to say about this week’s episode, but I bet I’ll enjoy it.
-
No, I’m not going to link to the video of the electrocution of Topsy the elephant. I’m sure you can find it on your own if you really want to see it. ↩
-
Occasional listeners of In Our Time know that the guest panel consists of three experts and may be wondering who the third guest is. Regular listeners will have guessed that it’s Marcus du Sautoy of Oxford, who seems to appear on every BBC show on math. ↩
The Toyota pedal problem
February 3rd, 2010 at 9:59 pm
I’m not a big fan of the Chicago Tribune,1 but I have to say it did a pretty good job yesterday explaining the Toyota pedal recall that’s been all over the news lately. The article is only so-so, but the graphic that accompanies it, by Phil Geib and the improbably-named Max Rust, answered many of the questions I had.
[Click on the graphic to get a slightly larger version.]
Comparing the drawings to a photo of an actual pedal (on my 2007 Camry), we see that the parts in question are all inside a plastic housing near the pedal’s pivot.

I couldn’t shoot a photo with the same point of view as the drawing because its a little cramped down there, but I think you get a sense of where everything is. In addition to the gas pedal, you can see the brake pedal (lower left foreground) and part of the steering mechanism (the shaft with the yellow-orange stripe at the upper left corner).
The gas pedal is a “drive-by-wire” system. There is no mechanical connection between the pedal and the engine; the pedal sends electrical signals that describe its position to a controller which runs the fuel injectors. (In my photo you can see the wires coming up off the top of the pivot housing and leading into a black corrugated conduit.) This is very different from the way cars used to work, and to give the pedal the traditional “feel,” Toyota has incorporated two sets of plastic teeth that rub against one another and provide some of the resistance felt by the driver’s foot.
Additional resistance comes from the pedal’s return spring, which, for clarity, isn’t included in the drawing. The return spring is what, under normal circumstances, pushes the pedal back up when you take your foot off the gas.
The toothed portions of the blue and tan parts slide on one another, the blue part rotating with the pedal and the tan part remaining stationary. The friction between the teeth is what generates the resistive force. Apparently, moisture on these plastic parts can increase the friction between them, and if the friction gets large enough, the return spring can’t overcome it and the pedal won’t return to the up position when you remove your foot. You may have heard this called “sudden acceleration” in news reports, which gives the impression of the gas pedal moving down on its own. “Stuck throttle” or “stuck accelerator” would be a more accurate name for the problem.
[Aside: Friction is an interesting force because it always opposes motion. When you press down on the gas, the friction and the return spring are acting in concert, both pushing up to resist the downward motion. When you take your foot off, the return spring continues to push up, but the friction suddenly changes direction to push down, resisting the spring.]
Toyota’s page for the pedal recall mentions wear of the plastic as another factor in the sticking pedal problem, so it’s not clear whether the problem is caused by an increased coefficient of friction, surface damage from galling, or some combination of both. Regardless, Toyota’s solution is to change the relative positions of the plastic teeth and reduce the friction.
Dealers will be installing what Toyota is calling a “reinforcement bar” (but should really be called a “spacer” or “shim” because it isn’t changing the strength of the parts, it’s changing their position) behind the tan part. The Tribune drawing does not do a good job of explaining how that shim is going to reduce the engagement of the two sets of teeth, but it seems clear that that’s the intent.
One thing I still don’t understand, and something I’ve not heard Toyota address publicly: How will the new, reduced friction affect the feel of the gas pedal? Presumably, the pedal resistance I get now will be lessened after I take my car in for the recall fix. Will it feel too floppy? If not, why did Toyota have the higher resistance to begin with?
Frankly, I’m curious why a friction mechanism was chosen in the first place. Toyota obviously wanted to get a particular relationship between the resistive force and the pedal deflection, but I don’t see why that couldn’t be achieved with a spring package of some sort. Mechanical engineers have been designing spring mechanisms for a long time and can get all kinds of force-deflection relationships.2
Maybe I’m just out of date and friction mechanisms like this are common in brake systems nowadays. If you know what other manufacturers do, I’d like to hear about it in the comments.
Update 2/4/10
I’ve known for a few days that there are “good” pedals and “bad” pedals, but it wasn’t until this morning that I learned who their manufacturers are. The good pedals, not subject to the recall, are made by Denso, and the the bad pedals, which are going to have the shim fix described above, are made by CTS.
It turns out that my pedal is a Denso. The Denso name is molded into the pivot housing, something you can’t see in my photo. Also, the housings of the two designs look very different; the CTS doesn’t have that circular area with radial spines sticking out of the side. You can see photos of the two designs at this site. Note: I am not endorsing anything said on that site, as I have not read through it in detail. I’m just linking to it as a source of photos showing the difference between the two types of pedal. It also has some nice photos taken with the housings opened.
Update 2/24/10
I’d like to say something about this week’s Congressional hearings into Toyota’s problems, especially since much of the testimony covered other explanations—mainly electronic—for sudden acceleration. But I don’t have a copy of the primary engineering report referenced in the testimony, so I don’t feel comfortable commenting yet. I was hoping the House subcommittee would post a PDF of the report, but it hasn’t so far. If you know where I can download a copy, leave a URL in the comments or send me an email directly.
-
What’s wrong with the Trib? To start: its editorial position, its choice of columnists on the op-ed page, its placement of John Kass in the old Royko spot, and its many years of owning the Cubs. ↩
-
If your experience with springs is limited to what you learned in physics class, you may think that all springs are linear. Ut tensio sic vis, and all that. But if you expand your concept of “spring” beyond helical coils of uniform wire many more things are possible. ↩
Newton, the apple, and reading comprehension
January 18th, 2010 at 9:35 pm
I’ve seen several links to this article at Scientific American today, and I really don’t understand why. The Royal Society has made a scan of the original handwritten manuscript of William Stukeley’s Life of Newton available for viewing on the internet, and all the linkers to think this is some new confirmation of the story that Newton was inspired to develop the law of gravity from watching the fall of an apple. It doesn’t.

Read the SciAm article and tell me:
- Is this a newly found memoir? No, Stukeley published it in 1752 and its text has been available on the internet for years.
- Does the handwritten manuscript differ from the known text? No, there’s no claim of that.
- Have we learned something new about Newton’s inspiration? No, we just have a new way of looking at an old memoir.1
I know professional bloggers have a tendency to exaggerate to get pageviews, but why should I trust—and continue to read—anyone who can’t even properly summarize a four-paragraph story?
-
One new thing I have learned is that the Royal Society hates me. Their preferred, super-duper way of reading Stukeley’s manuscript is through a program that doesn’t run on a Mac. The next best way is to install a bunch of Silverlight crapware (which wouldn’t work on my iBook, anyway, because Silverlight is Intel-only). The so-distasteful-they-can-barely-stand-it way is to just look at a bunch of JPEGs, which they’ve laid out in a series of pages that take an inordinate number of mouse clicks to navigate. ↩
I’m nonnonplussed
January 11th, 2010 at 11:24 pm
You may have seen some of this AP story about Sarah Palin. When I read this part,
In an interview with the CBS news magazine “60 Minutes,” Steve Schmidt described Palin as “very calm — nonplussed” after McCain met with her at his Arizona ranch just before putting her on the Republican ticket.
I had that weird feeling I sometimes get when I realize I’ve made some horrible, embarrassing mistake. Is nonplussed a synonym for calm? Have I had it exactly wrong my whole life? Have I used it that way in front of people who know better?
I opened the Dictionary program on my Mac, the definitions in which are taken from the New Oxford American Dictionary, and went to the entry for nonplussed. It said, basically, that it means surprised, which is what I thought. Then, below the definition, was this:
USAGE In standard use, nonplussed means ‘surprised and confused’: : the hostility of the new neighbor’s refusal left Mrs. Walker nonplussed. In North American English, a new use has developed in recent years, meaning ‘unperturbed’—more or less the opposite of its traditional meaning: : hoping to disguise his confusion, he tried to appear nonplussed. This new use probably arose on the assumption that non- was the normal negative prefix and must therefore have a negative meaning. Although the use is common, it is not yet considered standard. The preferred spelling is nonplussed.
In other words, Americans (and maybe even Canadians?!) have become such dumbasses that we use words that mean the opposite of what we think. And Steve Schmidt, like all Republicans, is a Great American.
Climate bullshit from Forbes
December 7th, 2009 at 12:20 am
You may have seen “The Fiction of Climate Science,” a short article at forbes.com that tells us we should ignore the current warnings of climatologists. It’s an astonishingly dishonest (or possibly stupid, but I’m betting on dishonest) article, and it bothers me that so many people seem to be linking to it uncritically. It doesn’t take much digging to learn that the author, Gary Sutton, is lying to his audience.
The overarching theme of the article is that global warming has no scientific basis, that it’s just something the government wants us to believe. Which government is that? you might ask. The government that was, until recently, under Republican control? The government that wouldn’t sign the Kyoto Protocol? The government that has refused to take the steps climatologists say are necessary to slow or halt global warming? Yes, that’s the government Sutton says is egging on the scientists to make up climate change stories.
There are, no doubt, plenty of people willing to put their brains on hold and believe this patent nonsense. Global warming is seen as a liberal cause, and therefore something that good conservatives—most Forbes readers, I imagine—must reject. Sutton knows his audience’s prejudices and knows he can get away with dopey arguments.
Not surprisingly, Al Gore makes an appearance in the article. Conservatives take it as an article of faith that Gore is the evil international head of the global warming conspiracy. Sutton says Gore “thought he might ride his global warming crusade back toward the White House.” How Gore expected to be elected without actually running in either 2004 or 2008 is a detail that Sutton knows he can safely ignore.
Perhaps my favorite part of the article is its opening, which tells us that the government now pushing a global warming lie was, in the mid-70s, pushing a global cooling lie. I do, in fact, remember stories from back then about the possibility of a coming Ice Age, but they were popular accounts and pretty speculative. I’m pretty sure I read a Science Fact article about it in Analog. I don’t want to slag on Analog, but one of its earlier Science Fact pieces—back when it had the much cooler name Astounding Science Fiction—was L. Ron Hubbard’s original Dianetics article, the founding document of the Church of Scientology. Hail, Xenu!

(source: Modemac on Wikipedia)
Sutton points to a book called The Weather Conspiracy, which he says was part of the government’s push to get us to believe in a coming ice age.

(source: LibraryThing)
As you might guess from the cover, this was not a government publication, as Sutton would have us believe,1 nor was it a weighty scientific tract. According to this contemporaneous review written by an actual scientist, The Weather Conspiracy was more of a “pot boiler” which didn’t acknowledge that “we just don’t know enough to chose [sic] definitely at this stage [1977] whether we are in for warming or cooling—or when.”
But wait! Sutton says global cooling wasn’t just in popular science accounts:
In 1974, the National Science Board announced: “During the last 20 to 30 years, world temperature has fallen, irregularly at first but more sharply over the last decade. Judging from the record of the past interglacial ages, the present time of high temperatures should be drawing to an end…leading into the next ice age.”
Well, that sure looks like scientists had come down strongly on the side of cooling. But, gosh darn it, Sutton seems to have had some trouble in copying that quote. First, it’s a synthesis of two quotes. The first sentence was written in 1974, the second in 1972. Let’s look at that 1972 quote as a complete sentence:
Judging from the record of the past interglacial ages, the present time of high temperatures should be drawing to an end, to be followed by a long period of considerably colder temperatures leading into the next glacial age some 20,000 years from now.
Had Sutton included the part about 20,000 years, it wouldn’t have seemed quite so alarmist and wouldn’t have supported his thesis so well. So he just left it off. Even less supportive of his thesis is the very next sentence:
However, it is possible, or even likely, that human interference has already altered the environment so much that the climatic pattern of the near future will follow a different path.
Well, shit, we can’t be quoting that. Best to just leave it out. After all, who’s going to bother looking it up? No one at Forbes, obviously.
By the way, researching this doesn’t take a staff of crack librarians. There’s a Wikipedia page with all the links you need.
So, in the end, what do we have? An article with a ridiculous conspiracy theory propped up by selective and dishonest quoting. Presented to us by a publication that can’t be bothered to do elementary fact checking. This is the face of climate change denial.
Update 12/8/09
There’s now a post up at fair.org that makes some of the same points I do using rather similar language. I hope it’s just coincidence.
-
It did rely on a couple of reports from the CIA, the folks who believed they could overthrow Castro with a poisoned cigar. ↩
Adapting BBC Radio recording scripts
October 13th, 2009 at 5:06 pm
Reader Chris Nelms sent me a nice email over the weekend. He’s a fan of several BBC Radio 4 programs and had been recording them with Audio Hijack Pro for listening to in his car—similar to my time-shifting of Radio 2 shows, except that Chris’s recordings probably have more legitimacy, as he’s a UK resident and has presumably paid the BBC license fee. When the BBC changed its program URL scheme, it broke his AHP setup. He found my scripts for recording Radio 2 shows (first discussed in this post, then updated and put in a GitHub repository) and adapted them for Radio 4.
The most important changes were to my Python radio2.py module. That module starts like this
1: import datetime
2: import urllib
3: import BeautifulSoup
4: import re
5:
6: # The particulars for the shows we're interested in.
7: showinfo = {'jukebox': (5, 'Mark Lamarr'),
8: '70s': (6, re.compile(r'Sounds of the 70s')),
9: '60s': (5, re.compile(r'Sounds of the 60s')),
10: 'soul': (2, 'Trevor Nelson')}
11:
12:
13: def recentScheduleURL(showday, day=datetime.date.today()):
14: 'Return the schedule URL for the most recent showday (0=Mon, 6=Sun) on or before day.'
15:
16: backup = datetime.timedelta((day.weekday() - showday) % 7)
17: programDay = day - backup
18: return 'http://www.bbc.co.uk/radio2/programmes/schedules/%d/%02d/%02d' % (programDay.year, programDay.month, programDay.day)
19:
20:
21: def programCode(show):
22: 'Return the code of the program page for showname on the most recent showday.'
23: try:
24: schedHTML = urllib.urlopen(recentScheduleURL(showinfo[show][0])).read()
25: schedSoup = BeautifulSoup.BeautifulSoup(schedHTML)
26: return schedSoup.find(name='span', text=showinfo[show][1]).parent.parent['href'].split('/')[-1]
27: except KeyError:
28: return None
To adapt it to Radio 4, Chris changed the schedule URL string in Line 18 to Radio 4’s URL and he changed the showinfo dictionary in Lines 7-10 to reflect the shows he listens to and the days of the week on which they air. Because the BBC’s site overhaul made its URLs more uniform in structure, those changes were all that were needed.
I didn’t ask Chris which shows he records, but I did notice that, unlike the Radio 2 programs I listen to, many Radio 4 shows are daily rather than weekly. This makes crafting a workable showinfo dictionary a bit more challenging. For example, the Today program runs in the morning, Monday through Saturday. If you wanted to record each episode in the afternoon or evening of the day it aired, there are a couple of ways to go about it.
The brute force technique would be to create a showinfo entry for each day the show airs:
6: # The particulars for the shows we're interested in.
7: showinfo = {'montoday': (0, re.compile(r'^Today$')),
8: 'tuetoday': (1, re.compile(r'^Today$')),
9: 'wedtoday': (2, re.compile(r'^Today$')),
10: 'thutoday': (3, re.compile(r'^Today$')),
11: 'fritoday': (4, re.compile(r'^Today$')),
12: 'sattoday': (5, re.compile(r'^Today$'))}
13:
14: def recentScheduleURL(showday, day=datetime.date.today()):
15: 'Return the schedule URL for the most recent showday (0=Mon, 6=Sun) on or before day.'
16:
17: backup = datetime.timedelta((day.weekday() - showday) % 7)
18: programDay = day - backup
19: return 'http://www.bbc.co.uk/radio4/programmes/schedules/fm/%d/%02d/%02d' % (programDay.year, programDay.month, programDay.day)
20:
21:
22: def programCode(show):
23: 'Return the code of the program page for showname on the most recent showday.'
24: try:
25: schedHTML = urllib.urlopen(recentScheduleURL(showinfo[show][0])).read()
26: schedSoup = BeautifulSoup.BeautifulSoup(schedHTML)
27: return schedSoup.find(name='span', text=showinfo[show][1]).parent.parent['href'].split('/')[-1]
28: except KeyError:
29: return None
The search criterion for the show name had to be a regular expression with start and end anchors (^ and $), because Radio 4 also has a daily show called Farming Today, the name of which would interfere with a search that didn’t have the anchors. Note that I’ve also made the necessary change to the schedule URL string in Line 19 (née 17).
The problem with the brute force approach is that it requires six different AHP sessions and six different audio source AppleScripts, one for each day of the week. A better approach would be this:
6: # The particulars for the shows we're interested in.
7: showinfo = {'today': ((0,1,2,3,4,5), re.compile(r'^Today$'))}
8:
9: def recentScheduleURL(showday, day=datetime.date.today()):
10: 'Return the schedule URL for the most recent showday (0=Mon, 6=Sun) on or before day.'
11:
12: if isinstance(showday, tuple):
13: backups = [ (day.weekday() - d) % 7 for d in showday ]
14: backup = datetime.timedelta(min(backups))
15: else:
16: backup = datetime.timedelta((day.weekday() - showday) % 7)
17: programDay = day - backup
18: return 'http://www.bbc.co.uk/radio4/programmes/schedules/fm/%d/%02d/%02d' % (programDay.year, programDay.month, programDay.day)
19:
20:
21: def programCode(show):
22: 'Return the code of the program page for showname on the most recent showday.'
23: try:
24: schedHTML = urllib.urlopen(recentScheduleURL(showinfo[show][0])).read()
25: schedSoup = BeautifulSoup.BeautifulSoup(schedHTML)
26: return schedSoup.find(name='span', text=showinfo[show][1]).parent.parent['href'].split('/')[-1]
27: except KeyError:
28: return None
Here, I’ve generalized the recentScheduleURL function to accept either a tuple or an integer for the showday argument; either way, it finds the most recent episode. Taking advantage of this, I’ve used a tuple to define the days of the week on which Today runs. Now a single AHP session and a single AppleScript will suffice to record all the episodes in the week.
I like this approach so much, I’ve incorporated the tuple option into radio2.py. Although I don’t need it now, I can foresee a time when I’d want to record a daily show. My thanks to Chris Nelms for his help.
The updated version is available at the GitHub repository.
Tribune’s head in the cloud
October 12th, 2009 at 11:45 am
The top story in this morning’s Chicago Tribune business section is a fluff piece about Microsoft’s big new data center in the suburb of Northlake. I know that a fluff piece in the business section is about as common as dishonesty in Charles Krauthammer’s column, but this one is worth a look.
The gist of the piece is how cloud computing is the future of computing and, of course, how wonderful this new data center—and, by extension, Microsoft—is. The article includes a big photo, thoughtfully provided by Microsoft, sighting down a row of blue, futury-looking servers in the center. What the article does not include is any mention of the huge loss of data that hit T-Mobile’s Sidekick cell phone users this weekend. The Sidekick apparently stores all its data in the cloud, and when the servers went down, they took all that information with them. The failed servers were operated by a company called Danger, which happens to be a Microsoft subsidiary.
Now I’m sure the fluff article was researched, and probably written, a while ago. But you’d think someone at the Tribune—the writer, Greg Burns, or one of his editors—would have recognized that an article extolling the virtues of MS cloud computing would have to at least mention the Sidekick disaster. You’d be wrong.
Fortunately, the list of links on the Tribune web site does, in a small way, what the article should have done.












