The Mini Newspaper Project

Many of you know I'm a big proponent of "S.T.E.A.M.", namely Science, Technology, Engineering, Art, and Math. The "Art" is often the most important letter in the STEAM acronym, as it provides the motivation for learning all that other stuff. To quote one of my friends, "Nobody wants to learn how to code, people just want to solve problems. If you could you solve problems without writing code, nobody would do it."

In this case, I wanted to stumble down the basics of "wanting to learn more about linux" through a mini newspaper project.

The goal: Use the label maker I normally use for shipping labels to print a receipt each morning with the weather report and a comic strip.

printer

The project runs on my laptop and I'm getting ready to move it to a Beaglebone linux box. All together it's less than maybe 25 lines of code, but it encompasses a bunch of skills. If you're curious about the source code, it's all up at https://github.com/awkwardengineer/PaperPrinter

Skills Involved:

The code is relatively simple. In short, a linux shell script runs the show, kicking off a python program that downloads the websites I provided for the weather report and for the comic strip. The shell script then resizes the comic strip image and processes it for the printer using a utility called ImageMagick. Finally, the shell script sends the weather report and the comic to the printer to the Common Unix Printing System, or CUPS. A crontab job is the administrative tool used to automatically run this script at 6am every morning.

Python: A computer language

Beautiful Soup: A python computer language library for processing the raw text of webpage HTML to extract information from it.

RegEx: Regular Expressions. Like search strings on steroids. Where most people are used to seeing wildcard characters, for example "*Po*" might result in "Pooh", "Pooh Bear", or "Winnie the Pooh", our RegEx is used to process the weather report text for wordwrap newline characters that are preceded by at least 40 text characters that are not other newline characters. Then the matching newline characters are removed.

ImageMagick: A command line utility for resizing, cropping, editing, and doing a whole bunch of other stuff to pictures.

Command line: A text based way to issue commands in linux. Because it's text based and doesn't rely on a user "clicking", it lends itself very well to writing "scripts", or sequences of text commands that can be automatically entered

CUPS: The Common Unix Printing System. Besides running the printer and printer queues, it provides a whole bunch of command line utilities for sending files to the printer.

Crontab: A utility to schedule commands to automatically run at preset times. The name has something to do with chronometers and tables.

HTML/CSS: HTML and CSS are some of the basic building blocks for making websites. It describes what and how items should appear on a webpage.

SSH: A secure method to remotely connect the BeagleBone. I used this to access the command line on the BeagleBone using my laptop.

VIM: A text editor that can be used in a text-only window. Very useful when writing code in a (text only) SSH session terminal.

So that was the printer project. Simple in many ways, but relied on gluing a whole bunch of separate pieces together that I all needed to learn about. Which is exactly what makes a good educational project.


Leave a comment

Please note, comments must be approved before they are published