Skip to content

Instantly share code, notes, and snippets.

kendellfab / golang-json-marshall
Created Aug 16, 2013
Handling custom Json marshalling in golang.
View golang-json-marshall
type Whatever struct {
someField int
func (w Whatever) MarshalJSON() ([]byte, error) {
return json.Marshal(struct{
SomeField int `json:"some_field"`
SomeField: w.someField,
kendellfab / goto-sublime
Created Aug 1, 2013
Add mouse click `goto definition` in sublime text 3.
View goto-sublime
Linux - create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User
Mac - create "Default (OSX).sublime-mousemap" in ~/Library/Application Support/Sublime Text 3/Packages/User
Win - create "Default (Windows).sublime-mousemap" in %appdata%\Sublime Text 3\Packages\User
"button": "button1",
"count": 1,
"modifiers": ["ctrl"],
"press_command": "drag_select",
kendellfab / read_line.go
Created Nov 11, 2013
Golang --> Read file line by line.
View read_line.go
func readLine(path string) {
inFile, _ := os.Open(path)
defer inFile.Close()
scanner := bufio.NewScanner(inFile)
for scanner.Scan() {
kendellfab / golang-request
Created Aug 26, 2013
Golang Example for adding custom headers to a request.
View golang-request
client := &http.Client{]
req, err := http.NewRequest("POST", "", bytes.NewReader(postData))
req.Header.Add("User-Agent", "myClient")
resp, err := client.Do(req)
defer resp.Body.Close()
View user_context.go
import (
type key int
var contextKey = key(22)
func SetUser(usr *User, r *http.Request) {
View kttime.go
// KTTime is an example of a type that is aliased to time, than implements the json marshaling functions.
// This is an example for how to build serialization interopability with kotlin/gson.
package kttime
type KTTime time.Time
func (t KTTime) MarshalJSON() ([]byte, error) {
gt := time.Time(t)
f := gt.Format(ktFormat)
return json.Marshal(f)
kendellfab /
Created Jul 14, 2012
Bash script for changing version code and version name in an android manifest.
VERSIONCODE=`grep versionCode $MANIFEST_FILE | sed 's/.*versionCode="//;s/".*//'`
VERSIONNAME=`grep versionName $MANIFEST_FILE | sed 's/.*versionName="//;s/\.[0-9]*".*//'`
echo "Updating Android build information. New version code: $NEWCODE - New version name: $NEWNAME";
sed -i 's/versionCode *= *"'$VERSIONCODE'"/versionCode="'$NEWCODE'"/; s/versionName *= *"[^"]*"/versionName="'$NEWNAME'"/' $MANIFEST_FILE
kendellfab / GoPath Bin
Created Aug 1, 2013
Add this to $PATH variable to have multiple gopath bin directories.
View GoPath Bin
View supervisord_config
; supervisor config file
file=/var/run//supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/ ; (supervisord pidfile;default
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
View mysql_user
GRANT ALL PRIVILEGES ON dbTest.* To 'user'@'hostname' IDENTIFIED BY 'password';