Skip to content

Instantly share code, notes, and snippets.

@lgelo
lgelo / issue28.vtc
Created November 26, 2014 14:03
Test case for libvmod_cookie issue #28
varnishtest "Test issue #28"
server s1 {
rxreq
txresp
} -repeat 40 -start
varnish v1 -vcl+backend {
import cookie from "${vmod_topbuild}/src/.libs/libvmod_cookie.so";
@lgelo
lgelo / rate_limiter.py
Created October 6, 2014 09:29
Simple rate limiter based on token bucket algorithm
#!/usr/bin/env python
from time import time
from threading import Lock
class RateLimiter:
"""
An implementation of rate limiter based on token bucket algorithm.
Original implementation:
@lgelo
lgelo / git-export.sh
Last active August 29, 2015 14:01
Export branch from git repository and preserve existing file listed in variable or .gitattributes
#!/bin/bash
REPO="[email protected]:lgelo/demo.git"
BRANCH="master"
TARGET="/srv/app/demo"
PRESERVE=( settings.py )
STAGING=$(mktemp -d)
CWD=${PWD}
@lgelo
lgelo / lsi-bbu-autolearn
Last active August 29, 2015 13:57
LSI Battery Backup Unit (BBU) Autolearn status
#!/usr/bin/env bash
abort() { echo -e "\nERROR: $1" >&2; exit 1; }
usage() { echo -e "\nUsage:\n$0 [-h] | [-s on|off] [-a <adapter>]\n"; exit 0; }
if [ "$(whoami)" != root ] ; then
abort 'Please run this script as root.'
fi
MEGACLI=$(which megacli) || abort 'megacli not found in the path.'
@lgelo
lgelo / diskinfo.py
Created February 7, 2014 16:00
Linux disk drive information
#!/usr/bin/env python
"""
Linux disk drive information: model, serial, firmare version
"""
import sys, os, fcntl, struct, glob
def list_devices(pattern = 'sd*'):
return [os.path.basename(d) for d in glob.glob('/sys/block/' + pattern)]