TIL

Following long established precedent.

Serialisation Link to heading

JSON leaves numeric precision as an implementation detail

As usual with ser-des operations, it is paramount to have explicit agreements between sender and receiver. Source

Shell Link to heading

Get completion context (zsh)

You can do C-x h to get zsh’s completion context.

Get unique items

There is a simpler alternative to sort $file | uniq : sort -u $file

Ruby Link to heading

Use blocks

Prefer blocks for code paths that are potentially slow. For example, if you have a #slow_method:

# bad: calling the method even on higher log levels
logger.debug("result: #{slow_method}")
# good:
logger.debug { "result: #{slow_method}" }

# bad: calculating the default even when some_key is present
some_hash.fetch(some_key, slow_method)
# good:
some_hash.fetch(some_key) { slow_method }

Databases Link to heading

Deferred joins

You can speed up a query like

 SELECT *
 FROM
   people
 ORDER BY
   birthday, id
 LIMIT 20
 OFFSET 450000;

By rewriting it as

 SELECT * FROM people
 INNER JOIN (
   SELECT id FROM people ORDER BY birthday, id LIMIT 20 OFFSET 450000
 ) AS people2 USING (id)
 ORDER BY
   birthday, id

Random/non-technical Link to heading

Check for holidays

Obvious in retrospect, but when working with different countries in B2B it helps to check when their holidays are.

Re-think allowing emails

Letting customers send customised e-mails through your platform will attrack very persistent scammers or varying sophistication levels.