Leon Mika

Advice to those working with annotations in Preview

For those of you using Preview in macOS for viewing an annotated PDF, if you need to move or delete the annotations in order to select the text, be sure to undo your changes prior to closing Preview. Otherwise your changes will be saved without asking you first.1

This just happened to me. I have a PDF annotated with edits made with the iPad pencil and I wanted to copy the actual text. The annotations seemed to sit on top of the text in an image layer, which means that in order to select the text, I have to move or delete this layer first. I didn’t want the annotations mixed up with the ones on the other page, so I decided to delete this layer instead of moving it. This was a mistake.

I copied the text and wanted to get the annotations back. I probably should have just pressed ⌘Z to undo my changes, but I saw “– Edited” in the title bar so I assumed that if I just closed Preview, it would discard my changes and I would be able to get my annotations back just by reopening the PDF. But it turns out, after closing it and opening it again, the changes were saved without asking me first, resulting in my annotations being lost.

Developers of macOS: this is a terrible user experience that needs to be fixed. Preview saving my changes from under me has now resulted in data loss, the cardinal sin of any software. Either ask me before saving changes when the application is closed, support a notion of versions, or do something else. But do not just save my changes without asking me, and do not imply that Preview is aware of pending changes by having “– Edited” in the title bar if it isn’t going to discard the changes, or confirm that they should be saved when I close the app.

Ugh, I need another coffee now.


  1. This is macOS Mojave. I hope this has been fixed some way in later versions. [return]

Seeing the photos in this article of an empty airport, especially one I’m familiar with, is somewhat haunting.

I’ve justed walked all the way to the shops before I realised I completely forgot my wallet. I didn’t come back with a coffee, but I did just setup Android Pay so that this will never happen again.

Doughnut Day 2020

Good day today. From a high of 725 Covid-19 cases in August 25, Victoria has just had 24 hours of zero new cases and zero deaths. This is during a period of extensive testing in the north of the metropolitan, during a testing blitz in an attempt to contain an outbreak. Labs have been processing tests late into the night, with not a single one so far coming back positive.

As good as this news is, I’d imagine the government wants to remain cautious here. The easing of restrictions that were scheduled for yesterday have been delayed, I guess to make sure that contact tracers are on top of things in the north. As disappointing as this is, I can see why they did this. It makes sense that they take advantage of the current situation to get as much information about where the virus is as they can. I don’t believe anyone wants to go back into lock-down a third time so they really have one shot of this. The government is still confident that we are on track for lifting restrictions before November 1st. I guess we’ll see what happens when they give their briefing this morning, but after going through this for 4 months, I can wait a few more days.

For the moment, it’s good seeing this result. Truth is, things were always touch and go in Victoria even during the relative period of free movement that we experienced in June, when we last had a day of zero new cases. Seeing this now, with the restricted movement and testing blitz, gives me hope that we can keep this virus suppressed until a vaccine comes in.

Update at 15:45: Results from the testing blitz from the northern suburbs have been trickling all day, and so far still no positive cases. It looks like the Victorian government is happy with this result because they have announced that the state will be moving to the 3rd step of re-opening on Wednesday.

It’s coming to the point where I think I need a custom text entry control on all my devices that, when I try to post something, throws up a prompt saying “Are you absolutely sure what you’re about to post is right? Did you proofread it? Is the spelling correct? Please check!”

Case in point: it took me 2 edits to get this post right.

Over the last few weeks, while Melbourne has been under lock-down to drive the Covid-19 cases down, the government has been ramping up it’s contact tracing infrastructure. It’s been quite flaky at the start but from what I hear now on Coronacast it’s in a pretty decent state. It has delt with outbreaks in both Kilmore and Shepparton, two regional cities here in Victoria.

Now the real test comes, with the potential of an outbreak at a school here in the north of Melbourne, a few days before restrictions are lifted. From what I’m reading, it looks like the testing and contact tracing infrastructure has moved in quite rapidly. The school has closed due to a precaution, popup testing sites have been deployed, and some 300 people have been told to self-isolate.

We’ll see how this goes over the coming days. If all goes well, then I will have greater confidence that the Vic government will be able to handle these outbreaks and we can move to Covid-normal like the rest of the country.

P.S. Only 5 cases today. This is a little higher than the 1 to 2 that we’ve been experiencing over the last week or so, but still quite good.

Reflections On Writing On The Web

I fell into a bit of a rabbit hole about writing and publishing online yesterday after reading this article from Preetam Nath and this article from James Clear. I’ve been thinking about creating and publishing on the web for a little while now, which is probably why these two articles resonated with me.

These articles highlight the importance of creating and publishing regardless of what the topic is. There have been a few things that I’ve been wanting to share but I haven’t done so, probably because I worry about what other people think. The interesting thing about that line of thinking is that I tend to enjoy reading posts from other people as they go about their lives. I guess that’s what the original intention of blogging actually is.

There have also been times during the past week that I’ve been craving content, either from Twitter, Micro.blog or the various RSS feeds that I read. And there have been times when I’ve caught up with everything that I follow, and nothing happens for a while. I think to myself, “when will someone post something? I need to be distracted for a while.” I think I need to remember that someone needs to create that content in order for it to be consumed, and although it’s much easier consuming content than it is to produce it, I should not feel entitled to it and expect others to amuse me.

The interesting thing about these thoughts is that it is joining a confluence of other changes to my daily work setup that has happened recently. I use to write in my Day One journal almost every day, but since moving to Linux for work that has prooved a little difficult to maintain. It might be that more of my journalling will go here instead, given that micro.blog provides a nice, cross-plaform interface for writing entries of any size.

It wasn’t until about a week ago, when I was looking very closely at the Robot Or Not show art, that I realised how cleaver the name and logo of this 🎙️ podcast actually is.

I’ve removed Twitter my iPad and my phone. I’m starting to get a bit sick of it. It’s not doing anything positive for my mental health anyway.

No more news for the day either. Just RSS and micro.blog.

Daily walk after work, today through the forest reserve near my home. I didn’t think I had something to say until I started blogging, and the micro.blog community is the friendliest and most welcoming on the internet.

Melbourne, AU at 4:58 PM AEDT (+11 UTC) #adayinthelife

Unit Tests and Verifying Mocks

I’m working with a unit test that uses mocks in which every method in the mock is verified after the method under test is called, even if it is not relevant to the test. Furthermore, the tear down method verifies that every dependent services has no more interactions, which means that removing a verification that is not relevant to the specific test case will cause the test to fail.

Please do not do this. It makes modifying the tests really difficult and results in really long unit tests that hides what the test is trying to assert. It also makes it harder to create new tests to verify a particular behaviour, as you find yourself copying all the verification code that is not relevant to the case that you’re trying to test for.

In my opinion, tests should clearly demonstrate the specific behaviour that you’re trying to verify, and should only include verification of mocks that are directly related to that case. Writing tests that are effectively photo-negatives of the method being tested, one in which the dependent services are verified instead of called, is not a good practice for unit testing.

Instead, have multiple, smaller unit-tests that asserts a particular behaviour, and only verify the mocks that are explicitly required. You gain the coverage by having all these unit tests effectively overlap the various paths a particular method will take. But the important benefit is that it results in more maintainable tests that are easier to work with. That makes it easier to write tests, which means you find yourself doing so more often. Path of least resistance and all that.

Looks like Google Play music is no longer letting me play the music I’ve got stored on the device without setting up a YouTube music account, which I’m not interested in doing. It looks like I’m going to have to start relying more on the music player app I’ve been building on the side over the last few months. Probably a good testing opportunity to iron out all the bugs that are still there.

After moving from Mac to Linux for work 1.5 months ago, I’ve lost the abiliy to be remember keyboard shortcuts on both platforms. Just now I’ve tried typing Option-Left Arrow to move back one word, and the browser window snapped to the left side of the screen.

Be forewarned: this might not be a happy post.

I’m feeling a bit dispirited this morning seeing 15 new cases of Covid-19 in Victoria over the last 24 hours, along with the Melboure average rise for the first time in 2 months. All last week the case numbers were just under 10, and the weekends usually have lower case numbers anyway, so seeing 15 new cases yesterday, and 14 cases on Saturday does not feel me with optimism.

It also doesn’t help listening to the ABC News Coronacast episode this morning where they were talking about how Victoria’s contact tracing system is coming up from behind. I can’t imagine it being easy overhauling the entire contract tracing infrastructure during a pandemic. I just wish it was up to snuff before the coronavirus came to our shores.

I understand the state government is doing all they can, but I am upset that these series of mistakes have led to this situation. I can only hope they can get on top of it as quickly as they can. Optimism can only take you so far, and I bet most people are just getting tired by the whole thing. I know I am.

Update: I feel a little better this afternoon, especially after hearing that 10 of the 15 cases seem to be linked with known clusters. The government is also expanding the number of people that are considered close contacts, which is hopefully why the case numbers are slightly higher today in that they’re catching these cases before they spread.

Update 2: I should also note that, as fustrated as I am about the numbers today, I still rather the state government do the safest thing they think is possible to avoid a third wave. If that means staying locked down for a while longer then so be it.

I don’t know how this keeps happening, but it feels like the Bluetooth stack on Android gets a little worse every release. Now with Android R, it takes a good 3-5 seconds since turning on my headphones before the audio is routed to them.

A Database Client Wishlist

I’ve recently started a new job so I’ve been spending a bit of time trying to become familiar with how the relational databases are structured. Usually when I’m doing any database work, I tend to use the CLI clients like mysql or pg_sql. I tend to prefer them, not only as they’re usually easy to use via SSH, but the REPL is a nice interaction model when querying data: you type a query, and the results appear directly below it. The CLI tools do have a few drawbacks though. Dealing with large result sets or browsing the schema tend to be harder, which makes it difficult when dealing with an unfamiliar database.

So I’ve been finding myself using the GUI database browsers more, like DataGrip or MySQL Workbench. It is much easier and nicer to navigate the schema using these, along with deal with large result sets, but they do remove the connection between a query and the associated results. The queries are usually entered in an editor-like console, like those used to enter code, and the results are usually in another window panel, or in a separate tab. This mode of interaction has nothing like the recency or locality between the query and the results that you get from a CLI.

While working with both of these tools and seeing their shortcomings, I’ve been casually wondering what a perfect decent database client would have. I think it will need these attributes in some prominent way (this covers the complaints listed above but also addresses some others I think would also help):

Results appearing below queries: I think this tool will need an interaction model similar to the CLI tools. There is so much benefit in seeing the results directly below the query that produce it. Anything other than this is likely to result in a situation where I’ll be looking at seven different queries and wondering which of them produced the single result set that I see.

An easy way to view, filter and export large result sets: Although the interaction should be is closer to the CLI, there must be a way to deal with large queries and result sets, something that the GUI tools do really well. There should also be a way to export them to CSV files or something similar without having to remember the appropriate copy command.

Some sort of snippet support and persistent scroll-back: This one can be best summarised as “whatever you find yourself copy and pasting into notepad”. The ability to store snippets and saved queries will save time trying to find or rewrite the big complex queries. And the persistent scroll-back of previously executed queries, with their results, will help with maintaining my train of thought while investigating something. This can come in handy especially when the investigation spans multiple days.

A quick way to annotate queries or results: Big long SQL queries eventually look the same to me after a while, so it would also be nice to add inline comments or notes to remind myself what the results actually represent.

An easy way to browse the schema: This could be a tree-like structure similar to all the GUI tools, which will make browsing the schema really easy. I think at a minimum, it should be a consistent set of meta-commands such as listing tables in a database or describing a tables columns, etc.

An easy way to run automation tasks: Finally, some form of scripting language to be able to “orchestrate” multiple queries without having to formulate one large SQL query, or copy and paste result sets around. It’s true that writing an external tool to do this is also possible, but avoiding the context switch would be a huge benefit if this was available from within the app. Doesn’t have to be full featured either, in fact it’s probably better if it isn’t.

It would be interesting exploring this further. I think the last thing I need now is another project to work on, but maybe over the weekend I might start prototyping this to see if the workflow makes sense.

I’ve only just realised that the Victorian CHO Twitter account includes a daily Covid-19 case breakdown report. The Twitter client is such a mess so I’m trying out the Feedbin Twitter integration to get these. If it’s any better, I might add some more.

Sharing links to private podcast episodes

There have been times when I’ve wanted to share a link to an episode of a podcast that I pay for, but I’m hesitant to do so as the feed is private and unique to my account. The episode is also available in the public feed, but has been trimmed as an incentive for listeners to pay for the show. I can always find the episode in the public feed and share that, but I’m wondering if there’s a better way to handle this.

How do other podcast listeners share links to episodes from private feeds that also have a public version? Is there something in the RSS standard1 that allows for podcast producers to link a private episode to the same one in the public feed? If so, do the major podcast players, specifically Pocketcasts, honour this link when sharing an episode?

I’m asking as a podcast listener: I don’t have a podcast myself (yet).


  1. “Standard” is probably not the right word here but let’s go with it for the moment. [return]

Friday evening walk. The photo does not do justice to how lovely the evening light can be during this time of year.

We are potentially two weeks away from a significant reduction in restrictions, and this weekend is proving to be a bit of a test in Melbourne’s mettle. A spate of warm weather has driven people to the beach, and there have been reports of people not social distancing or wearing masks on Friday. The police have increased patrols to enforce social distancing restrictions and the local council has threatened to close the beach if people continue to flout the rules.

I can only hope that this does not cause a spike in cases. We are so close, and it will be devastating to see the effort of the last 3 months thrown away. The good news is that colder, rainier weather is on the way.

A good way to be reminded of all the services you’re currently subscribed to is to have credit card that will expire soon and have all these services send emails reminding you to update your payment details.

After reading the recent news articles, along with hearing what the founder prioritises, it’s looking like Nikola is just another money grab a. la. WeWorks. Here’s hoping it doesn’t poison the well for non-petroleum transportation companies.

Let's hold the line, Melbourne. We've got this.

Today is a good day. Melbourne’s 14 day daily Covid-19 case average is now 29.4, which is beyond the 30 to 50 band required to move to the next stage of reopening. Seeing the fruits of our collective sacrifice, bringing the daily case numbers from a peak of around 740 in August down to the 11 we saw on Monday, makes me proud to be a Melburnian.

As much as I like for things to reopen sooner than planned, I think we should hold the line for as long as we possibly can. The potential prizes for doing so – the crushing of the virus, the ability to travel interstate again, the chance to eat at restaurants without fear of infection, the chance for a normalish Christmas and summer – are within reach. I know that’s easy for me to say as someone who has the ability to work from home, and I completely recognise those of us suffering right now being unable to work at all. But just like the darkest hour is before the dawn, so too will the sweet taste of victory and accomplishment be when we finally crush this virus and meet the rest of the country where they are. To rush this, to reopen too early, and see our effort thrown away would be upsetting.

Let’s hold out that little bit longer, Melbourne. We’ve got this.

Ah, Day One. At least let me get through the day first.

I wonder if it’s possible to develop something like ambidexterity for Mac and non-Mac keyboard shortcuts.