Bing Desktop Backround Picture Downloading

For Fun and (No) Profit

For a few years now, I've made the Important Life Choice about my computer's desktop backgrounds (aka "wallpaper"): downloaded photos of spectacular vistas, amazing animals, breathtaking architecture, … I'm not particular. Rotate them every so often to avoid boredom. This is often called a "slideshow".

This, even though my open windows usually obscure the background. I know it's there though, and it makes me happy. (And the Start-D key combo works to minimize all windows if I really want to peruse it.)

The OS environments I use (Windows 10, Fedora Linux/Cinnamon) make it easy to configure a slideshow: just find the configuration page, point it to a directory containing the pictures you like, choose a switching interval, and that's it. (If your environment doesn't let you do this easily, maybe you should find a better environment.)

That leaves only one issue: setting up the picture directory. My personal choice is to have my Windows "Pictures" directory shared via VirtualBox's shared folders feature to the Linux guest. (Detail: to allow me to write to this directory from Linux, my account must be added to the vboxsf group. It's on my "things to do" list when creating a new Linux guest.) I keep 400 pictures in this directory; when more new pictures are added, the same number—the oldest ones—are removed.

I used to download daily pictures from the National Geographic site, but they made that difficult awhile back; I don't remember the details, and I haven't checked recently to see if they relented. Instead I grab Bing's home page picture; there's a new one every day, and downloading, while not exactly a breeze, is not too difficult.

The Perl script I use to download is get_bingpics (script here, prettyprinted HTML here). Notes:

  • There's a magic URL at Bing that can be queried (with proper parameters) to divulge the recent Bing pictures and their names. Specifically, the page will contain (at most) the eight most recent. The query I use asks for 16.

  • For some reason, I request the JSON version of the picture data. This is decoded (naturally enough) into a Perl data structure with the decode_json function from the JSON::PP module.

  • For the available images, the script checks each to see if it has already been downloaded. For each image not previously downloaded, it uses the LWP::Simple function getstor to download to the shared directory.

    Although I typically run this script daily, this design allows me to skip up to eight days without missing any pictures. (For example, if I'm on vacation.)

  • I run this script out of anacron daily, details left as an exercise for the reader.

The other part of this equation is getting rid of older pictures. That's accomplished by the remove_old_pics script (script here, prettyprinted HTML here). Notes:

  • It's pretty simple.

  • Its claim to geekery is using the Schwartzian Transform to obtain a list of JPEG files in the picture directory in order by modification time. Sweet!

  • The code can be easily tweaked to change directories, the types of files examined, and how many "new" ones to keep.

  • This too is run daily via anacron.

OK, so how many of you out there are shaking your heads at this and saying: "Doesn't this boy realize he needs professional help?" Let's see a show of hands…

Last Modified 2017-11-16 5:38 AM EST

My Book Picker (and Unpicker)

Another example of the mental aberration that causes me to write Perl scripts to solve life's little everyday irritants. In this case two little irritants:

  1. I noticed that I had a lot of books on my shelves, acquired long past, that I never got around to reading. Either because (a) they were dauntingly long and dense (I'm thinking about Infinite Jest by David Foster Wallace); or because (b) they just fell through the cracks. Both poor excuses, but there you are.

  2. I sometimes want to methodically read a series of books in a particular order.

In other words, I needed a way to bring diligence and organization to my previous chaotic and sloppy reading habits.

Here's how I went about scripting that:

I conceptualized my "to be read" books as a collection of book stacks, like the picture at (your) right (except more of them). Each stack is a list of books:

  1. either organized around a specific theme (usually an author) or is a catchall (e.g. "non-fiction"); and

  2. maintained in the order I want to read them. (This goes back to the issue mentioned above: sometimes a series really "should" be read in publishing order, for example C.J. Box's novels featuring protagonist Joe Pickett.)

The implementation of this concept: each stack is a .list file in my Linux directory ~/var/reading_lists. As I type, sixteen of them:

(pas@oakland) ~/var/reading_lists: ls -l *.list
-rw------- 1 pas pas 183 Oct 20 17:47 amber.list
-rw------- 1 pas pas  41 May 17 18:05 asimov.list
-rw------- 1 pas pas 242 Jul 25 06:09 box.list
-rw------- 1 pas pas  93 Oct  9 12:27 connelly.list
-rw------- 1 pas pas  43 Sep  7 10:28 conservative_lit_101.list
-rw------- 1 pas pas  75 Sep 17 13:32 docford.list
-rw------- 1 pas pas  46 Jun 30 11:12 elmore.list
-rw------- 1 pas pas  83 Mar 29  2016 francis.list
-rw------- 1 pas pas 266 Oct 28 06:52 genfic.list
-rw------- 1 pas pas  65 Apr 13  2017 monkeewrench.list
-rw------- 1 pas pas 144 Oct 16 17:11 moore.list
-rw------- 1 pas pas 199 Oct 25 13:47 mystery.list
-rw------- 1 pas pas 523 Oct 16 13:12 nonfic.list
-rw------- 1 pas pas  56 Jul 18 15:04 reacher.list
-rw------- 1 pas pas 333 Aug 30 15:37 sci-fi.list
-rw------- 1 pas pas  45 Jun 11 15:50 winslow.list

Each list has one or more lines:

(pas@oakland) ~/var/reading_lists: wc -l *.list
   6 amber.list
   1 asimov.list
  11 box.list
   3 connelly.list
   1 conservative_lit_101.list
   5 docford.list
   4 elmore.list
   2 francis.list
   8 genfic.list
   4 monkeewrench.list
   5 moore.list
   6 mystery.list
  13 nonfic.list
   2 reacher.list
   9 sci-fi.list
   2 winslow.list
  82 total

… and each line in each file contains a different book title. Example with elmore.list, a list I created in lieu of watching the six seasons of Justified on Amazon Prime for the fourth time.

(pas@oakland) ~/var/reading_lists: cat elmore.list
Riding the Rap
Fire in the Hole

I.e., four books written by the late Elmore Leonard where Raylan Givens appears as a character.

The picking algorithm is simple and "works for me". When it's time to choose the next book to be read from this agglomeration, I pick a pile "at random" and take the book from the "top of the pile" (i.e., the one named in the first line of the file).

There is one more little tweak: the "random" pick is weighted by the length of the list. So (for example) since there are 82 books total in all lists above, and the nonfic.list has 13 lines, a book from that list would be picked with probability 1382. (Note the probabilities calculated this way add up to 1, the probability that some book from pile will be picked.)

That's not as hard as it might sound. I'd pseudocode the algorithm like this:

Given: N lists (indexed 0..N-1) with Bi books in the ith list…

Let T be the total number of books in the lists, B0 + B1 + … + BN-1

Pick a random number r between 0 and T-1.

i = 0
while (r >= Bi)
     r -= Bi

… and on loop exit i will index the list picked.

So: the "picking" script, bookpicker, is here. A prettyprinted HTML version is here. Notes:

  • You just run the script with no arguments or options.

  • I left "debugging" print statements in.

  • You're responsible for maintaining the lists; no blank/duplicate lines, etc.

  • For the "picked" list, the script writes a smaller file with the picked title missing. The old list is saved with a .old appended to the name. That's important, because next…

One last little gotcha: the randomization is sometimes a little too random. Specifically, sometimes after reading a book by a certain author, the picking script picks… the next book in the list by the same author. I don't want that. Variety is better.

So  there's also a script to "undo" a previous pick, bookpicker_unpick. If you run it before any other changes are made to the list files, it will find the most-recently-modified .list file, and "restore" the corresponding .list.old file. The script, is here. A prettyprinted HTML version is here.

Last Modified 2017-10-30 6:17 AM EDT

A BCD Clock Simulator

[Amazon Link]

I got a "binary-coded decimal clock" (made by the good folks at Anelace Inc.) a few Christmases back. Picture via Amazon link at right, if you're not seeing it, turn off your ad blocker. The time shown is 10:48:36.

[And make no mistake, Anelace is a Good Company. I shorted out the power supply adapter by clumsy accident. I emailed, asked where I could buy a replacement, they just sent me one, free. Whoa.]

When I worked at UNH, I kept it in my cubicle as a conversation piece. The thing that sticks in my mind today is how many IT managers needed me to explain what it was and how to interpret the LEDs. No geeks they.

Shortly afterward, on a lark, I wrote a small Perl script to simulate the clock display in a terminal window. I recently exhumed and updated the script to more modern standards. It's short and (I think) fun.

Here's a screen snapshot of what it looks like in action. The red dots inside indicate "on" LEDs. The LED array is updated every second, as is the time displayed at the bottom.


Plaintext source is here; Prettyprinted HTML source here.


  • The Term::ANSIScreen Perl module available from CPAN handles text positioning, color, and formatting. I think most terminal emulation programs do ANSI commands these days.

  • The LED-on "dot" is a UTF-8 character. If your terminal program doesn't handle UTF-8, the code has a commented out alternate that might work: a space with a red background.

  • The Term::ReadKey module handles non-blocking terminal reads. This was implemented so that pressing the Q key will quit. [Pressing control-C might leave your terminal window in a funny "raw input" state. Fixing that left as an exercise for the reader.]

  • It could well be that a more judicious selection of fonts, characters, etc. would make the display more pleasing. Obviously, it's easy to play with.

  • There's a "sleep 1" in the script's main loop. Since the calculations inside the loop also take a finite amount of time, it's likely that a second will be skipped every so often. I haven't noticed that happening, though.

Questions? Comments? Let me know.

Last Modified 2017-10-23 7:10 AM EDT

Fedora 27 Beta

Some Informal Notes


I've been using the Fedora Linux distribution since, well, since there was such a thing as Fedora. (Wikipedia dates this as November 2003.) Over the past couple years, I've taken to installing pre-release versions. Occasionally Alpha releases, but they stopped doing that. Fedora 27 Beta (F27) was released on October 3, I installed it on my home workstation that very day, and it has been "in production" since.

This is not an installation tutorial—other people out there do that better—but I did run into a "gotcha" that may affect a handful of folks. Unfortunately, it requires some background explanation.

I would probably fail a Linux geek purity test, because I don't install Fedora on "bare metal". Instead, I run Oracle's (free) VirtualBox software on a Windows 10 host, and install Fedora as a virtual guest. I started using this method back on my pre-retirement work computers, and it worked so well-like having two computers, one Windows, one Linux, at my fingertips—I continued the scheme at home, post-retirement.

Also: over the past few releases, I've grown fond of the Cinnamon desktop over the default GNOME desktop Fedora provides. Your mileage may vary, and that's fine, but there's a reason that (as I type) Googling "arrogant GNOME developers" gets "about 85,900 results".

I have, by now, ritualized the upgrade method. Which, oddly enough, doesn't involve an upgrade of the existing system. There are a lot of advantages to virtualization, and one of them is that it's easy to generate a new OS installation from scratch, keeping the previous one in reserve in case you mess up.

One of the goodies of Virtualbox is its so-called Guest Additions, which installs into the guest OS and provides (among other things) "shared folders", directories available to both the host and the virtual guest. That's useful to an easy upgrade, as we'll see.

An outline of my upgrade process:

  1. Save my custom configurations and data from Fedora N to a shared folder. (I have a script to do this, so I don't forget anything.)

  2. Shut down Fedora N.

  3. Install Fedora N+1 in a new virtual guest. (The sainted Fedora developers make this easy for Cinnamon-preferers: they provide a Fedora Cinnamon Spin on the same release schedule as default Fedora.)

  4. Install any and all necessary custom packages not included in the default install.

  5. Install VirtualBox's Guest Additions and restore the shared folder configuration.

  6. Restore the saved configurations and data from the shared folder in step 1 into the new guest.

And that's it! I'm eliding a lot of gory details. But…

In Step 4, it's not always obvious what non-default packages you should install, for two reasons: First, the default installation package set always changes between releases, so you might need to explicitly install something you didn't have to previously. Second: You don't want to install something you don't need. So, in practice, it's an iterative process; you observe some breakage due to something you missed, you go back to figure that out. (To a certain mindset, this detective work is kind of fun. As long as you're not racing against the clock to fix something critical to your organization. But I'm not in that position any more.)

But what happened this time is Step 5 failed silently. Why?!

Two reasons:

  1. Cinnamon (apparently) has a new default terminal emulation application: tilix. Which is fine (this isn't Russia) but as near as I can tell, they don't install any other terminal applications.

    Problem occurs when the Guest Addition script runs: as it turns out, it looks for a terminal emulation program using a list of fixed names: Konsole, gnome-terminal, mate-terminal and xterm. So the script fails. Silently.

    So: install xterm and try again…

  2. And we fail again, because the Guest Additions installation requires the dkms (Dynamic Kernel Module Support) package to be installed. Also no longer in the default set of installed packages. So install that and try again. (This also drags in the C compiler and kernel development packages.)

And then things worked. Yay!

Finally, not that it matters, but: tilix is not my cup of tea. I've grown used to/fond of a gnome-terminal feature: tabbed sessions in a single window. You can't do that in tilix, and the developers say: Sorry, no.

Reading Schedule Generator

[] October 2017 Update: I regret that I let this article get badly out of whack with reality. Notably, most of the links to my code, which were on the old UNH "pubpages" server, went stale when I retired. In addition, I've cleaned up the code some and fixed a nasty Daylight Savings Time-related bug. I hope. Further notes at the bottom of the article.

Note: this post is out of whack with normal Pun Salad content. Only recommended for:

  1. computer geeks who (like me) tend to approach everyday issues by asking: how could I write code to make this easier?; or
  2. psychologists who might be interested in whatever mental aberration causes the behavior exhibited in (a).

A few years back I noticed I was doing a miserable job of reading the magazines to which I was subscribed; the new issue would show up and I would have just read few if any articles in the previous one.

A similar problem with books: I would check them out of the library and return them unread. And my to-be-read pile of owned books just was getting bigger.

What worked for me was to set up a reading schedule for each "new" book or magazine. Simply read through a reasonable, fixed number of pages each day, until done. Lather, rinse, repeat.

I'm currently implementing this scheme by generating a calendar-format schedule for each item in HTML. Example for a book I read back in 2014, Freedom™ by Daniel Suarez:

[Sample Reading

I (1) print the schedule from my web browser, (2) cut it out, (3) attach to a card, and (4) use the result as a bookmark for the item. And each day, I try to meet the page goal for each item.

(Not that it matters, but for magazines I staple the schedule to one of the subscription cards that invariably accompany each issue. For books, I tape it to one of the plastic advertising cards the Yankee Candle company sends us, which are significantly more substantial.)

Now I'm not psycho about this: it's OK to get ahead of the goals if the material is compelling and I have the time. It's also OK to fall behind if there's just too much other stuff going on. (However, in my experience, just knowing that I've "fallen behind" is just enough self-nudging motivation to carve out some extra time to catch up later.)

Enough for the mechanics, on to the code. For a long time I ran a Perl script from a Linux command line to generate a schedule. But I realized that it would be (slightly) more flexible to set up an HTML form to get the schedule parameters, calling a CGI backend to display the result.

The form I'm using is here. (Do I have to mention that you can use your browser's source-viewing capabilities to view the HTML source? Nah, probably not.) What it looks like:

Schedule Generator Form]

The only remotely interesting thing is use of the Javascript jQuery UI datepicker widget for getting the schedule's start and end dates. I didn't know nothin' about jQuery before I did this. (And I only know slightly more now; if you examine the source code for the form, it's not very complicated.)

The form also uses a CSS stylesheet found here; I originally wrote it to make the documentation I wrote at UNH look better, and it has a lot of cruft. Feel free to steal and clean it up.

So you fill out the form, for example:

Schedule Generator Form]

… hit the submit button and the resulting page should produce the appropriate schedule. (I'm pretty sure it would work for you if you want to try it.)

The real work is performed by the Perl CGI script, which relies heavily on the smarts contained in the, HTML::Template, and Date::Manip modules. If you'd like to look at that (feel free to adapt it to your own preferences if you are so inclined): the plaintext Perl file is here and the html-prettyprinted version is here. The HTML template used by the script is also important and that's here.

Additional notes (October 2017).

  • As previously mentioned, the original version of the CGI script lived on the UNH "pubpages" webserver, where I enjoyed root access. It's now on the Pun Salad server, where I don't. This is problematic when you need to install some random CPAN perl module.

    Solution (or, at least, what I'm doing): use cpanm to install necessary modules "unprivileged" and put use local::lib; in scripts to find them. (This seems to work for CGIs, surprisingly.)

  • The most recent bug squashed was one I've struggled with for years: if your timezone does DST, not all days are 24 hours: the "spring forward" day has only 23; the "fall back" day has 25. This resulted in strange behavior when a reading schedule traversed one of those days.

    The fix turned out to be relatively easy: tell the script to pretend it's in the UTC timezone. Duh. That's accomplished by (for example) the line

    $startdate->config( 'setdate', 'now,UTC' );

Last Modified 2017-10-13 7:58 PM EDT

Fedora 19

fedora poker chips I’ve been using Red Hat flavors of Linux since 1996 (with a brief flirtation with Slackware in 1995), and I’ve been married to the offspring Fedora distribution since early 2004. I’ve been tempted to stray to some other distro, but I’m just not adventuresome that way. In theory, some major malfeature could make me file for divorce, but that hasn’t happened yet.

[Notice the strained analogy in the above paragraph? It’s not far off.]

Fedora 19 is their latest version, in Beta as I type (scheduled for actual release on July 2). On a whim I decided to install it on machines at work and home. (The work machine is a VMWare virtual machine run under Windows 7 on a Dell Optiplex 780; my home box is an older Dell running Linux-only.)

Some notes:

  • Well first, an important one. Your mileage may vary. Poor Rand Simberg, for example, encountered display problems and data loss during/after his upgrade. (Although the latter can’t really be blamed on Fedora.)

    Bottom line: no matter how knowledgeable you are, an OS upgrade is good time to wear both suspenders and a belt. If you have a working environment with precious data, you’ll want to be able to fall back to it if things go wrong.

    But things didn’t go wrong in my case. So yay.

  • The Fedora 19 installer is not much changed from the Fedora 18 installer. Which at least one guy found to be “counter-intuitive, dangerous and useless, all at the same time.” But once I figured out what the deal was, I thought it was OK.

  • I made things slightly more challenging by opting to use the MATE desktop environment instead of the Xfce environment that I’d been using for the past few iterations of Fedora. (Cinnamon might have been another candidate, but I arbitrarily passed.)

    I’d switched to Xfce after hitting and bouncing off Gnome 3, which became the default with Fedora 15. What an awful decision for the Fedora honchos to make! And it didn’t help that the Gnome developers came off as snooty and unsympathetic; if we puny users could not appreciate their brilliant design, it was our fault. True fact: Googling gnome arrogance brings up 2.7 million hits, and they’re not all talking about the garden statues.

    I understand Gnome may have gotten better since then. Don’t care. Fortunately, you can easily choose which environment to install. And you can have multiple environments installed if you want to compare and contrast.

  • As stated, the work machine was a spankin’ new virtual machine; the only tricky part was setting it up to use a different IP address than the Windows host; VMWare makes this pretty easy, although you have to remember where it is and when you have to do it.

    The minor tricky part: getting all the necessary Perl modules back. I didn’t want to mindlessly re-install everything I had before, since that might well contain some unused cruft built up over the last few months with Fedora 18. I settled for an incremental approach (wait for things to break, then fix them). I really should come up with a better method the next time around.

  • My home machine isn’t virtualized, but has a tricky disk partitioning scheme: I divided the disk into three parts, each holding boot and root partitions: current release, previous release, and the one before that. So pre-upgrade I had Fedora 16, 17, and 18. The upgrade reformatted and replaced the F16 partitions with 19. Again, the installer made this pretty easy. (As above: just pay attention to where it is and when you have to do it.)

Last Modified 2013-06-27 5:18 AM EDT

Pun Salad Makes Wikipedia; More Perl Geekiness

Not that I sit up nights and ponder my referrer logs, but I noticed an odd one today: the Wikipedia entry for songwriter P. F. Sloan. And sure enough:

Well, … sometimes. If you keep an eye on the subtitle under "Pun Salad" at the top of the page, you'll notice it changes from time to time. Specifically: the subtitle on the primary page at changes whenever the page changes; clicking permalinks or archive links generate pages on the fly, and they get a random subtitle.

The subtitle is picked via a standard Perl idiom that chooses a random line from a text file (here called subheads):

    open( F, "<subheads" ) || die "Can't open subheads: $!\n";
    while (<F>) {
	rand($.) < 1 && chomp( $subhead = $_ );
After that bit of code, the $subhead variable contains the chosen random line.

There are (as I type) currently 46 possible subtitles, so you have about a 2% chance (1/46) of seeing the one referred to by Wikipedia:

… has been seeking P. F. Sloan, but no one knows where he has gone.

This is a reference to an old Jimmy Webb song, described in the Wikipedia article as a "catchy, bittersweet composition, which seems to be about the costs and disappointments of being a creative groundbreaker." Yeah, I guess; I just like the song (you can probably give it a listen here). Wikipedia also describes some weirdness associated with it:

While Sloan helped Webb get started on his career, it was because of a personal dispute with him that Webb denied the existence of "P.F. Sloan" when asked about the song's title character during an article interview, saying that he had made the name up. Ironically, this led Eugene Landy, the controversial psychologist, to lay claim to being the real P.F. Sloan when he was asked by reporters why he considered himself able to direct Beach Boys lead singer Brian Wilson's musical career. Landy claimed to have written the songs attributed to "P.F. Sloan", and this soon led to his losing his license.

P. F. Sloan wrote some pretty decent songs, but he also wrote "Eve of Destruction", a three minute and thirty-eight second demonstration of how stupidly self-righteous the 1960s were.

Last Modified 2012-10-08 7:57 PM EDT

Perl Date Geekery

Last August, Pun Salad moved from its UNH host (specifically, the workstation under my desk) to Arias Web Hosting. They've been great, and if you're looking for a provider that allows you a decent amount of control over your site, I can recommend them.

However, the server is (apparently) located out there in the great US/Central time zone. (At least that's what the shell command date +%Z claims.) And so the timestamps at the bottom of each post dutifully reported US/Central time.

But Pun Salad's heart and soul (and, arguably, brain) is almost always zoned on US/Eastern time. So the discrepancy has been something I've been meaning to fix.

The first whack was pretty easy. The script that generates Pun Salad is written in Perl, and Pun Salad's host is running Linux. And (it turns out) in that environment, you can tell Perl to imagine it's in a different time zone by setting the TZ environment variable at the top of your script:

    $ENV{'TZ'} = ':/usr/share/zoneinfo/US/Eastern';
Hey, that worked great!

But, there was still a minor problem, one which Pun Salad has had since its inception: the timestamps would show up as EST or EDT (or CST/CDT) depending on when you looked at them. (Specifically: when the script generating the page was run.)

Irritating! If I posted an article at 6pm EDT on July 15, it should always show up as being posted at 6pm EDT, even when viewed in EST-February.

This turned out to be surprisingly difficult using my Perl date manipulation package of choice, Date::Manip. Ordinarily, this package is awesome. And (to the author's great credit), the problem shows up prominently in the documentation, under "Known Bugs": "Date::Manip does not handle daylight saving time." Rats!

Fortunately, this is fixable using the standard Perl localtime and POSIX::strftime routines. Roughly, I replaced Date::Manip code that looked like:

    use Date::Manip;
    # given Linux timestamp $ts, generate human-readable date/time
    $date = UnixDate(ParseDate("epoch $ts"), "%Y-%m-%d %i:%M %p %Z");
with something like this:
    use POSIX qw/strftime/;
    # given Linux timestamp $ts, generate human-readable date/time
    $date = strftime("%Y-%m-%d %-I:%M %p %Z", localtime($ts));
Ahhhh, that's better. If you want to check out what I said last June on the hysteria about "speculators", you'll note that it was posted and modified on Eastern Daylight Time, which it was.

Now if only I could get decent Google ads. As I type, due to my stimulus-bashing over the past few weeks, they are titled "Obama Is Giving You Money", "$37,383 Stimulus Checks", "Your Stimulus Check", and "Free Stimulus Grants Kit". Google not only hates America, they also think you're pretty stupid. (But feel free to click away, if you'd like to be amused or disgusted, at the same time sending a few pennies this way.)

Last Modified 2012-10-08 7:55 PM EDT

Rotating GNOME Wallpaper in Fedora 10

We don't usually talk programming here on Pun Salad, but …

I wrote a small Perl script a number of years ago that would rotate the "wallpaper" background on my Linux boxes, changing it to the least-recently-used JPEG file in a directory collection I've maintained. I stuck the script in my crontab file to execute every hour, and—voila!—I was mildly entertained by the automatically-changing background of scenic vistas, cute animals, etc.

This stopped working when I upgraded to Fedora 10. And, eventually, I noticed: my background was stuck on the same picture throughout my login session.

Telling symptom: the script worked fine when I ran it from the command line, but it was not working out of crontab.

Explanation: In GNOME (Fedora's default desktop software), the actual background-changing work is performed by a program called gconftool-2; the latest version requires an environment variable (specifically, DBUS_SESSION_BUS_ADDRESS) to be set in order to affect the current session's configuration. This environment variable is automatically provided to programs run from the command line, but aren't normally available to programs run out of crontab.

So I had to add some lines to my script to dig out the value of this variable and make it avaiable to gconftool-2; fortunately, this article from the Srijith Unplugged blog showed a technique for making that happen in a Bash script that wasn't tough to translate to Perl.

More information and a pointer to my script is on my "Hacks" site here.

Last Modified 2012-10-08 8:25 PM EDT

Linearly Regressed Movie Watching

Although I know all the cool kids use Netflix, I've been a customer of Blockbuster Online for awhile. I have a hopelessly long queue, both movies and TV shows. I can, of course, move things up and down in the queue.

I started wondering if there was some way I could optimize the queue. All the movies have ratings at the Internet Movie Database (IMDB); most also have ratings at Rotten Tomatoes (RT).


So I did the Statistics 101 thing, aided by some Perl web-crawling scripting and Gnuplot: a scatter plot for each movie in my queue that had both an IMDB rating and a RT rating. (click to embiggen):


I've seen worse data! They look kind of correlated, so let's also put in the linear best-fit line:


Looks almost like science! For anyone who knows what "correlation coefficient" means: it's 0.79 for this data.

Some miscellaneous observations:

  • The data should not be taken to represent anything general about IMDB and RT ratings. For example, I've either already seen, or decided I don't want to see, very high-rated movies. Similarly, there aren't a lot of dreadful movies in the queue. So the movies in the data aren't necessarily representative of movies in general

  • RT advertises their "Tomatometer" ratings prominently, but I used their fine-print "Average Rating" instead. The Tomatometer is (roughly) the fraction of critics who liked the movie; the Average Rating is more comparable to what IMDB does: each movie gets a score between 0-10.

  • Fun facts: although IMDB rates movies from 1-10, there are only two movies at IMDB with ratings greater than 9: The Shawshank Redemption and The Godfather. And there are only 38 movies with ratings under 2. I'm pretty sure the lowest-IMDB-rated movie I've ever watched is Epic Movie, which has a 2.2.

  • The movie up there in the northeast corner of the plot is The General, a silent Buster Keaton movie from 1927. It gets an 8.3 at IMDB and an 8.8 at RT. I'll move that up in the queue.

  • Down there in the southwest corner with IMDB ratings under 5.5 and RT ratings under 5.0: M. Night Shyamalan's The Happening; The Mummy: Tomb of the Dragon Emperor; and Balls of Fury (the ping-pong comedy with Christopher Walken). Maybe I shouldn't bother with those, at least not until I've seen every other better movie.

  • Somewhat interesting are the outliers: Eagle Eye was relatively despised by the critics (RT rating: 4.6) but the rankers at IMDB didn't think it was that bad, giving it a 6.8. (In the same boat: War, with Jason Stethem and Jet Li, 6.2 at IMDB, 3.9 at RT.)

    The other way around: the RT critics adored Sidekick, a direct-to-DVD underperformer (7.3 Average Rating, 100% on the Tomatometer). But the IMDBers were like, eh!, giving it a mediocre 5.7.

    Not sure what to do with those.

Last Modified 2012-10-09 8:20 AM EDT