Skip to content

Instantly share code, notes, and snippets.

View jamesoff's full-sized avatar

James Seward jamesoff

View GitHub Profile
@jamesoff
jamesoff / read-irg.py
Created February 11, 2023 14:38
Hacked-together code to read an IRG file's image
from PIL import Image, ImageDraw
WIDTH = 180
HEIGHT = 240
im = Image.new("L", (WIDTH, HEIGHT))
with open("230119180929.irg", "rb") as in_file:
in_file.seek(0x7E)
draw = ImageDraw.Draw(im)
@jamesoff
jamesoff / disable-guardduty-k8s-everywhere.sh
Last active January 29, 2022 12:21
Disable Amazon GuardDuty's k8s feature everywhere
#!/usr/bin/env zsh
# Disable Amazon GuardDuty's k8s log parsing thing everywhere
# Assumes at most one GuardDuty detector in each region
# Docs: https://docs.aws.amazon.com/guardduty/latest/ug/kubernetes-protection.html
for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
detector=$( aws guardduty list-detectors --query DetectorIds --output text --region "$r" )
if [[ -z $detector ]]; then
@jamesoff
jamesoff / arq-backup-running.sh
Created December 12, 2020 11:56
Check if Arq 6 backup is running (for Bartender 4)
#!/usr/bin/env zsh
log_path=/Library/Logs/ArqAgent/backup
last_file=(${log_path}/*(om[1]))
if grep -q "Backup activity ended" "$last_file"; then
echo no
exit 1
fi
echo yes
#!/usr/bin/env bash
#MIT No Attribution
#
#Copyright 2020 James Seward
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this
#software and associated documentation files (the "Software"), to deal in the Software
#without restriction, including without limitation the rights to use, copy, modify,
#merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
@jamesoff
jamesoff / instance-types.sh
Created April 21, 2019 22:46
Get available instance types in a region
http https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/eu-west-2/index.json | jq '[ .products | to_entries | .[].value.attributes.instanceType | select(. != null) | scan("^[a-z0-9]+") ] | unique'
@jamesoff
jamesoff / maths.py
Created September 23, 2018 18:06
maths challenge practice
#!/usr/local/bin/python
"""Ask complicated maths questions."""
__revision__ = 1
import sys
import random
import operator
@jamesoff
jamesoff / fizzbuzz.py
Created September 23, 2018 17:58
fizzbuzz without comparison operator
"""
fizzbuzz.py
Implement fizzbuzz without using a comparison operator.
Because I said I could.
"""
import sys
@jamesoff
jamesoff / simplemonitor.service
Created April 15, 2018 18:41
Sample simplemonitor systemd config
[Service]
Type=simple
ExecStart=/usr/bin/python monitor.py
WorkingDirectory=/home/james/src/simplemonitor
User=james
[Install]
WantedBy=multiuser.target

Keybase proof

I hereby claim:

  • I am jamesoff on github.
  • I am jamesoff (https://keybase.io/jamesoff) on keybase.
  • I have a public key ASBSO3lGnQgxcM5X_Ze4NCcJMHoRwGx9GRzpsmj-jxJAXgo

To claim this, I am signing this object:

@jamesoff
jamesoff / compare-bucket.sh
Last active September 25, 2016 19:01
Script to compare local file checksums with those in S3.
#!/bin/bash
missing_s3md5() {
echo "Can't find/exec s3md5"
echo "Get it from https://github.com/antespi/s3md5 and put in PATH, or export S3MD5 to point at it."
exit 1
}
S3MD5=${S3MD5:-$( which s3md5 )}