Skip to content

Instantly share code, notes, and snippets.

View mrpatrick's full-sized avatar

Patrick Tully mrpatrick

View GitHub Profile
@mrpatrick
mrpatrick / puppet.conf_config_version
Created April 25, 2012 16:43
Set the config_version to git version in puppetmaster puppet.conf file
config_version = /usr/bin/git --git-dir /etc/puppet_[name]/.git describe --long
@mrpatrick
mrpatrick / ssl_check_expire_days.py
Last active September 8, 2020 07:39
Updated to use OpenSSL and cert tags as subprocess no longer works with latest dd-agent
import time
import datetime
from OpenSSL import crypto as c
from checks import AgentCheck
class SSLCheckExpireDays(AgentCheck):
def check(self, instance):
metric = "ssl.expire_in_days"
certfile = instance['cert']
cert_tag = 'cert:%s' % (certfile.split('/')[-1:],)
@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 / wp-cli-new-admin.sh
Created August 2, 2016 16:31
Create new wordpress admin user using wp-cli / docker
docker run -e --user=apache -i -t -w /var/www/ --volumes-from PROJECTNAME_PROJECTNAME_1 --link channelone_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 user create admin myemail@myhost.com --role=administrator
@mrpatrick
mrpatrick / emacs_cheet_sheet
Last active April 9, 2017 10:18
emacs cheat sheet
C-x r t - insert char on entire selection
M-$ - flyspell the word the cursor is on (or near)
M-v - page up
X-m - smerge-mode (syntax highlight git merge conflicts)
(set-face-attribute 'default nil :height 100) - increase font size
prepend string - entire region
`M-x string-insert-rectangle RET`
@mrpatrick
mrpatrick / mysqldump_regex_tables.sh
Created October 28, 2016 15:15
mysqldump tabels with regex. This is useful if you want to ONLY dump wp_* tables within a larger database. From: http://stackoverflow.com/questions/5268936/mysqldump-only-tables-with-certain-prefix-mysqldump-wildcards
mysql -N -uroot -e 'show tables like "wp\_%"' mydb | xargs mysqldump -uroot mydb > /tmp/wp_tables_prod.20161028.sql
@mrpatrick
mrpatrick / branch_diff_rever_single_file.sh
Created August 9, 2016 20:59
Check the diff between branches and revert single file from specific commit
# Check the diff between branches
git diff release-v2.0.0..Develop public/wp-content/themes/mytheme/my-page.php
# revert single file from specific commit
git checkout 26608ec4a393b0086e02851b6d6f6b72af265a67 public/wp-content/themes/mytheme/my-page.php
# commit (the diff won't show until it's commited)
git commit
# re-diff file (will show no diff)
@mrpatrick
mrpatrick / auto-rsync.el
Created June 29, 2016 18:57 — forked from mtmtcode/auto-rsync.el
auto-rsync.el - Emacs minor mode to execute rsync automaticlly
;;; auto-rsync-mode -- minor mode for auto rsync
;;
;; Author: @l3msh0
;;
;;; Example
;;
;; (require 'auto-rsync)
;; (auto-rsync-mode t)
;; (setq auto-rsync-dir-alist
@mrpatrick
mrpatrick / bootstrap-salt.sh
Created March 10, 2016 15:30 — forked from rmohr/bootstrap-salt.sh
fixed salt boostrap file because of moved corp repositories
#!/bin/sh -
#======================================================================================================================
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en cc=120
#======================================================================================================================
#
# FILE: bootstrap-salt.sh
#
# DESCRIPTION: Bootstrap salt installation for various systems/distributions
#
# BUGS: https://github.com/saltstack/salt-bootstrap/issues
@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