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 | |
| # | |
| # Run speedtest-cli and extract data from csv in useful format for bash scripts | |
| # | |
| # Copyright (C) 2022 Michael T. Babcock -- Licensed LGPL-2.0-or-later | |
| import csv | |
| import subprocess | |
| def speedtest_parse(data): |
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 | |
| # 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: |
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 | |
| 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): |
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
| #!/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 |
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 <mtb-code@mikebabcock.ca> | |
| # 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 "{}" ";" |