Skip to content

Instantly share code, notes, and snippets.

View mttjohnson's full-sized avatar

Matt Johnson mttjohnson

View GitHub Profile
@mttjohnson
mttjohnson / PHPStormRegExExamples.md
Last active February 3, 2016 19:58
PHPStorm RegEx Examples

Multi word search anywhere in a file:

(text1)[\s\S]*(text2)|\2[\s\S]*\1

Mulit word search on the same line in a file

^.*text1.+?text2

@mttjohnson
mttjohnson / wp_create_user.sql
Created May 19, 2016 04:01
create wordpress user from sql
SET @user_login := 'mjohnson';
SET @user_pass := 'securePassword';
SET @user_email := 'matt.johnson@classyllama.com';
INSERT INTO `wp_users`
(`user_login`, `user_pass`, `user_email`, `user_registered`)
VALUES
(@user_login, MD5(@user_pass), @user_email, now());
SELECT @user_id := LAST_INSERT_ID();
INSERT INTO `wp_usermeta`
(`user_id`, `meta_key`, `meta_value`)
@mttjohnson
mttjohnson / cap_deploy_commit.sh
Created October 10, 2016 16:21
Capistrano deploy specific commit
stage.rb
set :branch, ENV['BRANCH'] || 'develop'
BRANCH=074e9eb--entire-commit-has-in-this-branch-variable--cab54fcc2fde8b bundle exec cap stage deploy
@mttjohnson
mttjohnson / braintree_settlement.sh
Created November 29, 2016 23:22
Braintree manual transaction settlement
# Setup local directory with braintree example and libraries
git clone git@github.com:braintree/braintree_php_example.git
cd braintree_php_example
composer install
# Create and define configuration options
echo '
BT_ENVIRONMENT=sandbox
BT_MERCHANT_ID=xxxxxxxxxxxx
BT_PUBLIC_KEY=xxxxxxxxxxxx
@mttjohnson
mttjohnson / systemd_info.sh
Created December 9, 2016 19:47
Managing SystemD
# CentoOS 7 - Systemctl
# https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
# https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files
# Enabled user space units
/etc/systemd/system/multi-user.target.wants/varnish.service
# System library of available units
/usr/lib/systemd/system/varnish.service
@mttjohnson
mttjohnson / email_cleanup.sql
Created January 9, 2017 20:43
email cleanup sql
' replace mydomainnamehere.com
' replace db_name_here
use information_schema;
SET SESSION group_concat_max_len=10000000;
select
group_concat(
concat('UPDATE `',`table_name`,'` SET `',`column_name`,'` = REPLACE(`',`column_name`,'`, SUBSTRING(`',`column_name`,'`, LOCATE(''@'', `',`column_name`,'`)), CONCAT(''+'', SUBSTRING(MD5(SUBSTRING(`',`column_name`,'`, LOCATE(''@'', `',`column_name`,'`))) FROM 1 FOR 6), ''@example.com'')) WHERE `',`column_name`,'` NOT LIKE ''%@mydomainnamehere.com'';') SEPARATOR '\n\n') as q
from `columns` as c
where
@mttjohnson
mttjohnson / nginx_fastcgi-buffers.md
Last active March 15, 2017 18:23
Tweaking fastcgi-buffers
@mttjohnson
mttjohnson / ansible-references.txt
Created March 27, 2017 18:37
Ansible References
# A really good fail-safe setup for destructive ansible playbooks
http://stackoverflow.com/questions/18195142/safely-limiting-ansible-playbooks-to-a-single-machine/18195217#18195217