Category Archives: General

Who’s gonna drive you home tonight?

googlecarJohn’s recent column about self-driving cars made me ponder some of the conversations I’ve had about them recently.

I’m a huge fan of the idea, because I think it will transform society in ways we can only begin to imagine, and most of these will be highly beneficial. To those friends kind enough to humour me, I can enthuse for ages about decluttering the narrow residential streets of Cambridge, currently filled with empty, parked, individually-owned cars; or about the joys of rural living when you can read a good book, enjoy breakfast, or even sleep during your commute; about not having to share the roads with heavy goods vehicles, since they’ll mostly be cruising to their destinations in the small hours of the morning…

My favourite dream, though, is that of owning a self-driving motorhome. One evening, not too far off, I’ll use an iPhone app to summon it from its out-of-town parking space, and when it pulls up outside, Rose, Tilly and I will climb aboard with a good movie and a bottle of wine, and I’ll say, “Chamonix, please!”, before settling down for the evening. The following morning, I’ll take the dog for a walk in the Alps. Oh, and if a large vehicle will be a bit too cumbersome for exploring the winding roads of Haute-Savoie once we get there, I’ll just tell my car to follow us.

Now, when it comes to these ‘autonomous vehicles’, there are plenty of naysayers around. There are those who are concerned that cars will have to make ethical decisions in the face of potential accidents, and may not always make the right ones. Conspiracy theorists talk about young or high-net-worth individuals being spared while elderly or impoverished pedestrians are sacrificed. Others fear that a car swerving to miss a dog will hit a human, and so forth. It’s not, however, clear to me that human drivers, often with less information available in that split second, will necessarily do any better, especially if they are drunk, elderly, tired, distracted or short-sighted. Many of the objections are often really variations on Phillipa Foot’s classic Trolley Problem, which has been debated for many decades without any machines being involved.

It does seem clear, however, that road safety overall will be improved greatly by this technology, so unless things are sidetracked by expensive and complicated litigation in individual cases — a real danger — the lower insurance premiums associated with self-driving cars may eventually pay for their wide deployment. In fact, I expect that driving your own car will eventually be something only the rich can afford to do.

So I’m somewhat bemused when I see articles stating, for example, “The autonomous Google car may never actually happen“. Such headlines are, of course, mostly just link-bait, but it seems to me self-evident that autonomous vehicles will eventually not just ‘happen’, but will be the norm, and we’ll look back with astonishment at the time when two fallible humans were allowed to hurtle these deadly missiles in opposing directions within a few feet of each other.

Self-driving cars will come eventually. The question is simply how long it will take us to get there, and how many political and legal potholes they have to dodge en route. I, for one, can’t wait: I’ll be buying an autonomous vehicle just as soon as somebody makes one I can afford. Even if it isn’t a motorhome.

Pick your own

Block’s Farm Market, in Romulus, Michigan, is a great place.

I particularly liked the way they sell sweetcorn: a tractor drives in from the nearby field towing a couple of trailers, and you just help yourself. You pack as many as you can fit in two large bags, for $5. It’s also, I have to say, perhaps the best sweetcorn I’ve ever tasted.

20150828-13265699-900

Replace wildcard imports in Python code

From our just-in-case-you’re-Googling-for-it department…

In Python code, wildcard import statements, such as:

from foo import *

can be very convenient, but are now usually considered bad practice.

I’ve written a really simple tool called dewildcard to help replace them with full expansions, which can then be trimmed down using a tool like pylint or pyflakes.

Just in case it’s useful…

Goodbye, Android

I meant to post this when it came out a month ago…but better late than never…

Lorenzo Franceschi-Bicchierai, a computer security journalist, wrote about why he’s ditching his Android phone for an Apple one, in an article entitled Goodbye, Android. He’s not a particular fan of the Apple ecosystem but feels he must make the change for security reasons, and that’s not Google’s fault — they’re quite prompt about issuing security patches — it’s a feature of the Android ecosystem.

Google still has very little control over software updates, and Android users are basically at the mercy of their carriers and phone manufacturers when it comes to getting updates or new operating system versions. For example, it took Sony more than six months to push Android 5.0 Lollipop to its new line of Xperia Z phones, despite the fact that it had promised for a much shorter turnaround after Lollipop was released by Google. Just for comparison’s sake, when Apple released iOS 8 in September of last year, it immediately became available for all iPhone users, even those with an 2011 iPhone 4S.

As security expert Cem Paya put it, that was a conscious decision Google made when it created Android. Paya called it a Faustian deal: “cede control over Android, get market-share against iPhone.” Basically, Google was happy to let carriers put their bloatware on their Android phones in exchange to having a chance to fight Apple in the mobile market. The tradeoff was giving carriers and manufacturers control over their Android releases, leaving Google unable to centrally push out operating system updates.

Men are from Mars

If you enjoyed Andy Weir’s book, The Martian, anything like as much as I did, then you’ll certainly enjoy this splendid hour-long interview with him. (If, for some reason, you haven’t yet read it or listened to the audiobook, you should probably save this until you’ve done so.)

Shell ‘Fill Up & Go’ – or ‘How Not To Introduce A Service’

shell_logoA couple of months ago, at my local Shell petrol station, I noticed they had installed big QR codes by the pumps. Interesting. Inside the store, I found leaflets telling me about Fill Up & Go, their new payment option: you can just scan the code at the pump using their app, and then fill up, confirm the transaction on your phone and drive away: it’s billed to your Paypal account.

Excellent. I’m a big fan of anything that moves us towards electronic payments, and a big user of Paypal, and this sounded rather fun, so I took a leaflet, went home and downloaded the app. But I couldn’t find anything at all relating to QR codes or to Paypal. Strange. So I filled in a support query and sent it off. Sigh.

It was a little over a week before I got a standard canned email reply, which said that it would be available through their app ‘later this year’. So why are they installing QR codes and giving out leaflets now? Who knows? But, “We are really excited to be offering this innovation to our customers, beginning with you.” Mmm, yes.

The message did, however, say it was currently available through the Paypal app. Ah! OK. So I went and looked at that more carefully. Errm… no. Sorry. Nothing there either. Sigh again.

So I gave up. Well, almost. I didn’t actually get around to deleting the app from my phone. And so it was that this last week, a notification popped up saying that Fill Up & Go was now available! Hurrah! OK – I fired up the app again, filled in my Paypal details, chose a PIN… and then it died with an error. Sigh yet again.

A few days passed, and then another notification from the app popped up. This one apologised for the problems some users had experienced setting up their payments, and said things had now been fixed. “Finally!”, I thought, and went back in and successfully set up the Paypal account. Things were looking better. It confirmed the connection. It let me set a PIN. It even told me that my friendly local station was the nearest place I could use it. Great!

So I drove around the corner, pulled up at the pump, pulled out my phone, turned to look at the sign, and what did I see? The QR codes had been removed and replaced with a ‘Coming soon’ message. Sigh. This was starting to become farcical.

Today, however, I had some time to spare, and was passing a different Shell station, where I knew they had QR codes. At last. My chance to experience the future. I turned in. Waited only a brief period for the pump to be free. Pulled up. Fired up the app. Scanned the QR code… and got a message. “Problem connecting with that Paypal wallet. Please pay in the store.” I drove off. Sighing.

I got home, and looked at their website… where they have a nice map that still shows my local QR-free garage as one of the places you can use it.

Now, Shell, since you are so determined to refuse my attempts to give you money, can we try the other way around? My team and I could keep using you as an object lesson in ‘how not to do it’, or we could offer you some very nice consulting for a very reasonable price…

In the meantime, here’s some free advice. Just install Apple Pay. It works.

Communities of Learning

A fun and inspiring TED talk by John Green.

Making your Mac keyboard function better (as it were…)

Here are a couple of menu-bar apps I run on all my Macs:

Keyboard Maestro

Keyboard Maestro is a quirky and exceedingly useful utility. It’s a bit like Automator, but with a whole range of different capabilities. At its simplest, it responds to an event (like a particular key combination) and executes a set of actions (like, say, opening an app and moving its window to the top-right quarter of the screen).

But it can do more complex operations. Sometimes, for example, I have apps that respond to particular hot-keys, but only if they’re running; I can use Keyboard Maestro to detect the keystroke, and if the app isn’t currently open, it’ll fire it up and then send the keystroke on to it, or choose the equivalent option from its menus. More about keyboard shortcuts later.

A set of actions can be triggered by more than just keystrokes, too. You can have them run when:

  • The system wakes from sleep
  • The contents of the clipboard change
  • A button is pressed on an attached MIDI controller
  • A particular USB device is plugged in or turned on
  • You connect to a particular wifi network
  • Every 15 minutes
  • An item is added to a particular folder
  • A particular application starts
    to name a few…

Its one of those utilities that will be used in a different way by almost everyone who installs it. Here are some of my most-used triggers:

  • When I press Fn-J, it opens my journal (nvAlt)
  • When I plug my GPS logger into the USB socket, it moves all the track files onto Dropbox and runs various scripts on them, then ejects the USB drive so I can just unplug it.
  • When I turn on (or open the lid of) my scanner, it fires up various things to help with my paperless workflow. When I turn it off, it closes all the windows it opened.
  • When I wake up my laptop, it waits a few seconds to let things stabilise, then checks whether I’m on my home wifi network, and if so, it mounts my photo and music shares from my Synology server.
    None of these is vital, but all of them make my life easier, and creating them with keyboard Maestro is really pretty easy. Recommended.

Karabiner

Karabiner used to go under the snappy name of KeyRemap4MacBook, which was horrible, but at least somewhat descriptive! This little utility is even more quirky than Keyboard Maestro, and has a rather poor user interface, but it’s one of those things that, once you’ve set it up, does its job reliably and predictably, so you seldom need to touch it again.

It lets you remap your keyboard in various ways, and, despite its previous name, works on much more than just MacBooks. You can do very powerful things with this, especially if you want to go as far as customising bits of XML configuration, but normally you’ll just want to pick from a few of the standard options.

It’s really useful if you switch between different keyboards and want, say, to make the PC-style keyboard in the office work more like the Mac keyboard at home, or the other way around. I have Apple keyboards everywhere, so this is less of an issue, but I use it for just two things:

A ‘hyper’ key

I have a few global keyboard shortcuts that I use all the time, like the one mentioned above to open my journal, and another to create an item in my to-do list. I don’t want these to be buried under two many modifier keys (shift-ctrl-T), but I also don’t want them to clash with keyboard shortcuts used by my apps: I want them to work the same everywhere.

The secret is to create a new modifier key, sometimes called ‘Hyper’, which nothing else uses! I forget who came up with this idea originally, but the trick is to map, say, your Function (fn) key to produce Shift-Ctrl-Alt-Command, which no app ever uses for its shortcuts because it’s too much of a pain to type. Karabiner has a setting to do precisely this, without affecting The normal use of Fn when pressed with, say, the function keys. The, by setting my hotkeys in things like Keyboard Maestro to things like Fn-J (which it interprets as Shift-Ctrl-Alt-Cmd-J), I can just type Fn-T to create To-do items, Fn-J to create journal entries, Fn-D for my diary, and so forth, and I know that they work anywhere on my system.

A coder’s UK keyboard

I have UK keyboards, which I prefer to US ones, except that they have a £ when you type shift-3. I’m a programmer, and not a wealthy one, which means I need a ‘#’ far more often than I need a ‘£’. This does involve a short bit of XML: you just need to follow these instructions and paste in the code below, after which you’ll have an option called ‘Swap £ and # on UK keyboard’.

I hope others find those useful too!

<?xml version="1.0"?>
<root>
    <list>
        <item>
            <name>Swap £ and # on UK keyboard</name>
            <identifier>private.swap_pound_and_hash</identifier>
            <autogen>--KeyToKey-- KeyCode::KEY_3, ModifierFlag::SHIFT_L, KeyCode::KEY_3, ModifierFlag::OPTION_L</autogen>
            <autogen>--KeyToKey-- KeyCode::KEY_3, ModifierFlag::OPTION_L, KeyCode::KEY_3, ModifierFlag::SHIFT_L</autogen>
        </item>
    </list>

</root>

Coming into alignment

The project I’m currently involved in at the University Computer Lab is investigating how we can make use of some of the lab’s computer vision and human interface expertise to improve the experience for car drivers. This is being done in conjunction with Jaguar LandRover, and we’ve been equipping a Discovery with several cameras, some looking at the driver and passengers, some at the surroundings.

2015-07-09_10-56-23-07

We can also record various bits of other telemetry from the car’s internal CAN network, and some of the cameras are synchronised to this, but not all of them.

My knowledge of computer vision techniques is about a quarter of a century out of date, so as part of a learning experiment today I was thinking about ways of automatically synchronising the video to the data. The two graphs below show the first minute and a half of a recording, starting with the stationary car moving off and going through a couple of turns. This isn’t how we’ll eventually do it, but it was a fun programming experiment!

This first plot shows the angle of the steering wheel, as recorded by the car’s own sensors.

steer

This second plot shows the average horizontal component of optical flow seen by one of the front-facing cameras: in essence, it’s working out whether more of the pixels in the view that the driver sees are moving left or right.

flow

I’m quite pleased that these two completely independent sources of data show such a nice correlation. Optical flow is, however, pretty time-consuming to calculate, so I only got through the first 90 seconds or so of video before it was time for dinner.

Fun stuff, though…

The great gluten-free diet fad

seed-head-wheatI thought this BBC post by William Kremer presented a pretty balanced view about dietary gluten. Here’s a quick summary for people like me who knew nothing about this:

  • As a general rule, avoiding gluten is a bad idea because we get valuable vitamins and fibres from it that you would then have to supplement in some other way.
  • A little under 1% of people, however, suffer from coeliac disease which gives them serious gluten intolerance, and the increasing availability of gluten-free foods is very valuable for them.
  • There is a larger group of people who may have some gluten sensitivity, perhaps as high as 6%, and can benefit from reducing or avoiding it. This is hard to test for, and its existence is somewhat debated, but double-blinded trials with placebos suggest that it isn’t completely imaginary.
  • Nearly 30% of Americans, however, feel that they ought to try and avoid gluten in their diet. This is a recent trend.
  • If you replace gluten-containing foods – e.g. baked goods – with gluten-free alternatives, you will often be worse off because they tend to be more calorific. You can lose weight, however, by replacing them with fruit and vegetables.

Strike action

lightning

There seem to have been a few reports of people being struck by lightning recently – this recent tragedy in the Brecon Beacons being one example.

So what should you do if you find yourself at risk? My first thought would be to get close to something taller and more conductive than me. But this site suggests it’s a bad idea – being close to a strike can be almost as dangerous as being hit. They also recommend sitting on your rucksack, to insulate you from the ground, which I guess is fine as long as there hasn’t been any rain recently.

On a cheerier note, I saw some reports last week about a man who had been struck twice in his life, and survived both. This was pretty unusual in itself, but the focus of many of the articles seemed to be his name: Rod.

Photo: Kent Porter. Thanks to Jo for the link to the mountain safety site.

A Colossal Hit

One of the websites I most enjoy browsing, perhaps because it’s really rather different from most of my other reading, is Colossal.

Dedicated to ‘Art, Design, and Visual Culture’, it’s somewhere you can always find striking images. Here are some of my recent favourites – click on them to go to the relevant articles and find out what they’re all about…

rolling-1

leaf-9

bubble-1-600x828

pencil-5

tent-2

© Copyright Quentin Stafford-Fraser