Skip to content

Instantly share code, notes, and snippets.

@defanator
defanator / sentry-fake.py
Created March 2, 2021 08:48
fake wsgi app to act as a sentry API receiver to debug raven/sentry-sdk locally
#!/usr/bin/env python3
import ujson
import zlib
import gzip
SVCPORT = 9999
def application(environ, start_response):
environ_summary = "ENVIRON:\n\n" + "\n".join(["{0}: {1}".format(k, environ[k]) for k in sorted(environ.keys())]) + "\n"
@defanator
defanator / flaskapp-jaeger.py
Created March 22, 2021 14:36
Sample app demonstrating nginx + opentracing with Flask
#!/usr/bin/env python3
import hashlib
import logging
from jaeger_client import Config
from flask_opentracing import FlaskTracing
from flask import Flask, request
from werkzeug.debug import get_current_traceback
#!/usr/bin/env python3
"""smtptest.py: command-line smtp test mail sender
https://github.com/turbodog/python-smtp-mail-sending-tester
Usage: python smtptest.py [options] fromaddress toaddress serveraddress
Examples:
python smtptest.py [email protected] [email protected] mail.example.com
python smtptest.py --debuglevel 1 --usetls -u bob -p xyzzy "Bob <[email protected]>" [email protected] mail.example.com
@defanator
defanator / generate-xml.sh
Created May 5, 2021 09:57
Generate valid XML with repeatable sequence of data
#!/bin/sh
NUMITER=1
if [ -n "$1" ]; then
NUMITER=$1
fi
cat <<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
@defanator
defanator / Makefile.xpadneo-osmc-aarch64
Last active December 20, 2021 08:43
Building xpadneo kernel driver under OSMC on Raspberry Pi 4
#!/usr/bin/make -f
KERNEL_VERSION=$(shell uname -r)
KERNEL_HEADERS_DIR=/usr/src/rbp464-headers-$(KERNEL_VERSION)
KERNEL_SOURCES_DIR=/usr/src/rbp464-source-$(KERNEL_VERSION)
CHROOT_DIR=/opt/osmc-tc/aarch64-toolchain-osmc
ifeq ($(shell id -u), 0)
SUDO=
OUSER=$(SUDO_USER)
@defanator
defanator / error.log
Created December 28, 2021 11:30
nginx/1.21.5 and ModSecurity-nginx built with PCRE2 - memory leaks
This file has been truncated, but you can view the full file.
2021/12/28 11:22:36 [notice] 25136#25136: ModSecurity-nginx v1.0.2 (rules loaded inline/local/remote: 0/1818/0)
2021/12/28 11:22:36 [notice] 25136#25136: using the "epoll" event method
2021/12/28 11:22:36 [notice] 25136#25136: nginx/1.21.5
2021/12/28 11:22:36 [notice] 25136#25136: built by gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
2021/12/28 11:22:36 [notice] 25136#25136: OS: Linux 5.4.0-91-generic
2021/12/28 11:22:36 [notice] 25136#25136: getrlimit(RLIMIT_NOFILE): 131072:131072
2021/12/28 11:22:36 [notice] 25137#25137: start worker processes
2021/12/28 11:22:36 [notice] 25137#25137: start worker process 25139
2021/12/28 11:23:51 [notice] 25137#25137: signal 1 (SIGHUP) received from 25150, reconfiguring
2021/12/28 11:23:51 [notice] 25137#25137: reconfiguring
@defanator
defanator / error.log
Created December 28, 2021 12:55
nginx/1.21.5 and ModSecurity-nginx built with PCRE1 - memory leaks
2021/12/28 12:47:31 [notice] 76906#76906: ModSecurity-nginx v1.0.2 (rules loaded inline/local/remote: 0/1818/0)
2021/12/28 12:47:31 [notice] 76906#76906: using the "epoll" event method
2021/12/28 12:47:31 [notice] 76906#76906: nginx/1.21.5
2021/12/28 12:47:31 [notice] 76906#76906: built by gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
2021/12/28 12:47:31 [notice] 76906#76906: OS: Linux 5.4.0-91-generic
2021/12/28 12:47:31 [notice] 76906#76906: getrlimit(RLIMIT_NOFILE): 131072:131072
2021/12/28 12:47:31 [notice] 76907#76907: start worker processes
2021/12/28 12:47:31 [notice] 76907#76907: start worker process 76909
2021/12/28 12:50:53 [notice] 76907#76907: signal 1 (SIGHUP) received from 76927, reconfiguring
2021/12/28 12:50:53 [notice] 76907#76907: reconfiguring
@defanator
defanator / query-phpfpm-status.sh
Created February 4, 2022 16:00
Query php-fpm status from multiple instances/sockets
#!/bin/bash
# vim:sw=4:ts=4:et:
ENDPOINTS="/run/php/php7.4-fpm1.sock:/status1 /run/php/php7.4-fpm2.sock:/status2 /run/php/php7.4-fpm3.sock:/status3"
ENDPOINTS="$ENDPOINTS /run/php/php8.0-fpm1.sock:/status1 /run/php/php8.0-fpm2.sock:/status2 /run/php/php8.0-fpm3.sock:/status3"
for endpoint in $ENDPOINTS; do
socket=${endpoint%:*}
script=${endpoint##*:}
sudo -u nginx SCRIPT_NAME=${script} SCRIPT_FILENAME=${script} QUERY_STRING=full REQUEST_METHOD=GET cgi-fcgi -bind -connect ${socket}
@defanator
defanator / signing-gpg-keys.md
Created June 20, 2022 14:34 — forked from F21/signing-gpg-keys.md
Signing someone's GPG key

This is a quick guide of the commands we use to sign someone's GPG key in a virtual key signing party.

Note: The steps cover only the technical aspects of signing someone's key. Before signing someone's key, you must verify their identity. This is usually done by showing government-issued ID and confirming the key's fingerprint

The commands will work for both GPG and GPG2.

I use Julian's key for the examples. His key id is 2AD3FAE3. You should substitute with the appropriate key id when running the commands.

Signing the key

  1. List the keys currently in your keyring: gpg --list-keys.
@defanator
defanator / find-images.sh
Last active October 20, 2022 11:38
Find AWS AMI images of popular distros
#!/bin/bash
LIMIT=1
usage() {
echo "usage: $(basename $0) [-l N] distro arch [arch...]" >&2
exit 1
}
rhel() {