RSSAmplifier

Blog

Shadowfacts

shadowfacts.netRSS feed ↗10 posts

Latest posts

Custom Property Wrappers in SwiftUI

You can use SwiftUI by trying to fight the framework or by trying to work with it. One of the best ways I’ve found of working with the framework is by using custom property wrappers. Of all the tools that SwiftUI provides, property wrappers are the one that most consistently makes me feel like I’m using the framework how it wants to be used. In Swift, property wrappers are simply types that are…

FocusedValues in SwiftUI

In my last post , I wrote about using preferences in SwiftUI to make the shape of the graph do work for you. This post is something of an addendum to that, focused on focused values. We’ll look at how focused values work, and then see a few ways of taking advantage of them. Here’s the one sentence explainer: the FocusedValues system is like preferences but where the reducer function is “whichever…

SwiftUI Preferences

Most data flow constructs in SwiftUI propagate data down the view tree. Preferences work in the opposite direction: passing data up the hierarchy. This makes them very powerful, both in ways that are fairly straightforward and by enabling more complex behavior. A preference is defined by two things: a default value, which is the value used when nothing writes an explicit value, and a reducer…

On AI

I’ve been watching a lot of woodworking YouTube lately. The trope of software engineers taking up woodworking as a hobby is well-worn, and the consensus seems to be that its parallels to building software—combined with the physical tangibility—are attractive after spending so much time staring at a computer screen. But I don’t believe that explanation wholly captures the phenomenon. I don’t think…

Version 7

Welcome to version 7 of my website. What started as a rewrite of the backend last fall has since snowballed into a complete redesign of the frontend as well (if you’re using an RSS reader, check out the actual site). The previous design dates back to the fall of 2019 and, after doing a bunch of work to rewrite the backend, rebuilding the exact same frontend again wasn’t an attractive prospect.…

Belief

I do not pretend to know fully understand how this came to be the case, or what to do about it, but I am increasingly of the opinion that the single most pressing problem of the American polity is that of amorality. Not immorality, amorality . It is not the case that we collectively believe what we are doing to be wrong—or believe it to be right; we simply do not care. We are too eager to look for…

Your View's Lifetime Is Not Yours

When SwiftUI was announced in 2019 (oh boy, more than 5 years ago), one of the big things that the Apple engineers emphasized was that a SwiftUI View is not like a UIKit/AppKit view. As Apple was at pains to note, SwiftUI may evaluate the body property of a View arbitrarily often. It’s easy to miss an important consequence this has, though: your View will also be initialized arbitrarily often.…

Parsing HTML Slower

Last time , I wrote about how to parse HTML and convert it to NSAttributedString s quickly. Unfortunately, in the time since then, it’s gotten slower. It’s still a good deal faster than it was before all that work, mind you. At fault is not any of the optimizations I discussed last time, fortunately. Rather, to get the correct behavior across a whole slew of edge cases, there was more work that…

Parsing HTML Fast

The urge to overengineer something recently befell me, and the target of that urge was the way Tusker handles HTML parsing. Mastodon provides the content of posts (and profile descriptions, and some other things) as HTML, which means that, in order to display them properly, you need to parse the HTML, a notoriously straightforward and easy task. For a long time, the approach I took was to use…

Passkey Sign In with Elixir and Phoenix

Passkeys are a replacement for passwords that use public/private cryptographic key pairs for login in a way that can be more user-friendly and resistant to a number of kinds of attacks. Let’s implement account registration and login with passkeys in a simple Phoenix web app. This work is heavily based on this article by Adam Langley, which provides a great deal of information about implementing…