Skip to content

Instantly share code, notes, and snippets.

View colinmollenhour's full-sized avatar

Colin Mollenhour colinmollenhour

View GitHub Profile
@colinmollenhour
colinmollenhour / parallel_jobs.sh
Created May 9, 2015 04:09
Invoke jobs in parallel and capture the output and exit statuses
#!/bin/bash
###############################################################################
# This script invokes all jobs in parallel and organizes the output by job
#
# Author: Colin Mollenhour
###############################################################################
[ -z "$1" ] && { echo "Usage: $0 <commands_list>"; exit 1; }
wd=$(pwd)
@colinmollenhour
colinmollenhour / Config.php
Last active July 30, 2021 07:18
Mage_Core_Model_Config (Magento CE through 1.9 - fixes stampeding)
<?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 April 15, 2016 19:11
Optimize PNG and JPEG images - incrementally
#!/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 / Varien.php
Last active July 19, 2024 09:25
Mage_Core_Model_Session_Abstract_Varien - dropped session fix
<?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 / Update.php
Created August 16, 2016 20:58
Improve Magento Layout Cache Efficiency
<?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 / innodb-snapshot.sh
Last active July 20, 2022 11:26
Innobackupex/XtraBackup Helper
#!/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 / shell_delete_unused_images.php
Last active February 17, 2020 18:51 — forked from aleron75/shell_delete_unused_images
Delete no more used Product Images on Magento
<?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 / simple_modman_test.sh
Last active April 26, 2017 15:35 — forked from syhe/simple_modman_test.sh
Simple modman test
#!/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 / log_deadlocks.sh
Created April 25, 2018 08:20
Log Innodb Deadlocks
#!/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
@colinmollenhour
colinmollenhour / process-mysqldump.c
Last active July 10, 2018 00:11 — forked from divinity76/process-mysqldump.c
Add newlines before parenthesis for a SQL mysqldump
// 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