Skip to content

Instantly share code, notes, and snippets.

Avatar

Matias Forbord codeluggage

View GitHub Profile
@brock
brock / nodereinstall.sh
Last active May 1, 2021
Complete Node Reinstall. I've moved this to a repo at http://git.io/node-reinstall
View nodereinstall.sh
#!/bin/bash
# node-reinstall
# credit: http://stackoverflow.com/a/11178106/2083544
## program version
VERSION="0.0.13"
## path prefix
PREFIX="${PREFIX:-/usr/local}"
@mrvdot
mrvdot / save.go
Created Nov 24, 2013
Convenience method to save any object into the GAE datastore using Go. For a full walk-though of what and why, see the article at http://www.mrvdot.com/all/creating-a-universal-save-method-in-go-on-gae
View save.go
func Save(c appengine.Context, obj interface{}) (key *datastore.Key, err error) {
kind, val := reflect.TypeOf(obj), reflect.ValueOf(obj)
str := val
if val.Kind().String() == "ptr" {
kind, str = kind.Elem(), val.Elem()
}
if str.Kind().String() != "struct" {
return nil, errors.New("Must pass a valid object to struct")
}
dsKind := kind.String()
@sanatgersappa
sanatgersappa / alt.go
Last active Mar 28, 2020
Alternative handler for multiple file uploads in Go.
View alt.go
package main
import (
"html/template"
"io"
"net/http"
"os"
)
//Compile templates on start