RSSAmplifier

Blog

Khanlou

khanlou.comRSS feed ↗10 posts

Latest posts

Faking Value Semantics with Custom FormatStyles

NSFormatter is an old API riddled with pits to fall into. It’s very expensive to create a formatter (or adjust its configuration) because it needs to load huge tables of data from ICU for different languages. Contexts, like a SwiftUI View’s body , that are expected to run quickly and may be called multiple times are bad place to create new formatters. We needed a path out of this tangle, and thus…

Accessibility That Fits

How many times have you seen a perfectly laid out mockup that was then implemented in elegant code that immediately breaks when a slightly different text size or locale is imposed upon it? Such cruelty! Building a design that’s responsive to both its contents and its environment is a one of the primary challenges of robust user interface programming. There are some false gods out there and some…

Advanced Techniques In Meridian

After my latest blog post on Meridian, a few people took note of the library and asked some questions on Mastodon. Because of these questions, I realized that a lot of the more advanced tricks that I’ve been exploring with Meridian may not be obvious to those who are casually observing, and I thought I would write about some of those ideas. Parameterizing Responders Defining an endpoint in…

The State Of Meridian

A few years ago, I open sourced my Swift on the Server frame, Meridian . There have been a few big updates in the intervening time which I wanted to talk about here. I’ve now deployed Meridian for a number of sites and projects, and there have been a lot of changes and fixes to make it more reliable and allow it to be deployed for long periods of time without restarts. However, Meridian’s big…

SchemaSwift

I’ve been doing a lot more server-side programming in the last few years. Being able to write Swift on both sides is a real joy. I have a client with whom I’ve built a reasonably full-featured social app in Vapor , and all my personal stuff has been using Meridian , which has been going great. (I will have some contracting availability for server-side Swift coming up soon, so definitely get in…

Arbitrary Beautiful Colors

RGB kind of sucks. RGB, not unlike ASCII, memory addresses, and having 86,400 seconds in day, is one of those things that makes programming a little simpler for a bit, until it doesn’t anymore. In theory, RGB is a group of color spaces that lets you tell the display how much voltage each subpixel needs. However, in practice, we now have phones with displays that let you show more than 100% red ,…

Which Collection?

I recently had occasion to give my old Sudoku talk again. For those who haven’t seen the talk, I live-code my way through a Sudoku problem and together we write a solver that can solve any valid grid. It’s a very fun talk to give and I hope it’s enjoyable to watch as well. While preparing for the talk, I took the chance to update and modernize some of the code. I was able to use multi-line strings…

Name Your Colors!

Here’s a fun experiment: if your app has a designer, ask them how many colors they think are in your app. Then, count the number of colors that you actually use in your app. The bigger the app, the more comical the difference will be. I’ve got a solution for this which is pretty fun to boot. You should name your colors. I find that a lot of people do a good job picking colors, but when it comes…

Download Progress With Awaited Network Tasks

Async/await is here! Five (5!!) years ago, I wrote about what async/await might look like in Swift : async func getCurrentUsersFollowers() throws -> [User] { let user = try await APIClient.getCurrentUser() let followers = try await APIClient.getFollowers(for: user) return followers } I put the async keyword in the wrong place (it actually goes next to the throws ), but otherwise, pretty close to…

The Context And The Logic

As a professional programmer, there are two main types of tasks you work on. I’ve started thinking about them as the context and the logic . The logic is what you think this job is going to be about when you first start. How do I slice this collection up? How do I find all the paid invoices for this client and sum up their amounts? How does this date get turned into a string to be displayed on the…