SwiftUI Auto-Expanding Text Views

I’m currently in the process of rewriting the Compose screen in Tusker to use SwiftUI. This has mostly been a smooth process, but there have been a few hiccups, the first of which was the main text box. The updates to SwiftUI introduced in iOS 14 included TextEditor, the SwiftUI equivalent of UITextView to allow multi-line text editing. Unfortunately, there’s no (straightforward) way of disabling scrolling, making it unsuitable for some designs where the text view is embedded in a separate scroll view. Additionally, the fact that it’s not available at all on iOS 13 means layouts that require non-scrolling multi-line text editors must wrap UITextView themselves in order to be achievable with SwiftUI.

Implement a Gemini Protocol Client Using Network.framework

Gemini is a small protocol bulit on top of TCP and TLS that’s designed to serve as a transport mechanism primarily for text documents while lacking a great deal of the complexity of HTTP. Network.framework was introduced to Apple’s platforms in 2018 as a modern framework for dealing with network connections and building custom network protocols. So, let’s use it to build a Gemini client implementation.

Replicating Safari's Link Preview Animation

In iOS 13, Apple replaced the Peek and Pop force touch system with new context menus and previews[1]. These new previews have a fancy animation for when the appear, in which they expand out of the content and onto the screen. Back when I first replaced the previews in Tusker with the new context menus (over a year ago, shortly after WWDC19), I wanted to replicate the behavior in Safari for links and mentions in post bodies. At the time, there was pretty much zero official documentation about the new context menu APIs, so I decided to wait for either Apple to publish docs or for someone else to figure it out first. Now that WWDC20 has come and gone, and I’ve been working on it a little bit at a time for over a year, I finally have a fully working implementation.

Algorithmic Bias

I am subscribed to Marques Brownlee on YouTube. I watch almost every one of his videos. YouTube is smart. It knows this, it recommends me almost all of his videos. But not this one. No matter how many times I refresh the page. No matter how far down the page I scroll. Despite the fact that the video has gotten 2.3 million views in 16 hours, performing better than a number of his recent videos. Despite the fact that it’s recommending me videos that are from people I am not subscribed to, videos that are years old, videos that I have watched before, videos that are about politics, videos that are about the ongoing Black Lives Matter protests in the wake of George Floyd’s murder.

This is what algorithmic bias looks like. Algorithms are not neutral.[1]

YouTube thumbnail of an MKBHD video
A screenshot of the thumbnail for a YouTube video from MKBHD titled "Reflecting on the Color of My Skin".

  1. “Algorithm” is a word here used not in the purely computer science sense, but to mean a element of software which operates in a black box, often with a machine learning component, with little or no human supervision, input, or control. ↩︎

Switching to Vim

At the beginning of last summer, for reasons that I can no longer recall, I set a goal for myself to learn Vim over that summer. Now that summer is over and almost here again, I wanted to reflect on that process and whether I achieved my goal. By no means have I mastered Vim or am a Vim expert, but I feel reasonably proficient. I use Vim itself on the command line and in GUI form, as well as Vim bindings/plugins in all my IDEs. It has gotten so strongly ingrained into my muscle memory that I now find myself hitting ESC to exit insert mode in text boxes in my web browser and typing Vim commands into word processors.