Operators are just a special type of function that can help make your code easier to read. Operators you might be familiar with include +, -, and even ??. They come in three flavors: prefix, infix, and postfix, depending on where you put them with respect to their arguments: Prefix operators go before their (only)… Continue reading Quick Swift: Operators
Blog
What makes a good network layer
Here's what I want in a networking layer: Should be easy to switch between different hosts and API versions while keeping all the endpoints the sameShould be possible to separate the logic for setting up a network call and firing itShould be easy to mock server responsesShould be easy to separate concerns when handling responsesShould… Continue reading What makes a good network layer
Slippers: a library for paging, refreshing, and JSON
Slippers is not a networking library. It won't make server calls for you (I have other libraries for networking). What it will do, however, is make it easy for you to trigger network calls when you need to. It does this by providing some protocols and simple implementations thereof to control common network tasks like… Continue reading Slippers: a library for paging, refreshing, and JSON
Quick Swift: Combine (Just the Basics)
There are three things you generally want to do with Combine: publish values, manipulate those values, and receive those values elsewhere. Let's see how we can do each of those. Publishing Values Values are published with, predictably, Publishers. The most common way I see this happen is through @Published fields. So, for instance: class App… Continue reading Quick Swift: Combine (Just the Basics)
Coronemoting: Remote work during the coronavirus pandemic
Hello! Your company is probably remote now due to coronavirus/COVID-19. As a full time remote worker, I have some advice (and encouragement!). First, though, a caveat. If COVID-19 is causing your first experience with remote, understand that this isn’t normally how things go. This situation sucks, period. Even I'm not getting as much done, simply… Continue reading Coronemoting: Remote work during the coronavirus pandemic
When did New Yorkers start taking COVID-19 seriously? An analysis based on subway app usage
My company owns a bunch of subway apps, but one of our most popular ones is SUBWAY:NYC. Obviously, this app in particular has seen dramatic decreases in usage as a result of the worldwide pandemic that's hit NYC especially hard. While that's bad for me, I thought it might be interesting to look at the… Continue reading When did New Yorkers start taking COVID-19 seriously? An analysis based on subway app usage
Coronavirus: a mathematical prediction and what you can do about it
Caveat: I’m not the CDC. I’m just a former math professor who had a long flight last week and wanted to figure out the odds that someone on my plane had coronavirus. That said, the model I describe below is a reasonable approximation of the situation we're in for the time being; that is, unless… Continue reading Coronavirus: a mathematical prediction and what you can do about it
ReactiveSwift to Combine Cheat Sheet
This is a cheat sheet for converting from ReactiveSwift to Combine. The origin of this document is me converting some of my libraries from one to the other, so they're just basic use cases of things I've used. As a result, this sheet by no means exhaustive, but is a good start and includes caveats… Continue reading ReactiveSwift to Combine Cheat Sheet
Quick Swift: Generics
Generics are basically placeholders for types. They help you write specific code that can be used with (almost) any type. Suppose you're really tired of the whole if let dance. You want to write a function that will do that for you, so you can save some lines of code. Generics to the rescue! You could… Continue reading Quick Swift: Generics
Quick Swift: Protocols
Protocols allow you to define functions and properties that any class or struct which conforms to it must implement. This gives you the ability to rely only upon the things you need, while not putting too many restrictions on the conforming type. Let's look at an example. Consider the following: protocol Fireable { func fire()… Continue reading Quick Swift: Protocols