This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Example CLI.""" | |
import argparse | |
class Example: | |
"""Python lorem ipsum.""" | |
@staticmethod | |
def show_base(**arguments): | |
"""Show the current base.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Multiprocessing and threading example.""" | |
import logging | |
import multiprocessing.pool | |
import random | |
import threading | |
import time | |
logging.basicConfig( | |
level=logging.INFO, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Multiprocessing and threading.""" | |
import logging | |
import multiprocessing.pool | |
import random | |
import threading | |
import time | |
logging.basicConfig( | |
level=logging.INFO, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo ECS_CLUSTER=My-Cluster >> /etc/ecs/ecs.config | |
echo ECS_BACKEND_HOST= >> /etc/ecs/ecs.config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#444043,#444043,#F0A141,#ffffff,#df6d33,#Ffffff,#57c1ad,#cb2c42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum install -y amazon-efs-utils; mkdir -p /efs; mount -t efs fs-id:/ /efs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 $! |