Skip to content

Instantly share code, notes, and snippets.

View JonathonReinhart's full-sized avatar

Jonathon Reinhart JonathonReinhart

View GitHub Profile
@JonathonReinhart
JonathonReinhart / powerline.md
Last active December 14, 2021 23:13
Installing Powerline on Debian

First, install powerline:

$ sudo apt install powerline

Optionally consult docs:

$ less /usr/share/doc/powerline/README.Debian

Enable in ~/.bashrc:

@JonathonReinhart
JonathonReinhart / findoldpy.py
Created August 7, 2021 06:05
Find Python scripts which use an old Python shebang
#!/usr/bin/env python3
import os
from pathlib import Path
import sys
bad_shebangs = {
'/usr/bin/python',
'/usr/bin/env python',
}
@JonathonReinhart
JonathonReinhart / data.txt
Created April 2, 2021 22:03
Are multiple MAP_PRIVATE mappings of the same file, in the same process, still private?
0123456789ABCDEF
@JonathonReinhart
JonathonReinhart / google_dns_thing.py
Created February 19, 2021 05:29
Fetch all Google mail netblocks
#!/usr/bin/env python3
import dns.resolver
from ipaddress import IPv4Network, IPv6Network, ip_address
GOOGLE_NETBLOCKS = [
'_netblocks.google.com',
'_netblocks2.google.com',
'_netblocks3.google.com',
]
@JonathonReinhart
JonathonReinhart / .env
Last active January 4, 2021 02:55
phpdotenv unset variable demo
# A simple, constant env var
CONST='A constant env var'
# Derived from another variable
DERIV="I came from ${CONST} with some more"
# An environment variable we expect to be set on the outside
EXT_SET=${ENV_EXT_SET}
# An environment variable we expect *not* to be set on the outside
@JonathonReinhart
JonathonReinhart / decrypt-pfsense-config.sh
Created November 5, 2020 09:17
Decrypt pfSense encrypted config backups
#!/bin/bash
# Adapted from https://forum.netgate.com/topic/139561
set -o pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: $(basename $0) <encrypted-config>"
exit 1
fi
inpath="$1"
tmpout="$(mktemp)"
@JonathonReinhart
JonathonReinhart / docker-compose.yml
Last active June 1, 2023 21:39
Mysql docker image: Always run initialization scripts
version: '2'
services:
# MySQL Database
db:
image: mysql:5.6
volumes:
- ./data/mysql:/var/lib/mysql
- ./mysql-entrypoint.sh:/custom-entrypoint.sh:ro
@JonathonReinhart
JonathonReinhart / ANSI.md
Last active September 17, 2020 19:14 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1b
  • Decimal: 27
@JonathonReinhart
JonathonReinhart / compatrand.py
Last active September 1, 2020 00:46
Python 2.7, 3 compatible random seeding
from __future__ import print_function
import random
import sys
class CompatibleRandom(random.Random):
# Inspired by https://stackoverflow.com/a/55800424/119527
def seed(self, a):
if sys.version_info >= (3, 2):
super(CompatibleRandom, self).seed(a, version=1)
else:
@JonathonReinhart
JonathonReinhart / ve.sh
Created August 18, 2020 01:07
Bash function for easy virtualenv activation
# Put this in your .bashrc or .bash_aliases
# List virtual envs
function list-virtualenvs() {
for d in *; do
if [[ -d "${d}" && -f "${d}/bin/activate" ]]; then
echo "${d}"
fi
done
}