Skip to content

Instantly share code, notes, and snippets.

View andrewgross's full-sized avatar

Andrew Gross andrewgross

View GitHub Profile
@andrewgross
andrewgross / gist:11183809
Created April 22, 2014 15:33
Whos the dumbest GoT character
This isn't even close. Catelyn Stark.
Did she make a single good decision during her lifespan? She chased away Jon Snow when another strong male would have been a huge asset. She went to pieces when Bran fell, and left the family in the hands of an inexperienced teenager. She convinced Ned to trust Littlefinger, which got him killed. She captured Tyrion, which started a war and made Sansa into a hostage. She didn't convince her teenaged son that marrying his new girlfriend was a horrible idea, which got all of them killed. She betrayed her own son.
This is a woman who claimed to care about her family more than anything, but managed to get almost the entire clan killed in under three years.
Cersei isn't a rocket scientist, and Viserys was an idiot, but he got himself killed before he could do much damage to anyone else. Joffrey wasn't stupid, he was batshit insane.
@andrewgross
andrewgross / gist:9261189
Created February 27, 2014 22:41
Suble AWS API Trolling
# Describe Launch Config formatting
<BlockDeviceMappings>
<member>
<DeviceName>/dev/xvdp</DeviceName>
<Ebs>
<SnapshotId>snap-1234abcd</SnapshotId>
<Iops>1000</Iops>
<DeleteOnTermination>true</DeleteOnTermination>
<VolumeType>io1</VolumeType>
<VolumeSize>100</VolumeSize>
def _parse_block_device_mappings(user_input):
"""
Parse block device mappings per AWS CLI tools syntax (modified to add IOPS)
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html
Syntax:
/dev/xvd[a-z]=[snapshot-id|ephemeral]:[size in GB]:[Delete on Term]:[IOPS]
- Leave inapplicable fields blank
- Delete on Termination defaults to True
@andrewgross
andrewgross / gist:8922636
Last active August 29, 2015 13:56
api.py using requests.
import copy
import datetime
import itertools
import logging
import os
import re
import socket
import subprocess
import threading
import urllib2
curl 'http://localhost:9200/_all/fluentd/_search?size=1&pretty=true' -XPOST -d '{
"query": {
"query_string": {
"fields": ["uri"]
"query": "entagara-"
}
}
}'
@andrewgross
andrewgross / gist:8549654
Last active January 4, 2016 01:39
Weird MVEL issue
// This works:
discount = 50.0
if (!doc["discount"].empty) {
discount = doc["discount"].value;
} else {
discount = 50.0;
}
// This works:
discount = doc["discount"].empty ? 50.0 : doc["discount"].value;
@andrewgross
andrewgross / gist:6902381
Created October 9, 2013 14:40
My favorite part of working with AWS SDKs in Java
for (Reservation reservation : descInstances.getReservations()) {
for (Instance instance : reservation.getInstances()) {
@andrewgross
andrewgross / util.rb
Created July 15, 2013 14:20
Helper functions for safely working with node attribute keys.
def has_nested_key?(key, hash)
hash = hash.to_hash
if has_indeterminate_key?(key, hash)
return true
end
hash.values.each do |v|
if v.is_a?(Hash) && has_nested_key?(key, v)
return true
end
publish:
@if [ -e "$$HOME/.pypirc" ]; then \
echo "Uploading to Pypi"; \
python setup.py register ; \
python setup.py sdist upload ; \
import re
import os
from setuptools import setup, find_packages
def parse_requirements():
"""Rudimentary parser for the `requirements.txt` file
We just want to separate regular packages from links to pass them to the
`install_requires` and `dependency_links` params of the `setup()`