Skip to content

Instantly share code, notes, and snippets.

View kainz's full-sized avatar

Bryon Roché kainz

  • Asteroid N° B-2¹2
View GitHub Profile
@kainz
kainz / golang-github-prometheus-common:debian:patches:0004-Disable-Conntrack-For-Loop-Break.patch
Created July 8, 2021 05:24
build loop fix for http_config conntrack in golang-git-hub-prometheus-common (needs to be worked into a build profile and probably alternate tag conditional build)
diff --git a/debian/patches/0004-Disable-Conntrack-For-Loop-Break.patch b/debian/patches/0004-Disable-Conntrack-For-Loop-Break.patch
new file mode 100644
index 0000000..5e3d203
--- /dev/null
+++ b/debian/patches/0004-Disable-Conntrack-For-Loop-Break.patch
@@ -0,0 +1,26 @@
+diff --git a/config/http_config.go b/config/http_config.go
+index 4dd8875..38a50dd 100644
+--- a/config/http_config.go
++++ b/config/http_config.go
@kainz
kainz / gist:9895bc8f2f04eab5c629932c69e2b501
Created November 10, 2019 09:32
systemd <242 limit_memlock fix
Only in systemd-240-mine: build-deb
Only in systemd-240-mine: build-udeb
Only in systemd-240-mine/debian: .debhelper
Only in systemd-240-mine/debian: debhelper-build-stamp
Only in systemd-240-mine/debian: files
Only in systemd-240-mine/debian: install
Only in systemd-240-mine/debian: libnss-myhostname
Only in systemd-240-mine/debian: libnss-myhostname.debhelper.log
Only in systemd-240-mine/debian: libnss-myhostname.substvars
Only in systemd-240-mine/debian: libnss-mymachines
#!/bin/bash
set -e
restoreboot=0
if [ "$1" == "restoreboot" ]; then
restoreboot=1
fi
#!/bin/sh
[[ -n "$1" && -n "$2" ]] || { echo "Usage: $0 <interface to grab multicast packets from> <interface to send modified packets to> [target MAC address 1] [target MAC address 2] ..."; exit 0 ; }
IIF=$1
OIF=$2
shift
shift
SRC_MACADDR=`ip link show $OIF | awk '/ether/ {print $2}' | tr -d :`
"\n".join([ ":".join([str(c[0]), "".join([ c[1][i] for i in filter(lambda t: c[0] % t == 0,c[1].keys() ) ]) ]) for c in [ (x, {3: 'Fizz', 5: 'Buzz'}) for x in range(100) ] ])
# to make it even worse
[ ":".join((str(n), re.sub(r'^((?:Fizz|Buzz){0,2}).+$', r'\1', reduce(lambda i, a: re.sub(r'((?<!x)(x{{{0}}})+(?!x))$'.format(a[0]),r'{}\1'.format(a[1]), i), ( (3, 'Fizz'), (5, 'Buzz') ) , 'x' * n )), )) for n in xrange(100) ]
# Still tricky, but not nearly so horrible
[ (x, "".join([ v for k,v in {3: 'Fizz', 5: 'Buzz'}.iteritems() if x % k == 0 ])) for x in range(100)]
Why are these so horrible? Well, number two is a classic example I think of mistyping. Namely, we are generating a flat string then using a parameterized regex as a DFA to mutate the string into an annotated state, then using a final regex to separate the structure once again (if you could call it thath).
Number one is also horrible, though seemingly shorter, because it combines multiple hard-to-parse features of Python into a single line. N
from flask import Flask, make_response
app = Flask(__name__)
@app.route("/simple.png")
def simple():
import datetime
import StringIO
import random
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas