Skip to content

Instantly share code, notes, and snippets.

Tom Townsend RadioactiveMouse

  • UK
Block or report user

Report or block RadioactiveMouse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@RadioactiveMouse
RadioactiveMouse / curl.log
Last active Dec 14, 2015
Go gist to help explain issues with content parsing errors. NB: headers are going to be modified differently and handed into query function.
View curl.log
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 Mar 3, 2013
Golang Reference issue
View main.go
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 != "" {
View main.go
package main
import (
"fmt"
"encoding/xml"
"net/http"
"errors"
)
type Answer struct {
View Example.md
View Example.md

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 Jun 19, 2012
Express key binding for get route
View GETExpressKeyBinding.md
{ "keys": ["super+shift+r"],
  "command": "insert_snippet",
  "args" : {
  	"contents": "app.get(\"/${1:}$SELECTION\", routes.${1:}$SELECTION);${0}"
  }
}
@RadioactiveMouse
RadioactiveMouse / snippet.md
Created Jun 19, 2012 — forked from harthur/snippet.md
console.log() key binding for Sublime Text
View snippet.md

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}"
      }
    }
You can’t perform that action at this time.