Skip to content

Instantly share code, notes, and snippets.

View tayopal's full-sized avatar

Taylor Opal tayopal

View GitHub Profile
#!/usr/bin/env python3
# This is a little test of the game theory problem posed in this scene:
# https://www.youtube.com/watch?v=CYyUuIXzGgI
import random
class Door:
GOAT = 1
CAR = 2
@tayopal
tayopal / ssh-signed.zshrc
Created December 21, 2023 20:57
Check signed SSH cert for expiration
# .zhsrc
function signed {
expiry=$(ssh-keygen -L -f ~/.ssh/id_rsa-cert.pub | grep Valid | awk '{ print $5 }')
expiry_epoch=$(date -j -f "%Y-%m-%dT%H:%M:%S" "${expiry}" "+%s")
current_epoch=$(date "+%s")
if [ $current_epoch -gt $expiry_epoch ]; then
echo $fg[red] "SSH -"
return -1
else
(( seconds_left = $expiry_epoch - $current_epoch ))
#! /usr/bin/env zsh
function saws()
{
valid_profiles=($(~/.local/bin/parse_aws_config))
if [ -z "$1" ]; then
# Maybe just echo what profile is _still_ active
echo "Current profile is: $AWS_PROFILE"
return 0
fi
#! /usr/bin/env python3
import configparser
import os
aws_config_filepath = os.path.expanduser('~/.aws/config')
config = configparser.ConfigParser()
config.read(aws_config_filepath)
@tayopal
tayopal / ls_profiles.py
Last active September 13, 2022 16:45
Print "export" statements for AWS_PROFILE for profiles in ~/.aws/config
#!/usr/bin/env python3
### Parse AWS config
# Cluster roles by environment and alphabetize
# Print easily copy/pasta export statements for env selection
# Allow selection of internal or customer environments
### Example AWS config that works with this:
# [profile sso]