Skip to content

Instantly share code, notes, and snippets.

View mrpatrick's full-sized avatar

Patrick Tully mrpatrick

View GitHub Profile
docker rm $(docker ps -a |grep -v RUNNING_CONTAINER_NAME | awk '{print $1}')
@mrpatrick
mrpatrick / docker-exec.sh
Last active January 6, 2016 21:34
enter a container with exec
# where the container is 0f4fe0b1f413
docker exec -i -t 0f4fe0b1f413 bash
# or for an apache instance
docker exec -ti projectname_projectname_1 /bin/bash
# or for example mysql
docker exec -ti projectname_db_1 /bin/bash
@mrpatrick
mrpatrick / git_subtree_add.sh
Last active August 29, 2015 14:27
Add a subtree repo/project to an existing repo
# Works with master branch
git subtree add --squash --prefix=circle [email protected]:avatarnewyork/circleci.git master
@mrpatrick
mrpatrick / largest_tables.mysql
Created August 12, 2015 14:21
Find the largest (byte size) 20 tables in GB in MySQL 5.x - taken from: https://www.percona.com/blog/2008/02/04/finding-out-largest-tables-on-mysql-server/
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 20;
@mrpatrick
mrpatrick / remove_known_host.sh
Created September 8, 2015 13:23
remove host from .ssh/known_hosts file
ssh-keygen -R [HOSTNAME]
@mrpatrick
mrpatrick / table_names_by_engine.sql
Created October 19, 2015 17:50
show table names by engine
SELECT table_name, engine FROM INFORMATION_SCHEMA.TABLES order by engine;
docker stats $(docker ps | awk '{if(NR>1) print $NF}')
@mrpatrick
mrpatrick / wp-cli_dockerize.sh
Last active January 5, 2016 21:34
Wordpress CLI for dockerenv projects Some useful wp-cli commands to run that allow you to search/replace and update to your dev/stage domain names. Update params as needed (i.e. docker tag, project_name, etc)
# Update wp home/siteurl vars
docker run -e --user=apache -i -t -w /var/www/ --volumes-from MYPROJECTNAME_MYPROJECTNAME_1 --link MYPROJECTNAME_db_1:db_1 docker.io/avatarnewyork/dockerenv-apache:php56 docker-umask-wrapper.sh /.composer/vendor/wp-cli/wp-cli/bin/wp --allow-root --path=/var/www/html option update siteurl "http://MYPROJECTNAME.stage.avatarnewyork.com/"
docker run -e --user=apache -i -t -w /var/www/ --volumes-from MYPROJECTNAME_MYPROJECTNAME_1 --link MYPROJECTNAME_db_1:db_1 docker.io/avatarnewyork/dockerenv-apache:php56 docker-umask-wrapper.sh /.composer/vendor/wp-cli/wp-cli/bin/wp --allow-root --path=/var/www/html option update home "http://MYPROJECTNAME.stage.avatarnewyork.com/"
# Update all wp post / image data that contain source url's
# REMOVE --dry-run to actually execute
docker run -e --user=apache -i -t -w /var/www/ --volumes-from MYPROJECTNAME_MYPROJECTNAME_1 --link MYPROJECTNAME_db_1:db_1 docker.io/avatarnewyork/dockerenv-apache:php56 docker-umask-wrapper.sh /.composer/vendor/wp-c
@mrpatrick
mrpatrick / mysqlcli_sphoinx
Created January 20, 2016 20:03
Connect to sphinx from mysql commandline. Use sphinxQL
mysql -P9306 --protocol=tcp
@mrpatrick
mrpatrick / lti_testing_tool
Created March 8, 2016 16:19
LTI Testing Tools
http://ltiapps.net/test/tc.php http://ltiapps.net/test/tp.php