As what as you like

  • New blog setup

    Bye bye Blogger, hello GitHub Pages. This means no more comments, and probably a bunch of posts have terrible formatting at the moment, but at least my blog is now just static Markdown files I can edit nicely 😁

    (Also the domain has changed, is the new :)

  • Changing GPG key

    It’s been 15 years and my GPG key is now looking hilariously out of date - 1024bit DSA key. Yuck. So, time to start over. Below is a statement about the change, with details of my new and old keys, signed by both keys. Since it will almost certainly not paste properly out of a browser, I have also uploaded it to GitHub: here.

    Hash: SHA256
    Hash: SHA256
    Hello world
    My name is Chris Jones and I am changing my GPG key.
    The original key fingerprint is: 6C99 9021 9B3A EC6D 4A28  7EE7 C574 7646 7313 2D75
    The new key fingerprint is: 79D2 2E89 6591 210E 45F3  75D3 BCA2 36E2 E19F 727D
    You should find this message signed by the new key, and that combined message signed by the old key, as proof that I am doing this. I have also updated my account and secured a couple of signatures on the new key to start rebuilding my place in the web of trust.
    Thank you for your time,
    - -----BEGIN PGP SIGNATURE-----
    Version: GnuPG/MacGPG2 v2.0
    - -----END PGP SIGNATURE-----
    Version: GnuPG/MacGPG2 v2.0
    -----END PGP SIGNATURE-----
  • Raspberry Pi project: PiBus

    The premise of this project is simple - my family lives in London, there’s a bus route that runs along our road, and we use it a lot to take the kids places. The reality of using the bus is a little more complex - getting three kids ready to go out, is a nightmare and it’s not made any easier by checking a travel app on your phone to see how close the bus is.

    I don’t think there is much I can do to make the preparation of the children any less manic, but I can certainly do something about the visibility of information about buses, mainly thanks to the excellent open APIs/data provided by Transport For London. So, armed with their API, a Python 3 interpreter and a Raspberry Pi, I set out to make a little box for the kitchen wall which will show when the next 3 buses are due to arrive outside our house. The code itself is easy enough to throw together because Python has libraries for everything (it also helps if you don’t bother to design a decent architecture!). Requests to fetch the bus data from TfL, json/iso8601 to parse the data, Pillow to render it as an image, and APScheduler to give it a simple run-loop. The question then becomes, how to display the data. The easiest answer would be a little LCD screen, but that brings with it the downside of having a backlight in the kitchen, which would be ugly and distracting, and it also raises the question of viewing angles. Another answer would be some kind of physical indicator, but that requires skills I don’t have time for. Instead, I decided to look for an E-Ink display (think Kindle) - it would let me display simple images without producing light. The first option I looked at was the PaPiRus, but it’s in the window between its crowdfunding drive having finished, and being available to buy. The only other option I could find was the E-Paper HAT, from Percheron Electronics, which also started life as a crowdfunding project, but is actually available to buy. Unfortunately, these displays are super fragile, which I discovered by destroying the first one, but Neil at Percheron was super helpful and I quickly had a new display and some tips about how to avoid cracking it. My visualisation of this data isn’t going to win any awards for beauty, but it serves its purpose by showing a big number to tell us how many minutes we have, and I managed to minimise the number of times you see the white-black-white refresh cycle of the eInk display with partial screen updates. Here are some photos of the project in various stages of construction: | | |————————————————————————————————————————————————————————————————————————————| | | | Freshly assembled out of the box |

    The smallest USB WiFi adapter I’ve ever seen
    Sadly I had to make some modifications to the
    PiBow case to fit this particular rPi
    Running one of the eInk display test programs

     Initially I was rather hoping I could use the famous font that TfL (and London Transport before it) use, which is known as Johnston, but sadly they will not licence the font outside their own use and use by contracted partners. There is a third party clone of the font, but it may have legal issues, presumably because TfL values their braaaaaand. Instead, I decided to just drop the idea of shipping a font with the code, and exported Courier.ttf from my laptop to the Pi directly.

    This would have been nice, but I cannot have nice font things.

    I did briefly try Ubuntu Mono, which is a lovely font, but the zeros look like eyes and it freaked me out.


    The display needs to handle various different situations, most obviously, when no data can be fetched from the API. Rather than get too bogged down in the details of whether our Internet connection is down, TfL’s API servers are down, London is on fire, or it’s just night time and there are no buses, I went for a simple message with a timestamp. Once this has been displayed, the code skips any further screen updates until it has valid data again. This makes it easy to see when a problem occurred.

    Maybe aliens stole the Internet, maybe it's a bus strike.
    It doesn't matter.

    I also render a small timestamp on valid data screens too, showing when the last data fetch happened. This is mostly so I can be sure that the fetching code isn’t stuck somehow. Once I trust the system a bit more, this can probably come out.

    The final design, showing a fallback for when there is data for  0 < x < 3 buses
    Data for three buses, plenty of time to get ready for the second one!

    So there it is, project completed! Grab the code from, install the requirements on a Pi, give money to the awesome Percheron Electronics for the E-Paper HAT (and matching PiBow case), throw a font in the directory and edit the scripts for the bus stop and bus route that you care about!

  • Sending iMessages and SMS through with AppleScript

    I was searching around for ways to automate sending iMessages, so I could write a plugin for Hammerspoon. I found various scripts lurking around the place for sending iMessages, but I also found one that can send SMS if you have SMS Relay enabled (which means you need OS X 10.10 and an iPhone running iOS 8.1). I figured I’d collect them as a single post, to help future searchers, so without further ado, here are two stripped down AppleScript snippets that let you control to send either an iMessage, or an SMS. Firstly, sending an iMessage:

    tell application "Messages"
      send "This is an iMessage" to buddy "" of (service 1 whose service type is iMessage)
    end tell

    The buddy address can be either an email or a phone number that’s registered with Apple for use with iMessage. Secondly, sending an SMS:

    tell application "Messages"
      send "This is an SMS" to buddy "+1234567890" of service "SMS"
    end tell

    Here, the buddy address should be a phone number. Simple! (and for the Hammerspoon users, you’ll find hs.messages available in the next release, 0.9.23)

  • The curious Moto X pricing

    Comparing the Moto X to the Nexus 4 is interesting in one particular respect - the price. The Nexus 4 (made by LG, sold by Google) had very respectable specs when it was launched, but its price was surprisingly low ($300 off contract). We were told this was because it was being sold very close to cost price. The Moto X (made by Motorola, which is owned by Google) has mid-range specs, but its price is surprisingly high ($200 up front *and* an expensive two year contract). Overall Motorola is probably getting something like $400-$600 for each Moto X sold, when you factor in the carrier subsidy. The inevitable question is why Google is happy to make almost no money off the Nexus 4, but wants to have its Motorola division make a respectable margin on the Moto X.

    • Is it because doing otherwise would undermine the carriers’ abilities to sell other phones, so they would refuse to do it?
    • Is it because Google wants the Motorola division to look good in their accounts, which is easier if you are selling mid-range phones for the kind of money that an iPhone sells for?
    • Something else?