This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Parses the output of storcli: | |
# storcli /c0 show all J | |
import sys | |
import json | |
output_dir = "." | |
data = json.load(sys.stdin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP | |
-------------------------------------------------------------- | |
Total Iterations: 10,000,000 | |
time(): 0.73976612091064 seconds (13,517,785/sec) | |
microtime(): 4.2245488166809 seconds (2,367,116/sec) | |
microtime(true): 1.2555038928986 seconds (7,964,929/sec) | |
HHVM | |
-------------------------------------------------------------- | |
Total Iterations: 10,000,000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set PHP-FPM pool workers CPU affinity so each worker gets one CPU core | |
# Note that FPM recycles threads, so you'll need to run this on cron periodically | |
# Author: Steve Kamerman | |
CPUS=$(grep -c CPU /proc/cpuinfo) | |
FPM_PIDS=$(ps auxw | grep php-fpm | grep pool | awk '{ print $2; }') | |
if [ "$FPM_PIDS" = "" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# This script will DESTROY /dev/xvdb and /dev/xvdc and remount them | |
# for Docker temp and volume storage. | |
# It is intended for EC2 instances with 2 ephemeral SSD instance stores | |
# like the c3.xlarge instance type. | |
service docker stop || true | |
# Setup Instance Store 0 for Docker Temp | |
# (set in /etc/default/docker) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper functions for dealing with Docker containers | |
# Returns "missing", "stopped" or "running" | |
get_container_state() { | |
local CONTAINER_NAME=$1 | |
# Faster check to see if the container *might* exist | |
CONTAINER_MISSING=$(container_does_not_exist "$CONTAINER_NAME") | |
if [[ $CONTAINER_MISSING = "true" ]]; then | |
echo -n "missing" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package something | |
import ( | |
"bytes" | |
"errors" | |
"fmt" | |
"io/ioutil" | |
"net/url" | |
"path" | |
"sync" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$loops = 100000; | |
$str = "whois foobar"; | |
$algos = hash_algos(); | |
$algo_padding = array_reduce($algos, function($carry, $val) { | |
$len = strlen($val); | |
if ($len > $carry) { | |
$carry = $len; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# HAProxy Performance Statistics | |
# by Steve Kamerman | |
# | |
# To use, pipe your HAProxy log with timing information (like "0/0/1/1/3 200") to | |
# this script. It will output min, max, med, avg and a latency distribution graph. | |
# | |
# Info on timing logging in HAProxy: http://code.google.com/p/haproxy-docs/wiki/TimingEvents | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Start this script before you start NGINX, so it is ready and waiting for log data. | |
# You should start it in the background with & or run it from supervisord or something. | |
# If the port is above 1024, you can run this script as a non-root user (recommended). | |
# | |
# It listens for raw Syslog data over UDP, parses is, aggregates it, and writes | |
# it to a file every flush_interval seconds. The output file format looks like this: | |
# key<TAB>value | |
# Here is an example (note that the delimiter is actually TAB, not a space): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A better bash-git prompt using git-prompt | |
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh | |
LIGHT_WHITE="\[\033[1;37m\]" | |
WHITE="\[\033[0;37m\]" | |
GRAY="\[\033[1;30m\]" | |
BLACK="\[\033[0;30m\]" | |
RED="\[\033[0;31m\]" | |
LIGHT_RED="\[\033[1;31m\]" | |
GREEN="\[\033[0;32m\]" |