Skip to main content


Making an old USB printer support Apple AirPrint using a Raspberry Pi

There are longer tutorials on how to connect a USB printer to a Raspberry Pi and make it accessible via AirPrint but here's the minimal one that's just a list of commands and simple instructions. 1. Install Raspbian on a SD card 2. Mount SD card on some machine and navigate to / . Add a file called ssh and set up wpa_supplicant.conf for WiFi access. Now you have headless and don't need a keyboard or monitor. 3. Boot. Login. sudo raspi-config . Change password. 4. Connect printer via USB cable 5. Then execute the following sequence of commands to set up CUPS and make it accessible on the network. sudo apt-get update sudo apt-get full-upgrade sudo apt-get install cups sudo usermod -a -G lpadmin pi sudo cupsctl --remote-any sudo systemctl restart cups 6. Visit http://raspberrypi:631/admin and add the local printer. Make sure "sharing" is enabled on the printer. 7. Then make sure AirPrint is set up sudo apt-get install avahi-daemon sudo reboot Printer should work
Recent posts

Receiving the WWVB time signal in Portugal (by accident)

For many, many years I've owned a Sharper Image clock that sets itself from the WWVB time signal in Fort Collins, CO. Well, it used to set itself when I lived in the US. For much more than a decade the clock has sat by the bed and I've manually set it. And it dutifully looked for a time signal it never received. But it worked absolutely fine with manual setting. Until last night.  At some point between 0300 UTC and 0600 UTC the clock received the WWVB time signal and set itself to EST with DST enabled. This morning the clock was "off" by five hours based on time in Lisbon. The NIST propagation chart for the night doesn't show the signal hitting Portugal but somehow my trusty little clock picked it up. Although it makes sense that it set itself between those hours as that's the best time to "hear" the signal outside North America. It's about 7,700 km along the great circle route from Fort Collins to Lisbon but the signal made it! Since this is a

Cloudflare's SSL/TLS recommender on

The Plan 28 website is a small, static site that I really ought to move to Cloudflare Pages , but... currently it's running on a server that I rent. Since it uses SSL from Cloudflare I wanted to make sure that both the browser to Cloudflare and the Cloudflare to John's Server connections were encrypted.  So I dropped into the Cloudflare Dashboard to check the settings. Sure enough both connections were encrypted but it wasn't using the most secure option (Full (strict)) that requires a certificate on the server that Cloudflare can validate. That can either be one that Cloudflare issues or from a commercial or free CA. Recently, Cloudflare introduced a service that automatically discovers the highest possible security setting for SSL on a site. So I clicked the button... And let Cloudflare do its thing. Not long after I received an email saying that I could use Full (strict) already. Which was a bit of a surprise because I didn't remember setting up a valid certificate

Moving to Cloudflare Pages

At work there's a cool product for deploying websites that has great integration with GitHub, it's called Cloudflare Pages . I use and pay for a lot of Cloudflare products but hadn't got around to using Pages. The nudge came when an old friend from university who has been managing for 24 years(!) told me she'd like to decommission the server. The actual content on was originally generated by a Perl script that output static HTML. From time to time I'd modify the Perl, run it, and deploy the HTML using FTP. Really old school. Over time I moved to just running everything on the server without the FTP mess. And, in reality, most of the content on is on this blog, and that uses Blogger. So I decided to try Cloudflare Pages for the home page and go for the simplest possible page. It's all text and a single page and it looks like this: It's a single HTML file containing a small amount of CSS for the colours and a small amount of JavaScrip

Aeronear: an ambient device showing nearby aircraft

Here in Lisbon it's common to see aircraft because the main airport is in the city rather than being on the outskirts. And for a long time I used FlightRadar24 to answer the question "where did that aircraft come from or where is it going to?" But I really like ambient devices such as my Totoro that gives the weather forecast or bus that shows when the next bus arrives . So, it was time to use a few things I had lying around and make a desktop ambient aircraft monitor that looks like this: This uses a  Raspberry Pi Model 3 ,  PiTFT 3.5" touch screen  (which is kind of wasted because I don't use the touch functionality), a  24 LED NeoPixel ring ,  28BYJ-48 stepper motor , and the ULN2003 driver, and a small model aircraft. It's all contained in an acrylic pot that I got from Muji. The screen shows flight information and model aircraft and LED show the current direction the aircraft is flying (the track) and where to look for the aircraft. The first time the

Dividing n elements into groups of at least size g minimizing the size of each group

At work there's a little project to break up groups of employees into random groups (size 4) and set up Zoom calls between them. We're doing this to replace the serendipitous meetings that sometimes occur around coffee machines, in lunch lines or while waiting for the printer. And also, we just want people to get to know each other. Which lead to me writing some code. The core of which is 'divide n elements into groups of at least size g minimizing the size of each group'. So, suppose an office has 15 employees in it then it would be divided into three groups of sizes 5, 5, 5; if an office had 16 employees it would be 4, 4, 4, 4; if it had 17 employees it would be 4, 4, 4, 5 and so on. I initially wrote the following code (in Python):     groups = [g] * (n//g)     for e in range(0, n % g):         groups[e % len(groups)] += 1 The first line creates n//g  ( // is integer division) entries of size g (for example, if g == 4 and n == 17 then groups == [4, 4, 4, 4] ). Th

All the symmetrical watch faces (and code to generate them)

If you ever look at pictures of clocks and watches in advertising they are set to roughly 10:10 which is meant to be the most attractive (smiling!) position for the hands . They are actually set to 10:09.14 if the hands are truly symmetrical. CC BY 2.0 image by Shinji I wanted to know what all the possible symmetrical watch faces are and so I wrote some code using Processing. Here's the output (there's one watch face missing, 00:00 or 12:00, because it's very boring): The key to writing this is to figure out the relationship between the hour and minute hands when the watch face is symmetrical. In an hour the minute hand moves through 360° and the hour hand moves through 30° (12 hours are shown on the watch face and 360/12 = 30). The core loop inside the program is this:   for (int h = 0; h <= 12; h++) {     float m = (360-30*float(h))*2/13;     int s = round(60*(m-floor(m)));     int col = h%6;     int row = floor(h/6);     draw_clock((r+f)*(2*col+1), (r+f)*(row*2+1),