Collection enumeration performance in Swift

Swift’s Collection and Sequence protocols provide two primary ways to enumerate (filter, map, reduce, etc): functional-style and imperatively. For example: Or: Nominally these are equivalent – they’ll produce the same results for all correctly-implemented Collections and Sequences. So in principle which you use is purely a matter of stylistic preference. But is it? Do they… Read more

Zsh has neat shortcuts for decomposing file names & paths

I only just learned that the venerable basename and dirname are no longer necessary, let-alone the horrible string splitting required for teasing apart names from file extensions. Zsh has some awesomely convenient expansion modifiers which do it all! e.g. given the path “/Users/me/Documents/Work.zip”: $file:t → Work.zip $file:h → /Users/me/Documents $file:r → /Users/me/Documents/Work $file:e → zip… Read more

Now available in Fedivision®

With the release today of the ActivityPub plug-in version 1, I’ve configured my wee blog here to publish to the “Fediverse” (basically, Mastodon). You can find it at @everything@blog.wadetregaskis.com. Bafflingly there’s apparently no way to deep-link into Mona (or ‘Mastodon’ generally), so apparently you’ll have to copy-paste that user ID into your client of choice’s… Read more

getifaddrs never specifies broadcast addresses

Apple “Feedback” #12149764. According to man 3 getifaddrs: The ifa_dstaddr field references the destination address on a P2P interface, if one exists, otherwise it contains the broadcast address. In my testing the ifa_dstaddr field is never non-null. I’m not sure I have any suitably configured P2P interfaces, but I definitely have interfaces with broadcast capabilities… Read more

getifaddrs returns truncated sockaddr_in’s for AF_INET ifa_netmasks

Apple “Feedback” #12149675. Some netmasks returned by getifaddrs have family of AF_INET yet a length less than sizeof(sockaddr_in), e.g. 5, 6, 7, or 8. On macOS Ventura 13.3.1, at least. It looks like it’s actually allocating only eight bytes for the ifa_netmask (not the 16 that is the size of sockaddr_in per MacOSX13.3.sdk/usr/include/netinet/in.h), as it… Read more

Apple Watch Ultra is a poor dive computer

Note: this was written in 2021 (and updated in 2022) based on version 1 of the Oceanic+ app. In September 2023 version 2 of that app was released, and it appears to have fixed quite a few limitations (e.g. you can finally export your log book, as a standard UDDF file). Once I’ve gathered some… Read more