Skip to content

Instantly share code, notes, and snippets.

View rojenzaman's full-sized avatar
🏴
Why?

Rojen Zaman rojenzaman

🏴
Why?
  • localhost
  • Istanbul, Turkey
  • 11:55 (UTC +03:00)
View GitHub Profile
@rojenzaman
rojenzaman / url-shortener.sh
Last active May 21, 2020 17:49
URL Shortener For Static Web Pages (written by bash shell programming language)
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "./`basename $0` <write url here> <write your site directory here> [second] [\"title\"] [\"html code or txt\"]";
exit 1;
fi
url=$1
directory=$2
if [ "$#" -gt 1 ]; then
@rojenzaman
rojenzaman / ban.sh
Created March 3, 2020 09:15
fail2ban'da 5 defadan fazla banlanan ip adresi olursa onu /etc/hosts.deny dosyasına ekleyecek bir script
#!/bin/bash
#Written by @keraattin
CURRENT_DATE=$(date +"%Y-%m-%d")
CREATE_TODAY_FILE=$(touch /tmp/today_banned.txt)
TODAY_BANNED=$(cat /var/log/fail2ban.log | grep $CURRENT_DATE | grep Ban | gawk '{print $8}' >> /tmp/today_banned.txt)
COUNT=$(sort /tmp/today_banned.txt | uniq -c)
@rojenzaman
rojenzaman / slug_v0.2.2.sh
Last active April 12, 2021 15:11
Turkish URL Slug, Bash Script
#!/bin/bash
# a little update to: https://gist.github.com/rosiba/d9c06fe15a661094d4da4565355225a8
#
# define replacements
declare -a repls=(
"Ğg"
"ğg"
"Çc"
@rojenzaman
rojenzaman / pdf2title
Created May 25, 2020 19:04
Simple manage PDF title and author name by exif data.
#!/bin/bash
#
# Change the PDF title.
function guide() {
echo -e "usage: `basename $0` \"PDF Title\" \"Author Name\" pdfFileName.pdf";
exit 1;
}
@rojenzaman
rojenzaman / image-compress.sh
Created May 25, 2020 19:40
code to compress your hugo website images
#!/bin/bash
#add code to hugo project dir.
find static/images/uploads/ \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' \) -print0 | xargs -0 -P8 -n2 mogrify -strip -thumbnail '1000>' -format jpg
@rojenzaman
rojenzaman / parse_getopts.sh
Created June 13, 2020 22:59
parse command line arguments with getopts
#!/bin/bash
function one() {
echo "one > $1"
}
function two() {
echo "two > $1"
}
@rojenzaman
rojenzaman / update_cdn_ip.sh
Created July 9, 2020 17:08
UFW Rules Update for Cloudflare CDN
#!/bin/bash
cd /root/cf
curl https://www.cloudflare.com/ips-v4 > ips-v4
curl https://www.cloudflare.com/ips-v6 > ips-v6
for i in `<ips-v4`; do ufw allow from $i proto tcp to any port 80,443; done
for i in `<ips-v6`; do ufw allow from $i proto tcp to any port 80,443; done
@rojenzaman
rojenzaman / wdb-create.sh
Created July 9, 2020 17:10
Wordpress Database Creator
#!/bin/bash
if [ "$#" -lt 4 ]; then
echo "`basename $0` <db name> <db user> <ip> <db password> [sql]";
exit 1;
fi
mysql <<EOF
CREATE DATABASE $1;
CREATE USER $2@localhost IDENTIFIED BY '$4';
GRANT ALL PRIVILEGES ON $1.* TO $2@localhost identified by '$4';
CREATE USER $2@$3 IDENTIFIED BY '$4';
@rojenzaman
rojenzaman / install-wp.sh
Created July 9, 2020 17:17
Install WordPress from command line.
#!/bin/bash -ex
if [ "$#" -lt 2 ]; then
echo "`basename $0` <site> <wp.zip>";
exit 1;
fi
SITE=$1
WPZIP=$PWD/$2
cd /var/www/$SITE/public_html
@rojenzaman
rojenzaman / gen_pass.sh
Last active July 9, 2020 17:31
Password Generator Bash (Very Simple)
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "`basename $0` <8-92>";
exit 1;
fi
PASS=`date +%s | sha256sum | base64 | head -c $1`
echo "$PASS";