Skip to content

Instantly share code, notes, and snippets.

View lumonald's full-sized avatar
🏠
Working from home

Luke McDonald lumonald

🏠
Working from home
View GitHub Profile
@lumonald
lumonald / gist:df7dfb129faf7ce2ee4fc7a875cf6030
Created January 10, 2019 16:25
sudo rsync file to remote
rsync --rsync-path 'sudo rsync' -v -e "ssh -i /path/to/private_key" /local/path/to/file user@host:/remote_path_dest
@lumonald
lumonald / docker-compose.yml
Created September 18, 2018 16:02
WordPress docker compose
# Local WordPress installation with persistent data.
# Quickly bring up containers to test WordPress things. The following folders are required in the root of the project as they are mounted as volumes:
# - site
# - database
version: '3.1'
services:
site:
@lumonald
lumonald / gist:6685bd0f4968caf34e6d5bb5b6f83af2
Created May 2, 2018 16:29
remove all exited containers
docker rm $(docker ps -a -f status=exited -q)
@lumonald
lumonald / gist:bf6403a92127ae5d9355dd378ba80642
Created May 2, 2018 16:29
remove images that are <none>
docker rmi $(docker images -f "dangling=true" -q)
@lumonald
lumonald / gist:257cd1cc54a6100854f60ff2092ed334
Created April 6, 2018 11:02
access mysql client on CL in running docker container
// first
docker exec -it {mysql_container_id} bash
// then
mysql -u {username} -h {mysql_container_name} -p
@lumonald
lumonald / docker-compose.yml
Created February 16, 2018 16:45
quick php7 playground
version: '3.1'
services:
app:
image: php:7.2.2-apache-stretch
volumes:
- ./app:/var/www/html
ports:
- 8080:80
@lumonald
lumonald / gist:5d483e2a2401e1125cf492522e42473f
Created February 13, 2018 14:41
Get in to shell of running container
docker exec -it {containerID} bash
@lumonald
lumonald / gist:dda7ab1ddf004eb4107ecfde1f85b53d
Created October 16, 2017 15:16
Quick dirty write to log file in PHP
<?php
$log_file = "/internal/path/to/file/log.txt";
$fh = fopen($log_file, "a"); // or die("Could not open log file.");
fwrite($fh, date("d-m-Y H:i:s")." - some data \n"); // or die("Could not write file!");
fclose($fh);
?>
# protect .htaccess
<files .htaccess>
order allow,deny
deny from all
</files>
# protect wpconfig.php
<files wp-config.php>
order allow,deny
deny from all
</files>
@lumonald
lumonald / preg_replace.php
Created October 12, 2017 14:37
PHP regex replace all except
<?php
$var_cleaned = preg_replace("|[^0-9a-zA-Z -]|", '', $_POST['var']);
?>