Skip to content

Instantly share code, notes, and snippets.

Andrew Kirkpatrick magickatt

Block or report user

Report or block magickatt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@magickatt
magickatt / exception_traceback.py
Last active Oct 30, 2019
Get class, filename and line number from Python Exception
View exception_traceback.py
import os, sys, logging
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
try:
number = 1 / 0
except ZeroDivisionError as exception:
exception_message = str(exception)
exception_type, exception_object, exception_traceback = sys.exc_info()
filename = os.path.split(exception_traceback.tb_frame.f_code.co_filename)[1]
@magickatt
magickatt / github_clone_using_token.sh
Created Sep 6, 2019
Clone a GitHub repository using a Personal Access Token
View github_clone_using_token.sh
export GITHUB_USER=magickatt
export GITHUB_TOKEN=secret
export GITHUB_REPOSITORY=magickatt/ContainerisingLegacyApplicationsTalk
git clone https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
@magickatt
magickatt / tolist.tf
Last active Jul 19, 2019
Iterate over set for resource using count and index in Terraform
View tolist.tf
resource "aws_route" "transit_gateway_private_subnet_route" {
count = length(data.aws_route_tables.private_subnet.ids)
route_table_id = tolist(data.aws_route_tables.private_subnet.ids)[count.index]
destination_cidr_block = var.destination_cidr_block
transit_gateway_id = var.transit_gateway_id
}
data "aws_route_tables" "private_subnet" {
vpc_id = var.vpc_id
tags = {
@magickatt
magickatt / vpc_subnet_cidr.tf
Last active Mar 18, 2019
How to retrieve CIDR ranges
View vpc_subnet_cidr.tf
# Fetch the VPC as a Data Source
data "aws_vpc" "vpc" {
filter {
name = "tag:Name"
values = ["vpc-name"]
}
}
# Fetch the Subnet IDs from the VPC
data "aws_subnet_ids" "public" {
@magickatt
magickatt / docusaurus_images.md
Last active Feb 28, 2019
Example of how to embed images in a Docusaurus markdown file so that the path gets correctly referenced at build time
View docusaurus_images.md
## Section

Lorem ipsum dolor sit amet.

![alt text](assets/image.png)
@magickatt
magickatt / upgrade_pip.sh
Last active Apr 18, 2018
Safely upgrade PIP in CentOS/RHEL 6
View upgrade_pip.sh
# This will upgrade PIP 7.1 to PIP 10.x, which will break PIP
#sudo pip install --upgrade pip
# This is the last version of PIP that will work with CentOS/RHEL 6
sudo pip install pip==9.0.3
# Installing collected packages: pip
# Found existing installation: pip 7.1.0
# Uninstalling pip-7.1.0:
# Successfully uninstalled pip-7.1.0
@magickatt
magickatt / labels.py
Last active Oct 31, 2017
Add labels to Google Cloud Compute Engine instances
View labels.py
import os
labels = [
{
'server': 'something',
'environment': 'production'
'client': 'pizza',
'service': 'orders',
'component': 'database'
}
View vagrant-ssh-config.txt
$ vagrant ssh-config
Host default
HostName 127.0.0.1
User deploy
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/akirkpatrick/Virtualization/SomeVagrantBox/private_key
@magickatt
magickatt / pg_hba.conf
Created May 3, 2017
Change PostgreSQL IPv4 connection allowed IP
View pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 0.0.0.0/0 md5
@magickatt
magickatt / postgresql.conf
Created May 3, 2017
Change PostgreSQL listening port
View postgresql.conf
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
You can’t perform that action at this time.