Skip to content

Instantly share code, notes, and snippets.

Avatar
🤡
Cranking Out The Code

Andrew Watson andrewwatson

🤡
Cranking Out The Code
View GitHub Profile
@andrewwatson
andrewwatson / rgbExport.js
Last active Feb 28, 2018
bookmarklet that exports a piskel and logs the C code to the console
View rgbExport.js
javascript:(function(){
var rgbToCHex = function (r, g, b, a) {
var hexStr = '0x';
hexStr += ('00' + r.toString(16)).substr(-2);
hexStr += ('00' + g.toString(16)).substr(-2);
hexStr += ('00' + b.toString(16)).substr(-2);
return hexStr;
};
var export_to_unit8_t = function () {
View hangman.js
// This array holds the words we are going to choose from.
// Feel free to add new words!
var words = ['falcons', 'panthers', 'patriots', 'chargers', 'saints'];
var wordCount = document.getElementById('wordCount');
// console.log(wordCount);
function chooseWord () {
theWord = words[Math.floor(Math.random() * words.length)];
View item_search.go
func performIndexSearch(ctx context.Context, userQuery string, options *SearchOptions) ([]Item, map[string]RefinementCollection, error) {
index, err := search.Open(searchIndexName)
if err != nil {
return nil, nil, errors.Wrap(err, "Search Index Unavailable")
}
var keys []*datastore.Key
query := ""
@andrewwatson
andrewwatson / storage.go
Created Apr 27, 2016
Connect to Datastore from outside GAE
View storage.go
package storage
import (
"io/ioutil"
"golang.org/x/net/context"
"golang.org/x/oauth2/google"
"google.golang.org/cloud"
"google.golang.org/cloud/datastore"
)
@andrewwatson
andrewwatson / storage.go
Created Apr 26, 2016
Google App Engine Datastore Adaptor
View storage.go
package storage
import (
"io/ioutil"
"golang.org/x/net/context"
"golang.org/x/oauth2/google"
"google.golang.org/cloud"
"google.golang.org/cloud/datastore"
)
View keybase.md

Keybase proof

I hereby claim:

  • I am andrewwatson on github.
  • I am andrewwatson (https://keybase.io/andrewwatson) on keybase.
  • I have a public key whose fingerprint is 7F6F 76DF C495 7FA2 E7D6 44D8 F237 701D 048F A350

To claim this, I am signing this object:

@andrewwatson
andrewwatson / gist:deb53c5367533e3dfe6b
Created Jul 15, 2015
running docker machine and docker from terraform local-exec
View gist:deb53c5367533e3dfe6b
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"
}
@andrewwatson
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}}
{{end}}
{{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}}
{{end}}
@andrewwatson
andrewwatson / logspout-min.yaml
Created May 1, 2015
docker-compose for logspout
View logspout-min.yaml
logspout:
image: gliderlabs/logspout:master
volumes: /var/run/docker.sock:/tmp/docker.sock
You can’t perform that action at this time.