Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
mttjohnson / m2-static-deploy-rebuild.sh
Created November 3, 2016 04:36
Magento 2 Static Content Deploy - Rebuilding
rm -rf pub/static/*
touch pub/static/deployed_version.txt
mr config:set dev/js/minify_files 0
mr config:set dev/css/minify_files 0
bin/magento cache:flush config
https=off
bin/magento setup:static-content:deploy en_US
https=on
bin/magento setup:static-content:deploy en_US --no-javascript --no-css --no-less --no-images --no-fonts --no-html --no-misc --no-html-minify
@mttjohnson
mttjohnson / genpasswd.sh
Last active June 25, 2023 15:27
Generate a password from the shell
# Defined function for generating random password
genpasswd() {
local l=$1
[ "$l" == "" ] && l=20
LC_CTYPE=C tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}
NEW_PASSWORD=$(genpasswd 16)
echo $NEW_PASSWORD
@mttjohnson
mttjohnson / mysql-performance-tuning.sql
Last active August 23, 2024 17:54
MySQL Performance Tuning
-- Query the database to calculate a recommended innodb_buffer_pool_size
-- and get the currently configured value
-- The rollup as the bottom row gives the total for all DBs on the server, where each other row is recommendations per DB.
SELECT
TABLE_SCHEMA,
CONCAT(CEILING(RIBPS/POWER(1024,pw)),SUBSTR(' KMGT',pw+1,1))
Recommended_InnoDB_Buffer_Pool_Size,
(
SELECT CONCAT(CEILING(variable_value/POWER(1024,FLOOR(LOG(variable_value)/LOG(1024)))),SUBSTR(' KMGT',FLOOR(LOG(variable_value)/LOG(1024))+1,1))
@mttjohnson
mttjohnson / watch-monitoring.sh
Created November 23, 2016 16:42
website monitoring
watch -d -n 5 'curl -s -v --connect-timeout 15 --max-time 30 http://example.com/ > /dev/null'
# Could not resolve hostname
watch -d -n 5 'curl -s -v --connect-timeout 15 --max-time 30 http://asdfasdfasdf.asdf/ > /dev/null'
* Could not resolve host: asdfasdfasdf.asdf
* Closing connection 0
@mttjohnson
mttjohnson / memory_monitoring.sh
Last active February 25, 2020 12:09
Memory monitoring
# Commands to use for determining memory usage in linux
# https://github.com/pixelb/ps_mem
ps_mem
top
# https://hisham.hm/htop/
htop
@mttjohnson
mttjohnson / nginx_monitoring.sh
Created November 29, 2016 18:46
nginx monitoring
# https://goaccess.io/
yum install -y glib2 glib2-devel glibc make geoip geoip-devel ncurses-devel
cd ~/
wget http://tar.goaccess.io/goaccess-1.1.1.tar.gz
tar -xzvf goaccess-1.1.1.tar.gz
cd goaccess-1.1.1/
./configure --enable-geoip --enable-utf8
make
make install
@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 [email protected]: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 / ssh_testing.sh
Last active September 26, 2020 20:06
SSH SFTP Authentication Testing
# Make changes to sshd configuration
vi /etc/ssh/sshd_config
PasswordAuthentication no
# Test configuration changes
sshd -t
# Restart service
service sshd restart
@mttjohnson
mttjohnson / mock-varnish-backend-request.sh
Last active April 5, 2019 15:43
Mock Varnish Backend Request
# Consider filtering the varnishlog output
# https://feryn.eu/blog/varnishlog-measure-varnish-cache-performance/
varnishlog -i "RespHeader,Req*" -X "RespHeader:(x|X)-" -I "timestamp:Resp" -x reqprotocol,reqacct -g request
# Capture the log output from varnishlog and look for BereqHeader
# -n name is how you can specify a specific named instance of varnish
# remove -n if you just want to access the default instance
varnishlog -n stage