Remembering the 90s Web

This morning I had a lovely meeting with Andreas Marakis, who’s researching the sociological impact of the Web of the 1990s on people who experienced it first-hand.

I’m seeing more and more interest in this period – even, surprisingly, among people too young to be nostalgic about it – as the countercultural “web renaissance” tiptoes out of the shadows and encourages newcomers to take their first steps in building their own Web identity with HTML, CSS, and (maybe) JavaScript.

Anyway: chatting to Andreas was great and it reminded me of quite how grateful I am to have gotten to experience a lot of these seminal technologies when they were at their newest and most-experimental.

Is midnight in the middle of the night?

This is a reply to a post published elsewhere. Its content might be duplicated as a traditional comment at the original source.

Niki said:

I was curious if midnight is, in fact, a middle of the night. Turned out it is! In winter time. In summer time, middle of the night is around 1 am.

Graph showing sunrise, sunset and middle point between them for a year

Also explains why winters are so brutal: 16 hours of darkness between sunset and sunrise on Jan 1! Charted for Berlin

It does, of course, depend on your position within your solar timezone!

Berlin is about 13.5 degrees East of the Prime Meridian, so it’s 13.5 / 360 * 24 = 0.9 hours. So that means it’s 54 minutes East of UTC.

UTC is functionally equivalent (for normal humans) to GMT, which is calibrated based on the solar time at the Prime Meridian.

Germany’s timezone is UTC+01:00 in the winter, so you’d expect solar “midnight” (and “midday” for that matter) to be 6 minutes “early”, on average. Which is probably exactly what your graph shows! (There’s a little bit of a wobble because of complicated orbital physics and inclination and stuff, but it’s ABOUT right.)

Being out by an hour in summer is, of course, because the clocks are “wrong” by an hour in the summer, compared to solar time. Or rather, in Berlin, wrong by an hour and six minutes.

This rule, of course, doesn’t hold true everywhere. If you live in the far West of China, your true solar time might be only UTC+05:20, but China’s timezone is UTC+08:00, so solar events like sunrise, sunset, midday and “midnight” would fall over two and a half hours “late”!

What you’re seeing in Berlin is the consequence of you being almost-exactly in the centre of the idealised solar UTC+1 timezone. Look at a timezone map that extends bands all the way to the top or bottom and you’ll see what I mean! And spare a thought for the folks in Reykjavík who are on UTC+0 despite being at a solar position of approximately UTC-01:25!

I want my friends to have blogs too

This is a repost promoting content originally published elsewhere. See more things Dan's reposted.

Blogs. The curated, written looking glass into someone’s perspective. That’s what I love about them. Blogs. Waking up in the morning and spending a little time reading over the carefully chosen words of another human being. Truly astounding. Blogs. Poured time and energy, someone distilling themselves into this personal, sharable medium. Blogs.

I guess to bring this post to an end… if you don’t have a blog, change that! (especially if I know you IRL, seriously). I wanna hear about you and your life! Start that quirky and personalised website. If you already do, tell me and share! Every one of them is awesome; from digital gardens to byte-based megacities. Fill them with you and share! I can’t wait to start reading :)

Oh, so very much this.

There was a time, a couple of decades and change ago, when almost all of the people I spent time with in my real life blogged. Nowadays, it’s far fewer. Ruth shares interesting bits of tech (plus Thames Path walks!), and I keep an eye out in case Gareth shares more ‘plane-related news or Andy takes a deeper dive into his music… but nowadays the active blogs I follow are, for the most part, people I know online (or, at least, people I knew online first, even if I’ve subsequently met them in person).

That’s not bad. I like meeting people online. And increasingly, the smallweb’s becoming better-interconnected and less-lonely than ever.

Daniel really puts it well:

Blogs allow for a deeper level of thought; not everything is well suited to an in-person chat. We sometimes need time to get our thoughts in order and detailed concepts are often much better understood in writing. It’s honestly a shame that we have confined ourself to short processing times and quick responses. A back and forth can sure be fun, but so can the meticulous; and nothing’s stopping you from chatting over the stuff you’ve written – imagine how insightful that could? Blogging really recaptures that “handwritten letter” spark.

Getting updates from people over text is kinda hard too. While I’ve been abroad, I have missed so many moments in peoples lives (good and bad), of which I usually only hear a summarised fraction. I get it though, asking is hard and responding is even harder; retyping a shortened version of something for the 5th time isn’t much fun. I dream of a time where more of my friends write blogs, a world where I can easily grasp and know the wheres and whats in someone’s life without feeling like I am nagging for details; where the focus is being a friendly part of their lives…

I don’t expect this repost to encourage any of my IRL friends to dust off their old blogs (or start new ones). But I can dream!

AI is not a person

This is a repost promoting content originally published elsewhere. See more things Dan's reposted.

You didn’t “have a conversation” with ChatGPT.

It doesn’t “think you should…” It doesn’t think.

It didn’t “tell you that…” It doesn’t speak.

It doesn’t “feel that the best option is…” It doesn’t feel.

AI is a cheap parlor trick. You provide words, and it provides words back that are most likely to occur alongside the words you provided.

A useful reminder for the next time you’re tempted to personify or humanise an LLM.

LLMs are statistical tools. There are some things that the statistics of language can be good at, especially on average: stuff like summarisation, sentiment analysis, pattern identification, and checking for internal consistency.

But they’re just maths. They’re not a person.

It’s not even that they don’t care about you or don’t want to help you. They don’t even go that far: they’re incapable of “caring” or “wanting” in the first place. What they do is take all of the information they’ve ingested, plus their training and prompt, plus the conversation you’d had with them so far, plus a random number, and produce output which is, after a fashion, a prediction of what comes next.

As always: that’s not to say it’s useless. (It’s also not to say it’s always useful.) But as a tool, it’s pretty opaque to most normal people.

Unless you’ve really taken a deep-dive into understanding low LLMs work, they must seem like magic (hell; speaking as somebody who has taken such a deep-dive, they sometimes seem like magic!). I’m sure that some of the time, they must seem like they’re a living thing, or at least an approximation of one.

But they’re not. And it’s important to remember that.

I Hate (Most) Keyboard ‘Fn’ Keys

Duration

Podcast Version

This post is also available as a podcast. Listen here, download for later, or subscribe wherever you consume podcasts.

Hi, HackerNews! Please be kind/friendly! I’d love to hear your experiences of these (IMHO horrible) keyboard features, whether good or bad. Drop me a comment or join in on the thread over there.

In my living room1 is an ageing Windows media centre PC, which is connected to the TV and principally used for Jellyfin, Netflix, Nebula, Steam, and the like. For convenient sofa use, I’ve equipped it with a wireless keyboard/trackpad combo.

A slim Microsoft all-in-one keyboard and touchpad, in British layout, alongside two game controllers.
The keyboard is, for the most part, fine. You wouldn’t want to type an essay on it, but if you’re searching for a YouTube video it does the job.

Unfortunately, the manufacturers of this keyboard decided that it needed a dozen extra functions, and repurposed the F-keys F1 through F12 for these purposes.

It was nice that they gave dedicated keys to volume control/toggling muting – we use those all the time. And there are three other dedicated keys in the top right which we never use… so there was clearly capacity for a little extra. And they still they felt the need to do… this:

Close-up of the F4 key, showing a 'moon' icon. Of the other visible function keys, F3 shows 'fast forward', F5 shows 'hourglass', F6 shows what appears to be an illustration of a supercollider spinning up, and so on.
That F4 key has been repurposed as a “sleep” button. This poses a problem.

I don’t want any of these “special function keys. Occasionally, I suppose, I might need one2, but mostly I’d just like F1 through F12 to remain the multi-purpose, context-dependent keys that they have been since they first appeared in 1965.

And so, because I don’t want to hold Fn every time I want to press an F-key for its intended purpose, I used the arcane shortcut Fn+Caps to “lock” the keyboard into “standard” mode, where multipurpose F-keys remain multipurpose F-keys unless I hold down the special magic button that transforms them into rarely-used single-purpose special function keys.

But here’s where the problem occurs. If the batteries get changed, or if the keyboard gets turned-off for an extended period, or sometimes – seemingly – just randomly… that function-lock gets switched off.

And I’ll grab the keyboard and, to quickly quit Steam Big Picture or a Jellyfin Client or something, I’ll press Alt+F4. Which will send the “sleep” command. And because this computer’s a bit older, it’ll hibernate.

Instead of closing one application, which is what I intended, I now have to wait upwards of a minute for the old box to finish copying all of its RAM into a file, and shutting down, and then booting up again (in response to my repeated and frustrated hammering of the space bar), and then loading everything back into RAM… just to put me back where I started3.

What’s most-frustrating is at F4 is the only key with such a time-consuming and annoying function. If I accidentally paused some music or opened the system settings or did whatever-the-hell the icon on the F6 key is supposed to mean, that wouldn’t be so bad. But man; the three or four times a year that this catches me out are just aggravating enough to piss me off without being quite bad enough for me to do something about it4.

Close-up of a WASD keyboard with Pride rainbow keycaps, focussing on its Menu/Fn key and the handful of media keys it supports (which are primarily the Pause, Insert, Home, Delete, End, Page Up and Page Down keys).
This is the WASD Code keyboard on another of my computers5, showing how a Fn key can be done right.

It doesn’t have to be this way.

My WASD Code gets it right by resigning the effects of all double-duty keys to minor conveniences only, and making them the secondary functions of the keys to which they’re attached. I use these volume control buttons and they’re fine6

My Keychron K10 gets it right by having the double-duty keys mirror those of the Mac it attaches to7: again, all minor, low-impact functions that are easily and quickly un-done. Also, when you lock it to traditional F-key mode it stays that way, even if it’s disconnected and left unpowered for an extended period.

Close-up of Mac-style double-duty function keys F9 through F12, for fast-forward, mute, volume-down and volume-up respectively.
I had one of those Macbooks with the stupid LCD screen in place of keys, once, and I hated that “feature” and was glad to see it disappear (although occasionally I still see it on other hardware): who the hell wants a hardware keyboard that they can only use by looking at it? This is a much saner design, and I appreciate how easy it is to switch it to “normal” mode8.

These keyboards – which are my daily drivers – show that an Fn key can be done right.

Here’s what “doing Fn right” looks like, to me –

  1. Where keys do double-duty, it’s a low-impact and quickly reversible operation, so there’s little cognitive load or delay in correcting any mistakes.
  2. The default state is the traditional key function, or if that’s not the case, switching mode is easy (doesn’t involve looking up an underdocumented shortcut or installing a proprietary driver).
  3. When you switch the default state, it stays switched and doesn’t swap back to factory defaults just because of a loss of power or other arbitrary and unrelated trigger.

Sadly, a great number of keyboards get their Fn key implementations wrong. And I hate them for it.

Footnotes

1 By which, right now, I mean the living room of the Chicory House, on account of my actual house being busy having its underfloor foundations torn up.

2 In particular, this keyboard lacks dedicated page up/page down keys, and I don’t mind pressing Fn+F11 or Fn+F12 for that. And maybe once or twice I’ve used Fn+F2 for pause/play. But other than that, they’re completely pointless.

3 Yes, I’m fully aware that I could just disable all sleep/hibernation functions at an OS or even BIOS level. But at the time I remember that, all I want to do is get back to watching the latest episode of Star City or something.

4 I mean, except for write this blog post, I suppose. But for that I blame Terence Eden, who put the idea in my head with a recent poll.

5 And why yes, I do have Pride keycaps in place of my function keys, why do you ask?

6 The volume control knob of the mechanical it replaced, a Das Keyboard 3, was better, but you can’t have everything.

7 The Keychron itself is super versatile and OS-independent: it’s easily toggled between layouts and even comes with spare keycaps to make it “look like” your preferred operating system, assuming that unlike me you don’t routinely use around three different ones in a typical session.

8 Don’t get me started on Apple’s other UX decisions like “natural scrolling” which makes no sense whatsoever on a mouse… but – unlike every other operating system I’ve checked – won’t let you configure a different scrolling orientation on a mouse than for a trackpad: both have to be kept aligned in MacOS. Argh!.

× × × ×

F-Day plus 115

115 days since our house flood, the beginnings of the very first of the remedial works are taking place. Today, builders will drill through and lift part of a cracked poured-concrete foundation to work out what’s beneath and whether it’s stable enough to lay a new floor on top of. Also, somebody’s coming around to quote for the laying of new floors (and we’ll see if their numbers line up with those estimated by the insurance company).

Several vehicles parked in the rain on the rural residential driveway of 'The Green'.

×

So Unbelievable it Sounds Like you Googled It

“To Google”

When it first appeared, Google Search was a breath of fresh air. Simple, powerful search that Just Worked. It’s little wonder that the phase “to Google” something became synonymous with “to search for” something.

Somewhere,  Google lost its way.1 Perhaps the latest example of that is the injection of AI into every search2:

I’ve been to the cinema a few times lately so I’ve seen the Google AI ad that inspired me to make this parody… a lot.
Music by Dead Tubes Foundation (click to unmute/mute).

Apparently the kids these days don’t “Google it”. At least, not in their colloquialisms: they’re still probably using the search engine.

They say that they’ll “search it up”.

And this presents us with an opportunity:

Let’s reclaim the phrase “to Google”

I was inspired by a blog post by Mr Scribs (itself inspired by a Fediverse conversation), discovered via Bubbles:

We should turn the verb use of googling into an insult.

Example: “That’s so unbelievable it sounds like you googled it.”

I love this, and I’m absolutely going to start using it. “To Google” can absolutely transform from meaning “to search for, using a Web search engine” to meaning:

  • to seek knowledge in a lazy and convenient way, without regard for its accuracy
    (“I Googled from a guy at the pub that 5G caused Covid”)
  • to acquire information that can’t accurately be sourced or verified
    (“don’t quote me on that, though: I Googled it”)
  • to prefer an answer to a question that’s mildly more-convenient for the asker, even if getting it was ethically problematic
    (“pass me the jump leads, I’m going to Google one of the hostages”)

DeGoogling is so… 2010s. Let’s make the 2020s the decade where we redefine Google as a verb, in a way that better represents what it means to continue to buy in to the ever-increasingly toxic Google Search ecosystem.

Footnotes

1 Maybe it was then the Search-Chrome-Analytics trifecta that positioned the company as both the assistant to, and the adversary of, the users. Maybe it was when they dropped “don’t be evil”. Maybe it was when they stopped listening to users, or when they stopped listening to their own developers. Maybe it was when they helped sterilise the Web. Maybe it was AMP and they way they abused their monopoly to force it down everybody’s throats. Maybe it was when they killed (insert your favourite service here). Maybe it was when they started enshittifying Android. Make your own mind up.

2 Yes, I’m aware that some other search engines include AI summaries in results, too. But they all seem easier to turn off… and I’m yet to see a cinema advertisement about the fact that they do it for anything other that Google Search.

Yodawg

“Size matters not. Look at me. Judge me by my size, do you? Hmm? Hmm.”

A fawn-coloured French Bulldog wrapped in a blanket in a way reminiscent of robes. This, combined with her wrinkled features, makes her look a little like Yoda.

×

F-Day plus 113

It’s been a hundred and thirteen days since the flood that wrecked our house, and we’re told that repair work will start imminently. Like: as soon as next week!

So today I returned to the house to try to disassemble my sit/stand desk. An enormous and heavy thing that was constructed in-situ, it survived the flood without significant damage but is sort of hard-to-move for the purpose of getting it out of the way of the folks who’ll hopefully soon be repairing walls, floors, electrics and the like.

A large, L-shaped office desk with thick motorised metal legs lies on its edge, upright, in a bare concrete-floored home office.
This way up. For now.

Unfortunately it proved just too difficult to disassemble the beast. I’d anticipated that it would be able to be easily separated into two major pieces – the “top”, and the “frame” – but the guy who built in for me1 made some creative decisions about the placements of the controllers and the motors which has meant that the two now can’t be separated without taking the whole thing apart into a lot of tiny bits.

I’ll speak to the builders when they come. Maybe a floor can be laid elsewhere in the house and then the desk, which I’ve collapsed as small as its little motors will carry it, can be moved onto the newly-constructed floor so that it’s out of the way here.

Close-up of tiny sockets on ribbon cables within the housing of a laptop.
Wowsa, these are some tiny connectors!

So I got started on my other hardware task of the day: attempting to repair Ruth‘s laptop. It’s reporting via LED codes a graphics fault and its screen isn’t coming on, and the most-likely cause it an un-seated signal cable. So I picked up some teeny-tiny screwdrivers (my usual ones all being packed in boxes) and had a go.

But no dice; I’ve reseated the cables and it’s still sad, so I’m guessing it’s an actual issue with the screen. Sigh.

Two for two on hardware failures today. I should go back to writing some software. Fortunately; there’s lots of that that needs my attention too, this weekend!

Footnotes

1 Who – I suspected at the time and of which I’m now even more-confident – might well have been high when he assembled it. There’s some wacky choices here, plus he’s drilled several holes on the underside that he then didn’t actually use!

× ×

The improvement to code quality that drops the coverage metric 40%!

Working with an old codebase today, I moved a method from one file to another. CI was happy.

Then I realised the method didn’t have any automated tests, so I wrote one. It turns out its entire (new) file didn’t have any, so my change would improve test coverage. Nice.

But it didn’t. CI complained that test coverage had dropped. Wait, what? All I did was move some code and add a unit test.

Then I realised that the coverage analysis tool was only counting files that actually contained any tested code. By adding a test to part of a previously-untested file, that file became part of the scored codebase. Uh-oh.

Looked deeper. Turns out the code coverage tool was also counting the test files themselves as being part of the code-under-test.

Fixed all of the above. Code coverage score dropped by about 40%. 😱

Now I’ve got more work to do.

Happy Friday. Check what your coverage tool is inspecting, folks.

Optional AUP

Got to say, it’s very sporting of AWS to make compliance with their terms of service and acceptable use policy optional.

Screenshot of dropdown field labelled 'Will you will comply with AWS Service Terms and AUP - optional', currently set to 'Yes'. The label is saying that the field is optional, but the joke is that it sounds like complying with the terms of service is optional.

×

Hackers Simply Asked Meta AI to Give Them Access to High-Profile Instagram Accounts. It Worked

This is a repost promoting content originally published elsewhere. See more things Dan's reposted.

Hackers say that they used Meta’s AI support chatbot to break into a host of high-profile Instagram profiles by asking the support bot to change the email address associated with the target account. The claims coincide with a series of high-profile Instagram account takeovers, including the Barack Obama White House account, the Chief Master Sergeant of Space Force’s account, and Sephora’s account.

Well this is unsurprising and unshocking. Turns out that if you give your chatbot help interface unrestricted access to your backend systems – rather than, say, the access level of the human talking to it – then obviously hackers are going to try to jailbreak it in ways that you can’t possibly predict or guardrails against and, if/when they succeed, they’ll break into all the systems to which you’ve given the system access.

This shouldn’t even have to be said. Meta’s mistake here is so self-evident that they should be embarrassed.

Sending a test email from WordPress/ClassicPress using WP-CLI

Note to self: ignore search results that say to install a plugin; the absolute fastest way to send a test email from a WordPress/ClassicPress installation (assuming you’re using WP-CLI) is just to run something like:

wp eval 'wp_mail("recipient@example.com", "Test Email", "A test email from WP-CLI");'

The “ChangeNames.co.uk” Scam

👋 Hi! If you came here after going to ChangeNames.co.uk, congratulations: you just dodged getting scammed.

To actually change your name for free as a British citizen, without giving your personal information to scammers (or anybody else who doesn’t need it!), I suggest you use FreeDeedPoll.org.uk. Want an alternative? DeedPoll.lgbt is good too!

I help people change their names

As a British citizen, you can change your name for free. That’s the entire premise behind my website FreeDeedPoll.org.uk, which since 2011 has helped thousands of people change their names1 for free and without a solicitor.

Screenshot showing FreeDeedPoll.org.uk.
It’s a pretty useful website, if I say so myself.

I aim to run the most-ethical service of its type:

  • As noted, it’s completely free and collects no personal information whatsoever.
  • It’s funded out of my own pocket so it doesn’t need to depend upon advertising.
  • It’s open source so anybody can inspect my code, or run it themselves, or even set up a “competing” copy (so long as they give away the code to that, too)!
  • I try to answer every email I receive from anybody who’s having difficulty with the process.2

Scammers will barely help you, but they will steal your data

Others, however, don’t.

I’m not talking about all the paid-for services. Some of them provide a useful service, albeit one that you don’t strictly need to pay for.  I’m not a fan of those that try to market themselves as “official”, though, because that just feels like fraud. No, I’m talking about a level of sliminess that goes well beyond merely charging somebody for something they’re entitled to for free.

Like… let me show you an email I received today:

Email from Malvin at ChangeNames to Dan Q, reading: Your video on free deed polls for British citizens caught my attention. You made the point well that people should not have to pay for something they have a legal right to do themselves. That is exactly what ChangeNames.co.uk is built on. Free deed poll service, no charges, no upsells. We also run a YouTube channel and TikTok covering the whole name change process for people who need a bit of guidance. If you ever mention it to your audience or link it in a video description, that would mean a lot. The people watching your content are exactly the people we are trying to reach.
My bullshit alarm was going off as soon as I saw this email, but I figured I’d dig a little deeper before I decided whether or not to consign it to the spam folder.

I tried to visit their website but it looks like they haven’t even bought the domain name they’re advertising, yet. Just for fun, I’ve registered it and set it up as a permanent redirect to this blog post3.

Their TikTok channel exists, but it’s not at the URL they provided. So far, so incompetent.

Screengrab from a YouTube video showing a white woman with brown-and-red hair saying "please see the FAQs for any questions you have have around deed polls[sic] and the rules." alongside a logo for "Change Names".
Gotta admit, their video production quality’s better than mine… even if the content isn’t!

Both their YouTube and TikTok channels provide a link not to their “website” but to a kit.com page that asks for some personal details with the promise of a deed poll at the end of it.

When you fill in the form – and obviously you shouldn’t do so using real information – you get added to a marketing email list and a handful of other mailing lists get pushed at you.

Screenshot from the scammers' web form, requesting your full name, your first name, address, postcode, and reason for changing your name. It states that 'we respect your privacy' and that you can 'unsubscribe at any time'.
“Why are you changing your name” is a mandatory free-text field. Why are they asking this? Who knows!

Kit.com require double-opt-in confirmation for mailing lists, but the email tries to trick you into clicking the button, saying that clicking the “confirm your subscription” button “help us know you have received the deed poll and everything works”. In reality, they’re just trying to legitimise their spamming.

And what do you get out of it after all this? A hyperlink to a publicly-accessible Google Drive folder called “Deed Polls”[sic]4 that a more-ethical outlet could have just linked to in the first place. it contains a couple of Word documents that require you to delete a ton of underscores in order to type your own content in.

Oh, the the templates are full of mistakes. Here’s one (there are others!):

Fragment of a document reading: "II. The name _______ will only be for professional purposes only."
This clause contains both a grammatical error (saying ‘only’ twice) but a legal one! For most people, a deed poll is used to change their name for all purposes, not merely specifically-and-exclusively for professional purposes.

Of all the scammy free deeds poll services I’ve seen, ChangeNames is the worst

What we’ve got here is…

  1. a marketing scam pretending to be a deeds poll service,
  2. being run ineptly, e.g. marketing using a domain name they haven’t yet purchased and providing broken links to their own social media,
  3. that are using unethical techniques to harvest personal information,
  4. in exchange for a deed poll template that’s riddled with errors. 🤦

But the really insane thing about this whole scam is that a human being found my video about my own (superior, ethical) service FreeDeedPoll.org.uk… and then figured that they’d email me to see if I’d like to pass some traffic to their (inferior, unethical) competitor.

That bit… that’s the bit that blows my mind.

Footnotes

1 I can’t tell you exactly how many because I make a deliberate effort to collect no personal information, without which I’m unable to pin down a specific number. But I’ve had many hundreds of emails from people who’ve changed their names, and have anonymous statistics to suggest that the number is almost-certainly in the tens of thousands, maybe in the low hundreds of thousands.

2 I’m not a lawyer, but I’ve become pretty familiar with lots of relevant parts of the laws about not just names but adjacent areas like citizenship, residency, gender identity, information protection, and parental rights, and I’ve been able to point many people towards satisfactory conclusions when they’ve had more-challenging name changes.

3 It might not be working yet, depending on the state of DNS propagation, but it’ll get there in a day or so I reckon.

4 The plural of deed poll is, of course, deeds poll, but one could hardly expect these clowns to know that.

× × × ×

Converting ISO Country Codes to Flag Emojis

Today I learned something that is probably already well-known in some circles… but I hadn’t noticed it before and it made me go “wow”:

There’s a really simple algorithm for converting ISO 3166-1 alpha-2 country codes into the emoji representations of the flags of those countries.

I made an interactive to show how it works (enter a two-letter country code!). There’s a longer explanation below:

Non-interactive widget demonstrative conversion of two-letter ISO country codes into emoji flags.

Here’s the essence of the algorithm:

  1. Take the two-letter country code, e.g. FR for France.
  2. Get the character code of the uppercase variant of each letter: so F becomes 70 and R becomes 82.1
  3. Add 127,397 to each of them, so now F is 127,467 and R 127,479.
  4. Render the unicode characters at those codepoints: F turns into 🇫 and R turns into 🇷.
  5. Concatenate those characters and you get the emoji of the flag: 🇫🇷

I’ve often find things that are wonderfully clever about Unicode, but this might be my new favourite.

func countryEmojiFlag(countryCode string) string {
  cc := strings.ToUpper(strings.TrimSpace(countryCode))
  if len(cc) != 2 || cc[0] < 'A' || cc[0] > 'Z' || cc[1] < 'A' || cc[1] > 'Z' {
    return ""
  }
  return string([]rune{rune(cc[0]) + 127397, rune(cc[1]) + 127397})
}
My actual implementation was Go, rather than JavaScript2, as part of a side project this weekend. Here’s the function I came up with.

Today was also the day that I discovered that while SU is a reserved 2-letter ISO 3166-1 designation for the Soviet Union, the flag of the USSR is not a registered emoji. But if it were, we can work out what codepoint it’d be at! So I can type this – 🇸🇺 – here, safe in the knowledge that if that emoji comes to exist in the future, then you’ll be able to revisit this blog post and see it!


You know what: there might be a game in these country codes and their flags somewhere. Like: a game where you have to get from one country to another: like, say, from the 🇨🇰 Cook Islands (CK) to 🇧🇯 Benin (BJ). But you’re only allowed to change one letter at a time and you have to land in a real country. I think the fastest route between those two takes three steps, e.g. 🇨🇰 Cook Islands (CK) to 🇹🇰 Tokelau (TK) to 🇹🇯 Tajikstan (TJ) to 🇧🇯 Benin (BJ)… It’s probably a bit easy though: I haven’t yet found any that require more than three moves and most can be done in just two.

It gets a lot harder if you require letters to only be changed to an adjacent letter, but this variant makes some permutations impossible. Maybe there’s an optimisation puzzle in the style of the Travelling Salesman problem? Or maybe by mixing in geographical restrictions such as an inability to visit a certain continent that would make it more challenging and fun? Just brainstorming here…

Footnotes

1 An alternative way of thinking about it is that you’re taking the number of the letter in the alphabet – e.g F=6, R=18 – and adding 64 to each. Here’s why, and why it’s beautiful.

2 I don’t get to write Go often, and I seem to get rusty at it quickly, but I enjoy the feeling of writing something so raw and yet so clean.