Skip to content

Instantly share code, notes, and snippets.

View colinmollenhour's full-sized avatar

Colin Mollenhour colinmollenhour

View GitHub Profile
@colinmollenhour
colinmollenhour / Varien.php
Last active December 19, 2017 15:08
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 / 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 / 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 / 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 / server.js
Last active May 9, 2018 16:00
Delays spooling of unrecognized domains (designed for SmarterMail)
/**
* Watch the spool, delay processing of emails from unrecognized domain names.
*
* Installation:
* npm install nedb
* npm install node-windows
* node server.js --install {spool_dir}
* net start SpamDelayer
*
* @Author Colin Mollenhour
@colinmollenhour
colinmollenhour / nginx_error_log
Last active September 10, 2016 15:30
Munin Plugin - nginx error_log
#!/bin/bash
: <<=cut
=head1 NAME
nginx error log - Munin plugin to monitor nginx error_log rates (debug, info, notice, warn, error, crit, alert, emerg).
=head1 APPLICABLE SYSTEMS
Any Linux host, running nginx, with bash version > 4.0
@colinmollenhour
colinmollenhour / Config.php
Last active April 22, 2020 09:45
Stampede-resistant Config Cache
<?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 / mysqlsnapshot.sh
Last active May 16, 2021 13:32
MySQL Snapshot Script
#!/bin/bash
DBNAME=mydb
SNAPSHOT_DAYS=2
ARCHIVE_DAYS=0
COMPRESS_INPLACE=1
mysqldump='docker exec mysql_mysql_1 mysqldump'
gzip=/bin/gzip
@colinmollenhour
colinmollenhour / log_deadlocks.sh
Last active December 4, 2018 20:51
Record all new deadlocks in separate files
#!/bin/bash
#
# Copyright Colin Mollenhour 2014
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' \
#!/bin/bash
#
# Store/update the DNS entry locally. Requires unbound install as a local DNS resolver
# and a cron job that runs this script.
#
# Copyright: Colin Mollenhour 2014
#
# Recommended DNS servers for querying:
# OpenDNS: 208.67.222.222 and 208.67.220.220
# Google: 8.8.8.8 and 8.8.4.4