Skip to content

Instantly share code, notes, and snippets.

Cranking Out The Code

Andrew Watson andrewwatson

Cranking Out The Code
View GitHub Profile
andrewwatson / latestatic.php
Last active Aug 29, 2015
Late Static Binding Question
View latestatic.php
class A {
protected static function doStuff() {
return "Hello ";
class B extends A {
View closure.php
* What will the following code output? (No cheating!)
class Test {
private $a;
private $b;
public function getFunction()
andrewwatson / conf.json
Created Sep 11, 2014
Consul 0.3.1 Panic
View conf.json
"data_dir": "/var/local/consul",
"datacenter": "california",
"enable_syslog": true,
"server": true,
"bootstrap_expect": 3
andrewwatson / fizzbuzz.go
Last active Aug 29, 2015
My first version of fizzbuzz.go
View fizzbuzz.go
package main
import (
func main() {
for i := 0; i < 100; i++ {
andrewwatson / cat.php
Created Sep 19, 2014
Respond to Twilio SMS with a random cat photo
View cat.php
$xml = new SimpleXmlElement(file_get_contents(""));
$cat_picture = $xml->data->images[0]->image->url;
<Media><?php echo $cat_picture; ?></Media>
andrewwatson /
Created Dec 30, 2014
influxdb getting started example not working
$ curl '' \
-H 'Origin:' \
-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:' \
-H 'Connection: keep-alive' \
--data-binary $'[{"points":[[{"name":"log_lines","columns":["line"],"points":[["here\'s some useful log info from"]]}]],"name":"log_lines","columns":["0"]}]' \
View gist:024e81c0056c7df97830
### Keybase proof
I hereby claim:
* I am andrewwatson on github.
* I am 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 / logspout-min.yaml
Created May 1, 2015
docker-compose for logspout
View logspout-min.yaml
image: gliderlabs/logspout:master
volumes: /var/run/docker.sock:/tmp/docker.sock
andrewwatson / haproxy.template
Created May 13, 2015
better consul-template service iteration
View haproxy.template
{{range services}}
{{if .Name | regexMatch "data*"}}
listen http-in
bind *:{{env "ENTERPRISE_BIND"}}{{range service .Name}}
server {{.Node}}{{.Port}} {{.Address}}:{{.Port}}{{end}}
View loop through services.tmpl
{{range services}}
{{.Name | regexMatch "manager"}}
listen http-in
bind *:{{key "service/{{.Name}}/bindport"}}
{{range service .Name}}
server {{.Node}} {{.Address}}:{{.Port}}{{end}}