Home Ian's Blog

The Daily Jumble

July 1, 2024

The local paper in Fredericksburg, The Free-Lance Star, was unfortunately bought by a news media conglomerate a few years ago. and has really gone downhill. These companies own bunches of papers and cut down on costs, which means reducing local coverage and using more generic AP articles. They also cannot seem to reliably hold and then restore delivery when you're out of town.

So we decided to ditch the paper and contribute to the Fredericksburg Free Press which is great local news. The one thing I miss from the paper delivery was the daily Jumble puzzle. It's silly but I enjoy working on it with a cup of tea in the morning.

So I wrote a script to download and print the jumble automatically for me every day. The first step was to find an online newspaper that has the jumble and find the pattern used for the URL of the image. I found that and can use the following to download the jumble of the day as an image file:


TODAY=$(date +"%m%d")
URL="https://cdn.wehco.com/adg/puzzles/$TODAY/jumblenh.jpg"
wget $URL -O "jumble-$TODAY.jpg"

The date command gets the date in any format you could want. Here the URL uses a two-digit month and day code. So July 1 would be 0701. We then put that code into the url and download it with wget.

I can't print a jpeg file, and so needed to convert the file to a PDF. Initially I tried doing this with the convert command from ImageMagick, but couldn't get it to make sure the PDF was an 8x11 inch document. Instead it would preserve the size of the image, or make the image itself 8x11 which was too large and blurry.

Instead, I used the img2pdf command:


img2pdf jumble-$TODAY.jpg --imgsize 5inx7in --pagesize letter -o jumble-$TODAY.pdf

Then we print the PDF on the default printer which is easy:


lpr jumble-$TODAY.pdf

Finally we wait a little while (just to make sure the PDF got to the printer fully) and delete the files so we don't clutter things up:


sleep 10
rm jumble-$TODAY.jpg jumble-$TODAY.pdf

Now I can run a script to get the jumble printed off every day, which is cool. But the crucial piece is making it happen automatically. I want to have it waiting like a newspaper delivery. So I put the script on our always-on home server. Then, we can use cron to run the script at a specified time and interval.We add jobs for cron using the following command:


sudo crontab -e

This opens an editor where we can add lines telling cron what we want. Each line has fields for minute, hour, day of the month, month, and day of the week. To run my script every day at 6:55 AM, it's just this:


55 06 * * * /home/ifinlay/jumble-print.sh

And once that's done the jumble gets printed out every day before I get up. It's a silly little thing, but I love any time programming can solve problems like this.

Copyright © 2024 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.