Skip to content

Instantly share code, notes, and snippets.

View aheld's full-sized avatar

Aaron Held aheld

View GitHub Profile
#!/bin/bash
REGION="us-east-1"
PROFILE="prod"
get_ecl_ip(){
aws ec2 describe-instances \
--profile $PROFILE \
--filters Name=tag:Name,Values=enrollecl \
--query "Reservations[].Instances[].PrivateIpAddress" \
@aheld
aheld / clean_old_snaps_images.sh
Created June 7, 2017 20:20
bash script to remove AWS snapshots and AMIs older then a certain date. use at your own risk....
# call with $OWNER_ID
# OWNER_ID=123123123123123 ./clean_old_snaps_images.sh
aws ec2 describe-images --profile prod --owners $OWNER_ID | \
jq '.Images[] | select ( .CreationDate <= "2017-01") .ImageId' -r |\
xargs -n1 -I JAWN sh -c 'aws ec2 deregister-image --profile prod --image-id JAWN'
aws ec2 describe-snapshots --profile prod --owner-id $OWNER_ID |\
jq '.Snapshots[] | select ( .StartTime <= "2017-01").SnapshotId' -r |\
xargs -n1 -I JAWN sh -c 'aws ec2 delete-snapshot --profile prod --snapshot-id JAWN'
<?php
/*
POST /knowledgebases/{knowledgebase ID}/generateAnswer
Host: https://westus.api.cognitive.microsoft.com/qnamaker/v1.0
Ocp-Apim-Subscription-Key: {subscriber key}
Content-Type: application/json
{"question":"hi"}
*/
// EDIT HERE ----
$path = '/knowledgebases/{knowledgebase ID}/generateAnswer';
@aheld
aheld / get_rds_tags
Created June 30, 2016 18:44
get RDS tags using AWS cli , this really seems too complicated
#!/bin/bash
REGION="us-east-1"
PROFILE="prod"
get_account_id(){
aws ec2 describe-security-groups \
--group-names 'Default' \
--query 'SecurityGroups[0].OwnerId' \
--output text \
@aheld
aheld / batchit.py
Last active June 10, 2016 21:02
simple batching of a generator
from pprint import pprint
from itertools import chain, islice
from time import sleep
from random import random
def make_req(x):
return {'id': x}
"Amateurs talk about tactics, but professionals study logistics."
- Gen. Robert H. Barrow, USMC
%
If you don't have time to do it right, when will you have time to do it over?
John Wooden
%
When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meagre and unsatisfactory kind
-Lord Kelvin 1883
%
"Beautiful as that wonderful work of nature [Niagara] is, it would be more beautiful still if those waters fell upon turbine wheels every one of which was turning the wheels of industry."
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
def bray(n):
if n < 1: return 0
if n == 1: return 1
accumulator = 1 + (2 * n-2) # this is the same as 1 + 2 + 2 +2 ....
return accumulator + bray(n-1)
for n in range(10):
bray(n)
print("n=%3d: bray(n) = %s\t square(n): %5d" % (n,bray(n),n*n) )
@aheld
aheld / pdf extracter
Created September 24, 2013 18:41
Quick and Dirty way to extract names our out of a PDF file and into a CSV file. Inspired (copied) from http://thottingal.in/blog/2009/06/24/pdfbox-extract-text-from-pdf/
package com.aaronheld;
import org.apache.pdfbox.cos.COSDocument;
import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.util.PDFTextStripper;
import java.io.File;
import java.io.FileInputStream;