Skip to content

Instantly share code, notes, and snippets.


David Alexander davidalexander

View GitHub Profile
View gist:6731541
grep "HTTP\/...\" 404" nginx-access.log | awk '{ print $16}' | sort | uniq
jbenet /
Last active Jan 8, 2022
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

View gist:6290973
delimiter ;;
drop procedure if exists build_catalog;;
create procedure build_catalog(IN categories INT, IN products INT)
SET @category_count = 1;
peterjaap / cleanImages.php
Last active Nov 26, 2021
Script to clean up the images tables in a Magento installation. Removes references to non-existing images, removes duplicate images, sets correct default image and deletes orphaned images from the filesystem.
View cleanImages.php
* This script deletes duplicate images and imagerows from the database of which the images are not present in the filesystem.
* It also removes images that are exact copies of another image for the same product.
* And lastly, it looks for images that are on the filesystem but not in the database (orphaned images).
* This script can most likely be optimized but since it'll probably only be run a few times, I can't be bothered.
* Place scripts in a folder named 'scripts' (or similar) in the Magento root.
astorm / gist:2974947
Created Jun 22, 2012
Magento's Performance Profile
View gist:2974947
There's multiple reasons Magento's performance profile is different
than most "mid-2000s" LAMP stack frameworks and CMS systems.
1. SQL Bottleneck: Magento's functionality is implemented in such a
way that there's a large number of SQL queries on each page request.
Between the special EAV structure of product/category models, and a
general "model first" approach to development, you end up seeing a lot
of SQL queries.
2. "Classical" (Java/C#) style OOP. Magento uses a class heavy
lg0 / markdown.xml
Created Apr 10, 2012
Markdown Syntax Highlighting for Sublime text 2
View markdown.xml
<!-- copy this to YOUR_THEME.tmTheme-->
<string>diff: deleted</string>
View gist:1086455

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

alistairstead / gist:1053331
Created Jun 29, 2011
Find bad things in Magento customisations
View gist:1053331
find . -name "*.phtml" -print | xargs grep --color=auto -iRnH "Mage::getModel("
find . -name "*.phtml" -print | xargs grep --color=auto -iRnH "Mage::getResourceModel("
find . -name "*.phtml" -print | xargs grep --color=auto -iRnH "Mage::getSingleton("
find . -name "*.phtml" -print | xargs grep --color=auto -iRnH "SELECT.*FROM.*;[\"\']"
find . -name "*.php" -print | xargs grep --color=auto -iRnH "htmlEscape("
find ./app/code/local -name "*.php" -print | xargs grep --color=auto -iRnH "htmlEscape("
find ./app/code/local -name "*/Block/*.phtml" -print | xargs grep --color=auto -iRnH "SELECT.*FROM.*;[\"\']"
find ./app/code/local -name "*.php" -print | xargs grep --color=auto -iRnH "\$_[GET|REQUEST|SERVER|POST]"
find ./app/code/local -name "*.php" -print | xargs grep --color=auto -iRnH "public _construct"
find . -name "*.php" -print | xargs grep --color=auto -iRnH "public _construct"