Skip to content

Instantly share code, notes, and snippets.

View andrewgross's full-sized avatar

Andrew Gross andrewgross

View GitHub Profile
@andrewgross
andrewgross / convert_url.py
Created March 23, 2017 21:56
CLI App that takes an HTTP address with a host similar to ip-10-32-9-122.ec2.internal and puts in your mac clipboard the HTTP address with the host converted to an IP address.
import cmd
from urlparse import urlparse
import sys
import re
import subprocess
def write_to_clipboard(output):
process = subprocess.Popen(
'pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
process.communicate(output.encode('utf-8'))
one_hour_ago := time.Now().AddDate(0, 0, -1).Add(time.Hour * 23)
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()`
vagrant plugin install vagrant-chef-zero
INFO global: Vagrant version: 1.1.2
INFO manager: Registered plugin: box command
INFO manager: Registered plugin: destroy command
INFO manager: Registered plugin: halt command
INFO manager: Registered plugin: init command
INFO manager: Registered plugin: package command
INFO manager: Registered plugin: plugin command
INFO manager: Registered plugin: provision command
INFO manager: Registered plugin: reload command
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/testtask.rb:104:in `block (3 levels) in define'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `call'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `sh'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in `sh'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils.rb:82:in `ruby'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in `ruby'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/testtask.rb:100:in `block (2 levels) in define'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:58:in `verbose'
/usr/local/Cellar/ruby/1.9.3-p385/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/testtask.rb:98:in `block in define'