Skip to content

Instantly share code, notes, and snippets.

View noahbailey's full-sized avatar
🐡

Noah Bailey noahbailey

🐡
View GitHub Profile
@noahbailey
noahbailey / focalyzer.py
Created November 24, 2023 20:14
A simple script to determine which focal length lenses you use most often
#!/usr/bin/env python3
from PIL import Image
from PIL.ExifTags import TAGS
import glob
import os
import sys
import math
#EXIF attribute identifier for "FocalLength"
#!/bin/bash
set -e
FMT="${1##*.}"
FILE=$(basename $1 .$FMT)
DIR=$(dirname $1)
ISO=$(exiftool "$DIR/$FILE.$FMT" -t -ISO | cut -f2)
echo "$FILE.$FMT :: Using ISO $ISO"
@noahbailey
noahbailey / blocklist_nginx.sh
Last active November 25, 2022 13:54
Nginx blocklist script
#!/bin/bash
# Ensure list exists
/usr/sbin/ipset list scanners 2>&1> /dev/null || \
/usr/sbin/ipset create scanners hash:ip hashsize 4096 counters
# IPs that hit the 'spam' log >10 times get banned:
for file in /var/log/nginx/spam.log*; do
if [[ "$file" != *"gz" ]]; then
awk '{print $1}' $file
#!/bin/bash
set -euo pipefail
# (c) Noah Bailey, 2022
#
# This script addresses CVE-2022-26134 for Confluence Server
# See: https://confluence.atlassian.com/doc/confluence-security-advisory-2022-06-02-1130377146.html
#
# ASSUMPTIONS
# This script makes several assumptions about your system:
//get the stdin when piping data into a go program
func getPipe() string {
var lines string
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
input := scanner.Text()
lines += input
}
return lines
}
@noahbailey
noahbailey / speedmon.sh
Created June 19, 2021 18:55
Speedtest to ElasticSearch
#!/bin/bash
# ElasticSearch server passed in as CLI param
# Example: ./speedmon.sh elastic-xy.gablogian.org
ELASTICSEARCH_SERVER="$1"
# Index suffix for current week of year
DATEFMT=$(date +%Y.%V)
# Select a random server from the 10 closest:
#!/bin/bash
SERVER_IP="192.168.122.200"
SERVER_PORT="5000"
sudo apt-get install -y collectd-core
cat << EOF | sudo tee /etc/collectd/collectd.conf
BaseDir "/var/lib/collectd"
PIDFile "/run/collectd.pid"
@noahbailey
noahbailey / nat-lb-config.sh
Created April 30, 2021 02:54
Configure IPtables NAT forwarding with Kubernetes ingress + load balancer
#!/bin/bash
set -euo pipefail
LOADBAL_SVC_IP=$(kubectl -n ingress-nginx get service ingress-nginx-controller \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}')
cat << EOF | ssh nat_update@firewall tee /etc/iptables/nat.rules
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
@noahbailey
noahbailey / kubeprep.sh
Last active May 2, 2021 01:00
Install the prereqs for Kubelet
#!/bin/bash
set -eo pipefail
# Load the kernel module
modprobe br_netfilter
cat <<EOF | tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
@noahbailey
noahbailey / install-docker.sh
Last active August 26, 2020 19:02
Quick and dirty script to get Docker installed on Ubuntu boxes...
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"