sallonoroff /about /blog /blog/archive /blog/stats /search

hello world. (2)

You may have noticed that things started to look a little different around here a few days ago. It’s not just the (style)sheets that have been changed though — the whole backend of this thing is different. I’ve ditched the self-hosted Wordpress installation and moved everything over to Jekyll, atop GitHub Pages. I thought that warranted use of another Hello World.

I’ll spare you the full details of how I shifted everything over to Jekyll — it’s not a particularly unique undertaking1 — suffice to say, this tool dealt with converting the 380 existing posts and, after one false-start trying to build it from scratch, Poole provided the basis of the new site. So the basic setup really took no time at all. Of course, it took quite a bit longer to get the site looking and functioning how I wanted, and there are still quite a few minor things left to sort out2.

The change is primarily a cost-saving exercise, since I really don’t write that much here anymore, but also a time-saving one too hopefully. I won’t have to work on keeping Wordpress (and a variety of plugins and themes) up-to-date. Nor will I have to worry too much about taking regularly backups. Furthermore, dear reader, you should find the site to be a whole lot snappier, thanks to it all being static HTML and CSS, served from GitHub’s network. On the down side, there’s no more commenting on posts (and i’ve lost all the old comments), i’ve currently no analytics to monitor visitor numbers3, and the blog’s rss feed has had to change.

Anyway, I hope you like the changes overall. And if you spot anything that looks broken, it probably is, so please let me know.

  1. I’ve saved a list of guides and other people’s blog posts that helped me to the repository’s Readme file, if you’re interested. 

  2. I’m not entirely happy with post layout, there are some broken video embeds, image-handling in the imported posts needs sorting out, lots of footnotes want neatening up, there are far too many tags, etc etc… 

  3. Long-time readers will recall I was using Wordpress Stats, after removing Google Analytics, but of course that’s no longer possible. It’s a little disappointing to find that GitHub Pages doesn’t have some sort of basic statistics. 

Using AppleScript to collect data from your inbox.

There are a host of ways of finding out where the cheapest fuel is for sale near you. I’ve been subscribed to PetrolPrices.com’s notifications for years and years, and occasionally even look at the emails. On one such day, realising I had quite the history of local at-the-pump prices, I wondered if I could easily collate and chart this data1. Being sat at a Mac, I turned to AppleScript.

I’d never written any AppleScript before but I knew it must be fairly straightforward to do what I wanted. The basic script that I eventually cobbled together simply loops through all the emails in a set Apple Mail mailbox, taking the subject line and date stamp of each message, then dumps this info into a CSV file. Here’s the relevent code2

tell application "Mail"
	set theMailbox to mailbox "testing" -- CHANGE THIS VALUE TO ALTER THE TARGET MAILBOX
	set messageCount to count of messages in theMailbox -- Find out how many emails there are
end tell

set filePath to (path to desktop as text) & "output.csv" -- SETS OUTPUT LOCATION AND FILE NAME

repeat with counter from 1 to messageCount -- Loop through all the emails
	tell application "Mail"
		set theMessage to message counter of theMailbox -- Pick the next email
		set msgSubject to subject of theMessage -- Gets the email subject
		set tempDate to date received of theMessage -- Gets the date and time
		set msgDate to date string of tempDate -- Strips the time bit from it
	end tell
	
	set theString to "Message " & counter & " of " & messageCount & "," & msgSubject & "," & msgDate & return -- Builds a line of the information we want
	
	set theResult to writeTo(filePath, theString, text, true) -- Save the line to file
	if not theResult then display dialog "There was an error writing data!"
end repeat

The output from my script (the CSV file) is rather messy, containing as it does the whole subject lines, but for me this was easier to deal with afterwards than trying to work out how to run pattern-matching in the AppleScript to remove the chaff. I was also extremely fortunate that PetrolPrices included a fuel price in their email subject line, otherwise I would have had to work out that pattern-matching stuff to search the email body text for the price (and probably given up).

Anyway, post-manual-processing of the output file, here’s the historical petrol price graph that I was able to produce with the gathered data…3

Sheffield petrol prices graph

For motorists, that line is a bit depressing. For me, it’s pleasingly similar to this one.

  1. Strictly speaking, the PetrolPrices.com terms and conditions probably forbid me from doing any of this. Back in the real world, however, I don’t see why the company would have any cause for complaint with the above. If you work at PetrolPrices and disagree, please get in touch

  2. If you want to use it, you might like to fetch the full, plaintext version which will be viewable in-browser but that can also be opened in OS X’s Script Editor. It also shows the important file-writing function. 

  3. For those wondering why a post published in March 2017 has a graph that only runs to April 2016… Well, that’s because PetrolPrices changed the format of their emails and my previous luck around inclusion of a price in the subject line ran out. Maybe I’ll work out the required regex/sed/grep/etc for version 2 of my script. (Holding your breath would be ill advised.) 

In Case of Emergency.

Remember in the olden days when you used to stick “ICE” onto names in your phone’s addressbook to denote an emergency contact? I’ve no clue if the emergency services ever made use of that information, but it was a well-meaning idea that took hold at some point1. Certainly, my wife still has me down as “ICE Mark” in her mobile. Only, in the age of smartphones, that’s no use now is it? She has an iPhone that (correctly) will more than likely be locked should she not be in a position to provide emergency contact details herself.

Clearly the ICE system needs revising for the modern, secure mobile. Fortunately, Apple’s iOS already has a solution to this: Medical ID.

Introduced in 2014 with the Health app in iOS 8, Medical ID allows the iPhone owner’s medical information – including emergency contact details – to be displayed on an otherwise locked device with just a few taps. Perfect.

I won’t bother repeating the details of how to set it up when good guides already exist, just make sure you take 5 minutes to follow those instructions. And then spread the word. After all, if you didn’t know about Medical ID, chances are your friends and family don’t either.

Further duplication.

I’ve no further insight into why this happens, but here’s another example of the same idea being independently germinated at around the same time.

Compare and contrast: Qubic Modular Power System and YOUMO Smart Modular Power Strip

Curious. I like both, by the way. And that the YOUMO raised €177,000 on Kickstarter against a 50K target suggests this sort of thing should have been made years ago. (It definitely should.)

PS. Funnily enough, I also came across this Kickstarter for “Splyt Light”, which instantly reminded me of Peter Larkam’s Branch (touched upon in that original “On ideas” post), only it’s a bit more practical and far less pretty.

PPS. I just noticed that since the Branch lighting system, Peter Larkam has had a go at designing a modular smartphone and that bears more than a passing resemblance to the Click concept produced by his former classmate Oliver Rooker. Plagiarism or inspiration? Intentional or unconscious? The only thing I’m certain of any more is this topic opening many cans of worms.

Another camera that follows you.

Almost a year ago I wrote about the Lily camera – a drone that automatically follows you around, photographing and filming your every move. It looked amazing in the marketing video but far from ready in a hands-on video I had found. It was due to ship February 2016 but at the time of writing still isn’t available.

You might recall, I also commented on the similar Hexo+ drone, which was more expensive (and required a separate Go Pro camera purchase) but also a bit more polished. Clearly it was: the Hexo+ is now available to buy (for a cool $1000).

Today I want to mention another of these follow-me drones I just learnt about: Hover Camera by Zero Zero Robotics. This thing appears to be more floating selfie-stick than the automatic outdoor-adventure cameraman of the Lily or Hexo+, but it’s equally impressive:

Sure that’s glossy promotional material by Zero Zero themselves, but go take a look at the hands-on feature that Engadget have published too. I remain impressed. The video footage captured by the drone definitely looks like it still needs work (I see much stuttering), but it’s small and light and the follow-me features look great. So, yet another to keep an eye on.