Skip to content

Instantly share code, notes, and snippets.

View colinmollenhour's full-sized avatar

Colin Mollenhour colinmollenhour

View GitHub Profile
@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
@colinmollenhour
colinmollenhour / sc-install.sh
Created April 6, 2014 02:57
Install StarCluster on Windows
#!/bin/bash
#
# Requires Python 2.7 64-bit
# Run using Git Bash program from "Git for Windows"
[ -d /c/Python27 ] || {
echo "Oops, I expected Python 2.7 to be installed at C:\Python27";
exit 1;
}
cd /c/Python27/
@colinmollenhour
colinmollenhour / tags.php
Last active August 29, 2015 13:56
Test browser performance of using 100 inline script tags with domReadyQueue vs 1 inline script tag.
<?php /* http://screencast.com/t/rFhmw1S2zsh */ ?>
<!DOCTYPE html>
<html>
<head><title>Script Block Test</title></head>
<body>
<?php if (isset($_GET['mode']) && $_GET['mode'] == 'inline'): ?>
<script type="text/javascript">
var domReadyQueue = [];
@colinmollenhour
colinmollenhour / tunnlr.sh
Created February 8, 2014 00:01
Easily configure and launch your Tunnlr.com SSH tunnel!
#!/bin/bash
#
# A simple function for starting an SSH tunnel (e.g. tunnlr.com)
#
# Add the function to your .bashrc file or use this script standalone
# Takes port to forward to as only parameter
function tunnlr(){
[ -z $1 ] && { echo "You must specify a port to forward to."; return 1; }
if [ -f ~/.tunnlr ]; then
@colinmollenhour
colinmollenhour / mongobackup.sh
Created July 30, 2013 21:53
Simple daily dump of mongo databases.
#!/bin/bash
cd /media/dumps
name=$(date +%b-%d)
year=$(date +%Y)
[ -d $year ] || mkdir $year || { echo "Could not create directory '$year'"; exit 1; }
mongodump --db t3_mage --out $name &> mongodump.log
if [ $? ]; then
tar -czf snapshots/$year/$name.tgz $name
if [ $(($(date +%d | sed 's/^0*//') % 10)) == 0 ]; then
@colinmollenhour
colinmollenhour / mysql_monitor.sh
Last active May 13, 2025 23:24
MySQL Monitor (like 'redis-cli MONITOR')
#!/bin/bash
#
# Monitor MySQL queries
# @author Colin Mollenhour
set -e
mysql="mysql"
test="test"
bash="bash"
@colinmollenhour
colinmollenhour / boris-mage.php
Last active December 17, 2015 08:19 — forked from Vinai/boris-mage.php
Search for boris in PHP default include path and Magento's lib directory.
#!/usr/bin/env php
<?php
//
// PHP REPL with initialized Magento environment
//
// Thanks to https://github.com/d11wtq/boris
//
// Run this script anywhere in the Magento directory tree to start the REPL
//
@colinmollenhour
colinmollenhour / etagtest.php
Last active December 10, 2015 00:28
Test reverse proxies for full ETag support.
<?php
$etag = date('s') < 30 ? 'one' : 'two';
header('Cache-Control: public, must-revalidate, max-age=60');
header('X-Foo: '.$etag);
header('Vary: X-Foo');
header('ETag: W/"X'.$etag.'X"');
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
$ifNoneMatch = $_SERVER['HTTP_IF_NONE_MATCH'];
@colinmollenhour
colinmollenhour / imap_learn.sh
Created November 21, 2012 21:10
IMAP Learn
#!/bin/bash
#
# IMAP Learn
#
# Copyright 2012 Colin Mollenhour (http://colin.mollenhour.com)
#
###############################################################################
#
# This script allows you to use an imap account to train your spamassassin server.
# Example script: