My learning diary

Installing Postgres on macOS

Before this, the last time I installed a Postgres database on my local machine was years ago. I wished I found Sami Korpela’s blog post sooner. It had everything I needed: # macOS Ventura Terminal brew install postgresql@15 echo 'export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"' >> ~/.zshrc source ~/.zshrc brew services start postgresql createuser -s postgres psql postgres # or psql -U your_username -d your_database ### postgres=# ### \l # List databases \du # List roles \c your_database # Connect to database \c your_database other_username # Connect to database as other_username \d # List relations (tables)

Continue reading "Installing Postgres on macOS"

Create React App environment variables

I worked on React codebases for years. For various reasons, I never had to deal with client-side environment variables. I first saw environment variable prefixes in Next. Unfortunately, it took me a while to realise that this concept also applied to create-react-app. As a result, I spent some time wondering why my environment variables were not replaced at build time. I started to think it was because they were replaced during runtime.

Continue reading "Create React App environment variables"

Don't catch everything

I did a catch when I didn’t need to. I defined the catch clause for an API request which should return a rejected Promise upon failure. As a result, the toast which indicated failure didn’t appear. In this commit, I removed the catch clause. And in another commit, I defined what failure is. While writing about this, I wondered if there could be a better way to express identical requirements. A quick search led me to this Stack Overflow thread - throw (but not in AngularJS).

Continue reading "Don't catch everything"

Push vs Pull CDN

It was only recently that I realised that there was more than one way to update the content that your CDN hosts. Since, to the best of my knowledge, Cloudflare was the closest thing to a CDN, I thought all CDN would work like that. Couldn’t be more wrong. I like that Cloudflare is so hassle-free to set up. It caches my site upon request + nothing in cache. There is no need to push any content to Cloudflare by myself.

Continue reading "Push vs Pull CDN"

react-hook-form validations

Feeling a little abashed about leaving a bug unresolved for the day, but I want a break and keep the team posted. And I also want to share what I’ve learnt. However, if you know what’s the problem with my commit, please don’t hesitate to reach out! Back to the main learning point I’m trying to share: In the pull request above, look at the first screenshot. The first screenshot was supposed to depict a form field that has gone through the validation function despite being untouched.

Continue reading "react-hook-form validations"