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 / 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 / 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 / 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 / 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 / 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 / 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 / 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!"
#!/bin/bash
check_port() {
sort $1 | uniq -c | sort -nr | awk {'print $2'} | while read -r ip;
do
if ping -c 1 -w 1 $ip > /dev/null 2>&1;
then
if nc -vz -w 3 $ip 25 > /dev/null 2>&1;
then
echo $ip - Port 25 Opened;
@hoangdh
hoangdh / get-asn.sh
Last active January 8, 2019 09:34
Free IP address to ASN database - API iptoasn.com
#!/bin/bash
IP2=$1
IP=${IP2:-$(echo $(($RANDOM % 256)) $(($RANDOM % 256)) $(($RANDOM % 256)) $(($RANDOM % 256)) | sed 's/ /./g')}
if [[ "$IP" =~ ^(([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))\.){3}([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))$ ]]; then
echo -n "$IP: "
curl https://api.iptoasn.com/v1/as/ip/${IP} -s | grep -Eo '\"as_number\"(.+?)([0-9]),' | grep -Eo '[0-9]+'
# curl https://api.iptoasn.com/v1/as/ip/${IP} -s | sed 's/,/ /g;s/\"//g' | grep -Eo 'as_number.*' | awk {'print $1'} | cut -d':' -f2
else
@hoangdh
hoangdh / change_md5_file_linux.md
Last active December 18, 2018 06:50
How to change MD5 of file using Linux command

How to change MD5 of file using Linux command

Either command should add 10 bytes to the end of your file. This should mean the MD5 (when next calculated) should be different.

truncate -s +10 <filename>.ext
dd if=/dev/zero bs=1 count=10 &gt;&gt; .