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 / dns.json
Created Jun 9, 2014
Consul DNS Configuration
View dns.json
{
"dns_config": {
"service_ttl": {
"*": "5s",
"web": "30s"
},
"allow_stale": true,
"max_stale": "10s"
}
}
@andrewwatson
andrewwatson / consulserver.json
Last active Aug 25, 2016
If every consul node has a service defined like this then any new node can join the cluster by joining consul.service.consul
View consulserver.json
{
"service": {
"name": "consul",
"tags": ["server"]
}
}
@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 / bigcouch.txt
Created Mar 6, 2012
BigCouch Bootup Effort
View bigcouch.txt
[root@ip-10-40-206-29 log]# /opt/bigcouch/bin/bigcouch
{error_logger,{{2012,3,6},{21,32,8}},"Protocol: ~p: register error: ~p~n",["inet_tcp",{{badmatch,{error,duplicate_name}},[{inet_tcp_dist,listen,1},{net_kernel,start_protos,4},{net_kernel,start_protos,3},{net_kernel,init_node,2},{net_kernel,init,1},{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]}]}
{error_logger,{{2012,3,6},{21,32,8}},crash_report,[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,<0.21.0>},{registered_name,[]},{error_info,{exit,{error,badarg},[{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]}},{ancestors,[net_sup,kernel_sup,<0.10.0>]},{messages,[]},{links,[#Port<0.120>,<0.18.0>]},{dictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,24},{reductions,486}],[]]}
{error_logger,{{2012,3,6},{21,32,8}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfargs,{net_kernel,start_link,[[bigcou
@andrewwatson
andrewwatson / wtf.php
Created Mar 2, 2012
#lolwtfphp #facepalm
View wtf.php
<?php
header('Content-type: image/gif');
echo base64_decode("R0lGODlhAQABAIAAAP///wAAACH5BAUUAAAALAAAAAABAAEAAAICRAEAOw==");
?>