Archive for the 'General' Category

When Flow typing didn’t quite work properly (and it was all my own fault)

I’m working on a Javascript and React application, which uses Flow to enforce types. For the most part, I love working with Flow, but it hadn’t been working properly for a while.

My IDEs (both Webstorm and VSCode) both reported type errors correctly, but running flow check at the command line (or on CircleCI) always returned No errors! Great, except there were errors lurking in there – loads more than Webstorm was finding!

It turned out to be because I had this line in my .flowconfig:


That was there so I could use absolute imports (meaning I could type import Foo from "utils/bar"; instead of import Foo from "../../../../../../../../utils/bar";). Unfortunately that turned out to a broken config, which masked a hell of a lot of problems! Luckily I wasn’t the first person to run into this. The correct way to do that is:

module.name_mapper='^utils/\(.*\)$' -> '<PROJECT_ROOT>/src/utils/\1'

And add another module.name_mapper line for each top-level folder under src.

If you’re importing from a file at the top level (e.g. import type { Foo } from "flow-types";) the module.name_mapper will look something like this:

module.name_mapper='^flow-types' -> '<PROJECT_ROOT>/src/flow-types.js'

Unfortunately, when I corrected the problem, it revealed a lot of Flow errors in my codebase. Flow has got a lot more strict since I introduced the problem (and that’s a good thing). Luckily, most of those issues are relatively simple to fix!

What to do when the HTML download attribute is ignored

It turns out web browsers will usually ignore the <a download="filename"> HTML attribute on cross-origin requests.

The answer is for the server to set the HTTP Content-Disposition header in the response:

Content-Disposition: attachment;

This assumes the filename on the server is correct. In my case (for complicated and boring reasons), it is not, so I also need to set a filename in in the Content-Disposition HTTP header, e.g. Content-Disposition: attachment; filename="example.pdf".

In my case, the files are stored on a Google Storage bucket. Their name is not the same as the name the user wants (e.g. the file is called export_yVW4Bg-f63rpZIUiXvWct.pdf but the user wants export_31Jan2022.pdf). So when I create the file, I also need to set the Content-Disposition header accordingly.

This code snippet is part of a Google Cloud Function running on NodeJS, and I’m using the @google-cloud/storage library:

const { Storage } = require("@google-cloud/storage");

// Set the metadata to make the PDF download correctly
const setFileMetadata = async (
) => await storage
        contentDisposition: `attachment; filename="${downloadFileName}"`,
        contentType: contentType,

await setFileMetadata("my-unique-bucket-name", "export_yVW4Bg-f63rpZIUiXvWct.pdf", "export_31Jan2022.pdf");

Google’s engineers have posted a more comprehensive code sample, showing how you can also set other headers (e.g. cache-control) and metadata on the file.

The 1996 GT LTS-3

I had one of those, in black! It was rad. Also terrible and squeaky. But mostly rad.

Electric milk floats

When I was a kid, we had milk delivered to our door every day. There’s plenty to be said about that, but today’s point: It was delivered by an EV, and at the time it was completely normal.

When I was growing up in the 1980s, we had fresh milk delivered to our door every day, by someone driving an EV. At the time that was completely normal. Over time, those EVs just faded away.

The EV design was chosen in part because they’re quiet (especially compared the the diesel and petrol engines of the time) – the milk was being delivered to residential streets in the early hours of the morning.

Unigate Milk Float
Unigate Milk Float by f1jherbert on Flickr.

There’s a lot of buzz around the likes of Amazon and UPS ordering huge numbers of EV delivery vehicles from companies like Rivian and Arrival. These things are super cool and potentially transformative, but the concept isn’t exactly new. Specialist electric vehicles designed for short hop (or last mile) deliveries in towns and cities have existed for nearly a century. It turns out Wales and Edwards started making these things in the early 1950s, and Morrison-Electricar were building them as far back as the 1930s.

We just forgot about them for a while.

Making it harder to screw up

Chris Coyier’s Make it hard to screw up driven development struck a chord with me. If there’s ever going to be more than one of you working on a codebase, having a style guide for your CSS or SASS or Javascript or whatever makes sense. Having it automatically applied when you hit save means you rarely have to worry about adhering to the style – it just happens for you. I’ve yet to have one of these tools break my code, either.

One thing Chris didn’t mention though was running a spellchecker over your code. It may sound completely bananas, but hear me out. Firstly, it’s a code-specific spell checker. Secondly, I’ve worked on projects before where we’ve ended up with 3 different spellings of the word “palette”, because 3 different people assumed they had it right. It also means you’re implicitly being encouraged to give your variables and CSS classes meaningful names, so when you revisit the code in the future it’ll make a bit more sense. We used cSpell to do this, but I’m sure other similar products are available.

These tools don’t just exist in the development tools, either. We have them set up in our CI environment, so you can’t merge a code change unless it passes all of the tests – and the tests include both spell checking and matching the style guide. The system won’t let you screw these particular things up – leaving you free to concentrate on not screwing up the actual logic.

I’m a big fan of working this way, in case it wasn’t obvious.

I’m glad I got paper train tickets

I nearly opted for e-tickets when I booked the train but had a gut feeling it was a bad idea. It’s one of my last trips to Manchester for work and the last Christmas ‘do’ I’ll be attending at this job.

I’m glad to have real paper tickets because this morning O2’s entire mobile network seems to be borked. Wouldn’t have been able to get my e-tickets at all.

I’m glad I brought a paperback to read, too. It’s This Is Going To Hurt by Adam Kay. The brilliantly written diary of an NHS junior doctor. I’ve spent the first 50 pages stifling laughter and squeamishly cringing, often at the same time.


We pulled into Wolverhampton station and I looked across, thinking I was seeing a reflection of my train in the window of the Pumpkin cafe.

That is until the reflection started moving. My train was stood still. I was looking through a window at another train platform. Things are not always what they appear to be.

It took me straight back to the Roppingi Hills complex in Tokyo, where we saw an exhibition by Leandro Erlich: “Seeing and Believing”. He took us through a series of set pieces designed to test our assumptions.

My favourite piece was the mock hairdressers’ salon. The mirrors on one side of the room worked perfectly – showing my reflection. The mirrors on the other side were broken. No, broken is the wrong word they just didn’t work properly. They reflected the room but not the people in it, as if we were vampires. In fact there was a completely different group of people in those mirrors. It took me a little while to figure out what was going on.

I was looking through a window at another salon.


On 28th January 2017, my mum, Lucy Mary Hodgson passed away after a long battle with Lymphoma. Here is the eulogy I read at her funeral.

Thank you for coming to celebrate Lucy’s life with us. It means a lot to see you all here. We can’t possibly hope to fully capture her in this eulogy everybody has their own perspective, but we’ll do our best. When I say we my Granny Mary and aunt Paula had a big hand in this.

Lucy was born in Stratford upon Avon on 20th April 1956. She was the eldest daughter and the third of seven children. Mary, her mother, described her as “an exceptionally beautiful baby who rarely cried”. Some qualities are clearly set at a very early age.

The family moved to Woking when Lucy was five and she attended the Providence Convent School, which was situated on the site of this church. She was a confident little girl and played the leading role of Little Red Riding Hood in a school production.

However, as she got older and changed schools she became shy, quiet and self-effacing. Perhaps because of this people often underestimated her. She was amongst the first intake when the new St John the Baptist School opened here in Woking.

She enjoyed spending a lot of time at the swimming pool with her sisters and by the age of twelve she could swim a mile. Throughout her life whenever she was near the sea she’d want to get in for a quick dip even in ridiculous Welsh winter conditions.

On leaving school she went to work at Slocock`s Nursery and studied horticulture concurrently at Merrist Wood.

Later, working in the greenhouses at Woking Park, she met and fell in love with the park’s foreman, Adam Hodgson. They married in 1979 and moved to Guildford where Adam started a landscaping business Adam the Gardener.

To help the business Lucy became adept at administration and book-keeping. They bought an early Amstrad PC, and she was soon an expert with spreadsheets and accounting software long before most people even knew what they were.

They had four children: me, Alice, Florence and Abigail. Lucy loved motherhood; her children were her pride and joy, she adored their company and would do anything for them.

Lucy had fond memories of her own childhood camping holidays, travelling all over the UK in a succession of family minibuses and converted ambulances. She kept up this tradition with her own family, making numerous trips to France, North Wales and even the Isle of Man to see the TT Races. Sometimes we joined forces with Sheila, Stephen or our friends’ families, camping en-masse so all the children and adults could play together.

She also took the family further afield to soak up the culture and sunshine in Malta, Cyprus, Florence, Rome and Florida.

Lucy travelled to Sri Lanka on her own, to Vietnam with her sister Sheila, and on a variety of European trips with her mother and as many of her siblings as possible. She loved to savour the local sights, cuisine and wine with her family.

She would have loved to have travelled more – she dreamed of seeing fall in Vermont, and of visiting her brother-in-law Piers in Australia. She loved to hear about all her children’s adventures too firing her own imagination.

Her husband Adam was a keen motorcyclist. He and Lucy attended many events together including all night rides and large weekend events with the local classic motorbike club.

In 1994 Adam died in a motorcycle accident, so Lucy was left to close the business and bring up her children alone. His sudden death when Abigail was only two was a crushing blow; but she faced this, as with all the challenges life threw at her, with dignity and fortitude. She was a very private person and kept most of her worries to herself.

Adam supported Crystal Palace football club. Lucy took up his season ticket and we cheered them on from the Holmesdale Terrace together for a couple of seasons. She supported them ever since taking great delight on the rare occasions when they embarrassed a much bigger team. I still remember her singing variations on “Que sera sera” when they were doing particularly well.

When we children had all started school or university, Lucy looked for work and for a while had three part-time jobs helping various small businesses with their admin.

Finally, she began working in the office of Woodbridge Hill Surgery, just around the corner from her home. She loved the job and adored the people she worked with. She started small, effectively just sorting the post. Over time she grew tremendously, taking on more and more complex roles. She worked her way right to the top, becoming Practice Manager an achievement she was rightfully very proud of.

Lucy had many hidden talents. In Woking at her old home there are several remarkable paintings completed when she was in her 20s. She carried on dabbling throughout our childhood, and in more recent years became a fixture at a local art class, developing her own signature watercolour style and making some good friends. Every year she would exhibit her work and sell her own Christmas cards and then downplay her accomplishments.

Not only was she a very talented artist, she could name most plants by their Latin names, and tell you when to prune them. She loved gardening, and every year she had some Gooseberries, Raspberries and Sweet Peas on the go. She could help you with your tax return. She knew all the details of football leagues and transfers, Formula 1 fixtures and tennis tournaments (all of which are quite incomprehensible to the rest of her siblings). She was a friend of the Royal Academy, a member of the National Trust and of the Guildford Cinema Club. She became engrossed in TV series as diverse as Star Trek, Doctor Who and Masterchef. More recently she took up badminton and proudly stuck to a workout regime at a local gym.

She loved music, attending festivals and gigs at first as a teenager, and then later with her own children. She saw some really big names over the years. Her vinyl record collection is huge and she would relish the opportunity to get them out and dance around the living room, usually with one or more of her daughters. Whenever we were planning to embark on a long car journey, she would compile a mix-tape to liven up the trip and make the miles fly by.

She was also a big reader, regularly losing herself in a good book. Her most recent accomplishment was completing the entire back catalogue of Kate Atkinson.

Although she lived in Guildford she came every Saturday night to Woking to attend mass here with Mary, and then to stay and catch up over supper and a glass of wine.

She was never particularly evangelical about her faith it was a very personal thing. She knew where she was going, and that gave her strength right at the end.

Lucy had a sweetness and kindness about her that made her the perfect restful company she was one of those people that made you feel better the moment they appeared. She was funny, sympathetic and constantly good natured.

Nevertheless, she had strong views about everything, from politics and current affairs to books, films, artists, as well as food and travel.

I loved chatting with her over a long drawn out breakfast (her poison was bacon) discussing anything and everything, especially if it was on the front page of the Guardian.

She was open-minded, with no big expectations of you. She wasn’t pushy, but rather wanted you to find your own way. She would love you whatever you did and she loved to hear all about it, too.

She got great pleasure from simple things; a new baby, cats, a Belgian chocolate truffle, a Stevie Wonder track, chickens, jigsaws, Sudoku, a good cheese, a glass of Petit Chablis in the sun, and all of our big family gatherings especially Christmas in Woking and new year in Cheltenham with Stephen and Helen.

Of course, the new baby Lucy was most excited about was Alice and Angus’s daughter. She was thrilled to be a grandmother and loved to spend time with little Astrid, see the latest photos and to hear about every stage in her development.

A little over a year ago Lucy was diagnosed with a rare and very aggressive blood cancer. One of the things I’m most proud of is how she faced up to it: Her attitude was always strong, positive and forward-looking. Although she was often scared, she found the strength to push on through and take on the next challenge. Even at her lowest, she never gave up hope.

In her mind, the future was always bright. And of course, it still is it’s just that now we’ll have to face it without her gentle loving presence.