Skip to content

Instantly share code, notes, and snippets.

View Jonalogy's full-sized avatar

Jonathan Tan Jonalogy

  • WatchTowr
  • Singapore
View GitHub Profile
@Jonalogy
Jonalogy / psql-basics.md
Created February 18, 2020 10:27
PSQL Basics

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:

  • kill :YOUR_PORT_NUMBER

Sources

@Jonalogy
Jonalogy / npm-useful-commands.md
Created June 12, 2018 03:43
NPM useful commands
View package peer dependencies

npm info package_name peerDependencies

  • To view info for specific version, package_name@version
@Jonalogy
Jonalogy / node: differnece-app-method-use.md
Last active February 2, 2021 17:29
`app.METHOD` vs `app.use`

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){

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 June 24, 2019 01:03
learn-node/exploring-local-node-modules-bin-folder

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 October 20, 2018 04:27
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
Jonalogy / how-do-middlewares-work.md
Last active December 7, 2022 15:18
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

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 March 12, 2019 01:40
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
Jonalogy / handling_multiple_github_accounts.md
Last active November 14, 2024 08:31
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