Skip to content

Instantly share code, notes, and snippets.

View hoangdh's full-sized avatar
🏠
Working from home

Dao Huy Hoang hoangdh

🏠
Working from home
View GitHub Profile
@hoangdh
hoangdh / ssh-key.sh
Last active January 17, 2019 10:29
Auto insert Public key.
#!/bin/bash
mkdir -p ~/.ssh/
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCg/QfGNy3EUYhBh6mtibywZofLY8IP4oAKhyHc7DdgDlWODpcdAKM7FEA89fV4CwEZ48/ywMoWPJAylPYgG4D8yhDe9TcQTfVPdktfoYJMiHL4kASzEf/MIHpH0fcWRZf/nccXyaLH2JrAbW9RUyQQzxzYoV5lM8z8DthMS9sEwdgZEmm413uWkfK3AkQ/aAMxyaEaZgt/piLjuSh2wZAWw9BWMEg+s3c6XaK1RAe6xJcKWfRJzox29602AlgpzIYmIRbp6YQFp3dCtfrGOG3ri2Ik5kjoxEaStDw2UCVYTDt+HFe7pmlYqSapg/JpVUpmg6mn6zT/2GaiT1mMxjV hoangdh" >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh/
chmod 600 ~/.ssh/authorized_keys
echo "Done!"
@hoangdh
hoangdh / maldet-c7.sh
Last active March 7, 2020 04:52
Install Maldet on CentOS 7.
#!/bin/bash
cd /tmp/
curl -O http://www.rfxn.com/downloads/maldetect-current.tar.gz
tar -zxvf maldetect-current.tar.gz
cd maldetect*
bash install.sh
sleep 5
sed -i 's/quarantine_hits=\"0\"/quarantine_hits=\"1\"/g;s/quarantine_clean=\"0\"/quarantine_clean=\"1\"/g;s/scan_ignore_root=\"0\"/scan_ignore_root=\"1\"/g' /usr/local/maldetect/conf.maldet
@hoangdh
hoangdh / netplan-sub-interface.md
Last active June 12, 2023 20:45
Adding sub-interface and IP Addresses using NetPlan on Ubuntu 18.04

Adding sub-interface and IP Addresses using NetPlan on Ubuntu 18.04

Edit /etc/netplan/*.yml

network:
  version: 2
  # renderer: NetworkManager
  ethernets:
 eth0:
@hoangdh
hoangdh / download-pixabay.sh
Last active January 17, 2019 13:20
Download videos from Pixibay
#!/bin/bash
get_link(){
for x in `seq 1 11`
do
echo "Crawling page: $x"
curl -s https://pixabay.com/en/videos/list/landscape/?pagi=${x} | grep -oP "<a href=\"[^\"]*[0-9]" | grep -Ev 'list|blog|:|photos' | sed 's/\"/ /g' | awk {'print $3'} >> /tmp/link-pixabay.txt
done
}
download(){
@hoangdh
hoangdh / filter_video_resolution.sh
Last active January 17, 2019 15:04
FFProbe - Filter video resolution
#!/bin/bash
get_resolution(){
VIDEOS=$(ls *.mp4)
for x in $VIDEOS
do
w=`ffprobe -v error -select_streams v:0 -show_entries stream=width -of csv=p=0 ${x}`
mkdir -p ${w}
mv ${x} ${w}/
done
@hoangdh
hoangdh / vov3.txt
Last active January 19, 2019 10:25
http://vov3.vov.vn:2018/Attachments/V3 0103 02H55 BAI DAN CA CO.mp3
http://vov3.vov.vn:2018/Attachments/2015/V3 01 09 02H55 BAI DAN CA CO.mp3
http://vov3.vov.vn:2018/Attachments/2015/V3 02 06 02H55 BAI DAN CA CO.mp3
http://vov3.vov.vn:2018/Attachments/2014/V3 02 09 02H55 BAI DAN CA CO.mp3
http://vov3.vov.vn:2018/Attachments/2014/V3 02 12 02H55 BAI DAN CA CO.mp3
http://vov3.vov.vn:2018/Attachments/2015/V3 03 02 02H55 BAI DAN CA CO.mp3
http://vov3.vov.vn:2018/Attachments/2015/V3 03 03 02H55 BAI DAN CA CO.mp3
http://vov3.vov.vn:2018/Attachments/2014/V3 03 09 02H55 BAI DAN CA CO.mp3
http://vov3.vov.vn:2018/Attachments/2014/V3 04 03 02H55 BAI DAN CA CO.mp3
http://vov3.vov.vn:2018/Attachments/2015/V3 04 08 02H55 BAI DAN CA CO.mp3
@hoangdh
hoangdh / loop-videos-to-1-minute.sh
Last active January 19, 2019 15:26
Loop videos to 1 minute.
#!/bin/bash
mkdir -p output/
ls *.mp4 | while read -r l;
do
sec=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$l")
round_sec=${sec%.*}
if [[ $round_sec -lt 60 ]]; then
loop=$(expr 60 / $round_sec)
round_loop=$(expr ${loop%.*} + 2)
# echo $l $round_loop $round_sec
@hoangdh
hoangdh / certbot-c7.sh
Created January 22, 2019 04:04
Note Certbot: Install and Usage.
#!/bin/bash
yum install -y epel-release
yum install -y certbot
echo -e "Usage:\nGenerate: certbot certonly --webroot /web/root -d domain.com\nRenew: certbot renew --cert-name"
@hoangdh
hoangdh / install-docker-u18.sh
Last active June 16, 2021 10:21
Install Docker on Ubuntu 18.04
#!/bin/bash
apt-get update -y
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update -y
#!/bin/bash
compare(){
file1="$1"
file2="$2"
count_m=0
count_mn=0
### So sanh phan zmlocalconfig
cat "$file1" "$file2" | grep -E "^zimbra.*"| awk {'print $1'} | sed 's/://' | sort -u | while read -r l;