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.

The Sorry State of Thunderbolt 3 Docks

My primary computer is a 2019 16" MacBook Pro. It has four ports. All of which are USB-C/Thunderbolt 3. Enough words by enough people have been expended complaining about how the lack of common ports makes their lives more difficult, so instead, I’m going to complain about how the solutions for connecting non-USB-C peripherals are awful. This is something I’ve ranted about multiple times on the fediverse, since it’s something you’d think would be a solved problem by now. But clearly it isn’t, so here we go again.

Writing a JavaScript Syntax Highlighter in Swift

For a project I’m currently working on, I need to display some JavaScript code[1], and because I’m a perfectionist, I want it to be nice and pretty and display it with syntax highlighting. Originally, I was planning to use John Sundell’s Splash Swift syntax highlighting library (both a “(Swift syntax) highlighting library” and a “Swift (syntax highlighting) library”). It can already render to my desired output format, an NSAttributedString, and it has an interface for defining new grammars, which I thought would make it relatively easy to extend to support JavaScript. After getting started, it quickly became apparent that it wouldn’t be quite so easy. In addition to writing all the code to parse JavaScript, I’d have to go through the Splash codebase and understand a decent amount about how it works. This grew uninteresting pretty quickly, so I decided I would try just writing everything myself. My highlighting needs were fairly simple, how hard could it be?

Simple Swift Promises

Recently, I’ve been working on cleaning up the networking code in Tusker, my iOS client for Mastodon/Pleroma and I briefly played around with using the new Combine framework as well as the built in URLSession.DataTaskPublisher helper. Combine, much like SwiftUI, uses Swift’s incredibly powerful type system to great advantage because it’s a Swift-only framework. It’s quite efficient, but because there are so many generic types and implementations of different protocols, the API (in my experience) isn’t the most pleasant to work with. I was thinking about other asynchronous programming schemes and the one that came to mind as being the nicest to use was JavaScript’s Promises. It has a fairly simple API, so I started wondering how much work it would be to build something similar in Swift. Turns out: not that much.

Faking the Mongo Eval Command

One of the changes in MongoDB 4.2 was the removal of the eval command. While a reasonable security measure, this is rather annoying if you’re building an app for interacting directly with a Mongo database. If you want to be able to run commands directly on the database, you now have to go through the mongo shell. This seems straightforward, but actually getting the data back into a format that’s usable is a bit of a hassle.