Skip to content

Instantly share code, notes, and snippets.

View andrewwatson's full-sized avatar
🤡
Cranking Out The Code

Andrew Watson andrewwatson

🤡
Cranking Out The Code
View GitHub Profile
@andrewwatson
andrewwatson / dns.json
Created June 9, 2014 18:27
Consul DNS Configuration
{
"dns_config": {
"service_ttl": {
"*": "5s",
"web": "30s"
},
"allow_stale": true,
"max_stale": "10s"
}
}
@andrewwatson
andrewwatson / conf.json
Created September 11, 2014 15:47
Consul 0.3.1 Panic
{
"data_dir": "/var/local/consul",
"datacenter": "california",
"enable_syslog": true,
"server": true,
"bootstrap_expect": 3
}
@andrewwatson
andrewwatson / fizzbuzz.go
Last active August 29, 2015 14:06
My first version of fizzbuzz.go
package main
import (
"fmt"
"strconv"
)
func main() {
for i := 0; i < 100; i++ {
@andrewwatson
andrewwatson / cat.php
Created September 19, 2014 03:31
Respond to Twilio SMS with a random cat photo
<?php
$xml = new SimpleXmlElement(file_get_contents("http://thecatapi.com/api/images/get?format=xml&results_per_page=1&size=small"));
$cat_picture = $xml->data->images[0]->image->url;
?>
<Response>
<Message>
<Body>Meow!</Body>
<Media><?php echo $cat_picture; ?></Media>
</Message>
</Response>
@andrewwatson
andrewwatson / curl.sh
Created December 30, 2014 15:23
influxdb getting started example not working
$ curl 'http://sandbox.influxdb.com:8086/db/callprocessing/series?u=andy&p=andy' \
-H 'Origin: http://sandbox.influxdb.com:8083' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Accept-Language: en-US,en;q=0.8' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/javascript' \
-H 'Referer: http://sandbox.influxdb.com:8083/' \
-H 'Connection: keep-alive' \
--data-binary $'[{"points":[[{"name":"log_lines","columns":["line"],"points":[["here\'s some useful log info from paul@influx.com"]]}]],"name":"log_lines","columns":["0"]}]' \
--compressed
### Keybase proof
I hereby claim:
* I am andrewwatson on github.
* I am andywatson (https://keybase.io/andywatson) on keybase.
* I have a public key whose fingerprint is A73A DC6B 059F FC6C A0D0 AC71 6AA2 5555 E811 C05C
To claim this, I am signing this object:
@andrewwatson
andrewwatson / logspout-min.yaml
Created May 1, 2015 16:57
docker-compose for logspout
logspout:
image: gliderlabs/logspout:master
volumes: /var/run/docker.sock:/tmp/docker.sock
@andrewwatson
andrewwatson / loop through services.tmpl
Created May 13, 2015 17:52
consul-template attempt
{{range services}}
{{.Name | regexMatch "manager"}}
listen http-in
bind *:{{key "service/{{.Name}}/bindport"}}
{{range service .Name}}
server {{.Node}} {{.Address}}:{{.Port}}{{end}}
{{end}}
@andrewwatson
andrewwatson / haproxy.template
Created May 13, 2015 18:13
better consul-template service iteration
{{range services}}
{{if .Name | regexMatch "data*"}}
listen http-in
bind *:{{env "ENTERPRISE_BIND"}}{{range service .Name}}
server {{.Node}}{{.Port}} {{.Address}}:{{.Port}}{{end}}
{{end}}
{{end}}
@andrewwatson
andrewwatson / gist:deb53c5367533e3dfe6b
Created July 15, 2015 20:08
running docker machine and docker from terraform local-exec
provisioner "local-exec" {
command = "docker-machine create -d generic --generic-ssh-user=ubuntu --generic-ip-address=${self.public_ip} --generic-ssh-key ${var.key_path} --engine-opt dns=172.17.42.1 --engine-opt dns-search=service.consul discovery-${count.index}"
}
provisioner "local-exec" {
command = "docker --tlsverify --tlscacert=\"$HOME/.docker/machine/machines/discovery-${count.index}/ca.pem\" --tlscert=\"$HOME/.docker/machine/machines/discovery-${count.index}/cert.pem\" --tlskey=\"$HOME/.docker/machine/machines/discovery-${count.index}/key.pem\" -H=tcp://${self.public_ip}:2376 ps"
}