Skip to main content


Showing posts from 2021

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