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 / 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 / collections.php
Last active March 19, 2019 17:36
Vardoc generator for Magento collection classes
<?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 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
@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 / 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 / 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 / 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 / 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
{