Skip to content

Instantly share code, notes, and snippets.

View erikhansen's full-sized avatar

Erik Hansen erikhansen

View GitHub Profile
@erikhansen
erikhansen / magento1_enterprise_index_diagnostics.sql
Created February 18, 2016 14:46 — forked from mttjohnson/magento1_enterprise_index_diagnostics.sql
Magento 1.x Enterprise Partial Indexing Diagnostics Toolset
-- When products are added/removed from a category this table stores all the relation data
select * from catalog_category_product where product_id = '218';
-- The index that is used for presenting products in a category on the frontend
select * from catalog_category_product_index where product_id = '218';
-- The change log table used for Magento EE partial index functionality
select * from catalog_category_product_index_cl where product_id = '218';
-- The cron job that gets executed on each cron execution - check for errors
@erikhansen
erikhansen / braintree_settlement.sh
Created November 29, 2016 23:29 — forked from mttjohnson/braintree_settlement.sh
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
@erikhansen
erikhansen / readme.md
Last active September 11, 2017 19:14 — forked from GianlucaGuarini/post-merge
Git hook that gets triggered after any 'git pull' whenever one of the files specified has changed. Useful to update any web application dependency.

How to create a global git commit hook by Matt Venables

1 Enable git templates (This tells git to copy everything in ~/.git-templates to your per-project .git/ directory when you run git init):

git config --global init.templatedir '~/.git-templates'

2 Create a directory to hold the global hooks:

mkdir -p ~/.git-templates/hooks

@erikhansen
erikhansen / mysql_size_info.sql
Created June 21, 2018 15:58 — forked from mttjohnson/mysql_size_info.sql
MySQL data usage queries
/* find the largest tables on the server */
SELECT CONCAT(table_schema, '.', table_name) 'db.table',
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;
@erikhansen
erikhansen / composer_private_repos.sh
Created November 7, 2018 17:47 — forked from mttjohnson/composer_private_repos.sh
Composer Notes and Private Repositories
# List the composer home directory
# Typically /Users/<user>/.composer or /home/<user>/.composer or C:\Users\<user>\AppData\Roaming\Composer
echo $COMPOSER_HOME
# List files in the composer home
ls -la $COMPOSER_HOME
# View auth.json in composer home used when no local ./auth.json exists in the directory executed from
cat $COMPOSER_HOME/auth.json
SET @utc_offset = 6;
-- Orders Per Year --
SELECT period_date, CONCAT("UTC-", @utc_offset) AS utc_offset, order_count, gross_revenue, ROUND(gross_revenue / order_count, 2) AS gross_aov
FROM (
SELECT
COUNT(*) AS order_count,
ROUND(SUM(base_grand_total), 2) AS gross_revenue,
date_format(date_sub(o.created_at, INTERVAL @utc_offset HOUR), "%Y") AS period_date
FROM sales_order o
@erikhansen
erikhansen / brew_vagrant_version.sh
Created February 8, 2019 18:22 — forked from mttjohnson/brew_vagrant_version.sh
Installing older version of vagrant/ansible with brew
# You can find the current list of casks on github, and the one for vagrant here:
# https://github.com/Homebrew/homebrew-cask/blob/master/Casks/vagrant.rb
# From there you may be able to load the history of that file and lookup previous versions of
# the cask which would be related to previous versions of vagrant as indicated in the cask definition file.
# If the github history of the file fails you can search through recent commit history and find a commit prior
# to the version change you are trying to avoid and get the commit hash before the change and use it to locate
# a previous version of the cask file.
# current (master branch) casks:
@erikhansen
erikhansen / rsync_examples.sh
Last active March 1, 2019 19:00 — forked from mttjohnson/rsync_examples.sh
rsync examples (two remotes)
# rsync with sudo
rsync -av \
--rsync-path="sudo -u www-data rsync" \
-e 'ssh -o StrictHostKeyChecking=no'
path_to_local_data/ user_name@example.com:/var/www/
# rsync media between two remotes that can not talk to each other
# this creates a port (50000) on the origin server that establishes a tunnel between the origin and destination through
# your computer, as long as your computer can access both servers you can rsync the files between the two
# Magento 2 Sandbox Snippet - You can copy and paste into any shell in a Magento root directory
# Extended: https://docs.classyllama.net/disciplines/engineering/magento/sandbox-file-m2
set +H # disable history expansion
PHP_CODE=$(cat <<'PHP_CODE'
<?php
header('Content-type: text/plain');
require __DIR__ . '/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
@erikhansen
erikhansen / createUsefulAssetManifest.js
Last active June 25, 2019 14:44 — forked from mdecorte/createUsefulAssetManifest.js
Script to create a useful asset-manifest file for CRA-3 that only contains paths to assets needed on page load
const fs = require('fs');
const path = require('path');
const assetManifestPath = path.join(__dirname, 'build/asset-manifest.json');
let assetManifest = fs.readFileSync(assetManifestPath);
assetManifest = JSON.parse(assetManifest)['files'];
const indexFilePath = path.join(__dirname, 'build/index.html');
const BUILD_PATH = path.join(__dirname, 'build/useful-asset-manifest.json');
// Filter paths that exists in the create-react-app generated `build/asset-manifest.json` and use the path from that file because that can contain the "homepage" prefix from package.json.