This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find /home -type d -name ".recycle.*" -exec tmpwatch -m 30d "{}" ";" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 -ttu | |
# | |
# For a list in format hh:mm:ss - hh:mm:ss, where hh: and mm: are optional, return seconds instead | |
# | |
# Free to use or critique, its not complex enough for licensing | |
import re | |
import sys | |
# Re-formatted for better visual parsing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from configparser import ConfigParser | |
def backup_mysql(): | |
config = ConfigParser() | |
config.read("/etc/sysconfig/mysqldump") | |
config = config['mysqldump'] | |
mysql_dump = ['mysqldump', | |
'--user=%(username)s' % config, | |
'--password=%(password)s' % config, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /var/qmail/control/notlshosts | |
cat /var/log/qmail/current \ | |
| sed -n 's/.*\delivery \([0-9]\+\):.*TLS_connect_failed.*/\1/p' \ | |
| xargs -n1 --replace={} grep "{}" /var/log/qmail/current \ | |
| grep -B1 TLS \ | |
| sed -n 's/.*to remote .*@\(.*\)/\1/p' \ | |
| sort | uniq \ | |
| xargs -n1 dnsqr mx \ | |
| grep answer: | awk '{print $6}' \ | |
| xargs -n1 touch |