This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Automatic Login | |
(c) 2008 Tim Wood | |
contact via: tmwood (at) datawranglers (dot) com | |
You are free to use this code as long as this notice is retained | |
Description |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
reload_command="/usr/sbin/nginx -s reload" | |
watchfile="/tmp/please_reload_httpd" | |
while read file; do | |
if [ "$file" = "$(basename "$watchfile")" ]; then | |
$reload_command | |
rm "$watchfile" | |
fi | |
done < <(exec inotifywait -e create --format '%f' --quiet --monitor "$(dirname "$watchfile")") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RANDSTR="$(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | head -c 40)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# e.g. for example.com/kirbycms/ | |
location /kirbycms/ { | |
if (!-e $request_filename) { | |
rewrite ^/kirbycms/(.*)$ /kirbycms/index.php last; | |
break; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
identify -format '%wx%h' image.png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 3 | |
def pprinttable(rows): | |
if len(rows) > 1: | |
headers = rows[0]._fields | |
lens = [] | |
for i in range(len(rows[0])): | |
lens.append(len(max([x[i] for x in rows] + [headers[i]],key=lambda x:len(str(x))))) | |
formats = [] | |
hformats = [] | |
for i in range(len(rows[0])): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'show databases;' | sudo mysql | tail -n+2 | grep -v _schema$ | grep -v ^mysql$ | xargs -n 1 -I _ bash -c 'sudo mysqldump _ | gzip > _.sql.gz' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT table_schema "Database", | |
Round(Sum(data_length) / 1024 / 1024, 0) "Data size (in MB)", | |
Round(Sum(data_length) / 1024 / 1024 / 1024, 3) "Data size (in GB)", | |
Round(Sum(index_length) / 1024 / 1024, 0) "Index size (in MB)", | |
Round(Sum(index_length) / 1024 / 1024 / 1024, 3) "Index size (in GB)", | |
Round(Sum(data_length + index_length) / 1024 / 1024, 0) "Total size (in MB)", | |
Round(Sum(data_length + index_length) / 1024 / 1024 / 1024, 3) "Total size (in GB)" | |
FROM information_schema.tables | |
GROUP BY table_schema; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original implementation is written in Pascal: | |
# https://github.com/HeidiSQL/HeidiSQL/blob/10.1/source/apphelpers.pas#L456-L506 | |
from itertools import zip_longest | |
from random import randint | |
def decode(hash): | |
def grouper(n, iterable, padvalue=None): | |
return zip_longest(*[iter(iterable)] * n, fillvalue=padvalue) |