Skip to content

Instantly share code, notes, and snippets.

View oerdnj's full-sized avatar

Ondřej Surý oerdnj

View GitHub Profile
@oerdnj
oerdnj / C-RW-WP
Created March 25, 2021 20:52
BIND 9 RWLock microbenchmark
80000000 loops in 8 threads, 0.000% writes, 0.776 seconds, 103057589.869 calls/second
80000000 loops in 8 threads, 1.073% writes, 1.041 seconds, 76831839.114 calls/second
80000000 loops in 8 threads, 10.084% writes, 3.380 seconds, 23665236.300 calls/second
80000000 loops in 8 threads, 49.904% writes, 12.871 seconds, 6215495.744 calls/second
80000000 loops in 8 threads, 89.962% writes, 19.354 seconds, 4133419.336 calls/second
80000000 loops in 8 threads, 98.959% writes, 19.849 seconds, 4030351.367 calls/second
80000000 loops in 8 threads, 100.000% writes, 18.199 seconds, 4395951.724 calls/second
40000000 loops in 4 threads, 0.000% writes, 0.724 seconds, 55247550.462 calls/second
40000000 loops in 4 threads, 1.073% writes, 0.839 seconds, 47693312.921 calls/second
40000000 loops in 4 threads, 10.084% writes, 1.843 seconds, 21706382.110 calls/second
#!/bin/sh
logfile=${1:-/var/log/nginx/packages.sury.org-access.log}
file_limit=480 # can go as low as 240 in the future
deb_limit=48 # can go as low as 24 in the future
perl -n -e '/^([^ ]+) ([^ ]+) ([^ ]+) (\[[^\]]+\]) "(.*) (.*) (.*)" ([0-9\-]+) ([0-9\-]+) "(.*)" "(.*)"/; print "$1 $6\n"' -- "$logfile" | sort | uniq -c | awk -v fl="$file_limit" dl="$deb_limit" '{ if ($1 > fl || (match($3,"\.deb") && $1 > dl)) { print $2 } }' | sort -u | xargs -i printf "deny %s;\n" "{}"
#!/bin/sh
# place into /etc/logrotate.d/httpd-prerotate/nginx-deny-list
TMPF=$(mktemp /etc/nginx/deny-ip.conf.XXXXXX) && (
(list-abusers /var/log/nginx/packages.sury.org-access.log) | sort -u > "$TMPF"
if ! diff -q /etc/nginx/deny-ip.conf "$TMPF" >/dev/null; then
mv /etc/nginx/deny-ip.conf /etc/nginx/deny-ip.conf.bak
mv "$TMPF" /etc/nginx/deny-ip.conf
if nginx -q -t; then
#include <stdio.h>
#include <string.h>
/* just make sure sizeof(out) is at least sz+1 large */
#define left_pad(out, sz, s) snprintf(out, sz+1, "%.*s", sz, s)
#define left_pad_str(out, sz, s, pad) snprintf(out, sz+1, "%.*s%s", (sz < strlen(s)) ? 0 : sz - strlen(s), pad, s)
@oerdnj
oerdnj / traceroute
Created February 5, 2016 14:09
sshida.com ns traceroute from lettie.labs.nic.cz
$ traceroute 222.228.173.205
traceroute to 222.228.173.205 (222.228.173.205), 30 hops max, 60 byte packets
1 217.31.192.129 (217.31.192.129) 1.514 ms 1.480 ms 1.497 ms
2 217.31.192.253 (217.31.192.253) 1.140 ms 0.784 ms 1.143 ms
3 20ge1-3.core1.prg1.he.net (91.210.16.201) 1.825 ms 2.275 ms 1.825 ms
4 100ge8-1.core1.fra1.he.net (184.105.213.233) 32.568 ms 32.961 ms 32.949 ms
5 100ge5-2.core1.par2.he.net (72.52.92.13) 48.038 ms 48.053 ms 48.041 ms
6 100ge7-1.core1.nyc4.he.net (184.105.81.77) 97.205 ms 96.648 ms 96.320 ms
7 100ge15-2.core1.sjc2.he.net (184.105.81.213) 152.841 ms 148.932 ms 148.903 ms
8 216.218.192.234 (216.218.192.234) 160.675 ms 160.752 ms 160.773 ms
@oerdnj
oerdnj / ubuntu-dists
Created December 30, 2015 18:09
Ubuntu PPA Build scripts
case "$PPA" in
php5-5.4) DISTS="precise";;
php5-5.5) DISTS="trusty vivid wily";;
php5-5.6) DISTS="trusty vivid wily";;
php-7.0) DISTS="trusty vivid wily";;
php) DISTS="trusty vivid wily";;
apache2) DISTS="trusty vivid wily";;
bird) DISTS="precise trusty vivid wily";;
knot) DISTS="trusty vivid wily";;
knot-lts) DISTS="precise trusty vivid wily";;
do_tmpfiles() {
local type path mode user group
if [ -r "$1" ]; then
if [ -x /bin/systemd-tmpfiles ]; then
/bin/systemd-tmpfiles --create "$1"
else
while read type path mode user group; do
case "$type" in
d)
mkdir -p "$path";
--- a2query.orig 2014-10-07 11:07:12.282070121 +0000
+++ a2query 2014-10-07 11:07:45.450068895 +0000
@@ -4,7 +4,7 @@
# Copyright (C) 2012 Arno Töll <debian@toell.net>
#
# This program is licensed at your choice under the terms of the GNU General
-# Public License vserion 2+ or under the terms of the Apache Software License
+# Public License version 2+ or under the terms of the Apache Software License
# 2.0.
#
@oerdnj
oerdnj / keybase.md
Created August 20, 2014 18:58
keybase.md

Keybase proof

I hereby claim:

  • I am oerdnj on github.
  • I am oerdnj (https://keybase.io/oerdnj) on keybase.
  • I have a public key whose fingerprint is 30B9 33D8 0FCE 3D98 1A2D 38FB 0C99 B70E F4FC BB07

To claim this, I am signing this object: