Skip to content

Instantly share code, notes, and snippets.

View jg75's full-sized avatar

James Garner jg75

  • Amber Engine
  • Michigan
View GitHub Profile
@jg75
jg75 / user_stuff.py
Created September 12, 2018 18:15
Just some stuff to remember
"""Some boto3 user stuff."""
import boto3
def get_account_id(session):
"""Get the account id for the current session."""
sts_client = session.client("sts")
identity = sts_client.get_caller_identity()
return identity["Account"]
"""Example CLI."""
import argparse
class Example:
"""Python lorem ipsum."""
@staticmethod
def show_base(**arguments):
"""Show the current base."""
@jg75
jg75 / threadpool.py
Created October 26, 2018 23:14
Multiprocessing and threading example.
"""Multiprocessing and threading example."""
import logging
import multiprocessing.pool
import random
import threading
import time
logging.basicConfig(
level=logging.INFO,
"""Multiprocessing and threading."""
import logging
import multiprocessing.pool
import random
import threading
import time
logging.basicConfig(
level=logging.INFO,
@jg75
jg75 / ECS-Agent-UserData
Created January 7, 2019 20:08
UserData for ECS Agent on EC2 instances
#!/bin/bash
echo ECS_CLUSTER=My-Cluster >> /etc/ecs/ecs.config
echo ECS_BACKEND_HOST= >> /etc/ecs/ecs.config
@jg75
jg75 / gist:95b04ca2131ba13a88ff29fe21e7b979
Created February 21, 2019 14:10
AmberEngine colors for slack
#444043,#444043,#F0A141,#ffffff,#df6d33,#Ffffff,#57c1ad,#cb2c42
@jg75
jg75 / ec2-docker-install.sh
Created February 27, 2019 17:00
How to install docker on an EC2 instance
# Needs to run as root
yum update -y
amazon-linux-extras install docker
systemctl enable docker
usermod -a -G docker ec2-user
# The above can go into user-data,
# but you'll still need to reboot because of the group add
reboot
"""
Sum of multiples.
l the limit
m the multiple
c the count the number of multiples (l / m)
s the sum of (mc + mc^2) / 2 for each multiple of m to l
for multiple multiples, subtract the sum of the multiples
that are common between the multiples
@jg75
jg75 / efs-user-data.sh
Created March 14, 2019 19:29
Setup EFS on EC2
yum install -y amazon-efs-utils; mkdir -p /efs; mount -t efs fs-id:/ /efs
@jg75
jg75 / dms_source_endpoints.sh
Last active March 21, 2019 20:10
Create AWS DMS source endpoints
#! /bin/bash
# Connect to mongo db's via an ssh tunnel,
# get a list of dbs to create DMS source endpoints
# dms_source_endpoints.sh port proxy [ name:dns:port ... ]
create-ssh-tunnel() {
local endpoint=$1
ssh -L $tunnel_port:$endpoint $proxy -N &
echo $!