Skip to content

Instantly share code, notes, and snippets.

@NguyenTrungTin
NguyenTrungTin / latest.go
Last active February 27, 2020 14:21
How to get unique and latest item of slice in Go (Golang)
package main
import (
"fmt"
)
func main() {
sl := []string{"zero", "one", "two", "one", "zero", "three", "five", "four", "five"}
duplicateIndex := []int{}
cat access.log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20
@NguyenTrungTin
NguyenTrungTin / extend-disk.md
Last active September 19, 2019 03:29
AWS - Extend AWS EBS volumes with no downtime
  1. Modify volume on AWS

  2. Type the following command to list our block devices:

lsblk
  1. Type the following command:
```bash
echo "alias python=python3" >> ~/.bash_aliases
source ~/.bash_aliases
```
```bash
sudo apt install python3-pip
```
```sh
hostnamectl set-hostname newName
```
Uninstall old versions
```
sudo apt-get remove docker docker-engine docker.io containerd runc
```
```bash
sudo apt-get update
sudo apt-get install \
Create ~/.ssh/authorized_keys on user's home folder
```sh
# Copy user public key
cd /home/username
mkdir -p .ssh
mkdir ~/.ssh/authorized_keys
### Step 1 - nginx-proxy
Start **nginx-proxy** with the three additional volumes declared:
```shell
$ docker run --detach \
--name nginx-proxy \
--publish 80:80 \
--publish 443:443 \
--volume /etc/nginx/certs \
Linux add new user
```bash
sudo adduser username
```
Add the new user to `sudo` group
```
sudo usermod -aG sudo username
@NguyenTrungTin
NguyenTrungTin / getProcessOnPort.txt
Created June 13, 2019 07:17
How to know what program is listening on a given port?
Open your terminal and type as
```sh
lsof -i :8000
```
For example, with port 8000 (python3 -m http.server):
```sh
$ lsof -i :8000