Skip to content

Instantly share code, notes, and snippets.

Ondřej Surý oerdnj

Block or report user

Report or block oerdnj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View list-abusers
#!/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" "{}"
View nginx-deny-list
#!/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
View left_pad.h
#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 Feb 5, 2016
sshida.com ns traceroute from lettie.labs.nic.cz
View traceroute
$ 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 Dec 30, 2015
Ubuntu PPA Build scripts
View ubuntu-dists
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";;
View lsb-init-tmpfiles
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";
View gist:5ad77e9740e376d732e6
--- 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.
#
View 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:

You can’t perform that action at this time.