Skip to content

Instantly share code, notes, and snippets.

View RadioactiveMouse's full-sized avatar

Tom Townsend RadioactiveMouse

View GitHub Profile
@RadioactiveMouse
RadioactiveMouse / curl.log
Last active December 14, 2015 20:19
Go gist to help explain issues with content parsing errors. NB: headers are going to be modified differently and handed into query function.
curl -v -d '{"":"testvalue"}' -H "Content-Type: application/json" http://127.0.0.1:8098/buckets/test/keys?returnbody=true
* About to connect() to 127.0.0.1 port 8098 (#0)
* Trying 127.0.0.1... connected
> POST /buckets/test/keys?returnbody=true HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 127.0.0.1:8098
> Accept: */*
> Content-Type: application/json
> Content-Length: 16
>
@RadioactiveMouse
RadioactiveMouse / main.go
Created March 3, 2013 12:37
Golang Reference issue
func (self *Client) Store(bucket string, returnBody bool, data *Data) (*Data, error) {
// check if the key exists for conditional put/post
path := ""
returnData := Data{}
resp := http.Response{}
// check if the key exists
if data.value == "" {
return &returnData, errors.New("RGO: no value defined for the key")
}
if data.key != "" {
@RadioactiveMouse
RadioactiveMouse / main.go
Created November 7, 2012 19:30
XML parsing in Go
package main
import (
"fmt"
"encoding/xml"
"net/http"
"errors"
)
type Answer struct {
@RadioactiveMouse
RadioactiveMouse / Example.md
Created October 25, 2012 11:50
Struct Mapping
@RadioactiveMouse
RadioactiveMouse / Example.md
Created October 25, 2012 11:40
Struct Printing

Struct Printing

Structs can be printed using the builtin print methods as they take advantage of the reflect package.

Print a struct as is with %v Print a struct with field names by %+v

Run the code here : http://play.golang.org/p/X8ke-0zPUT

@RadioactiveMouse
RadioactiveMouse / GETExpressKeyBinding.md
Created June 19, 2012 09:29
Express key binding for get route
{ "keys": ["super+shift+r"],
  "command": "insert_snippet",
  "args" : {
  	"contents": "app.get(\"/${1:}$SELECTION\", routes.${1:}$SELECTION);${0}"
  }

}

@RadioactiveMouse
RadioactiveMouse / snippet.md
Created June 19, 2012 08:25 — forked from harthur/snippet.md
console.log() key binding for Sublime Text

Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:

[
    { "keys": ["super+shift+l"],
      "command": "insert_snippet",
      "args": {
        "contents": "console.log(${1:}$SELECTION);${0}"
      }
 }