Skip to content

Instantly share code, notes, and snippets.

View bigntallmike's full-sized avatar

Michael T. Babcock bigntallmike

View GitHub Profile
@bigntallmike
bigntallmike / iptables.txt
Created January 6, 2021 17:57
iptables ipsec router basics
-t filter -A INPUT -i lo -j ACCEPT
-t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-t filter -A INPUT -p esp -j ACCEPT
-t filter -A INPUT -p udp --dport 500 -j ACCEPT
-t filter -A INPUT -p udp --dport 4500 -j ACCEPT
-t filter -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
# any other globally available services
-t filter -N INPUT-LAN
-t filter -A INPUT -i $INTIF -j INPUT-LAN
-t filter -A INPUT-LAN -p udp --dport bootps -j ACCEPT
@bigntallmike
bigntallmike / gist:ab977f7a7a516def6090d1cd4fe4ccbb
Created April 7, 2021 20:07
Removing old recycling from samba
find /home -type d -name ".recycle.*" -exec tmpwatch -m 30d "{}" ";"
@bigntallmike
bigntallmike / shadowgroupfix.py
Created June 2, 2021 15:22
Needed a script to remove entries from gshadow that weren't in groups
#!/usr/bin/python3
#
# After editing /etc/groups, generate a gshadow without the missing entries
def main():
groups = []
for groupname, other in readgroupnames("/etc/group"):
groups.append(groupname)
print(groups)
@bigntallmike
bigntallmike / gist:c81debe0f24f4640b340d0f46222a230
Created July 6, 2021 20:43
Basic QoS Settings Scripts for calling from Network Manager
# /etc/sysconfig/QOSDATA:
# Specify internal and external interface names and uplinks speeds
EXT="eno1"
INT="eno2"
EXTUP="10mbit"
INTUP="40mbit"
#/usr/local/libexec/qos_defaults:
#!/usr/bin/python3 -ttu
DISKINFO=("readios", "readmerges", "readsectors", "readticks",
"writeios", "writemerges", "writesectors", "writeticks",
"in_flight", "io_ticks", "time_in_queue",
"discardios", "discardmerges", "discardsectors", "discardticks",
"flushios", "flushticks")
def diskstats(disk):
with open("/sys/block/{}/stat".format(disk), "r") as diskstat:
#!/usr/bin/python3 -ttu
#
# Use exiftool to read data from image and translate to Python dictionary
#
# Copyright 2021 Michael T. Babcock <[email protected]>
# Released under MIT License, enjoy
import sys, os
from subprocess import run
import json
#!/usr/bin/python3 -ttu
#
# Off the top of my head, per https://www.youtube.com/watch?v=QPZ0pIK_wsc
for number in range(1,101):
#print("Debug: {}".format(number))
if number % 5 == 0 and number % 3 == 0:
print("fizz buzz")
continue
#!/bin/sh
#
# Make a local compressed copy of a backup file, typically being delivered by SSH
#
# Consider:
# xfsdump -l0 -M "$BACKUPNAME" -L "fullbackup" - /home | ssh $REMOTE "compressincomingbackup $BACKUPNAME"
#
# Copyright 2022 Michael T. Babcock
# Licensed to use freely under LGPL or MIT at user's discretion
@bigntallmike
bigntallmike / hammingdb.py
Created May 16, 2022 18:17
Starting hamming database
#!/usr/bin/python3 -ttu
class hamming_db:
def __init__(self, itemlen):
self._itemlen = itemlen
self._itemlist = []
# List of dictionaries, containing entries from itemlist that match
self._positiondb = [{} for _ in range(self._itemlen)]
def add(self, item):
#!/usr/bin/python3 -ttu
# Quick massage of cut'n'paste data from Royal Bank of Canada statement data:
import string
import sys
Months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
tabcount = 0
for data in sys.stdin: