information overload

by sebastian de deyne

E-ink newspaper artwork

19 Jul 2023 via projecteink.com

What a lovely project! Project E-Ink builds a large e-ink display that displays the front page of the newspaper.

{.short}

I have a strong attraction towards e-ink. I think it’s because despite being state of the art technology, e-ink doesn’t feel “digital”. In the case of this display: it’s there, it’s connected, but it’s static. It’s up to date but doesn’t grab your attention.

Read more

Beware of PHPUnit data providers with heavy setup methods

17 Jul 2023

Data providers can be a perfect fit to assert a lot of expectations without writing a full test for each.

This makes it cheap and easy to add more test cases. For an in-depth introduction to data providers, I recommend this excellent article on the Tighten blog.

class AddTest extends TestCase
{
    /** @dataProvider values */
    public function it_adds_values(int $a, int $b, int $result): void
    {
        $this->assertEquals($result, add($a, $b));
    }

    public function values(): array
    {
        return [
            [1, 1, 2],
            [1, 2, 3],
            [5, 5, 10],
            // …
        ];
    }
}

Data providers run setUp for each value. If you need a clean slate for every test, there’s no way around this. If you don’t, data providers make your tests slower than they need to be.

Consider a heavier integration test that migrate & seeds the database in setUp().

class MyTest extends TestCase
{
    public function setUp(): void
    {
        parent::setUp();

        // Migrate and seed database values…
    }

    /** @dataProvider values */
    public function it_does_something(string $value): void
    {
      // …
    }

    public function values(): array
    {
        return [ /* … */ ];
    }
}

Each case in values() will re-seed the database. If this isn’t needed, you’re better off looping over the values yourself.

class MyTest extends TestCase
{
    public function setUp(): void
    {
        parent::setUp();

        // Do some heavy lifting…
    }

    public function it_does_something(): void
    {
      $values = [ /* … */ ];

      foreach ($this->value() as $value) {
          // …
      }
    }

    public function values(): array
    {
        return [ /* … */ ];
    }
}

We recently updated a few tests in a project we’re working on, and it almost doubled the speed!

With a data provider:

Time: 00:08.517, Memory: 92.50 MB
OK (43 tests, 43 assertions)

In a loop:

Time: 00:04.448, Memory: 70.14 MB
OK (1 test, 43 assertions)

Read more

JavaScript Gom Jabbar

4 Jul 2023 via frantic.im

You stop to count how many tools and parsers work on your codebase: TypeScript, esbuild, swc, babel, eslint, prettier, jest, webpack, rollup, terser. You are not sure if you missed any. You are not sure if you want to know. The level of pain is so high you forget about anything else.

We’ve come a long way, but we’re not there yet.

Read more

Blogs, more than ever

2 Jul 2023

It’s been an odd few days with the changes on Reddit and Twitter – the only two major social media platforms I browse.

Platforms are great portals for discovery, but a guarantee for longevity is not their strong suit. And while the fediverse is interesting, my Mastodon experience feels more like a detox than something that stands on its own.

Read more

Fibonacci estimates

28 Jun 2023 via productplan.com

Estimating software projects will never be my strong suit, but I’ve learned using numbers from the Fibonacci sequence to judge the size sets me off to a good start.

To estimate a task (in hours or days), I only use numbers from the Fibonacci sequence:

1, 2, 3, 5, 8, 13, 21, 34, 55…

The further along the Fibonacci sequence, the bigger the difference with the next number becomes. This aligns well with how we should estimate, because the bigger the task, the more unknowns there are.

Read more

A blog post is a very long and complex search query to find fascinating people and make them route interesting stuff to your inbox

28 Jun 2023 via henrikkarlsson.xyz

A lovely essay by Henrik Karlsson on writing, blogging, and the power of the internet.

When writing in public, there is a common idea that you should make it accessible. This is a left over from mass media. Words addressed to a large and diverse set of people need to be simple and clear and free of jargon. […]

That is against our purposes here. A blog post is a search query. You write to find your tribe; you write so they will know what kind of fascinating things they should route to your inbox. If you follow common wisdom, you will cut exactly the things that will help you find these people.

Read more

PHP wishlist: Nested properties

27 Jun 2023

Next on my PHP wishlist are nested properties. This idea is less realistic than others, it’s more me thinking out loud. I don’t have a good syntax proposal for this, and I’m not even sure it’s the best solution for my problem. But it’s the best I’ve come up with so far.

Read more

How I built customizable themes using CSS custom properties & HSL

27 Jun 2023 via mailcoach.app

I published an article on the Mailcoach blog explaining the setup around customizable themes for newsletter archives.

I relied on CSS custom properties and HSL colors to allow users to customize their newsletter archives without fiddling with too many options.

Colors are often defined in RGB, but RGB is difficult to transform without custom functions. We ask the user to define the primary color in HSL instead. The benefit of HSL is that it’s easy to control a color by tweaking the parameters.

Read more

Thoughts on event sourcing: Replaying events

20 Jun 2023

When event sourcing, the stream of events is your source of truth where all data is derived from. A promise often made in event sourcing pitches is that you can destroy your data and rebuild (replay) it at any time. In my experience, it’s a lot more nuanced than that.

Read more

Read-only web apps

20 Jun 2023 via adactio.com

From Jeremy Keith:

Your app should work in a read-only mode without JavaScript. Without JavaScript I should still be able to read my email in Gmail, even if you don’t let me compose, reply, or organise my messages.

I like this take on progressive enhancement. JavaScript is the language for interactivity on the web. Reading does not require two-way communication.

Read more

Laravel closure validation rules

16 Jun 2023

Today I was looking for a way to create a custom Laravel validation rule without the overhead of a new class. The rule I needed would only be used in one place, so wanted to keep it close to (or in) the request class.

Upon re-reading the validation docs, I learned that Laravel supports closures as rules.

class JournalEntryRequest extends Request
{
    public function rules(): array
    {
        return [
            // …
            'lines' => [
                function (string $attribute, mixed $value, Closure $fail) {
                    $debit = collect($value)->where('type', 'debit')->sum('amount');
                    $credit = collect($value)->where('type', 'credit')->sum('amount');

                    if ($debit !== $credit) {
                        $fail("Debit and credit don't match.");
                    }

                    if ($debit !== 0) {
                        $fail("Amount must be greater than 0.");
                    }
                },
            ]
        ];
    }
}

Just what I needed!

Read more

Pretend Everyone Costs 1k Hr

15 Jun 2023 via notesonwork.transistor.fm

Caleb Porzio released this podcast episode earlier this year, but it’s been simmering in my head ever since.

The gist is to take things as far as you can before asking others. Instead of opening an issue, open a PR. Instead of replying “I don’t know”, find out. Before asking a question, write down the problem to make sure you’ve considered evey angle yourself.

Dealing with interactions this way gets things done more effectively, gives you the opportunity to learn something, and turns you into a nice person.

Read more