Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
#
# Memcache monitoring plugin for server density
# http://www.serverdensity.com/
#
# Depends on python-memcached
# http://www.tummy.com/Community/software/python-memcached/
# easy_install python-memcached
#
# based on:
@rwohleb
rwohleb / gist:5120844
Last active December 14, 2015 17:18 — forked from msonnabaum/gist:1306569
XHProf on PHP5.3 in MAMP 1.9
wget http://pecl.php.net/get/xhprof-0.9.2.tgz
tar -xzf xhprof-0.9.2.tgz
cd xhprof-0.9.2/extension
/Applications/MAMP/bin/php5.3/bin/phpize
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
./configure
make
cp modules/xhprof.so $(/Applications/MAMP/bin/php5.3/bin/php-config --extension-dir)/
echo "extension=xhprof.so" >> /Applications/MAMP/conf/php5.3/php.ini
#!/bin/bash
DIR="/path/to/big/files"
find $DIR -type f -exec md5sum {} \; | sort > /tmp/sums-sorted.txt
OLDSUM=""
IFS=$'\n'
for i in `cat /tmp/sums-sorted.txt`; do
NEWSUM=`echo "$i" | sed 's/ .*//'`
UUID = {
generateQuad : function() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
},
generateGuid : function() {
return (this.generateQuad() + this.generateQuad() + "-"
+ this.generateQuad() + "-" + this.generateQuad() + "-"
+ this.generateQuad() + "-" + this.generateQuad() + this.generateQuad() + this
.generateQuad());
}
@rwohleb
rwohleb / gist:6733890
Created September 27, 2013 19:23
Python fractal
print (lambda r,w,h:"\n".join("".join((" ","▲")[c]
for c in s)for s in reduce(lambda a,y:a+[[r>>(a[y][x-1]*4+a[y][x]*2+a[y][(x+
1)%w])&1for x in range(w)]],range(h),[[0]*(w/2)+[1]+[0]*(w/2)])))(90,63,31)
@rwohleb
rwohleb / jquery.nap-1.0.0.js
Created November 4, 2013 02:35
jQuery nap 1.0.0 www.frebsite.nl Copyright (c) 2010 Fred Heusschen Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php
/*
* jQuery nap 1.0.0
* www.frebsite.nl
* Copyright (c) 2010 Fred Heusschen
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
(function($) {
$.fn.nap = function(fallAsleep, wakeUp, standbyTime) {
@rwohleb
rwohleb / badips.conf
Created February 4, 2014 06:54
Fail2ban action for reporting to BadIPs.com
# Fail2Ban action for reporting to badips.com
#
# Author: Robert Wohleb
#
[Definition]
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#! /bin/sh
### BEGIN INIT INFO
# Provides: solr
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Solr
# Description: Solr advanced search engine
### END INIT INFO
@rwohleb
rwohleb / gist:0d590e2a3cefcfa0e09f
Created October 14, 2014 21:12
Upgrade MySQL to innodb_file_per_table [FOUND, UNTESTED]
#!/bin/bash -x
if test "$USER" != "root" ; then
echo "Must be root ..."
exit 1
fi
mysql_dba=root
mysql_pass=your_mysql_dba_password
@rwohleb
rwohleb / keybase.md
Created September 29, 2016 00:23
keybase.md

Keybase proof

I hereby claim:

  • I am rwohleb on github.
  • I am rwohleb (https://keybase.io/rwohleb) on keybase.
  • I have a public key ASBWaZZ8BO8Mpddeh5xInMOPelSREyOUtkXF7OuwewpcYQo

To claim this, I am signing this object: