Skip to content

Instantly share code, notes, and snippets.

View fbatschi's full-sized avatar
💭
Coding like there is no tomorrow

fbatschi

💭
Coding like there is no tomorrow
View GitHub Profile
@fbatschi
fbatschi / nginx-cache.sh
Last active January 2, 2020 05:12
Nginx fastcgi/proxy Cache Manager
#!/bin/bash
# search and optionally purge cached content from nginx by URL or parts of the URL
# you can set the default cache dir
DEFAULT_NGINX_CACHE_DIR=/dev/shm/nginx
function usage {
echo "nginx cache - search and purge content from nginx"
@fbatschi
fbatschi / adbscreen.sh
Last active August 9, 2016 12:41
Directly grab a Screenshot from an Android device via adb
#!/bin/bash
FILE=$1
if [ -z $FILE ]; then
FILE=screen.png
fi
adb shell screencap -p | sed 's/\r$//' > ${FILE}
@fbatschi
fbatschi / tcmount
Created July 16, 2015 21:09
Bash Script to handle mounting/unmounting a truecrypt encrypted drive with tcplay
#!/bin/bash
losetup -f
while getopts “u” OPTION
do
case $OPTION in
u)
UMOUNT=1
;;
esac
@fbatschi
fbatschi / bash-smtp-auth-email
Created March 17, 2015 21:18
How to send an email from bash via SMTP Auth
echo "PUT YOUR MAIL BODY HERE" | mailx -s "SUBJECT" -S smtp=smtp://yoursmtpserver.com -S smtp-auth=login -S smtp-auth-user=YOUR_USERNAME -S smtp-auth-password=YOUR_PASSWORD -S from="Sender Name <[email protected]>" [email protected]
@fbatschi
fbatschi / mysql-total-storage.sql
Created February 4, 2015 13:12
Shows total storage per MySQL database in MB
SELECT DBName,CONCAT(LPAD(FORMAT(SDSize/POWER(1024,pw),3),17,' '),' ',
SUBSTR(' KMGTP',pw+1,1),'B') "DataSize",
CONCAT(LPAD(FORMAT(SXSize/POWER(1024,pw),3),17,' '),' ',
SUBSTR(' KMGTP',pw+1,1),'B') "IndexSize",
CONCAT(LPAD(FORMAT(STSize/POWER(1024,pw),3),17,' '),' ',
SUBSTR(' KMGTP',pw+1,1),'B') "Total Size"
FROM (SELECT IFNULL(DB,'All Databases') DBName,SUM(DSize) SDSize,
SUM(XSize) SXSize,SUM(TSize) STSize
FROM (SELECT table_schema DB,data_length DSize,index_length XSize,
data_length+index_length TSize FROM information_schema.tables WHERE