Skip to content

Instantly share code, notes, and snippets.

View tranghaviet's full-sized avatar

Ha Viet Trang tranghaviet

View GitHub Profile
@tranghaviet
tranghaviet / nginxproxy.md
Created October 17, 2021 15:55 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@tranghaviet
tranghaviet / nginx-proxy
Created October 17, 2021 15:55 — forked from danielpereirabp/nginx-proxy
Nginx Proxy - SPA (Vue 2) + API/ADMIN (Laravel 5.6)
server {
listen 80;
server_name domain.com.br;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8181;
@tranghaviet
tranghaviet / install-zsh-windows-git-bash.md
Created April 13, 2021 19:59 — forked from fworks/install-zsh-windows-git-bash.md
Zsh / Oh-my-zsh on Windows Git Bash
@tranghaviet
tranghaviet / -setup-windows-wsl-devenv.md
Created April 8, 2021 01:31 — forked from leodutra/-setup-windows-wsl-devenv.md
Install and Setup Windows Subsystem 2 for Linux, Hyper, ZSH + Oh My Zsh + Powerlevel9k + plugins, FNM + VSCode (+ext) and Nerd Font

Setup Windows Subsystem 2 for Linux

Windows Subsystem 2 for Linux, Hyper, ZSH + Oh My Zsh + Powerlevel9k + plugins, FNM + VSCode (+ext) and Nerd Font

To setup native Linux, see this gist

Preview

Requirements

@tranghaviet
tranghaviet / postgres-cheatsheet.md
Created October 29, 2019 04:22 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@tranghaviet
tranghaviet / iso-639-1-codes.php
Created October 24, 2019 23:56 — forked from DimazzzZ/iso-639-1-codes.php
ISO 639-1 language codes array
<?php
$codes = [
'ab' => 'Abkhazian',
'aa' => 'Afar',
'af' => 'Afrikaans',
'ak' => 'Akan',
'sq' => 'Albanian',
'am' => 'Amharic',
'ar' => 'Arabic',
@tranghaviet
tranghaviet / crypto-aes-gcm.js
Created June 14, 2019 08:35 — forked from chrisveness/crypto-aes-gcm.js
Uses the SubtleCrypto interface of the Web Cryptography API to encrypt and decrypt text using AES-GCM (AES Galois counter mode).
/**
* Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
* (c) Chris Veness MIT Licence
*
* @param {String} plaintext - Plaintext to be encrypted.
* @param {String} password - Password to use to encrypt plaintext.
* @returns {String} Encrypted ciphertext.
*
* @example
* const ciphertext = await aesGcmEncrypt('my secret text', 'pw');
@tranghaviet
tranghaviet / README.md
Created December 20, 2018 06:25 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@tranghaviet
tranghaviet / latlong.php
Created December 6, 2018 09:43 — forked from arubacao/latlong.php
Latitude Longitude Regular Expression Validation PHP
<?php
/**
* Validates a given latitude $lat
*
* @param float|int|string $lat Latitude
* @return bool `true` if $lat is valid, `false` if not
*/
function validateLatitude($lat) {
return preg_match('/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/', $lat);
@tranghaviet
tranghaviet / deploy-pm2.md
Created November 22, 2018 16:43 — forked from hoangmirs/deploy-pm2.md
Deploy pm2 guide

1. Preparing the server

Install git

sudo apt install git-all

Generate Server's SSH public key

ssh-keygen -t rsa -b 4096 -C "deploy"
cat ~/.ssh/id_rsa.pub