Skip to content

Instantly share code, notes, and snippets.

View evindunn's full-sized avatar

Evin Dunn evindunn

  • Zoom Video Communications
  • Flagstaff, AZ
View GitHub Profile
@evindunn
evindunn / get_firewalld_state.py
Last active December 20, 2023 19:41
Poll Firewalld State as JSON
#!/usr/bin/env python3
import dbus
import json
FIREWALLD_BUS = "org.fedoraproject.FirewallD1"
FIREWALLD_RUNTIME_OBJ = "/org/fedoraproject/FirewallD1"
FIREWALLD_CONFIG_OBJ = "/org/fedoraproject/FirewallD1/config"
@evindunn
evindunn / crypto_worker.py
Last active June 27, 2022 23:29
Async argon2-ffi
from asyncio import wrap_future, get_running_loop
from concurrent.futures import ProcessPoolExecutor
from multiprocessing import cpu_count, Lock
from atexit import register as atexit_register
from argon2 import PasswordHasher
from argon2.exceptions import VerifyMismatchError
from os import getpid
@evindunn
evindunn / gcp_firewalld_ipset.py
Created May 26, 2022 17:16
Generates a firewalld ipset from the current list of GCP IPs
#!/usr/bin/env python3
import xml.etree.ElementTree as ET
from urllib.request import urlopen
from json import loads as json_loads
from xml.dom import minidom
def main():
@evindunn
evindunn / clock.py
Last active May 12, 2022 06:50
RPLCD World Clock
#!/usr/bin/env python3
from RPLCD.i2c import CharLCD
from pytz import timezone, utc
from datetime import datetime
from time import sleep, time as get_ts
from concurrent.futures import ThreadPoolExecutor
I2C_EXPANDER = "PCF8574"
#!/bin/bash
if [ $# -lt 1 ]; then
echo Provide a date to convert
exit 1
fi
# Provide 'Fri 18 Feb 2022 05:30:00 PM PST'
DATE=$1
@evindunn
evindunn / cockroach.docker-compose.yml
Last active December 6, 2021 20:18
CockroachDB cluster in docker-compose
# See https://www.cockroachlabs.com/docs/v21.2/start-a-local-cluster-in-docker-mac.html
version: "3.9"
services:
roach1:
image: "cockroachdb/cockroach:v21.2.2"
container_name: taxonTree-roach1
hostname: roach1
networks: [ roachnet ]
volumes: [ "roach1-data:/cockroach/cockroach-data" ]
command:
@evindunn
evindunn / temp_server.py
Last active September 28, 2021 20:38
DHT11 Temperature Sensor as HTTP Service
#!/usr/bin/env python3
from argparse import ArgumentParser
from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
from json import dumps as json_dumps
from threading import Thread, RLock
from time import sleep
import Adafruit_DHT
@evindunn
evindunn / lcd_server.py
Last active September 28, 2021 21:33
Raspberry Pi i2C LCD Server
#!/usr/bin/env python3
from RPLCD.i2c import CharLCD
from argparse import ArgumentParser
from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
from json import dumps as json_dumps
from sys import stderr
from threading import Lock
from board import I2C
@evindunn
evindunn / json2yaml.py
Last active June 25, 2021 22:35
json2yaml.py
#!/usr/bin/env python3
# Uses PyYAML>=0.2.5
from yaml import dump as yaml_dump
from json import load as json_load, JSONDecodeError
from argparse import ArgumentParser
from os.path import exists as path_exists
from sys import exit, stderr
#!/usr/bin/env python3
from urllib.request import urlretrieve
from tempfile import NamedTemporaryFile, TemporaryDirectory
from zipfile import ZipFile
from glob import iglob
from os.path import join as path_join
from xml.etree import ElementTree
from json import dumps as json_stringify
from re import sub as regex_sub