Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
South Bend, IN

Sean Summers seansummers

:octocat:
South Bend, IN
View GitHub Profile
View naovid-flatcar.ign
systemd:
units:
- name: etcd2.service
enable: true
etcd:
discovery: https://discovery.etcd.io/cfb401f0c192894e72c78cbd03a65442
passwd:
users:
- name: core
ssh_authorized_keys:
@seansummers
seansummers / walk.py
Last active Aug 17, 2021
Walk a Visitor to Leaves on a Graph in Python
View walk.py
from collections.abc import MutableMapping, MutableSequence
from typing import Callable, Iterable, Union
MutableCollection = Union[MutableMapping, MutableSequence]
Visitor = Callable[[str], str] # we only support string scalars for now
def visit(value: str) -> str:
"""Visit a string scalar, and mutate it if needed before returning it."""
if len(value) > 4: # example criteria
@seansummers
seansummers / jwks2asn1.py
Last active Oct 26, 2021 — forked from JonLundy/conv.py
JWKS parsing
View jwks2asn1.py
#!/usr/bin/env python3
#
# openssl asn1parse -noout -out private_key.der -genconf <(python jwks2asn1.py private_key.json)
# openssl rsa -in private_key.der -inform der > private_key.pem
#
# rfc7517.3 : urlsafe_b64decode
# rfc7517.A.1 : ints are big-indian
#
import base64
View s3_buffered_writer.py
import contextlib
import os
import tempfile
half_lambda_memory = 10**6 * (
int(os.getenv('AWS_LAMBDA_FUNCITON_MEMORY_SIZE', '0')) / 2)
@contextlib.contextmanager
View create_ami.py
import secrets
import boto3
import cfnresponse
ec2 = boto3.resource('ec2')
def create_ami(instance_id, ami_name, description):
instance = ec2.Instance(instance_id)
View update-api-keys.sh
#! /bin/bash -xe
# This script requires `jq` and optionally `awsume`
awsume --session-name ssummers-update-api-keys # or whatever method to assume an mfa session
AWS_EXPIRING_ACCESS_KEY=$(aws configure get aws_access_key_id)
AWS_USER=$(aws sts get-caller-identity --query Arn --output text | awk -F/ '/:user/ {print $2}')
if [[ $(aws iam list-access-keys --user-name ${AWS_USER} --query '*[]|length(@)') -ne 1 ]]
then
View .gitrc
# ----------------------
# Git Aliases, mostly from https://jonsuh.com/blog/git-command-line-shortcuts/
# ----------------------
alias ga='git add'
alias gaa='git add .'
alias gaaa='git add --all'
alias gau='git add --update'
alias gb='git branch'
alias gbd='git branch --delete '
alias gc='git commit'
@seansummers
seansummers / camel_snakes.py
Created Jul 24, 2018
Python Camel Snake Conversion
View camel_snakes.py
from itertools import tee
try:
from itertools import zip_longest
except ImportError:
from itertools import izip_longest as zip_longest
def snake_parts_from_camel(name):
parts = tee(name, 2)
next(parts[1])
@seansummers
seansummers / inventory-global.template.yml
Last active May 21, 2019
AWS Configuration Tracking
View inventory-global.template.yml
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Global assets needed for Inventory Discovery
Metadata:
AWS::CloudFormation::Interface:
View 01_export_aws_managed_policies.py
import boto3
import json
client = boto3.client('iam')
paginator = client.get_paginator('list_policies')
response_iterator = paginator.paginate(Scope='AWS')
managed_policies = []
for response in response_iterator:
for policy in response['Policies']: