My learning diary

for-in and for-of

I needed to change my async code into synchronous. I didn’t need to track the index of the array, so I wanted a for...?? loop. Was it or was it for...of!? Example: for (let key in someObject) const a = [4,5,6] const b = [{'k1':'v1'},{'k2':'v2'},{'k3':'v3'}] const c = {'k1':'v1'} for (let d in a) { console.log(d) } // 0 1 2 for (let d in b) { console.log(d) } // 0 1 2 for (let d in c) { console.

Continue reading "for-in and for-of"

Fixing a11y

I thought I’d need to jump through many hoops to resolve an a11y issue in this site. Today, I realised I didn’t need to. From my previous Lighthouse reports, Heading elements are not in a sequentially-descending order had been a thorn in the flesh. I didn’t want to override the original styles of the headers. But I wanted my h2 to look like h3. I wanted my h3 to look like h5.

Continue reading "Fixing a11y"

The SSH command

This is what man ssh gives: ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to provide secure encrypted communications between two untrusted hosts over an insecure network. X11 connections, arbitrary TCP ports and UNIX-domain sockets can also be forwarded over the secure channel. A simple usage would be: ssh $USERNAME@$TARGET_HOST And you will be prompted for your password.

Continue reading "The SSH command"

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"