Skip to content

Instantly share code, notes, and snippets.

View leonlaser's full-sized avatar
🍪

Leon Dietsch leonlaser

🍪
View GitHub Profile
@leonlaser
leonlaser / force_ssl.htaccess
Last active March 18, 2019 11:37
[Apache https redirect] #apache #htaccess #redirect #rewrite #https #ssl
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@leonlaser
leonlaser / mysql_tables_by_size.sql
Created March 18, 2019 11:31
[MySQL tables sorted by size] #mysql #sql #table #size
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
@leonlaser
leonlaser / ssh_forward_port
Last active March 26, 2019 10:32
[Forward remote port via ssh to localhost] #ssh #portforwarding #network #bash
#!/bin/bash
set -o errexit
# use -f to run in background
ssh $user@$host -NL $localport:localhost:$remoteport
echo "Forwarding ${host}:${remoteport} to localhost:${localpost}. (Press ctrl+c to stop)"
@leonlaser
leonlaser / ansible_install_python
Last active March 18, 2019 10:59
[Install python via ansible] #ansible #python #remote
#!/bin/bash
ansible ${target:-"*"} -m raw -a "apt-get install python-apt -y"