Skip to content

Instantly share code, notes, and snippets.

View IndianGuru's full-sized avatar

IndianGuru IndianGuru

View GitHub Profile
@IndianGuru
IndianGuru / geowebgap.go
Created September 22, 2015 05:08
geowebgap.go
package geowebgap
import (
"encoding/json"
"fmt"
"html/template"
"log"
"net/http"
"net/url"
@IndianGuru
IndianGuru / mongohqconnect.go
Created September 25, 2015 07:30
mongohqconnect.go
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"log"
"os"
)
@IndianGuru
IndianGuru / webapphr.go
Last active September 26, 2015 03:28
webapphr.go
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
@IndianGuru
IndianGuru / gomongohql.go
Created September 27, 2015 07:39
gomongohql.go
package main
import (
"fmt"
"html/template"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"log"
"net/http"
"os"
@IndianGuru
IndianGuru / blobstrex1.go
Created October 2, 2015 04:31
blobstrex1.go
func init() {
http.HandleFunc("/", handleRoot)
}
func serveError(c appengine.Context, w http.ResponseWriter, err error) {
w.WriteHeader(http.StatusInternalServerError)
w.Header().Set("Content-Type", "text/plain")
io.WriteString(w, "Internal Server Error")
c.Errorf("%v", err)
}
@IndianGuru
IndianGuru / blobstrex2.go
Created October 2, 2015 05:07
blobstrex2.go
var rootTemplate = template.Must(template.New("root").Parse(rootTemplateHTML))
const rootTemplateHTML = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/upper.css">
<title>Upload your Photo</title>
</head>
@IndianGuru
IndianGuru / blobstrex3.go
Created October 2, 2015 07:16
blobstrex3.go
func handleUpload(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
blobs, _, err := blobstore.ParseUpload(r)
if err != nil {
serveError(c, w, err)
return
}
file := blobs["file"]
if len(file) == 0 {
c.Errorf("no file uploaded")
@IndianGuru
IndianGuru / blobstrex4.go
Last active October 2, 2015 08:19
blobstrex4.go
func handleServe(w http.ResponseWriter, r *http.Request) {
// Instantiate blobstore reader
reader := blobstore.NewReader(appengine.NewContext(r),
appengine.BlobKey(r.FormValue("blobKey")))
lat, lng, _ := getLatLng(reader)
blobstore.Delete(appengine.NewContext(r),
appengine.BlobKey(r.FormValue("blobKey")))
@IndianGuru
IndianGuru / app.yaml
Created October 2, 2015 09:05
app.yaml
# This is a comment
# application is mandatory
application: blobstrex-1081
# version is mandatory
version: 1-0
# runtime is mandatory
runtime: go
@IndianGuru
IndianGuru / upper.css
Created October 2, 2015 09:07
upper.css
body {
background-color: #C2A7F2;
font-family: sans-serif;
}
h1 {
color: #2A1959;
border-bottom: 2px solid #2A1959;
}
h2 {
color: #474B94;