zerosleeps

Since 2010

Errors in Kindle books

The book I’ve just finished reading on Kindle had at least two occurrences of the string “'” instead of actual apostrophes. How does that happen? Obviously I know how it happens, but I don’t understand how it makes it into my hands like that. And this was a publication from 5+ years ago - how has it not been fixed?!

In my experience it’s fairly common to encounter weirdness in Kindle books. It’s usually layout things, where words are hyphenated in the middle of a line, or what should be one line is rendered as 5 lines with a couple of words each.

I don’t remember ever seeing such oddities in printed books. I’d have thought digital books would be easy peasy to get right, and the labour required to lay out a printed book would lead to mistakes. Shows what I know!

Updated Sublime Text timestamp command

After my last post I was looking through some of my own uses of Python’s datetime module, and one of the things I uncovered was a Sublime Text command I created years ago and have blogged about before. I don’t know what I was thinking when I originally created the class. Is that Python 2 code? No idea.

Here’s my current version of that same module:

import sublime_plugin
import datetime


class Rfc3339DateCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(
            edit,
            self.view.sel()[0].begin(),
            datetime.date.today().isoformat()
        )


class Rfc3339DateTimeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(
            edit,
            self.view.sel()[0].begin(),
            datetime.datetime.now().astimezone().isoformat(timespec="seconds"),
        )


class Rfc3339DateTimeUtcCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(
            edit,
            self.view.sel()[0].begin(),
            datetime.datetime.now(datetime.timezone.utc).isoformat(timespec="seconds"),
        )

(datetime.UTC has been an alias for datetime.timezone.utc since Python 3.11, but the current version of Sublime Text uses Python 3.8 at the time of writing this.)

When paired with appropriate entries in a .sublime-commands file these three functions insert something like the following respectively:

2023-11-24
2023-11-24T14:03:58+11:00
2023-11-24T03:03:58+00:00

datetime.utcnow() is now deprecated

Miguel Grinberg with a nice article about the deprecation of Python’s datetime.datetime utcnow() and utcfromtimestamp() functions.

I discovered the article via this post on Hacker News which has a really great discussion about the topic.

The core Python developers are stuck between a rock and a hard place on this one. If it was up to me I’d be updating these functions to return aware datetime objects. It’s obvious that utcnow() should return a UTC datetime object, right?

But it’s a good job it’s not up to me, because this standard library is almost certainly used by millions of Python scripts! How on earth do you change something like that without upsetting a lot of people? You can’t throw deprecation warnings for a while and then change the functions - you’ve got to remove them. The things using these functions have to fail loudly.

Naming things is hard.

Sleazy pricing

Screenshot from petbarn.com.au

Quick. How much is one bag of kitty litter from Petbarn?

There are seven dollar-amounts on that one product card. The price for a regular human is one of the hardest to read: thin grey font on a coloured background.

Call me old and grumpy, but shit like this makes me shop elsewhere and never look back.

myki is embarrassing

I was on a route 86 tram yesterday, and watched a gentleman studying the onboard information - route maps, the stopping pattern for the route we were on, stuff like that. You know how you can tell when someone is a bit lost, but they seem confident they’ll be able to figure it out by themselves? That was the situation.

Sure enough, a few moments later he approached me and rather than ask for directions - which is fairly common and what I expected - he asked how to use his myki! He seemed confused about touching off - did he need to touch off or not? A very good bloody question! He’d heard that you don’t need to touch off, but had then seen some of the signs around the tram that mention touching off in zone 2 and had no clue what or where zone 2 was.

The route we were on wasn’t going near zone 2 so I told him touching off was optional, which already sounds stupid. I also asked him where he was going as the tram we were on started it’s journey in the free tram zone. It turns out he was indeed travelling entirely within the free tram zone, so I then had to explain what that means and implored the guy not to touch on or off if he’s staying inside the free zone.

It’s embarrassing that the process takes more than one sentence to explain.

But I started thinking… is that stuff about keeping your myki away from the readers if you’re only travelling within the free tram zone true? I know myki used to charge you back when the free tram zone was new, but that was over 8 years ago. Surely they fixed that. So I pulled out my myki and touched on somewhere around Queen Street and touched off at the end of my journey (ignoring the “optional” complaint from above because I wanted to give the system all the information I could) and yep, I was charged $5 for a free journey.

It feels like whatever conglomerate runs myki gave up years ago - they knew their time would be up so why bother exerting any effort on the thing. I really hope the next incarnation of our once-world-leading ticketing system sorts this crap out.