How To

Stop firefox from exiting full screen on pressing escape

A while ago I got a new macbook, and installed firefox again. But I quickly ran into the issue where if you press escape, it closes the fullscreen. Which to me is an insane default, as I might press escape to try and close a modal for example.

Sep 4, 2024

See all the queries mysql does with the query log.

Learn how to enable mysql query log, and where to find the results

Sep 4, 2024

Keep retrying a bash command until it fails

This week I noticed a test was flaky, and was occasionally failing in CI. So I wanted to re-run my script until it failed. I had no clue how to do this, so after a bit of trying, I got the following script. This keeps running vendor/bin/phpunit until it fails. You can save it as run.sh and then just run sh ./run.sh in your terminal, and it will keep running.

Aug 5, 2024

Change extensions of all files in a folder

This week I wanted to change all the .js files to .ts recursively in a folder. To change all .js files in the assets folder. With a bit of bash, using a for loop and mv I got the following command to rename all my .js to .ts files.

Aug 5, 2024

Get a rough estimation of how many rows are in a table, without using count

Get a rough idea of how many rows your table has, without using count, and doing a full table scan.

Jul 3, 2024

Backing up files with one bash command

Learn how to back up files (and set them back) with a simple bash function, and do so right from the CLI

Jul 3, 2024

Remove an element from an array in javascript

Use splice, toSpliced or filter to remove elements from an array.

Jun 20, 2024

Check if an array contains an element in JavaScript

Use 'includes', 'find' or 'some' to check if an array contains an element

Jun 20, 2024

Allowing failure in GitLab CI

Set a step to allow failure or even a single part of the script

Jun 20, 2024

The difference between for .. in and for .. of in javascript

Learn the difference between for .. in and for .. of in javascript, and make better loops.

Jun 9, 2024