Skip to content

Instantly share code, notes, and snippets.

View rojenzaman's full-sized avatar
🏴
Why?

Rojen Zaman rojenzaman

🏴
Why?
  • localhost
  • Istanbul, Turkey
  • 20:00 (UTC +03:00)
View GitHub Profile
@rojenzaman
rojenzaman / httpcat
Created June 15, 2021 17:09
HTTP Cat
#!/bin/bash
#
# Usage:
# httpcat URL
if [ "$#" -lt 1 ]; then
echo "Usage: `basename $0` URL"
exit 1
fi
@rojenzaman
rojenzaman / telegram-send.sh
Created June 14, 2021 00:38
Telegram: Send files via their path names due using telagram bot API with telegram-send
#!/bin/bash
sleep_time="2"
large_location="$HOME/$RANDOM"
DIR="."
send_pdf() { find $DIR -type f -name "*.pdf" -exec telegram-send --file "{}" \; -exec sleep $sleep_time \; ; }
send_epub() { find $DIR -type f -name "*.epub" -exec telegram-send --file "{}" \; -exec sleep $sleep_time \; ; }
find_pdf() { find $DIR -type f -name "*.pdf" -exec ls "{}" \; ; }
find_epub() { find $DIR -type f -name "*.epub" -exec ls "{}" \; ; }
@rojenzaman
rojenzaman / gist:63597da2a52e8733d6e502672da3b082
Created June 13, 2021 21:47 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@rojenzaman
rojenzaman / httpstatus
Last active June 27, 2021 16:38 — forked from rsvp/httpstatus
httpstatus : bash script to get HTTP response code with optional status message (includes return true or false)
#!/bin/bash
URL="${1}"
UserAgent="[HTTPSTATUS]:[https://git.io/JcTUF]"
if [ "$#" -lt 1 ]; then
echo "Usage: ./`basename $0` URL"
exit 1
fi
function unknown_status() {
@rojenzaman
rojenzaman / rmzero.sh
Created June 9, 2021 10:09
BASH script to write zeros to file before remove | Use for non-secure HDD
#!/bin/bash
# use find exec to remove multiple files:
# find path/to/dir -exec ./rmzero {} \;
if [ "$#" -lt 1 ]; then
echo "./`basename $0` <file>";
exit 1;
fi
function load() { FILE="$(realpath $1)" ; MB_COUNT="$(du -m $FILE | awk '{print $1}')" ; }
@rojenzaman
rojenzaman / rclone.conf
Last active June 1, 2021 21:13
Rclone NGINX reverse proxy to Auth
server {
listen X.X.X.X:53682;
gzip on;
server_tokens off;
access_log /tmp/rclone.access;
error_log /tmp/rclone.error;
location / {
@rojenzaman
rojenzaman / exec.sh
Last active May 31, 2021 15:55
Run specific command or script in all sub-directories.
#!/bin/bash
cd "$(dirname "${BASH_SOURCE[0]}")"
function execute() {
cd $i
echo -e "\e[91m$x:\e[0m\e[92m`pwd`\e[0m"
case $1 in
ls) $@ --color=auto ;;
grep) $@ --color=auto ;;
fgrep) $@ --color=auto ;;
@rojenzaman
rojenzaman / automysqlbackup.sh
Last active May 31, 2021 15:06
automysqlbackup DOCKER
#!/bin/bash
# CRONTAB:
# @daily /path/to/automysqlbackup.sh hour
# @daily /path/to/automysqlbackup.sh day
# @weekly /path/to/automysqlbackup.sh week
# @monthly /path/to/automysqlbackup.sh month
# MAIL:
# apt install mailutils postfix
[[ -t 1 ]] || set -x
SCRIPT=$(realpath $0)
@rojenzaman
rojenzaman / generate_temp_dir.sh
Created May 30, 2021 11:14
Generate randomly directories by given count.
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "./`basename $0` <count> <dir>";
exit 1;
fi
for i in `seq 1 $1`; do
mktemp -d -t temp-XXXXXXXXXX --tmpdir=$2
done
@rojenzaman
rojenzaman / hosts.sh
Created May 29, 2021 12:27
/etc/hosts file refer to another configuration file
#!/bin/bash
case $1 in
0|--disable) cat /etc/hosts.local > /etc/hosts ;;
1|--enable) cat /etc/hosts.local > /etc/hosts ; cat /etc/hosts.d/* >> /etc/hosts ;;
esac