Upgrading a mac from Node 10 to Node 12

I upgrade Node infrequently enough that I can’t easily remember the process. To save myself some time in the future I decided to document my fumbling around while upgrading my mac from Node 10 to Node 12. $ node -vv10.17.0 Step 1 – Remember Brew Exists $ brew update$ brew search node$ brew unlink node$ …

Software Acronyms/Initialisms

The below are a bunch of common acronyms you might encounter in the software industry. The below definitions are not technically correct but are correct-ish. TDD Test driven development. First write the tests then write the code. This saved my ass early in my career. I needed to take a C library that converted map …

Postgres Performance Cheatsheet

Simple steps to improve performance in a Postgres database. Identify your problem queries SELECT query, round(total_time::numeric, 2) AS total_time, calls, round(mean_time::numeric, 2) AS mean, round((100 * total_time / sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu FROM pg_stat_statements where query != ” ORDER BY total_time DESC LIMIT 20; Enable the pg_stat_statements module if it isn’t already. Try …

An intro to Typescript 3.0’s ‘unknown’ type

Typescript 3.0 introduced the ‘unknown’ type. Anything is assignable to unknown but unknown isn’t assignable to anything. This is useful for the below situation. const s: string = loadData() let obj: unknown = JSON.parse(s) As soon as you try and assign obj to anything or try to pass it into a function you will receive …

Peer review and follow up tasks

While reviewing a pull request you and your fellow peer reviewers will likely identify bugs adjacent to the code already being worked on. “While testing this I noticed this other bug…” “Hey, while you’re there I noticed this other thing…” What is the appropriate response to this kind of peer review response? Obviously you can …

Manage your npm dependencies using VS Code and Version Lens

Once you have installed a dependency and its doing its job you can forget it exists. Apart from a line in your package.json there isn’t much to remind you that its even there. Its easy to never update it meaning you miss out on bug and security fixes. Version Lens is a thoroughly brilliant extension …

An ‘order by’ tweak for better/worse query performance

Imagine this if the query used to retrieve a listing of books for your website. select id, date_published from books order by date_published desc If there happen to be multiple books with precisely the same date_published their order is clearly defined. They will tend to come out of the database in the same order but …

Restore a database backup into a Postgres Docker container

Lets say you have a Postgres database running in a Docker container and you want to restore an sql database backup into it. If you have Postgres installed locally you will have psql available on your machine. If you don’t have Postgres locally installed its a little more tricky. cat databaseBackup.sql | docker exec -i …

React Error Boundaries and Javascript Scope

React 16 introduced the concept of an error boundary. Official docs about error boundaries Any React component becomes an error boundary by defining a componentDidCatch(error, info) method. componentDidCatch() will be called if any of the component’s children throw an error. It is the declarative equivalent of a try catch in imperative code. I’m a big …