Skip to content

Instantly share code, notes, and snippets.

View trongnghia203's full-sized avatar
🤠

Nghia Le trongnghia203

🤠
View GitHub Profile
@trongnghia203
trongnghia203 / mailsvr_dnsname_record.md
Last active June 26, 2020 08:57
Example DNS records for setting up mailsvr

lcl A record – points to ip 113.xxx.xx.12x #public ip of my mail server, of course lcl MX record – mail handled by lcl.infotechviet.com #the above A record mail CNAME record – is an alias of lcl.infotechviet.com #not necessary, this is just for my web client/admin access: ie: https://mail.infotechviet.com

@trongnghia203
trongnghia203 / Install-Ansible-on-Ubuntu-18.04.md
Last active June 26, 2020 08:59
Install Ansible on Ubuntu 18.04

Install Ansible on Ubuntu 18.04

Reference to: docs.ansible.com

sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt-get install ansible
@trongnghia203
trongnghia203 / .vimrc
Created April 24, 2019 08:27
How to custom your vim editor
" edit file:~ vi ~/.vimrc
" base
set nocompatible " vim, not vi
syntax on " syntax highlighting
filetype plugin indent on " try to recognise filetype and load plugins and indent files
" interface
set background=dark " tell vim what the background color looks like
set colorcolumn=120 " show a column at 100 chars
set cursorline " highlight current line
@trongnghia203
trongnghia203 / install_and_secure_redis_on_ubuntu.md
Last active June 26, 2020 08:59
Install and Secure Redis on Ubuntu
@trongnghia203
trongnghia203 / yes_no_confirm.sh
Last active June 26, 2020 14:41
Bash: Yes/No Confirm script - Advanced
#!/bin/bash
# Author: Nghia Le <trongnghia203@gmail.com>
# Description:
# - To make user confirm the privilege which they are using to run a bash script
# by asking user if they're sure and wanted to run this bash script as current log-in user.
read -n 1 -p "Do you want to run this bash script as $(whoami)? Yes/[No]: " YES_NO
echo -e "\n"
if [ -z ${YES_NO} ] || [ ${YES_NO} = "No" ] || [ ${YES_NO} = "no" ] || [ ${YES_NO} = "N" ] || [ ${YES_NO} = "n" ]; then
@trongnghia203
trongnghia203 / simple_yes_no_confirm.sh
Last active June 26, 2020 14:40
Bash: Yes/No Confirm script
#!/bin/bash
# Author: Nghia Le <trongnghia203@gmail.com>
# Description:
# - To ask user if they're sure and wanted to run this bash script as current log-in user
echo -e "\n"
read -n 1 -p "Do you want to run this bash script as $(whoami)? Yes/[No]: " YES_NO
echo -e "\n"
if [ -z ${YES_NO} ] || [ ${YES_NO} = "No" ] || [ ${YES_NO} = "no" ] || [ ${YES_NO} = "N" ] || [ ${YES_NO} = "n" ]; then
echo -e "\nYou select No, then it is going to exit now... "
@trongnghia203
trongnghia203 / ansible_update_user.yml
Last active December 8, 2022 14:49
Ansible: Add/update/remove user
---
# -----------------------------------------------------------------------------------------
# Purpose: To manage system users:
# - create/upadate a user who is allowed accessing via ssh connection
# - add public ssh-key of user into its authorized_keys
# - allow user to use sudo by putting a config into /etc/sudoers.d/
# - remove authorized_keys of inactive users
# - remove inactive users
# - remove sudo permission by removing its config file in /etc/sudoers.d/ if any
# Maintanance: Nghia Le [at] INFOTECHVIET
@trongnghia203
trongnghia203 / zalora-sre.md
Last active June 26, 2020 05:40
zalora-sre test

zalora-sre

1. README_1.txt

[sre_test@node045 ~]$ cat README_1.txt 
A php script is setup in this server and you can access to it by following command.

$ curl -v localhost
@trongnghia203
trongnghia203 / print_color_text.py
Last active June 26, 2020 14:44
Python: Print colored text
#!/usr/bin/env python
# Author: Nghia Le <trongnghia203@gmail.com>
# Description:
# - Yes/[No] Confirm to exit bash script
#
import os
def _wrap_with(code):
def inner(text, bold=True):