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
[core] | |
editor = vim | |
[alias] | |
reup = !git stash && git fetch && git rebase origin/master && git stash pop | |
au = !git add -u && git fetch >/dev/null && git diff --cached --no-ext-diff origin/master | grep --color=always 'pdb.set_trace()' -B 6 | |
re = reset | |
dc = diff --cached | |
st = status | |
co = checkout |
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
# | |
# For security purposes, the output has been obfuscated with '***' in a few places. | |
# | |
Error: Expected to find one security group with ID "", got: []*ec2.SecurityGroup{{ | |
Description: "SG for access to *** layer", | |
GroupId: "sg-*****", | |
GroupName: "*****", | |
IpPermissions: [ | |
{ |
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
eval $( ssh-agent ) | |
# Can add as many keys as you want | |
ssh-add /path/to/key | |
ssh -A user@host |
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 | |
# | |
# To add this as a fish function: | |
# function dockercleanup | |
# docker volume rm (docker volume ls -f dangling=true -q); docker system prune -a | |
# end | |
# funcsave dockercleanup | |
# |
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
#!/usr/bin/fish | |
# Name allows for "." | |
# so might as well use full domain minus the "*" | |
# if you are using a wildcard cert... | |
# | |
# But you should at least use one subdomain if you wildcard | |
# ...for security... just sayin. | |
# Using absolute path is more reliable. |
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 | |
PROFILE=${AWS_PROFILE:-default} | |
TAG=${TAG:-Name} | |
STATE=${STATE:-running} | |
aws ec2 --profile ${PROFILE} describe-instances \ | |
--filters Name=instance-state-name,Values=${STATE} | \ | |
jq .Reservations[].Instances[].Tags | \ | |
jq -c ".[] | select(.Key | contains(\"${TAG}\"))" | \ |
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
data "aws_availability_zones" "available" {} | |
# Assuming we vars for list of private_subnet_ids and or public_subnet_ids | |
# we take a slice of available AZs. | |
# | |
# Add or remove private/public vars when necessary. | |
locals { | |
available_azs = "${ | |
slice( | |
data.aws_availability_zones.available.names, |
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
""" | |
Note: Found somewhere on Stack Overflow but was unable to find again. | |
If found, please comment and I will update this gist with the source. | |
""" | |
def threadwrap(func, args, kwargs): | |
class res(object): | |
result = None | |
def inner(*args, **kwargs): | |
res.result = func(*args, **kwargs) |
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
def print_table(data, column_order=None): | |
""" Pretty print a list of dictionaries (data) as a dynamically sized table. | |
If column names (column_order) aren't specified, they will show in random order. | |
Author: Thierry Husson - Use it as you want but don't blame me. | |
Source: https://stackoverflow.com/questions/17330139/python-printing-a-dictionary-as-a-horizontal-table-with-headers | |
PEP8ed by: mijdavis2 | |
""" | |
if not column_order: | |
column_order = list(data[0].keys() if data else []) | |
l = [column_order] # 1st row = header |
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
import time | |
def timeit(method): | |
""" | |
Decorator useful for timing functions. | |
Source: https://medium.com/pythonhive/python-decorator-to-measure-the-execution-time-of-methods-fa04cb6bb36d | |
Usage: | |
@timeit | |
def my_function(): |