Skip to content

Instantly share code, notes, and snippets.

@chris-huffman
chris-huffman / query_largest_tables.sql
Created January 13, 2021 17:56
Gets the 10 largest tables in a db.
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 10;
@chris-huffman
chris-huffman / Force Production Mode
Created December 9, 2020 22:35
Force a local site to run in production mode
From within vagrant:
* $ sudo vi /etc/httpd/conf.d/httpd.conf
* SetEnv MAGE_IS_DEVELOPER_MODE 0
* SetEnv MAGE_MODE production
* $ MAGE_MODE=production
* $ bin/magento deploy:mode:set production
* $ sudo systemctl restart httpd
@chris-huffman
chris-huffman / pull-subscription-data.sql
Created July 21, 2020 18:43
Pull ParadoxLabs Subscription Data
SELECT
s.increment_id,
c.firstname,
c.lastname,
qa.city,
qa.region,
qa.postcode
FROM
`paradoxlabs_subscription` AS s
JOIN `customer_entity` AS c ON s.customer_id = c.entity_id
@chris-huffman
chris-huffman / elasticsearch_commands.sh
Last active June 12, 2020 18:48
CLI Commands to Interact with ElasticSearch (v6)
#Show indexes
curl 127.0.0.1:9200/_cat/indices
#Update max_result_window to avoid error about "Result window is too large"
curl -XPUT "http://localhost:9200/magento2_product_1_v2/_settings" -d '{ "index" : { "max_result_window" : 500000 } }' -H "Content-Type: application/json"
@chris-huffman
chris-huffman / rename_files.sh
Created May 26, 2020 19:17
Bash script to rename images. (This example, append "_1".)
for i in *.png; do mv "$i" "${i/.png}"_1.png; done
@chris-huffman
chris-huffman / install_ioncube.sh
Created May 18, 2020 21:22
Install Ioncube Loader
cd /tmp
wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfz ioncube_loaders_lin_x86-64.tar.gz
#Note: this install is specific to a specific version of PHP. Make sure to use the correct one for your system. The example below is using PHP 7.2.
php -v
Ioncube install:
copy ioncube_loader_lin_7.2.so to /usr/lib64/php/modules/
@chris-huffman
chris-huffman / setup_sourceguardian.sh
Last active January 26, 2024 18:11
Install source guardian for PHP 7.2
#Run the following commands to install SourceGuardian Loader
#The example below is for PHP 7.2. Please use the version that applies to your situation.
sudo su
mkdir /usr/local/sourceguardian
cd /usr/local/sourceguardian
curl https://www.sourceguardian.com/loaders/download/loaders.linux-x86_64.tar.gz --output loaders.linux-x86_64.tar.gz
tar xzf loaders.linux-x86_64.tar.gz
cp ixed.7.2.lin /usr/lib64/php/modules/
@chris-huffman
chris-huffman / Fix-setup-db-status-issue.patch
Created January 20, 2020 21:51
M2 Github Issue 19597 Patches
# Module: cms-staging
From 92b3db5210eb6730d22d6cd3bca2c3d9fb87d46a Mon Sep 17 00:00:00 2001
From: Chris Huffman <chris.huffman@classyllama.com>
Date: Fri, 17 Jan 2020 10:52:04 -0600
Subject: [PATCH] Fix setup:db:status issue
---
etc/db_schema.xml | 3 +++
1 file changed, 3 insertions(+)

#Rename a local and remote branch in git

  1. Checkout local branch.

  2. Rename local branch git branch -m {new-name}

  3. Delete the old-name remote branch and push the new-name local branch. git push {origin} :{old-name} {new-name}

@chris-huffman
chris-huffman / handle-porto-files.sh
Created December 12, 2019 17:12
Handle Porto Generated Files with Capistrano
scp -r client-envir:/var/www/html/releases/{release_dir}/pub/media/porto/configed_css pub/media/porto
#git commit files
#deploy