RSSAmplifier

Blog

Jeremy W. Sherman

Recent content on Jeremy W. Sherman

jeremywsherman.comRSS feed ↗94 posts

Latest posts

Turning a PDF into a Coptic-bound book

It’s sometimes convenient to turn an ebook into a paper book. My running example will be Skirmish: Wallet Friendly Wargaming by Biscuit Fund Games, which I wanted to have on hand at the table. But what’s a satisfying way to do this ebook to book conversion? I wound up creating a Coptic-bound volume that lays flat using a couple free tools I hadn’t encountered before and some…

Improving a testing-library test

Test clarity helps in understanding the claims being made and the various ways the test might fail. With JavaScript/TypeScript, asynchrony can make this syntactically more confusing. So I saw this code recently: // Test for official email address await waitFor(() => expect(screen.getByTestId('officialEmail').getAttribute('href')).toBe( 'mailto:OFFICIAL_any_string@email.com' ) ); This is using…

A Month of Terraform

I took Heroku for granted, and a month into setting up my own infra, I now know how much it bought me. A lot of my past work has been infrastructure-adjacent. I often find myself filling in the Build & Integration role - the person that gets continuous integration off the ground and keeps it actually continuing rather than falling flat on its face. But often I’ve just been building one of a…

Collected TILs

This post collects a number of “Today I Learned” messages I’d previously sent into a Slack workspace. Git TIL: Two ways to change git’s default comment handling so I can write Markdown headings: Use the –cleanup flag for git commit to set a different cleanup approach, like git commit –cleanup=scissors Change the comment character to something else with git…

Google Room and The Definitive Guide to SQLite

Why read a book on SQLite? The short answer: Because I needed to write a migration for a Google Room database. Limited past exposure I’ve mostly worked on Mac & iOS apps: iOS: The data all lives server-side, and persisting it is someone else’s problem. macOS: A database, even an embedded one like SQLite, just never was the right tool. What do you mean, not the right tool? Some folks…

What could MPI's evolution say about when to use CSP-style channels?

The reasons MPI is moving from two-sided to one-sided communication may be interesting in light of programs that may use CSP-style channels for communication rather than synchronization/signaling: The main communication paradigm for MPI point-to-point communication has been two-sided communication, where a send call at the source is matched by a receive call at the destination. This paradigm has…

Mixed-Language Testing: Fixing "fatal error: 'App-Swift.h' file not found"

If you have an Obj-C project that’s grown some Swift, you might find yourself with some Obj-C test code that needs to talk to some Swift code. You’re likely to run into just one little problem. You can’t import the header that actually declares the Obj-C interfaces to all that Swift code. More precisely, the compiler can’t find the header, even though you know it’s…

Downtime & Recovery: Bludgeoning DigitalOcean Arch into Working Again

This blog had some downtime yesterday. I have a DigitalOcean Droplet that’s an Arch x86-64 system, from back before they dropped Arch. When I went to poke certbot into renewing my LetsEncrypt cert, I found the system was down. Power cycle, and…it’s still down. Console Spew: Not Promising What follows are my notes from getting things working again. I ran into a couple dark corners where…

Cards: Closing Out a Wikipedia Crawl

I don’t recall how it started, but I’m at the tail end of a several-day Wikipedia crawl through playing cards and card games. Read on for fun trivia, neat games you might not have heard of, and, if your playing card experience is primarily American, probably the destruction of a lot of your assumptions around what a “standard deck of cards” is.

Microservices vs Distributed Objects

Distributed objects died out eventually; you can’t really hide the network layer without changing your system design to match. Here’s a Cocoa take. And here’s a Martin Fowler take found via the article below, with a sidebar suggesting a remote façade (to provide a coarse API as a remote endpoint) and data transfer objects (to provide coarse data transfer also as a way around slow…

The Gist of Regex

Regular expressions scare some people. They’re really quite warm and cuddly, or at least, conceptually very neat and tidy. If you don’t feel that way, this post is for you! Here’s how I think about regexen, in a nutshell. I use this conception on a regular basis; when it comes to writing regex, I think about what I want to do in this model, then translate it into whatever regex…

Iterative Development

“At last, my current practice of writing no automated tests has the blessing of science! See, TDD doesn’t do anything!” That’s how Fucci et al.’s 2016 conference paper An External Replication on the Effects of Test-driven Development Using a Multi-site Blind Analysis Approach was introduced to me. And, indeed, it concludes like so: Despite adopting such…

How to Work Around an Empty Zenfolio Zip File

My family recently had some holiday photos taken. The photographer was using Zenfolio to host their photos. I loved the photos and wanted to archive the originals on my laptop (and NAS, and Amazon Photos, and Time Machine, and Carbon Copy Cloner clone, and…). But every time I tried to download an original – of one photo, of all the photos, makes no difference – the server always sent me an empty…

A Practical Example of FlatMap

The Swift standard library introduces some unfamiliar concepts if you’re coming from Obj-C and Cocoa. map is one thing, but for some, flatMap seems a bridge too far. It’s a question of taste, and of background, if something comes across as a well-chosen, expressive phrase or if it just seems like status signaling, high-falutin’ bullshit. Well, I’m not going to sort that all…

The Internet Speaks: Testing FP Code

One problem I have writing Swift is that I’m not really sure how to tackle testing FP-ish code using XCTest. I did some quick Internet research. If you read it on the Internet, it must be true. This is a distillation of those great Internet truths. The Context: Data Persistence But first, some context. Why did I care about this? I ran into this in the context of sorting out how to persist…

Why I'm Meh About JSON API

JSON API has been pretty successful at providing a framework for APIs that lets you focus on roughly the entity–relationship diagram of your data. But I find it frustrating at some turns (too flexible!) and peculiar at others (why is it bound to just one content-type?). My frustrations with JSON API are ultimately because it doesn’t solve the problems I have as an API consumer, and its aim…

Father's Day: Happy Hurricane

This Sunday marks my second Father’s Day as a father. If you’re not yourself a parent, that won’t mean much to you. It certainly didn’t to me. If you’re en route to fatherhood, read on to learn what “fatherhood” actually means.

Types Complement Tests Complement Types

Types and tests are complementary. They might even be synergistic: The two together can accomplish what neither can alone. They definitely are not rivalrous goods, and if you’re picking only one, you’re doing yourself a disservice. If You Have To Pick One, Though There’s a ceiling to how far we can get with types. Most languages developers work in have rather limited type…

Beyond Type Wars: Types Can Be Tests Too

Types and tests are not at war. Choose both. In fact, if we tilt our heads a bit, types are just another flavor of test. Don’t use just one flavor of testing; use all the tools you have at your disposal to make the best software you can. Type Wars Robert C. Martin believes code TDD’d into existence, and so having 100% test coverage by construction, nullifies the value of types:

Beyond Our Ken

The more I poke around, the more convinced I become that actually knowing what a piece of software is supposed to do is truly rather rare and generally beyond mortal ken. Making it do what you think it should do is nearly beyond our grasp. If we’re honest with ourselves, we need every tool we can get just to wrangle software into behaving. That means types, that means tests, and that means,…

Here's to iOS apps in F#

At Build 2016, Microsoft announced that Xamarin is free with all versions of Visual Studio, and the Xamarin SDK will be open-sourced. My first thought was: iOS apps in F#? Lemme at it!

XCTestExpectation Gotchas

XCTestExpectation simplifies testing callback-style code, but some of its design choices make tests using it fragile unless they’re mitigated: It explodes if everything works right but later than you expected. It explodes if everything works right more than once. This article presents two concrete mitigations: Use weak references to ensure the expectation dies before it can cause you…

Embedded Content Contains Swift

If you’re developing a QuickLook plugin using Swift, make sure you flip on the EMBEDDED_CONTENT_CONTAINS_SWIFT build setting for the target, otherwise bundle loading will fail in a spectacularly unhelpful way.

Review: SE-0026: Abstract classes and methods

This is a review of SE-0026 “Abstract classes and methods”. I am against the acceptance of this proposal: It lacks a clear problem. The leap from a nebulous problem to abstract classes as the solution is a non sequitur. Its arguments are insufficient to justify the complication it would add to Swift, which is contrary the simplification and clarification aims of the Swift community.…

Go Versions and the Open-Closed Principle

People aren’t happy about Go’s approach to managing software versions: aren’t different API versions supposed to live at different import paths in Go? This works great if you have a proprietary codebase, are using a monorepo, and don’t support the sharing culture of open source. And, it doesn’t address the issue of minor or patch versions. Hello, Open-Closed Principle…

Housekeeping

This post automagically appeared on the site thanks to a post-receive hook. Every prior post was written, compiled, and rsynced from my laptop. No more! Now: I can post from my phone using Working Copy. Later: I’ll work out handling for microposts, so I can send those here and sync to ADN after. Later still: Figuring out a good workflow for link blogging from my phone. For ADN, I’ve…

Do more of less

The most valuable lesson of Kanban is to limit work in progress. At the personal level, this jives with studies showing that humans suck at multitasking. This is a hard lesson for me: My life is littered with the detritus of works begun, works planned, resources squirreled away against a future that rarely comes back to them.

Agile

I take agile as rejecting the notion of estimation as having value. In the event you have a deadline, the best you can hope for is to deliver as much working software as you can before that deadline. Dithering over what’s going to fall on which side of the deadline is time better spent delivering a feature and winnowing out low-value crap that came along with the high-value bits of your original…

Updating Plex on Synology NAS

My family has been using ChromeCast to send YouTube videos to the TV. While flipping through the ChromeCast app on my phone, I noticed Plex integrates with ChromeCast. Funny enough, Synology also ships a Plex server package. How hard could this be?

An Idris metaprogramming "hello world"

Idris is a programming language with dependent types. Like any civilized language, it has metaprogramming support; its REPL even supports interactively crafting metaprograms by employing tactic functions. Let’s walk through a small example that covers the bases of interactive metaprogramming. This article is an elaboration of a gist I posted a few days ago.

When is a proof not a proof?

When is a proof not a proof? When you think you’ve proven one thing, but actually, you’ve proven something else. In the last post , I addressed a good question raised in the first half of David Owens II’s article “Dependent Types: I’m Missing Something” , where he addresses my discussion of dependent types. This post looks at the latter half, which talks about…

What if you get your dependent type backwards?

David Owens II read my notes on “Why Dependent Types Matter” and asked a good question : This is the part I don’t get: we allow for incorrect code to be written in the non-dependent-typed case, but we assume that we can’t do the same with dependently-typed code? Why? What’s preventing me from swapping left and right in the Order type that is returned?

Read: Why dependent types matter

Altenkirch, Thorsten, Conor McBride, and James McKinna. Why Dependent Types Matter. 2005. 19 pages (+2 more of references). Accessed 2015-08-26. What is a dependent type? A dependent type is a type that depends, not just on other types, but on terms. This means you can have values – plain old data – in your types. A common example is that of length-indexed lists: /// A list parameterized by…

Read: A tutorial on the universality and expressiveness of fold

Hutton, Graham. A tutorial on the universality and expressiveness of fold. 1999. 16 pages (+ 2 more of references). Accessed 2015-08-18. Fold (reduce, inject, cata) lets you take a list and swap out its constructors for a combining function and base value of your own devising, like swizzling in + for cons/: and 0 for nil/[]: [1 , 2 , 3] == EXPAND THE SUGAR ==> (1 : (2 : (3 : []))) == FOLD (+) 0…

Read: Towards native higher-order remote procedure calls

I do a lot of reading on my iPhone 6+. It’s amazing what you can accomplish reading only a couple pages a day. I write notes in either Day One or Logsit, depending on how long the work is. They don’t do anyone much good buried in there, so I’m sharing my notes. Fredrikson, Olle, Dan R. Ghica, and Bertram Wheen. “Towards native higher-order remote procedure calls.” IFL…

Listened: SE Radio: Joe Armstrong

I listened today to an interview with Joe Armstrong recorded in late 2007. Joe Armstrong created Erlang. This interview took place right as interest in Erlang was rising due to the growth in generally available multicore machines. In case you’d like to give it a listen as well, this was Software Engineering Radio episode 89. My takeaways: Concurrency and fault tolerance are the heart of…

Using rbenv with fish

I switched from zsh to fish shell a month or so ago. I lost bang-history (no more !?gi ) and gained a shell small enough to understand and write scripts for without fearing I’m going to step into some gotcha from the 1970s. No more shell-as-quirks-mode! There’s a downside to shifting to a non-POSIX shell, though: scripts intended to modify the shell environment itself no longer Just…

Dodging State

Soroush Khanlou gives some concrete tips for reducing the amount of state in your code. I’m going to rephrase his advice into terms that connect better with other reading I’ve been doing: When you recognize cohesive groups of properties, bud off a new object. Prefer domain types to primitive types. Take advantage of computed properties to express derived state; reintroduce caching only…

Should DRY entail call-by-need evaluation?

Swift brings Cocoa devs a standard library that includes map, filter, and reduce. But in a strict language such as Swift, you’ll likely find yourself hand-fusing a composition of these operations at some point as a result of profiling-directed performance optimization. This isn’t new to Swift. Lennart Augustsson observed in 2011 in More points for lazy evaluation: Strict evaluation is…

CRC Cards

File under “old technique, still useful”: CRC cards The core elements of an object system are an object, its responsibilities, and its collaborators. With just that info, you can start walking through scenarios. You’ll note this doesn’t say anything about inheritance or protoypal delegation or whatever; that’s intentional: The cards are being used as props to aid the telling of a…

Using Swift Throws with Completion Callbacks

Swift 2 introduced the notion of throwing and propagating NSError values. It works pretty well in a linear, synchronous workflow, but at first glance, it doesn’t appear to address the common case of completion callbacks. Consider NSURLSession.dataTaskWithURL(_:completionHandler:). Swift 2 bridges this in like so: func dataTaskWithURL(url: NSURL, completionHandler: (NSData?, NSURLResponse?,…

Functor & Friends: Protocol + Tests

I’ve read articles that try to reduce the academic flim-flammery of functors, monads, and similar to concrete syntax by just presenting them as a series of interfaces, or protocols, that must be implemented. This is reassuring: It turns something unfamiliar into something familiar, if not downright mundane. Unfortunately, reducing these abstractions to protocols alone oversimplifies them and…

No Single Swift Style

“Swift is too young for us to say what good Swift style is, or to have developed a sense for idiomatic Swift.” Talks, blogs, and books repeat this sentiment or variations. This statement assumes that there will eventually develop a single, canonical Swift style. This is a mistake.

Radar tip: Shell one-liners to dump configuration info

With the current Xcode and Swift betas, I find myself needing to paste in the versions of my OS, Xcode, and Swift every time I file a new Radar. So I use these handy aliases: alias rdrconf='{ xcodebuild -version; echo; sw_vers; }' alias swfconf='{ xcodebuild -version; echo; sw_vers; echo; xcrun swift --version; }' The echo bits are there to put a blank line between the different lists of versions.…

Pervasive use of Optional in Swift is penance for nil

If you’ve looked to do anything significant with Swift, you’ve likely had to fall back on our old friend, Foundation, and likely also some newer friends in the form of other core Apple frameworks. One thing you cannot miss with this legacy APIs is the pervasive use of optional types. Thanks to them, we still get to angst about the billion-dollar mistake of nil, only now we get to pay a…

Intuition behind the Swift external/local parameter system

David Bryant Copeland picks out Swift’s external/local parameter system as something never before seen: The notion of giving named parameters different names for the caller than are used in the implementation is not something I’ve seen before, and it’s kinda genius. But further reflection convinced me that allowing different external and local parameter names is simply the Swift version of a…

VDM & The “Agile Spec” Problem

At the end of Distributed Programming & CALM, I mentioned how organically growing software often fails to produce a system with clear semantics. So I count myself lucky that Mark Fernandes recently mentioned the Vienna Development Method (VDM). It’s like if design by contract, abstract data types, first-order logic, and a small imperative/OO language with a collection library had a lovechild.…

Distributed Programming & CALM

Distributed programming doesn’t get much talk in those terms in Cocoaland. If you’re writing an iPhone app with a server, guess what: You’re writing a distributed system. For your users’ sake, I hope it’s also an offlineable system. And we can view a multithreaded program as distributed programming, only with the distribution being far more local. Ordering issues rear their head when you start…

Use jsonlint to debug bogus JSON data

NSJSONSerialization delights in an opaque “lolnope character 12341234” error message that provides zero context. It doesn’t even bother to take advantage of line numbers to help you out, even if the JSON data has linebreaks. This is a royal pain, especially if you’re working with hand-written stub data for a web service. I got fed up with this, went “there has to be a…

OptionBits and BOOL gonna bite you one day

I got to talking with a coworker about some code that tested bitmasks: BOOL isFoo = flags & FLAG_FOO; Don’t do this; you are inviting pain, suffering, and head-scratching debugging. I wrote about the wonderland of joy and kittens that is C arithmetic earlier , but only in the abstract. NSUInteger and BOOL provide concrete examples that hit where it hurts.