Tot Notes

Against my better judgment, I decided to write a Shortcut today. Even worse, I wanted it to be able to run on my Apple Watch. After several iterations, all of which looked to me to be functionally identical, I finally hit upon one that worked.

The goal was to have a complication on my watch that I could tap, dictate a short note to, and have the note saved to Tot with time and location stamps. Like this (but without the checkerboards to obscure my location):

Screenshot of dictated notes in the 7th dot of Tot

The complication that runs the Shortcut is at the bottom center of the Modular face, which is the one I normally use. This makes it handy for whatever ideas or observations I want to record when I’m out hiking or kayaking.

Apple Watch screenshot with Tot Notes complication at bottom center

I can, of course, run it from my phone, too, but the main point of writing this Shortcut was to have a quick way of making notes like this when the phone isn’t handy.

You can download the Tot Notes Shortcut from its iCloud link. Here’s an annotated view of all the steps:

StepActionComment
1 Tot Notes Step 01 Ask the user to dictate some text. This will be the note.
2 Tot Notes Step 02 Get today’s date and time.
3 Tot Notes Step 03 Format the date and time as yyyy-mm-dd HH:MM:SS.
4 Tot Notes Step 04 Get the current location.
5 Tot Notes Step 05 Get the latitude of the current location.
6 Tot Notes Step 06 Truncate the latitude to 6 decimal places.
7 Tot Notes Step 07 Get the longitude of the current location.
8 Tot Notes Step 08 Truncate the longitude to 6 decimal places.
9 Tot Notes Step 09 Put the date, time, latitude, longitude, and note into a paragraph with a trailing newline.
10 Tot Notes Step 10 Add the paragraph to the end of Tot dot #7.

As I said at the top, this is what I came to after quite a lot of backing-and-forthing with code that should have worked exactly like this version. Every earlier version did work when run from my phone; it was only this version that finally worked when run from the watch. That’s Shortcuts for you.

You may be wondering why I’m using Tot instead of Drafts. First, I bought Tot when it was on sale a few weeks ago, so it’s at the top of my mind right now. Second, while it’s nice that Drafts isn’t limited to just seven documents, I was worried that my notes would get lost in its infinitude. Tot’s limitations impose (I hope) a discipline that will have me going through my dictated notes and clearing them out frequently.


Followup on Wolfram county data

You may remember a post I wrote back in December about inexplicable holes in US county-level data in the Wolfram Knowledgebase. I say “you may remember” because I certainly didn’t until I got an email from Wolfram last week telling me that the holes had been filled. Yes and no, as it turns out.

I first discovered the problem in August of last year. I wanted to use Mathematica to get a list of all the county seats in Illinois, and I noticed that the data for DeKalb and DuPage counties were missing. It wasn’t available through a Mathematica function call or through a WolframAlpha query. Given that Wolfram is based in Illinois, I thought this was a particularly glaring error, so I sent them feedback.

By the time I wrote the post in December, I had looked into the issue further and discovered that the Knowledgebase was missing county seats for counties all over the country. I didn’t follow up with Wolfram on that because I thought they’d already memory-holed my original complaint.

But no! The email that came last week told me that the problem (for Illinois) had been fixed and said I could go to this link to see for myself. If you follow the link, you’ll have to tap the More button on that page, but when you do, you’ll see that DeKalb and DuPage counties now have their county seats. Which is nice.

Excerpt from WolframAlpha showing Sycamore and Wheaton

I changed the WolframAlpha query to look for California counties and found that the county seats for Mono and Sierra counties had also been filled in. Similarly for DeKalb and LaPorte counties in Indiana. So it looked like Wolfram had cleaned up the data across the country.

But that was in WolframAlpha. When I tried to get the same information through an equivalent function call in Mathematica, the county seats for DeKalb and DuPage were still missing.

It might not be immediately obvious, but if you look carefully, you’ll see Missing[NotAvailable] in the 19th and 22nd positions of the list.

The same problem can be found in other states: county seats that now appear in WolframAlpha on the web are still missing from the equivalent Mathematica function calls. This inconsistency is even weirder than the original missing data. How can calls to what should be the same database produce different results?

So I’ve sent feedback on this to Wolfram, and I’ll let you know when they answer. Given their previous speed, you can expect that post sometime next June.


A good (or bad) example

The one rule of plotting that every newly minted data scientist can repeat without fail is that your graphs should always start at zero. A graph that doesn’t start at zero is misleading, dishonest, and possibly nefarious. This rule is, of course, bullshit. Not a rule at all.

Oh sure, there are plenty of times when you should start at zero, but the best range to plot depends on what you’re plotting. This morning I saw a great example of a plot that started at zero when it really shouldn’t have.

It’s in an app that, among other things, is tracking my weight. Here’s the graph:

Column chart for weight

Because my weight over these seven days hasn’t changed by more than about 1.5%, the columns are all basically the same height. Even if I were to lose a lot of weight, I’d never go anywhere near zero. The only useful part of this chart is labeling over the columns—it could just as well be a table.

Where should the y-axis start? Depends on what the graph is being used for. If I had a target weight, I’d probably start at some round number below that target. I might put a thin horizontal line at the target. But I’d never do this.

The makers of the app have either internalized the rule that isn’t a rule or have decided that following it fends off criticism by idiots who think it is a rule. Too bad.


Numeronymize

Anil Dash quote-tweeted this post from Ian Brown on Mastodon this morning:

I was so excited to learn that abbreviations like “a11y” or “c14n” are called “numeronyms” that I wrote an #Emacs^H^H^H^H^H^H #E3s extension to make it easier to use them.

The tweet1 links to this GitHub page. First I thought it was funny to see a link to an Emacs Lisp script the day after I posted about my date-convert script. Then I thought “I want to be able to do that, but not in Emacs.” So I built this Keyboard Maestro macro, which I also called Numeronymize:

Screenshot of Keyboard Maestro Numeronymize macro

If you download and install it, it will appear in your Global Macro Group.

Here’s how to use it: Type the word you want to numeronymize in any editable text field. For example,

accessibility

With the cursor blinking at the end of the word, type ⌃⌥⌘3 (on standard American keyboards, the number symbol, #, is on the 3 key). The word before the cursor will be selected and shortened to its numeronym,

a11y

Honestly, I don’t think I’ll be using this macro very much, but it was fun and easy to write. The key is the Perl one-liner in the third step:

/usr/bin/perl -C -pe 's/(.)(.+)(.)/$1 . length($2) . $3/e'

I have more than one Perl executable on my computer, so I’m being explicit here about calling the one in /usr/bin that comes with macOS. The -C switch tells Perl to treat the input and output as UTF-8 (more on this below); the -p switch tells it to loop through the input, apply the code to it, and print out the result; and the -e switch tells it to treat the following string as the code to execute:

s/(.)(.+)(.)/$1 . length($2) . $3/e

This is the cool part, because Perl’s substitute command has an e option that means “evaluate.” It treats the replacement as a chunk of Perl code, evaluates it, and returns the result. Here, it concatenates the first letter, the length of the middle string of characters, and the final letter. When I saw what Brown’s numeronymize extension did, I immediately thought of this feature of Perl and knew I could do it in a one-liner.

The -C switch isn’t needed if all we care about are words made of ASCII characters. But what if we want to shorten this?

streichholzschächtelchen

Without the -C, we’d get

s23n

because the length function normally returns the length in bytes, and the ä takes up two bytes. But with the -C, length understands that we want characters, not bytes, so the macro returns

s22n

which is what we want.

A couple of other notes:

Thanks to Ian Brown for making the Emacs extension and to Anil Dash for bringing it to wide attention. Dash says his favorite numeronym is “e13n,” but I think he’s leaving out one of the T’s.


  1. Yes, I’m using “tweet” and “retweet” to refer to posts on Mastodon. Since Twitter has given up its name, I feel these words are now fair game for any Twitter-like service. After all, they were invented by the Twitter users, not the company.