Skip to content

Instantly share code, notes, and snippets.

Avatar
🏴
revolution

Rojen Zaman rojenzaman

🏴
revolution
View GitHub Profile
View httpcat
#!/bin/bash
#
# Usage:
# httpcat URL
if [ "$#" -lt 1 ]; then
echo "Usage: `basename $0` URL"
exit 1
fi
@rojenzaman
rojenzaman / telegram-send.sh
Created Jun 14, 2021
Telegram: Send files via their path names due using telagram bot API with telegram-send
View telegram-send.sh
#!/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 "{}" \; ; }
View gist:63597da2a52e8733d6e502672da3b082
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 Jun 27, 2021 — forked from rsvp/httpstatus
httpstatus : bash script to get HTTP response code with optional status message (includes return true or false)
View httpstatus
#!/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 Jun 9, 2021
BASH script to write zeros to file before remove | Use for non-secure HDD
View rmzero.sh
#!/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 Jun 1, 2021
Rclone NGINX reverse proxy to Auth
View rclone.conf
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
Run specific command or script in all sub-directories.
View exec.sh
#!/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
automysqlbackup DOCKER
View automysqlbackup.sh
#!/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
Generate randomly directories by given count.
View generate_temp_dir.sh
#!/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
/etc/hosts file refer to another configuration file
View hosts.sh
#!/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