humancode.us

More thoughts on remote work

August 28, 2023

What a great illustration of the perversion of capitalism: someone who owns two restaurants in downtown Minneapolis is asking Target to force thousands of employees to spend literal pieces of their lifespan every day (and polluting and adding to traffic and wearing down/depreciating their cars in the process) to return to office so that their restaurant business model continues to be profitable.

The remote work revolution is likely unstoppable: thanks to three years of lockdowns, workers now know that rote commuting is a waste of time. Flexible and remote work allows more work-life balance and costs everyone less to produce the same output.

The forces against remote work are almost entirely reactionary: a desire to return to the Old Ways, to Manage By Walking Around, to go back to the Old Business Models, to save Commercial Real Estate; in other words, to save old capital.

Read more…

Exposing Swift implementations to Objective-C

August 9, 2023

In this post I describe a recipe for exposing symbols implemented in Swift to Objective-C through a header file. The symbols supported are:

  • Functions
  • Classes
  • Categories
  • Protocols
  • Enumerations

If you want to go straight to code you can use, check out my github project.

Read more…

How to never miss a shift when driving a manual car

July 14, 2023

Car Nerd Time!

If you drive a manual transmission car you owe it to yourself to learn the “open palm” technique to eliminate missed shifts, especially during high-performance track driving.

The secret to never missing a shift is to not grip the shifter. If you do, bumps and jostles will easily shift the lever into the wrong position. Keep your palm open and relaxed, and be sure to apply forces only in the directions that result in a proper shift.

The open palm technique involves positioning your hand in various orientations and contacting the shifter only in certain locations that always result in the correct gear selection. After some practice, this will become so natural and subtle that you’d be able to do it without a thought.

Here’s what I mean. For these examples, I assume you’re driving a left-hand-drive car (e.g. US) so you’re using your right hand to shift. I also assume a standard H pattern, not a dogleg.

Read more…

Believe in magic while you’re learning

July 9, 2023

I find that a small amount of willful belief in magic goes a long way when learning something new.

As an experienced coder, I fall into the trap of prematurely analyzing how something works and constantly peeking under the hood while learning a new library, language, or abstraction. While the desire to disassemble toys to find out how they work is great, it often gets in the way of education.

I often have to force myself to accept magical behavior in order to keep progressing in my studies. Don’t look behind the curtain. Don’t worry too much about how that animation works, or how that sound is generated, or how that data got communicated. That level of curiosity is for later. For now, just accept things at face value—as simply magical—and continue your learning journey.

Remember that your goal is to be a knowledgeable novice at the end of the learning process. Don’t try to be an expert right away.

Don’t let experience get in the way of wonder.

All about Item Providers

July 8, 2023

The NSItemProvider class in Foundation is a powerful abstraction for making data available across processes that are otherwise isolated from one another. I hope this post can be a one-stop reference for developers who want a solid understanding how item providers work, and how to use the API in a modern way.

This section provides a history of NSItemProvider and its API surfaces. Feel free to skip it if you’re not interested.

NSItemProvider was introduced in iOS 8.0 to support passing data between an application and extensions. The interface introduced at that time relied heavily on runtime Objective-C introspection, and every extension point specified its own peculiar way in which apps had to provide and receive data.

When Drag and Drop for iOS was introduced in iOS 11.0, a new set of API was introduced on the class to meet new requirements: Swift made it impractical to use Objective-C introspection, and Drag and Drop needed a more consistent and generalized abstraction, since the source and destination processes could be any app or extension.

The introduction of UniformTypeIdentifiers in iOS 16.0 added a further extension to the class which uses UTType instead of String-typed identifiers for data type specifications. Methods to bridge between the Swift Transferable protocol and NSItemProvider were also introduced.

The existence of many historical layers in the NSItemProvider API makes it confusing for the contemporary developer to understand exactly what they need to use in their code. It is my hope that this post can help steer developers toward the best set of API to use in their apps.

NSItemProvider is a data promise

An NSItemProvider is a promise to provide data. A provider constructs an NSItemProvider object and registers available data. It then passes the item provider to some system API which will make it available to some consumer which will load the data. The provider needs not provide any data up front—data is requested only when a consumer attempts to load it.

Read more…