Skip to content

Instantly share code, notes, and snippets.

View bigntallmike's full-sized avatar

Michael T. Babcock bigntallmike

View GitHub Profile
@bigntallmike
bigntallmike / speedtest-data.py
Created August 17, 2022 17:30
Needed speed test data I could parse in a bash script with eval
#!/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):
@bigntallmike
bigntallmike / adventofcode2022day9.py
Created December 9, 2022 23:45
Advent of Code 2022 Day 9 Python -- no optimization
#!/usr/bin/python3
import sys
class location:
def __init__(self, x, y):
self.x = x
self.y = y
def deltax(self, other):
#!/bin/bash
SIGFILE="myfiles-`date +%Y%m%d`.lst"
find -type f -exec sha256sum "{}" ";" > $SIGFILE
gpg --detach-sig $SIGFILE
@bigntallmike
bigntallmike / procnetdata.py
Last active January 2, 2023 19:14
Wrote a quick class to parse /proc/net/dev data
#!/usr/bin/python3 -ttu
#
# Class to read and parse /proc/net/dev quickly and make the data available as a dictionary
# and/or json.
#
# Licensed: MIT. Just use it. Technically Copyright (C) 2022 Michael T. Babcock
from collections import OrderedDict
import re
@bigntallmike
bigntallmike / gist:0624858d4eead91d90baebfee4dcb94d
Last active November 17, 2023 22:11
Steps to reinstall RPMs with zero-length libraries
# With root file system mounted at /oldsys:
# Use at own risk!!
find /oldsys/usr/lib -size 0 >/tmp/badlibs
cat /tmp/badlibs \
| xargs --replace={} rpm --root /oldsys -qf "{}" \
| grep -v "not owned" \
| sort \
| uniq \
| xargs dnf -y --installroot=/oldsys reinstall
#!/usr/bin/python3
#
# Instead of just typing:
print("hello world")
# Do this (main is a placeholder; the actual thing it does is better):
def main():
#!/usr/bin/python3
#
# We want to open the file specified and read the data out of it.
import sys
def old_way(filename):
fd = open(filename)
if not fd:
print("error of some kind")
sys.exit(1)