Skip to content

Instantly share code, notes, and snippets.

View colinmollenhour's full-sized avatar

Colin Mollenhour colinmollenhour

View GitHub Profile
@colinmollenhour
colinmollenhour / dns_resolver_test.sh
Last active December 12, 2023 18:28
DNS resolver test - reports when DNS resolution is greater than 1 second
#!/bin/bash
# Check if resolver IP address is provided as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <resolver_ip> [<fqdn>]"
exit 1
fi
resolver_ip=$1
record=shops.myshopify.com
@colinmollenhour
colinmollenhour / poboy.js
Last active December 8, 2023 01:58
Poor man's in-memory exclusive lock mechanism for Javascript
/*
* Uses 100ms intervals to check for released lock - super simple
* @author Me and ChatGPT
*/
class PoboyLock {
constructor() {
this.lockedKeys = new Set();
}
@colinmollenhour
colinmollenhour / makePhpstormMap.php
Last active October 6, 2023 13:26
Generate map of factory method arguments to resolved class names for Magento projects
<?php
/* This script generates a mapping of factory methods/parameters to the resulting class
* names in such a way that PhpStorm 6.0.1 can use for autocompletion and chaining.
*
* Example:
* cd [magento root]
* php ~/makePhpstormMap.php > .phpstorm.meta.php
*
*/
@colinmollenhour
colinmollenhour / post-receive-redmine.sh
Last active September 1, 2023 21:56
gitolite update hooks to reject CRLF line endings and require formatted commit messages
#!/bin/bash
#
# see https://github.com/kahseng/redmine_gitolite_hook/blob/master/README.rdoc
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated. It is passed arguments in through
# stdin in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
@colinmollenhour
colinmollenhour / A-repo-moved.md
Created March 28, 2012 07:17
REPO MOVED! (Cm_Cache_Backend_File)
@colinmollenhour
colinmollenhour / maildelayer.js
Last active June 13, 2023 23:49
Watch the spool, delay processing of emails from unrecognized domain names.
/**
* 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 / cleanCache.php
Created May 17, 2012 00:50
Simplified cache cleaning script for production updates.
<?php
/**
* Set global/skip_process_modules_updates to '1' in app/etc/local.xml and
* then use this script to apply updates and refresh the config cache without
* causing a stampede on the config cache.
*
* @author Colin Mollenhour
*/
umask(0);
ini_set('memory_limit','512M');
@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 / 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