Skip to content

Instantly share code, notes, and snippets.

View leonlaser's full-sized avatar
🍪

Leon Dietsch leonlaser

🍪
View GitHub Profile
@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"
@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 / 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 / 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 / tcadefaults_example.typoscript
Created March 18, 2019 11:35
[TSConfig default values for TCA] #typo3 #tca #tsconfig #table
TCAdefaults.pages {
author = Max Mustermann
layout = 2
hidden = 1
}
@leonlaser
leonlaser / show_all_errors.php
Created March 18, 2019 11:37
[Show all php errors] Enable and show all php errors except for E_NOTICE #php #errors
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);
@leonlaser
leonlaser / search_file_with_regex
Last active March 21, 2019 14:27
[Search file/log with grep/regex and count occurrences] #regex #grep #file #logfile
#!/bin/bash
grep "$regex" -o $file | sort | uniq -c
@leonlaser
leonlaser / run_in_bg
Last active March 22, 2019 10:52
[Run command in background and save pid] #bash #nohup #pid #background
#!/bin/bash
nohup $command > ${logfile:-"nohup.log"} 2>&1&
echo $! > ${pidfile:-"nohup.pid"}
@leonlaser
leonlaser / typo3_maintenance_mode_via_env.php
Last active March 21, 2019 09:47
[TYPO3 CMS for maintenance mode via environment variables] #typo3 #maintenance #devip #adminonly
<?php
if(getenv('TYPO3_MAINTENANCE')) {
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_force'] = 1;
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling'] = getenv('TYPO3_MAINTENANCE_REDIRECT_URL');
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling_statheader'] = 'HTTP/1.0 503 Service Temporarily Unavailable';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = '127.0.0.1,::1,' . getenv('TYPO3_MAINTENANCE_DEVIPMASK');
$GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] = 2;
}
@leonlaser
leonlaser / typo3_page_cachetags.php
Last active March 20, 2019 11:53
[Cache handling in TYPO3 CMS via TSConfig/TypoScript/PHP] #cache #user #page #tags #tsconfig #typoscript #typo3
<?php
// PHP: Add cache tag to page
$GLOBALS['TSFE']->addCacheTags(['tagname', 'tagname2']);