Skip to content

Instantly share code, notes, and snippets.

View witscher's full-sized avatar

David Heidt witscher

  • Karlsruhe, Germany
View GitHub Profile
# Request Limiter checking multiple values with small footprint
# if referer is not set
map $http_referer $limit_referer {
default "";
"" "1";
"-" "1";
}
# if custom parameter is not set. i.e. you always expect urls like "/tracker?campaignid=1234"
@witscher
witscher / redis-stats
Last active August 29, 2015 14:15 — forked from zircote/redis-stats
#!/usr/bin/env python
import redis
import statsd
import time
import argparse
import logging
import sys
import os
@witscher
witscher / gist:3957793
Created October 26, 2012 09:16
custom nginx naxsi build instruction on Ubuntu 12.04
echo "deb http://nginx.org/packages/ubuntu/ precise nginx" > /etc/apt/sources.list.d/nginx.list
echo "deb-src http://nginx.org/packages/ubuntu/ precise nginx" >> /etc/apt/sources.list.d/nginx.list
wget -O - http://nginx.org/keys/nginx_signing.key | apt-key add -
apt-get update
cd /usr/local/src
apt-get install build-essential libpcre3-dev zlib1g-dev libssl-dev
apt-get source nginx
wget http://naxsi.googlecode.com/files/naxsi-core-0.48.tgz
tar -xvzf naxsi-core-0.48.tgz
cd nginx-1.2.4/
@witscher
witscher / unicorn.conf
Created July 27, 2012 13:40
Upstart script for unicorn, bundler and a user contained rvm installation
description "Unicorn"
# starting unicorn with bundler, and a user contained rvm:
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
chdir /path/to/current
@witscher
witscher / old-tomcat-threads
Created July 17, 2012 14:34 — forked from wataru420/old-tomcat-threads
Tomcat7 munin plugins
if($xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadsBusy'} &&
$xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadCount'}) {
print "busy.value " . $xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadsBusy'} . "\n";
print "idle.value " .
($xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadCount'} -
$xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadsBusy'}) . "\n";
} else {
print "busy.value U\n";
print "idle.value U\n";
}
@witscher
witscher / gist:3011497
Created June 28, 2012 13:49
very, very simple HTTP POST upload app
# set max_body_size and http_basic_auth in your nginx config
require 'rubygems'
require 'sinatra'
get '/' do
"none ya business"
end
@witscher
witscher / tomcat.conf
Created June 13, 2012 13:24
Apache Tomcat Upstart script
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
# run as non privileged user
# add user with this command:
## adduser --system --ingroup www-data --home /opt/apache-tomcat apache-tomcat