Skip to content

Instantly share code, notes, and snippets.

View barnybug's full-sized avatar
🏠
Working from home

Barnaby Gray barnybug

🏠
Working from home
View GitHub Profile
#!/usr/bin/env python
# Script to run dynamic dns for docker containers.
# DNS is served by dnsmasq running on the docker0 gateway ip, and dynamically
# updated at containers come and go.
#
# To use from docker, just provide the --dns option:
# docker run --dns <gateway> ...
# The gateway ip you need will be printed when this script is run.
@barnybug
barnybug / jg
Last active December 12, 2015 01:18
jg - json document generator
Moved to: http://github.com/barnybug/jg
@barnybug
barnybug / ec2names.py
Created September 9, 2012 19:17
Script to name all ec2 instances after the node name allocated to the elasticsearch running on that instance.
#!/usr/bin/python
# Script to name all ec2 instances after the node name allocated to the
# elasticsearch running on that instance. This makes it easy to track back
# to the physical system from visualization tools like bigdesk and head.
#
# Run directly on any elasticsearch node or port forward 9200 to a node in the
# cluster. Simple run without arguments:
# ./ec2names.py
#
@barnybug
barnybug / gist:2006593
Created March 9, 2012 13:52
IOException when limiting by fields and returning nested arrays.
curl -XPOST 'http://127.0.0.1:9200/test/a/1?pretty=true' -d '{"b": [{"i": [1]}]}'
curl -XPOST 'http://127.0.0.1:9200/_all/_flush?pretty=true'
curl -XGET 'http://127.0.0.1:9200/test/a/_search?q=*&fields=b.i&pretty=true'
curl -XPOST 'http://127.0.0.1:9200/test/a/1?pretty=true' -d '{"b": {"i": [null]}}'
curl -XPOST 'http://127.0.0.1:9200/_all/_flush?pretty=true'
curl -XGET 'http://127.0.0.1:9200/test/a/_search?q=*&fields=b&pretty=true'
{"ok":true,"_index":"test","_type":"b","_id":"1","_version":1}{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [ {
"index" : "test",
"shard" : 2,
SERVER='http://127.0.0.1:9200/'
curl -XDELETE "$SERVER/test/"
curl -XPUT "$SERVER/test/"
curl -XPUT "$SERVER/test/a/_mapping" -d '{"a": {"properties": {"field1": {"type": "integer"}}}}'
curl -XPUT "$SERVER/test/b/1" -d '{"field1": 1}'
sleep 1
curl -XGET 'http://localhost:9200/test/a/_search?size=0' -d '{"facets":{"f":{"terms":{"field":"field1"}}},"query":{"match_all":{}}}'