zerosleeps

Since 2010

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.

My computer history

Accidental Tech Podcast had a members special a couple of weeks ago where the hosts attempted to rank their all-time favourite laptops. Inevitably, much of the the conversation turned into reminiscences about their entire computer history, not just their top four favourite laptops.

It got me thinking about my own computer history. I’m very confident I’ve misremembered a lot of the earlier stuff, and I’ve almost certainly forgotten a bunch of computers, but using a combination of my memory, photos, and financial records, here it is.

The not-my-own-money years

It all started with a Commodore 64. I came home from school one day and there it was, sitting in my bedroom set up and ready to power on. I don’t know if Dad had owned it before then, or if it was acquired for me. Questions you don’t think to ask until it’s too late. I reckon this was roughly 1992.

I vaguely remember a Sinclair ZX being involved - I was sure it was a ZX80, but it had an evil fucking membrane keyboard that made it miserable to use, so it might have been a ZX81. I’m pretty sure it was bought at one of the annual Inner Wheel silent auctions my Mum was involved in.

Anyway, a couple of years after that I got a hand-me-down Amstrad 1512 (the twin floppy-drive edition no less), and was introduced to the world of (mostly) IBM PC-compatibility. It had previously been used by my parents to help run their farming business, but they’d upgraded to some other grey thing that had a 30MB hard drive - an unfathomable amount of storage. Most of my time with the 1512 was spent in GEM.

The next computer I remember propelled me into the world of Windows. Dad surprised me once again by purchasing a second-hand home-made machine from a guy in Dunning. It had a god-damned CD-ROM drive! The guy who sold it to us later popped over to upgrade it from Windows 3.1 to a bootleg copy of Windows 95.

That machine was upgraded piecemeal a few times, and at one point it’s guts were almost entirely replaced with a Cyrix 6x86 motherboard/processor/etc. The upgrade was performed by a guy running a computer maintenance business out of a shed next to his house in Perth. And once again, it was Dad who initiated and paid for the work.

The weekend-job-money years

We’re now in the 2000’s. The hero of this entire journey - Dad - got me a weekend job at the Spar general store in Auchterarder in the mid-90’s when I was in my early teens (I wish I had an exact date for that) so I had a little trickle of my own money now. In 2002 I bought my first digital camera, so this is where photographic evidence starts.

And straight away there’s a photos-don’t-lie moment because my library contains a picture from January 2003 of a grey Dell that I have almost no memory of! CRT monitor, Harman Kardon speakers, and a sea of grey plastic.

In May 2004 I went down down the home-build path again and spent a shit-load of money trying to build a quiet PC, something which was impossible on my budget at the time. I had a massive heavy case that was filled with sound deadening foam, a special caddy that attempted to keep hard drive vibrations separate from the case, fans that promised to be silent. None of it worked.

The introduction-to-Apple years

It’s not a computer, but in September 2004 during a family holiday to Florida I walked into a CompUSA store and bought a green iPod mini and was thus introduced to Apple’s world. Here it is docked in a Denison ice-Link Plus contraption (it presented the iPod as if it was a CD changer to the built-in head unit) in my Renault Mégane:

iPod mini in Renault Mégane

In November 2004 I gave up on my home-build and bought a Dell Dimension 4700 which came with a CRT monitor whether you wanted it or not apparently:

The boxes my Dell Dimension 4700 was delivered in

But just a few months later Apple announced the original Mac Mini and in February 2005 I took delivery of my first Mac and plugged my grey LCD monitor, grey keyboard, and grey mouse into it and never looked back.

In November 2005 my then-boyfriend bought me an iBook G4 - my first Apple laptop. I was bowled over by the thought that had gone into the design of that thing - the breathing sleep indicator, the way the metal latch sprung out of the way when the lid was open, the battery test LEDs that faded in and out when they could have just turned on and off.

The first-real-job years

At this point - mid-2006 - my computer history gets less interesting. The wild-west days of second-hand boxes, wonky-upgrades, and Windows are behind me. I’m smitten with Apple and completely over my desire to build and upgrade noisy unreliable PCs.

In January 2008 I replaced my G4 Mac Mini with an Intel Mac Mini. And in November 2009 during another holiday in Florida I really splurged and bought an iMac during the Black Friday sales.

In January 2010 when I found out I’d be moving to Australia I managed to convince one of my soon-to-be-ex bosses to give me an old company MacBook Pro.

In October 2011 I bought my first unibody MacBook Pro, and in December 2012 my second iMac - one of the ones that came in a trapezoid shaped retail box.

In July 2013 I replaced the spinning hard drive in that MacBook with an SSD - a pivotal point.

Replacement Samsung SSD

The MacBook Pro years

The last ten years of the story really does get very boring indeed: a MacBook Pro (2013) in October 2013, a MacBook Pro (2016) in March 2017, a MacBook Pro (2018) in September 2018, and a MacBook Pro (16-inch, 2019) in December 2019.

At some point prior to all of these MacBooks I’d purchased a Thunderbolt Display and fallen in love with the laptop-as-a-desktop lifestyle. That display was eventually replaced with a separate CalDigit TS3 Plus Thunderbolt 3 dock (which I’ve mentioned before) and Dell(!) monitor.

And in November 2021, the computer I’m typing this on now and my first Apple silicon machine: a MacBook Pro (14-inch, 2021), which is just bloody 😍