Skip to content

Instantly share code, notes, and snippets.

View davidalger's full-sized avatar

David Alger davidalger

View GitHub Profile
@davidalger
davidalger / poken-loader
Created April 10, 2013 06:19
Poken Load on OS X 10.8
sudo cat /dev/disk2s1 | php -r 'echo preg_replace("/.*(<html>.*<\/html>).*/s", "$1", file_get_contents("php://stdin"));' > ~/poken.htm; open ~/poken.htm
@davidalger
davidalger / strip-definer-comments.md
Last active July 22, 2020 15:56
Strip DEFINER comments from mysqldump. Usage is to pipe mysqldump through this sed command.

Stripping DEFINER from MySQL dumps with sed

LC_ALL=C sed -E 's/DEFINER[ ]*=[ ]*`[^`]+`@`[^`]+`/DEFINER=CURRENT_USER/g'

Typical Usage

pv /path/to/mysqldump.sql.gz \
@davidalger
davidalger / Magento_CE_1.7.0.2_v1-CSRF_Patch.diff
Created July 6, 2013 03:50
For details on this, please refer to this post on Magento SE: http://magento.stackexchange.com/a/3332/128 — DISCLAIMER: I have NOT TESTED this patch. The patch provided here is provided with NO WARRANTY and may or may not fully resolve the vulnerabilities referenced in the CE 1.8 release notes. As an untested patch, there is also no guarantee th…
Date: Fri, 5 Jul 2013 22:41:03 -0500
Subject: [PATCH] Magento_CE_1.7.0.2_v1-CSRF_Patch
---
.../core/Mage/Catalog/Block/Product/Abstract.php | 85 ++++-
app/code/core/Mage/Catalog/Block/Product/View.php | 10 +-
.../core/Mage/Catalog/Helper/Product/Compare.php | 28 +-
app/code/core/Mage/Checkout/Helper/Cart.php | 26 +-
.../Mage/Checkout/controllers/CartController.php | 69 ++--
.../Checkout/controllers/OnepageController.php | 70 +++-
@davidalger
davidalger / Cm_Cache_Backend_Redis-patch1.diff
Last active August 29, 2015 14:17
Cm_Cache_Backend_Redis SUNION Chunking
diff --git a/htdocs/app/code/core/Enterprise/PageCache/Model/Observer/Index.php b/htdocs/app/code/core/Enterprise/PageCache/Model/Observer/Index.php
index 57ece57..f0ad2a6 100644
--- a/htdocs/app/code/core/Enterprise/PageCache/Model/Observer/Index.php
+++ b/htdocs/app/code/core/Enterprise/PageCache/Model/Observer/Index.php
@@ -46,6 +46,7 @@ class Enterprise_PageCache_Model_Observer_Index
$entity->setId($entityId);
$cacheTags = array_merge($cacheTags, $entity->getCacheIdTags());
}
+ $cacheTags = array_unique($cacheTags);
if (!empty($cacheTags)) {
@davidalger
davidalger / ee-page-cache-flushing-enhancment.diff
Created May 4, 2015 16:03
EE Page Cache Flushing Performance Enhancement
diff --git a/htdocs/app/code/core/Enterprise/PageCache/Model/Observer/Index.php b/htdocs/app/code/core/Enterprise/PageCache/Model/Observer/Index.php
index 57ece57..f0ad2a6 100644
--- a/htdocs/app/code/core/Enterprise/PageCache/Model/Observer/Index.php
+++ b/htdocs/app/code/core/Enterprise/PageCache/Model/Observer/Index.php
@@ -46,6 +46,7 @@ class Enterprise_PageCache_Model_Observer_Index
$entity->setId($entityId);
$cacheTags = array_merge($cacheTags, $entity->getCacheIdTags());
}
+ $cacheTags = array_unique($cacheTags);
if (!empty($cacheTags)) {
@davidalger
davidalger / convert-tags.sh
Last active June 8, 2017 18:36
Converts long-form echo tags to short-echo tags
#!/usr/bin/env bash
#
# note: using *html vs *.phtml because one .html file has a use of <?php echo in it
#
function replace_tags {
find "$1" -type f -name "$2" -print0 | xargs -0 perl -pi -w -e "$3"
}
echo "==> Convert single-line long-tags to uniform short-echo tag format"
@davidalger
davidalger / compare_and_email.sh
Created July 29, 2015 16:29
Uses git to detect changes in web root and email administrators daily
#!/bin/env bash
#
# Example use: Add the following line to your crontab to run the script on a daily basis.
#
# 1 6 * * * ~/bin/compare_and_email.sh <full_path_to_webroot> "Email Subject Line" "user@example.com user2@example.com"
#
date=`date +%Y%m%d`
gitdir="$1"
subject="$2"
@davidalger
davidalger / magento
Last active March 20, 2023 19:20
Magento 2 Shell Wrapper
#!/usr/bin/env bash
# usage: put at /usr/local/bin/magento then call from anywhere within a magento 2 webroot
#
dir="$(pwd)"
while [[ "$dir" != "/" ]]; do
if [[ -x "$dir/bin/magento" ]]; then
"$dir/bin/magento" "$@"
exit $?
fi
@davidalger
davidalger / m2-metapackages-install.sh
Created November 18, 2015 17:17
Install M2 for a new project
#!/usr/bin/env bash
cd /sites
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition m2.demo
cd m2.demo
chmod +x bin/magento
bin/magento sampledata:deploy
composer update
mysql -e 'create database m2_demo'
bin/magento setup:install --base-url=http://m2.demo --backend-frontname=backend \
--admin-user=admin --admin-firstname=Admin --admin-lastname=Admin \
@davidalger
davidalger / m2-module-install-2.sh
Last active May 24, 2017 15:16
Install module directly or via composer
composer config repositories.alger/phpworld-talk2 vcs git@github.com:davidalger/phpworld-talk2.git
composer require alger/module-skeleton:dev-master
bin/magento setup:upgrade -q && bin/magento cache:flush -q
# OR
git clone git@github.com:davidalger/phpworld-talk2.git app/code/Alger/Skeleton
bin/magento module:enable Alger_Skeleton
bin/magento setup:upgrade -q && bin/magento cache:flush -q