Skip to content

Instantly share code, notes, and snippets.

View nhthai2005's full-sized avatar

Thai H. NGUYEN (Bob) nhthai2005

View GitHub Profile
@nhthai2005
nhthai2005 / .vimrc
Last active April 15, 2022 08:19
Howto Disable vim automatic visual mode on mouse select
# Disable vim automatic visual mode on mouse select
source /usr/share/vim/vim82/defaults.vim
# set compatible
set mouse-=a
@nhthai2005
nhthai2005 / install_necessary_tools_ubuntu.sh
Last active December 28, 2023 23:16
Howto Install necessary tools on Ubuntu
#!/bin/bash
sudo add-apt-repository ppa:bamboo-engine/ibus-bamboo
sudo apt-get update
# Install all necessary tools with the following command
sudo apt install vim htop terminator meld glogg curl git totem keepass2 \
kazam ksnip maven remmina libreoffice network-manager-l2tp-gnome \
ibus-bamboo gnome-calendar gnome-weather gnome-clocks \
qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager -y; \
@nhthai2005
nhthai2005 / ufw_firewall.sh
Last active April 10, 2022 03:41
Howto enable ufw firewall on Ubuntu
#!/bin/bash
# Check ufw status
sudo ufw status
# Enable ufw
sudo ufw enable
# Check ufw status again
sudo ufw status
@nhthai2005
nhthai2005 / .bashrc
Created April 10, 2022 03:36
Kubernetes completion script
# Kubectl Autocomplete
source <(kubectl completion bash)
alias k=kubectl
complete -F __start_kubectl k
alias kns='kubectl config set-context --current --namespace'
alias kurrent='kubectl config view --minify -o "jsonpath={..namespace}" | xargs -I %s echo "Current Namespace: %s"'
alias kcurrent=kurrent
alias nodetop='k get nodes | grep Ready | cut -d" " -f1 | xargs kubectl describe node | grep -E "Name: |cpu |memory "'
alias ktop=nodetop
export KUBECONFIG=$HOME/.kube/config
@nhthai2005
nhthai2005 / python_virtualenv.sh
Created April 10, 2022 03:30
Howto create virtual environment for Python project
#!/bin/bash
python3 -m venv <your-python-project>
# if Debian/Ubuntu, then:
# sudo apt install python3.10-venv
# python3.10 -m venv <your-python-project>
# To access your project
source /path-to-your-python-project/bin/activate
@nhthai2005
nhthai2005 / ubuntu_partition_size.txt
Last active April 10, 2022 03:20
Size of partition for installing Ubuntu on Laptop
# Size of partition for ubuntu
<Size> <mount point> <type>
50.000m / ext4
100m efi
Remain /home ext4
4096m /Swap swap
@nhthai2005
nhthai2005 / kafka-generate-ssl3.sh
Created January 4, 2022 03:43 — forked from anoopl/kafka-generate-ssl3.sh
Create Kafka JKS Keys
#!/bin/bash
#Step 1
#Generate server keystore and client keystore
keytool -keystore kafka.server.keystore.jks -alias localhost -validity 365 -genkey
keytool -keystore kafka.client.keystore.jks -alias localhost -validity 365 -genkey
#Step 2
#Create CA
openssl req -new -x509 -keyout ca-key -out ca-cert -days 365
#Add generated CA to the trust store
keytool -keystore kafka.server.truststore.jks -alias CARoot -import -file ca-cert
@nhthai2005
nhthai2005 / update-docker-compose.sh
Created December 21, 2021 06:59
Update docker-compose
#!/bin/bash
# Set location of docker-compose binary - shouldn't need to modify this
DESTINATION=/usr/local/bin/docker-compose
# Get latest docker-compose version
# VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep tag_name | cut -d '"' -f4)
# Output some info on what this is going to do
@nhthai2005
nhthai2005 / pg_upgrade_9.6_to_13.sh
Last active October 16, 2022 03:57
Migration postgres data from 9.6 to 14
#!/bin/bash
# MAINTAINER: NGUYEN HONG THAI
if [ $# -eq 2 ]; then
old_data=$(realpath $1)
new_data=$(realpath $2)
else
read -p "old_data: " old_data
old_data=$(realpath $old_data)
@nhthai2005
nhthai2005 / config
Created September 16, 2021 11:05
Speed Up SSH by Reusing Connections
# ~/.ssh/config
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
# https://puppet.com/blog/speed-up-ssh-by-reusing-connections/