Skip to content

Instantly share code, notes, and snippets.

View ngohuytrieu's full-sized avatar
👨‍🍳
Coding is cooking

TRIEU NGO HUY ngohuytrieu

👨‍🍳
Coding is cooking
View GitHub Profile
@ngohuytrieu
ngohuytrieu / macos-useful-tips.md
Last active June 21, 2023 07:51
MacOS Useful tips

Enable command auto suggestion in terminal

sudo nano ~/.inputrc

# Add following content
set completion-ignore-case on
set show-all-if-ambiguous on
TAB: menu-complete

# close terminal then try again
@ngohuytrieu
ngohuytrieu / package-vs-package-lock.md
Last active December 6, 2021 10:11
package.json vs package-lock.json

Different

  • package.json: list of module needs for project
  • package-lock.json: same idea but with lock specific version that already works when run npm i from package.json

Why do we need package-lock.json

  • Semantic Versioning (semver) has structure like: ^MAJOR.MINOR.PATCH
  • With ^ when run npm i it will install newest version of the same MAJOR. But with the newest MINOR or PATCH (install on new pc) could cause some issue or bug
  • The package-lock.json solves this by defining the MAJOR.MINOR.PATCH preciously that works.

Install

@ngohuytrieu
ngohuytrieu / docker-enoent-error.md
Created March 3, 2022 06:22
Docker error "npm ERR! enoent undefined ls-remote -h -t"

npm ERR! enoent undefined ls-remote -h -t

RUN apk add --no-cache git

@ngohuytrieu
ngohuytrieu / macOS-install-apache-config-virtual-host.md
Last active October 12, 2022 03:24
Setup apache and config virtual host on macOS

Setup apache and config virtual host on macOS

Since macOS Sierra 10.x apache has been built-in. Run these command to start / restart / stop apache

sudo /usr/sbin/apachectl start
sudo /usr/sbin/apachectl stop
sudo /usr/sbin/apachectl restart
sudo /usr/sbin/apachectl status

DocumentRoot

@ngohuytrieu
ngohuytrieu / macOS-install-php7.2.md
Last active March 3, 2022 10:11
macOS install php@7.2

macOS install php@7.2

Since PHP 7.2 is not supported anymore, it's got delisted from the Hombrew core repository.

You've to find a third-party repository that still contains an older PHP version, such as the shivammathur/php repository.

You need to tap the repository like this in your Homebrew:

brew tap shivammathur/php
@ngohuytrieu
ngohuytrieu / Ubuntu show branch name in terminal.md
Last active April 4, 2022 10:23
Ubuntu show branch name in terminal

Ubuntu show branch name in terminal

Add these lines in your ~/.bashrc file

sudo nano ~/.bashrc
# Show git branch name
force_color_prompt=yes
color_prompt=yes
@ngohuytrieu
ngohuytrieu / ssh-config
Last active May 5, 2022 10:15
VSCODE connect to remote server with pem file
#.ssh/config
Host domain.com
HostName [ip_addres]
User username
IdentityFile /path/to/pem/file/file.pem
@ngohuytrieu
ngohuytrieu / script.js
Last active April 9, 2022 08:57
Run async/await in javascript event functions
const data = []
// using promise.all
const data = await Promise.all(data.map(async (item, index) => {
// call async function here
item.products = await asyncawaitfunction()
return item
}));
@ngohuytrieu
ngohuytrieu / moment-js-timezones.txt
Created May 16, 2022 15:10 — forked from diogocapela/moment-js-timezones.txt
List of All Moment.js Timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.