Skip to content

Instantly share code, notes, and snippets.

@sa-jbrooks
sa-jbrooks / security-group-cleanup.py
Last active May 17, 2024 12:08 — forked from dritten/security-group-cleanup.py
Security Group Cleanup using boto3
#!/usr/bin/env python
import boto3
import argparse
def lookup_by_id(sgid):
sg = ec2.get_all_security_groups(group_ids=sgid)
return sg[0].name
@adejones
adejones / filerotator.py
Last active October 21, 2022 17:00 — forked from RWJMurphy/filerotator.py
Python class and utility for file rotation. Configurable daily, weekly and monthly retention; can use hard links to save space; supports `argparse` config files.
#!/usr/bin/env python3
# vim: ft=python ts=4 sw=4 expandtab
#
# Copyright (c) 2013 Reed Kraft-Murphy <reed@reedmurphy.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@anirudhjayaraman
anirudhjayaraman / graphUndirected.ipynb
Created July 28, 2016 07:58
Python Implementation of Undirected Graphs (Adjacency List and Adjacency Matrix)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#Original Author https://raw.githubusercontent.com/kgoedecke/python-ecs-example/master/python_ecs_example/deployment.py
import boto3
import pprint
import os
# Credentials & Region
access_key = os.environ["AWS_ACCESS_KEY_ID"]
secret_key = os.environ["AWS_SECRET_ACCESS_KEY"]
region = "us-east-1"
@maxivak
maxivak / __readme.md
Last active February 22, 2024 11:55
Building Docker image with Packer and provisioning with Ansible

Building Docker image with Packer and provisioning with Ansible

Overview

Packer

  • Packer is used to build image from a base image, perform provisions and store (commit) the final image.

  • We use provisioners and Packer templates to do the actual work to create the final image.

  • We use Ansible for provisioning.

@robsonke
robsonke / checkDockerDisks.sh
Last active February 18, 2024 12:44
This Bash script will loop through all running docker containers on a host and list the disk usage per mount. In case it's breaching the 65%, it will email you.
#!/bin/bash
# get all running docker container names
containers=$(sudo docker ps | awk '{if(NR>1) print $NF}')
host=$(hostname)
# loop through all containers
for container in $containers
do
echo "Container: $container"
@bpholt
bpholt / deregister.sh
Created November 4, 2015 22:14
Stop tasks on ECS Container Instance and Deregister it from ECS Cluster
#!/bin/bash
cluster=default
container_instance= # container instance guid
tasks=$(aws --region us-west-2 ecs list-tasks --container-instance $container_instance --cluster $cluster | jq -r '.taskArns | map(.[40:]) | reduce .[] as $item (""; . + $item + " ")')
for task in $tasks; do
aws --region us-west-2 ecs stop-task --task $task --cluster $cluster
done
aws --region us-west-2 ecs deregister-container-instance --cluster $cluster --container-instance $container_instance
@brock
brock / psql-with-gzip-cheatsheet.sh
Last active May 13, 2024 13:31
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@justinclayton
justinclayton / add-dns-record.sh
Created July 15, 2015 22:04
CLI to add DNS Records in Route53
#!/bin/bash -eo pipefail
## Allows for creation of "Basic" DNS records in a Route53 hosted zone
function main() {
record_name=$1
record_value=$2
[[ -z $record_name ]] && echo "record_name is: $record_name" && exit 1
[[ -z $record_value ]] && echo "record_value is: $record_value" && exit 1
@phrawzty
phrawzty / 2serv.py
Last active May 31, 2024 17:14
simple python http server to dump request headers
#!/usr/bin/env python2
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):