Skip to content

Instantly share code, notes, and snippets.


Jonathan Tan Jonalogy

  • StashAway
  • Singapore
View GitHub Profile

Connecting to PostgreSQL via CLI using PSQL

Ensure you have PSQL installed

Connecting to your DB

psql --host=localhost --port=5432 --username=developer --dbname=dummyDb --password

Once connected,


To show list of PID on a port:

  • lsof -t -i :YOUR_PORT_NUMBER

top command will show a list of all running processes and various statistics about each process. It’s usually most helpful to sort by processor usage or memory usage, and to do that you’ll want to use the -o flag

  • top -o cpu | grep :YOUR_PORT_NUMBER shows details of the respective pid

To kill a process by PID:



View package peer dependencies

npm info package_name peerDependencies

  • To view info for specific version, package_name@version
View node:

app.METHOD vs app.use


  • Apply this for route handlers.
  • METHOD here represents the available node methods HTTP verbs eg. get, post, put, delete ...etc


app.get('/', function(req, res){
View node:

Quick Notes of Node's module.export

console.log(module.exports); //-> {} = 'apple';
console.log(module.exports); //-> { apple: 'apple'}
module.exports['pear'] = 'pear';
console.log(module.exports); //-> { apple: 'apple', pear: 'pear'}
module.exports = 'uhoh';
console.log(module.exports); //-> uhoh
Jonalogy /
Last active Jun 24, 2019

Exploring node_modules/.bin folder.

This is just learning journal for myself and I welcome any help from the public to improve my understanding.

Whether a globally or locally installed module, eventually it will reside within a node_modules directory. The contents of this gist is scopped within the local node_modules of an application's directory. Now within the local node_modules there should always exist a .bin folder that houses all the excutable files.

What I've gathered thus far:

  1. On Unix/macOs, this files have the chmod 755 or 777 permissions to run as scripts.
  2. All of these files start with #!/usr/bin/env node on the very first line.
Jonalogy /
Last active Oct 20, 2018
A Quick Reference To Common Date & Time Formats In Web Development

Common Date & Time Formats

ISO8601 Date Format

Syntax: YYYY-MM-DDTHH:MM:SSZ+HH:MM eg:2018-10-19T03:00:00.000Z

This consists 4 parts:

  1. YYYY-MM-DD: Standard Gregorian calendar date
  2. T: Date-time delimiter, it seperates the date from the time
  3. HH:MM:SS:SSS: Standard time representation in 24hr format. Seconds SS and milliseconds SSS may be ommited for brevity
Jonalogy /
Last active Jul 7, 2017
How Do Middlewares work

How Do Middlewares work?

Here're my learnings from Redux Docs on Middlewares. If you haven't read through the docs yet, please do so first.


Middlewares work with the beauty of Currying.

What is Currying?

The concept of using a Higher Order Function to generate a new function with the partial application or all of its arguments.

Jonalogy /
Last active Mar 12, 2019
Useful Git Commands

git ls-files or git ls-tree -r master --name-only

List tracked files. Read more here

git rm --cached FILE_NAME

Untracks file from index source

Jonalogy /
Last active Dec 1, 2021
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes
 UseKeyChain yes