zerosleeps

Since 2010

News is bad for you

I’m currently reading “How to Make the World Add Up” by Tim Harford, which references an article titled “News is bad for you – and giving up reading it will make you happier” by Rolf Dobelli. This quote is from that Guardian article:

News items are bubbles popping on the surface of a deeper world. Will accumulating facts help you understand the world? Sadly, no. The relationship is inverted. The important stories are non-stories: slow, powerful movements that develop below journalists’ radar but have a transforming effect. The more “news factoids” you digest, the less of the big picture you will understand.

Here in late 2020 the stories and advice this one contains are more relevant than ever.

How to think about lockdowns

This video from CGP Grey is gloriously logical and well-reasoned, especially the first 7 minutes. A worthy reminder that (almost) everyone is doing the best they can given the information they have at the time.

Shout out to this quip in response to “How will lockdown affect education in the future?”:

I think this quarantine has made plain some of the necessary lies of civilisation around education, particularly higher education, but, I leave what those are as an exercise for the viewer. For now.

Yessir.

Simple tips for security and serial numbers

Seth Godin has some good tips for dealing with random-but-usable-by-humans strings and codes. It’s something I spent a bit of time on when building our wedding website: the codes needed to be mildly secure, but easy to enter.

The final solution, which doesn’t seem to have caused any issues, was a random selection of 6 characters from upper-case A–Z, minus “I” and “O”, plus digits 2–9:

choices = ('A'..'Z').to_a - ['I', 'O'] + ('2'..'9').to_a

When shown to humans, the codes are displayed as two groups of three characters:

A5D 8FU

But, the codes can be entered with or without the space, and will be accepted whether they’re entered upper-case or not:

Invitation.find_by rsvp_code: params[:rsvp_code].upcase.gsub(/\s/, '')

So the example above could be entered as “a5d8fu”.

I do disagree with Seth’s last comment about saying “please” in forms though. I don’t think this fools anyone - users know they’re looking at a form and not having a conversation with a human. No need to beg.

datetime

I’ve never been a huge fan of the datetime module in Python, but listening to one of the core developers of Python on “Talk Python” episode 271 has changed that.

I’d encourage anyone who stores dates and times in a database to listen to this. The guy does a really good job of explaining when we should use naive datetimes, aware datetimes, and why simply using UTC and converting as needed isn’t always the right choice.

I love this stuff.