Uncategorized

  • Parameter type widening, and the interface it unblocks

    Removing a type hint in a child class used to be a fatal error, which meant an interface written with a concrete type could never be relaxed without…

  • Consumer groups, and the pending entries list

    Reading a stream directly gives every consumer every message. A consumer group distributes entries between members and remembers which ones were handed out and not acknowledged. The pending…

  • usort is not stable, and the tiebreaker that fixes it

    PHP’s sorts are not stable, so two elements the comparator calls equal may come out in either order — and that order can differ between array sizes, because…

  • A Dockerfile per service, and why the shared one had to go

    One image with Apache, Nginx, PHP and MySQL in it, because that is how it starts. Splitting it, what each file may contain, and the uid problem on…

  • Declaring a type for a library that has none

    A JavaScript dependency without types is either an any, which defeats the point, or a declaration file, which takes ten minutes and only needs to describe what you…

  • The passive event listener flag, and the scroll jank it fixes

    A touchstart or wheel listener may call preventDefault, so the browser cannot start scrolling until the handler has run — which means every such listener delays scroll by…

  • iterator_to_array collides keys unless you tell it not to

    Materialising a generator with iterator_to_array preserves keys by default, and a generator that yields without a key restarts its counter on every inner traversal — so a nested…

  • systemd timers instead of cron, and why the logs are better

    A cron job that fails emails root, which goes nowhere on a modern server, so the standard arrangement is a job whose failures are invisible. Persistent=true runs a…

  • Cache the computation, not the query result

    Caching the rows a query returned saves the database round trip and leaves the hydration, the mapping and the aggregation to happen on every request anyway. Profiling usually…

  • splitChunks defaults are usually right

    CommonsChunkPlugin required declaring which modules were common, which meant knowing the dependency graph in advance and updating the configuration whenever it changed. chunks: ‘all’ lets it split synchronous…