Skip to content

Instantly share code, notes, and snippets.

@johngidt
johngidt / colors.py
Created May 11, 2016 22:00 — forked from arulrajnet/colors.py
python coloring for linux, based on this answer http://stackoverflow.com/a/26445590/3191896 and modified to make it more usable in a pythonic way.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Color(object):
"""
reference from https://gist.github.com/Jossef/0ee20314577925b4027f and modified bit.
"""
def __init__(self, text, **user_styles):
@johngidt
johngidt / user-data.sh
Created May 13, 2016 15:06 — forked from codeinthehole/user-data.sh
Get the value of an EC2 instance's tag
#!/usr/bin/env bash
#
# Get the value of a tag for a running EC2 instance.
#
# This can be useful within bootstrapping scripts ("user-data").
#
# Note the EC3 instance needs to have an IAM role that lets it read tags. The policy
# JSON for this looks like:
#
# {
@johngidt
johngidt / pretty.py
Created May 13, 2016 21:04 — forked from jeffskinnerbox/pretty.py
A library that provides a Python print, stdout, and string wrapper that makes colored terminal (Xterm/VT100 type terminals) text easier to use (e.g. without having to mess around with ANSI escape sequences).
#!/usr/bin/env python
"""pretty.py will color text for Xterm/VT100 type terminals using ANSI Escape Sequences
A library that provides a Python print, stdout, and string wrapper that makes colored terminal
text easier to use(e.g. without having to mess around with ANSI escape sequences).
Referance Materials:
Colored text in Python using ANSI Escape Sequences
http://nezzen.net/2008/06/23/colored-text-in-python-using-ansi-escape-sequences/
@johngidt
johngidt / encdec.py
Created June 13, 2016 21:25 — forked from jforr/encdec.py
2 way encryption decryption based on pycrypto
# Inspired and adopted from https://gist.github.com/sekondus/4322469
# COMES WITH ABOSLUTELY NO WARRANTY OF ANY KIND.
# TOTAL FREEWARE, NO CLAIMS MADE OF ANY SORT.
# SELL IT, BURN IT, PRETEND ITS YOUR OWN.
# RELEASED UNDER NOBODY CARES LICENSE.
import os
import base64
from Crypto.Cipher import AES
@johngidt
johngidt / ansible_logging.py
Created June 15, 2016 20:30 — forked from pragdave/ansible_logging.py
Logging plugin for Ansible
# Interpret the Ansible log for humans. In particular, we
# look for command executions and format their content
#
# - name: list files
# shell: "ls -lrt *e*"
#
# Might produce
#
# TASK: [1] ***********************************************************
# changed: [localhost]
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
@johngidt
johngidt / proxy.js
Created June 16, 2016 15:53 — forked from nakedible-p/proxy.js
AWS ES proxy
var AWS = require('aws-sdk');
var http = require('http');
var httpProxy = require('http-proxy');
var express = require('express');
var bodyParser = require('body-parser');
var stream = require('stream');
if (process.argv.length != 3) {
console.error('usage: aws-es-proxy <my-cluster-endpoint>');
process.exit(1);
@johngidt
johngidt / desc.md
Created June 16, 2016 21:43
boto3 Lacks EC2 Instance Identity Metadata Parsing

Given that boto/boto3#313 is not resolved, I hacked together something else in Python that I'm using.

@johngidt
johngidt / lambda-website-checker.js
Created February 8, 2018 17:11 — forked from marcelog/lambda-website-checker.js
This AWS Lambda can be used to check your website for availability
'use strict';
var url = require('url');
var target = 'http://www.yourwebsite.com'; // Change this one
exports.handler = function(event, context, callback) {
var urlObject = url.parse(target);
var mod = require(
urlObject.protocol.substring(0, urlObject.protocol.length - 1)
);
@johngidt
johngidt / gist:17a81e5b6247bcbdf799a50f0a2085ef
Created February 19, 2018 19:03 — forked from LarsFronius/gist:e579051d7f140fd803b0
If you ever want to debug a kinesis stream, copy this bash one liner.
On a mac, `brew install awscli gnu-sed` before.
streamname=staging;aws kinesis describe-stream --stream-name $streamname --output text | grep SHARDS | awk '{print $2}' | while read shard; do aws kinesis get-shard-iterator --stream-name $streamname --shard-id $shard --shard-iterator-type LATEST --output text | while read iterator; do while output=`aws kinesis get-records --shard-iterator $iterator --output text`; do iterator=`echo "$output" | head -n1`; echo "$output" | gsed 1d | grep RECORDS | while read record; do echo $record | awk '{print $2}' | base64 -D; done; done; done; done