Snippets

This is essentially a dumping ground for little snippets — usually of code or command-line tricks — that I've found useful.

Fixing Homebrew permissions

Posted 25th July 2020

Here's a quick fix for permissions errors when using Homebrew (High Sierra+):

sudo chown -R $(whoami) $(brew --prefix)/*

Fixing Composer out-of-memory issues

Posted 25th July 2020

If you find yourself getting out-of-memory errors when running composer install or composer update, here's a quick and simple way to run it to avoid that:

php -d memory_limit=-1 /usr/local/bin/composer

Generating a random string using JavaScript

Posted 25th July 2020

Here's a quick and elegant way of generating a random string in JavaScript:

[...Array(10)].map(i=>(~~(Math.random()*36)).toString(36)).join('')