Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Tan Jonalogy

  • StashAway
  • Singapore
View GitHub Profile
View psql-basics.md

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,

View how-to-identify-processes-with-bash.md

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:

  • kill :YOUR_PORT_NUMBER

Sources

View npm-useful-commands.md
View package peer dependencies

npm info package_name peerDependencies

  • To view info for specific version, package_name@version
View node: differnece-app-method-use.md

app.METHOD vs app.use

app.METHOD(PATH, ROUTE_HANDLER)

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

Syntax:

app.get('/', function(req, res){
View node: whatis-module-export.md

Quick Notes of Node's module.export

console.log(module.exports); //-> {}
exports.apple = '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
Jonalogy / exploring-local-node-modules-bin-folder.md
Last active Jun 24, 2019
learn-node/exploring-local-node-modules-bin-folder
View exploring-local-node-modules-bin-folder.md

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
Jonalogy / quick_ref_to_date_n_time_in_web_dev.md
Last active Oct 20, 2018
A Quick Reference To Common Date & Time Formats In Web Development
View quick_ref_to_date_n_time_in_web_dev.md

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
Jonalogy / how-do-middlewares-work.md
Last active Jul 7, 2017
How Do Middlewares work
View how-do-middlewares-work.md

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

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
Jonalogy / useful-git-cmds.md
Last active Mar 12, 2019
Useful Git Commands
View useful-git-cmds.md

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
Jonalogy / handling_multiple_github_accounts.md
Last active Dec 1, 2021
Handling Multiple Github Accounts on MacOS
View handling_multiple_github_accounts.md

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