Skip to content

Instantly share code, notes, and snippets.

Avatar

Colin Mollenhour colinmollenhour

View GitHub Profile
@colinmollenhour
colinmollenhour / collections.php
Last active Mar 19, 2019
Vardoc generator for Magento collection classes
View collections.php
<?php
/* This script generates @method annotations for magento collection classes.
* Example:
* cd [magento root]
* php shell/collections.php
*
*/
// Init framework
require __DIR__.'/../app/Mage.php';
Mage::app();
@colinmollenhour
colinmollenhour / process-mysqldump.c
Last active Jul 10, 2018 — forked from divinity76/process-mysqldump.c
Add newlines before parenthesis for a SQL mysqldump
View process-mysqldump.c
// gcc -O2 -Wall -pedantic process-mysqldump.c -o process-mysqldump
// Usage: cat dump.sql | process-mysqldump
// Or : process-mysqldump dump.sql
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#define BUFFER 100000
View log_deadlocks.sh
#!/bin/bash
dir=/root/deadlocks
[ -d $dir ] || mkdir -p $dir
cd $dir || { echo "Could not cd to $dir"; exit 1; }
mysql -be 'show engine innodb status;' \
| sed 's/\\n/\n/g' \
| awk '/TRANSACTIONS/{flag=0}flag;/LATEST DETECTED DEADLOCK/{flag=1}' \
> latest.txt
View simple_modman_test.sh
#!/usr/bin/env bash
set -e
MODMAN="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/modman"
TMPDIR=$(mktemp -d)
function cleanup () {
rm -rfv "$TMPDIR"
}
trap cleanup EXIT
@colinmollenhour
colinmollenhour / shell_delete_unused_images.php
Last active Feb 17, 2020 — forked from aleron75/shell_delete_unused_images
Delete no more used Product Images on Magento
View shell_delete_unused_images.php
<?php
require_once 'abstract.php';
class Mage_Shell_CheckImages extends Mage_Shell_Abstract
{
const CATALOG_PRODUCT = '/catalog/product';
const CACHE = '/cache/';
public function run()
@colinmollenhour
colinmollenhour / innodb-snapshot.sh
Last active Jul 15, 2018
Innobackupex/XtraBackup Helper
View innodb-snapshot.sh
#!/bin/bash
# ###################################
# Innodb Snapshot Helper
# ###################################
# Wrapper around innobackupex to either:
# - Take incremental snapshots that are immediately applied to the base snapshot
# - Apply a series of incremental snapshots to a base snapshot
# - Stream an incremental snapshot
#
set -e
@colinmollenhour
colinmollenhour / Update.php
Created Aug 16, 2016
Improve Magento Layout Cache Efficiency
View Update.php
<?php
/**
* This rewrite modifies the caching behavior so that the layout cache key references a SHA1
* hash of the layout XML instead of the XML itself to avoid duplication. The layout XML must
* still be generated once for each layout key, but it will not be saved if the identical
* contents already exist, saving considerable cache backend storage.
*/
class Template_Core_Model_Layout_Update extends Mage_Core_Model_Layout_Update
{
@colinmollenhour
colinmollenhour / Varien.php
Last active Dec 19, 2017
Mage_Core_Model_Session_Abstract_Varien - dropped session fix
View Varien.php
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@colinmollenhour
colinmollenhour / optimize_media.sh
Created Apr 15, 2016
Optimize PNG and JPEG images - incrementally
View optimize_media.sh
#!/bin/bash
#
# Optimize all jpg and png files in the cwd
# Run it again to optimize new files since the last run
#
# Example:
# echo "optimize_media.sh > /tmp/optimize.log" | sudo -u www-data bash -s
#
# Colin Mollenhour 2016
@colinmollenhour
colinmollenhour / Config.php
Last active Dec 13, 2019
Mage_Core_Model_Config (Magento CE through 1.9 - fixes stampeding)
View Config.php
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
You can’t perform that action at this time.