Uncategorized

  • Promise.race is how you write a timeout

    A fetch with no timeout waits as long as the browser is willing to, which on a bad mobile connection is a very long time. There is no…

  • Object cache groups, and which ones are global

    On multisite the object cache prefixes keys with the current blog id, so the same key on two sites does not collide. Some groups must not be prefixed…

  • Ubuntu 16.04 moved everyone to systemd and PHP 7 at once

    The April LTS changes two things at the same time, and either one alone would be a migration. service still works because systemd ships a compatibility shim, which…

  • RDB and AOF answer different questions

    Redis has two persistence mechanisms and the documentation presents them as a choice, which invites picking one. They fail differently, and on anything that matters both are usually…

  • Ship the logs before you need them

    The instinct is to set up log aggregation when there is a problem to investigate. By then the interesting logs have rotated away, and the incident is reconstructed…

  • Anonymous classes make a one-off test double

    Testing a class that takes an interface usually means either a mocking framework or a small stub class in its own file, which then lives forever and is…

  • The spaceship operator is a comparator, not a comparison

    <=> returns -1, 0 or 1, which makes it useless as a boolean and exactly right as the body of a usort() callback — the place where hand-written…

  • Vue 2 render functions are the escape hatch from templates

    Vue templates cover almost everything and become awkward at exactly one point: rendering a different element depending on a prop, which turns into a chain of v-if blocks…

  • get_option returns false for missing and for false alike

    get_option() returns false when the option does not exist, and also when it exists and holds false. Any setting that can legitimately be off is therefore indistinguishable from…

  • Passive event listeners stop the scroll jank

    A touchstart or wheel listener can call preventDefault(), so the browser cannot begin scrolling until the handler has run. Every such listener therefore delays scrolling, whether or not…