Skip to content

Instantly share code, notes, and snippets.

View JohnPreston's full-sized avatar
🏠
Working on AWS' cloud

John Preston JohnPreston

🏠
Working on AWS' cloud
View GitHub Profile
for map in `sed 's/^ .*//1' $file | sed '/^\s*$/d' | sed 's/\://g'`; do touch "$file"_"$map.yml"; done
AWS ARN TOPIC (py 3.6, re)
'(arn:aws:sns:([a-z]{2})-(east|west|central)-([0-9]{1}):([0-9]{12}):([a-z0-9]{1,256}))?'
@JohnPreston
JohnPreston / keybase.md
Last active September 25, 2017 16:57
keybase.md

Keybase proof

I hereby claim:

  • I am johnpreston on github.
  • I am johnpreston78 (https://keybase.io/johnpreston78) on keybase.
  • I have a public key whose fingerprint is 5C93 2084 E03F 7DD1 3ED8 16A4 9145 77AC 111D 1F0A

To claim this, I am signing this object:

@JohnPreston
JohnPreston / addip.service
Created March 8, 2017 19:17
Systemd call to script to add an IP
[Unit]
Description=Add Secondary IP
After=network-service.target network.target
Wants=network.target
[Service]
Type=forking
ExecStart=/etc/addip.sh 10.163.59.174/21
@JohnPreston
JohnPreston / addip.sh
Last active March 30, 2017 10:59
add secondary ip after primary has been set
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: addip.sh IPv4CIDR"
exit 1
fi
IPCIDR=$1
zypper ar http://smt-ec2.susecloud.net/repo/SUSE/Products/SLE-Module-Adv-Systems-Management/12/x86_64/product?credentials SMT-http_smt-ec2_susecloud_net:SLE-Module-Adv-Systems-Management12-Pool
zypper ar http://smt-ec2.susecloud.net/repo/SUSE/Updates/SLE-Module-Adv-Systems-Management/12/x86_64/update?credentials SMT-http_smt-ec2_susecloud_net:SLE-Module-Adv-Systems-Management12-Updates
zypper ar http://smt-ec2.susecloud.net/repo/SUSE/Products/SLE-Module-Containers/12/x86_64/product?credentials SMT-http_smt-ec2_susecloud_net:SLE-Module-Containers12-Pool
zypper ar http://smt-ec2.susecloud.net/repo/SUSE/Updates/SLE-Module-Containers/12/x86_64/update?credentials SMT-http_smt-ec2_susecloud_net:SLE-Module-Containers12-Updates
zypper ar http://smt-ec2.susecloud.net/repo/SUSE/Products/SLE-Module-Legacy/12/x86_64/product?credentials SMT-http_smt-ec2_susecloud_net:SLE-Module-Legacy12-Pool
zypper ar http://smt-ec2.susecloud.net/repo/SUSE/Updates/SLE-Module-Legacy/12/x86_64/update?credentials SMT-http_smt-ec2_susecloud_n
#!/usr/bin/env bash
vdisplay | grep Path | grep LV | awk '{print $NF}' | xargs -i -P 1 lvremove -f {}
vgdisplay | grep Name | awk '{print $NF}' | xargs -i -P 1 vgremove -f {}
pvdisplay | grep Name | grep PV | awk '{print $NF}' | xargs -i -P 1 pvremove -f {}
fdisk -l | grep xvd | grep -v xvd[a-i] | grep -v Disk | awk '{print $1}' | sed 's/[0-9]//g' | xargs -i -P1 parted -s {} rm 1
@JohnPreston
JohnPreston / spotmanager.json
Created November 7, 2016 16:05
IAM Policy for the SpotManager role as discussed on johnpreston.ews-network.net
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1476739808000",
"Effect": "Allow",
"Action": [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
@JohnPreston
JohnPreston / get_password.py
Last active July 1, 2019 23:22
Get password from DynamoDB and decrypt with KMS
import base64
import uuid
import httplib
import urlparse
import json
import boto3
import string
import random
@JohnPreston
JohnPreston / encrypt_password_to_dyndb.py
Last active November 18, 2023 08:29
Generates, encrypt and store password in DynamoDB
import base64
import uuid
import httplib
import urlparse
import json
import boto3
import string
import random