Skip to content

Instantly share code, notes, and snippets.

@jerm
jerm / touchsudo.sh
Last active July 27, 2023 05:21
script for easily setting up sudo auth via touch-id
#!/bin/bash
#
# I got tired of re-enabling this by hand every time there was a MacOS update,
# so now it's a script.
#
# sudo ./touchsudo.sh
#
# REQUIRES iTerm2 unless you remove that part. Why? Well...
#
# This opens a new iTerm sub-window in a root shell so that IF for some reason the new pam file
#!/usr/bin/env python
import csv
field_order_fh = open('field_order.txt',"r")
field_order_list = field_order_fh.readlines()
field_order_list_stripped=[]
for f in field_order_list:
field_order_list_stripped.append(f.rstrip('\n'))
with open('my.csv', newline='') as infile:
@jerm
jerm / update_ts_dns.py
Created January 30, 2021 19:59
Sync Tailscale hosts to route53
#!/usr/bin/env python
#
# Sync your tailscale hosts to a route53 hosted zone.
#
import json
import platform
import subprocess
import boto3
import click
# Git prompt stuff
echo .profile
__git_ps1(){
(:)
}
#[ -f ~/.git-completion.bash ] && source ~/.git-completion.bash
#[ -f ~/.git-config.bash ] && source ~/.git-config.bash
# Activate git completion and prompt functions. My Linux has these built-in in
# /etc/bash_completion.d/git
# On OSX I'm using homebrew where they can be found as below.
@jerm
jerm / update_paramater_store_creds.py
Last active March 29, 2019 05:29
Takes a 4 tier yaml file (project/app/level/key) and imports it into AWS encrypted parameter store
#!/usr/bin/env python
import os
import boto3
import yaml
import click
from ansible_vault import Vault
@jerm
jerm / use_paramater_store_creds.py
Last active March 29, 2019 05:23
POC python class and demo usage to get groups of credentials from parameter store
# This class retrieves /prefix/* parameters from aws parameter store and lets
# you either reference them individually or it will put them all into your os environment
# for fetching in familiar ways
import os
import boto3
class AWSParameterClass(object):
def __init__(self, prefix):
_project = boto3.client('ssm')
@jerm
jerm / ansible_vault_grep.sh
Created November 16, 2017 21:57
Make ansible vault files greppable
### Ansible vault grepping
export VAULTS_LIST_FILE='.vaults.txt'
vaultscan()
{
echo "Scanning `pwd` for ansible-vault files"
[ -n "$VAULTSCANBASE" ] && pushd "$VAULSCANBASE"
true > $VAULTS_LIST_FILE
IFS=$'\n'
set -f
for i in `find . -type f`
# Install autoenv (or similar)
# add an export ITERM_TAB_LABEL='thisproject' line in .env in each project
# add a noproject version in your homedir
# add this to .profile
# profit!
export ITERM_TAB_LABEL="Set Me"
set_tab_label() { echo "$ITERM_TAB_LABEL"; }
PS1="$PS1\[\033k\033\134\033k\h\033\134\]\[\e]0;\`set_tab_label\`\a\]"

Keybase proof

I hereby claim:

  • I am jerm on github.
  • I am jermops (https://keybase.io/jermops) on keybase.
  • I have a public key ASBBbEfmJpMCpL_Nx1V9kTRXmhSR4h3LkJ_yuCiL0_Y0Xwo

To claim this, I am signing this object:

@jerm
jerm / aws_ebs_snaps.py
Last active March 4, 2016 05:40
Easy way to snap all volumes on an instance.
import boto
import datetime
def lookup_instance_by_id(instance_id):
conn = boto.connect_ec2()
try:
instance = conn.get_all_instances(filters = {'instance_id':instance_id})[0].instances[0]
except IndexError:
return False
if instance.state != 'terminated':