Skip to content

Instantly share code, notes, and snippets.

@aadmathijssen
aadmathijssen / find-i18n-duplicates.php
Last active July 26, 2024 11:50
Find exact and approximate duplicates of source translations.
<?php
declare(strict_types=1);
namespace I18nDuplicateFinder;
use RuntimeException;
use SplFileObject;
use function array_key_exists;
@aadmathijssen
aadmathijssen / pre-commit.sh
Last active July 8, 2021 19:15
phpcs pre-commit hook using the gitstaged filter
#!/bin/bash
#stash all changes except for the staged ones
git stash push --keep-index --include-untracked -m "phpcs pre-commit stash"
#run phpcs on the staged files and store the exit code
vendor/bin/phpcs --filter=gitstaged
result=$?
#restore to the previous configuration
@aadmathijssen
aadmathijssen / composer
Last active March 18, 2021 11:25
Composer CLI version selector
#!/bin/bash
set -euo pipefail
for tool in jq composer1.phar composer2.phar; do
if ! [ -x "$(command -v ${tool})" ]; then
echo "Error: ${tool} is not installed." >&2
exit 1
fi
done
@aadmathijssen
aadmathijssen / testCategoryLoad.php
Last active December 6, 2018 12:56
Magento shell script used for analyzing the performance of the Emico_Tweakwise_Helper_Data::getFilterCategory method.
<?php
/**
* ISAAC Category Load Tester
*
* @category ISAAC
* @package ISAAC_Category
* @copyright Copyright (c) 2018 ISAAC Software Solutions B.V. (https://www.isaac.nl)
* @license proprietary
* @author ISAAC Software Solutions B.V. (https://www.isaac.nl)
*/
@aadmathijssen
aadmathijssen / add-checkout-form-key.sh
Last active October 29, 2019 13:52 — forked from schmengler/add-checkout-form-key.sh
Magento SUPEE-9767 Checkout Form Key Theme Patch
find -L app/design/frontend -name 'shipping.phtml' -or -name 'billing.phtml' -or -name 'shipping_method.phtml' -or -name 'payment.phtml' -or -name 'addresses.phtml' \
| xargs grep -L formkey \
| xargs perl -i -pe 's/<\/form>/<?php echo \$this->getBlockHtml("formkey") ?>\n<\/form>/g'
find -L skin/frontend -name 'opcheckout.js' \
| xargs grep -L form_key \
| xargs perl -i -pe 's/if \(elements\[i\]\.name=='\''payment\[method\]'\''\) \{/if (elements[i].name=='\''payment[method]'\'' || elements[i].name == '\''form_key'\'') {/g'
find -L js -name 'payment.js' \
| xargs grep -L form_key \
@aadmathijssen
aadmathijssen / post-checkout
Last active November 25, 2015 14:04 — forked from lyrixx/post-checkout
Git post checkout
#!/bin/bash
# Put this file at: .git/hooks/post-checkout
# and make it executable
# You can install it system wide too, see http://stackoverflow.com/a/2293578/685587
PREV_COMMIT=$1
POST_COMMIT=$2
NOCOLOR='\033[0m'