Negate KeyPath Values with not()

Swift KeyPath is a great shortcut for property-based mapping and filtering of collections: When you need a simple transformation, the simplest probably being the boolean negation operator, you only have two choices: So either you use the key path and separate the negation – which makes it harder to read as “I want the opposite of X”. Or you drop the key path and use a regular closure.

Continue reading …

Disable XeLaTeX Character Sequence Mappings for Inverted Question Mark and Inverted Exclamation Mark

I spend a couple of hours investigating the XeLaTeX purgatory where character mapping live. I didn’t know what these were before, too, don’t worry. I’ll walk you through it. The observable behavior is the following. Let’s say you start with Markdown with “dumb” quotes like this: … and use a conversion tool like Pandoc or MultiMarkdown to turn it into LaTeX, and you pick German quotation marks (the non-guillemet ones). You’ll see why it’s important for this example to use the German quotation marks. They are different from the curly quotes you know from English texts.

Continue reading …

You Absolutely (Do Not) Need to Comment Your Code

Of course you don’t need comments in your code. But your future self appreciates explanations: What is this nested loop good for? What is its purpose? Comments provide context, and shortcuts for understanding: “you don’t need to read this, just think of it as …” Once you explain what the purpose is, suddenly you may also find a way to express the intent clearly in code.

Continue reading …

Oh, You’re Making Apps, So You Are Working for Apple/Google/…?

Octavi Navarro reports that (some) people think (some of) his games should be free instead of paid: I’ve got hundreds of “this game should be free” angry reviews over the years but I find it shockinge every time. These are not evil corporation executives, but consumers (most probably underpaid workers themselves) who advocate very vocally against remunerated work.

Continue reading …

How to Disallow GPTBot Crawling in robots.txt

To tell OpenAI’s web crawler to skip your site, add these lines to your robots.txt (see docs): (via Hidde de Vries) The outlook is bleak: There’s no way to win this if you don’t want to be scraped at all, ever, except by not putting things online. If they don’t scrape your content, they scrape the copycat sites as Rik Schennink pointed out. Or ignore the robots.txt rule. (How could you tell, anyway?)

Continue reading …

Developer Voices on Property-Based Testing Made Me Realize PBT’s Value

I listened to “Automate Your Way to Better Code: Advanced Property Testing (with Oskar Wickström)” and I believe that Property-Based Testing (PBT) clicked for me a bit now. Maybe. It never made sense to me before, but Oskar Wickström has a lot of actually interesting examples.

My highlights are instances where you have to think outside the box, like a good puzzle:

  • You cannot describe complex actions on random data directly (like cutting gaps from audio tracks); but you can offer inverse actions, like undo operations, and then essentially test that applying an action, undoing it, redoing it, then undoing it again doesn’t change the result.
  • Testing a search function, you can’t actually test the search (without implementing the search functionality inside the tests again) because you don’t know the test data. But you can test that filtering the search results works, because filtering should product subsets of the unfiltered search.
  • You can describe web apps as state machines with valid transitions and then go ballistics with trying all kinds of interactions. That’s the promise of Quickstrom: You don’t need to specify each state of the web page as an example, but you specify the properties of each valid state and then ensure that no combination of interactions and button presses produces an invalid state. (Relying on app introspection, this probably works much better on the web with headless browsers than in Xcode/on mobile.)

None of this sounds like a replacement for what unit tests would do. But they do sound like a much better high-level approach to regression testing!

If nothing else, I’m intrigued to learn more about this now.

Can absolutely recommend this episode.

Actually, I recommend the whole podacst.