Skip to content

Instantly share code, notes, and snippets.

View IndianGuru's full-sized avatar

IndianGuru IndianGuru

View GitHub Profile
@IndianGuru
IndianGuru / apiaifile.go
Created May 3, 2016 04:14
Send text to get a .wav file
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
@IndianGuru
IndianGuru / QResponse.txt
Created May 2, 2016 09:45
Sample Response Struct
type QResponse struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Result struct {
Source string `json:"source"`
ResolvedQuery string `json:"resolvedQuery"`
Action string `json:"action"`
ActionIncomplete bool `json:"actionIncomplete"`
Parameters struct {
Name string `json:"name"`
@IndianGuru
IndianGuru / response.txt
Created May 2, 2016 09:43
Sample JSON response
{
"id": "cfcbd337-6b66-4393-a6a3-74fc5487cedb",
"timestamp": "2016-02-16T00:30:13.529Z",
"result": {
"source": "agent",
"resolvedQuery": "hi my name is Sam",
"action": "greetings",
"actionIncomplete": false,
"parameters": {
"name": "Sam"
@IndianGuru
IndianGuru / apiai.go
Last active May 2, 2016 10:07
Go program that uses the api.ai service
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"
)
@IndianGuru
IndianGuru / text.go
Last active March 10, 2018 20:11
Reads the text within images
package main
import (
"encoding/base64"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
@IndianGuru
IndianGuru / request.txt
Created April 23, 2016 04:05
Request format
{
"requests":[
{
"image":{
"content":"<base64-encoded-image-bytes>"
},
"features":[
{
"type":"<FEATURE_TYPE>",
"maxResults":1
@IndianGuru
IndianGuru / label2.go
Last active April 23, 2016 10:11
Second cut of program
package main
import (
"encoding/base64"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
@IndianGuru
IndianGuru / label1.go
Last active April 22, 2016 03:09
First cut of program
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
)
func main() {
@IndianGuru
IndianGuru / process.go
Created January 19, 2016 04:16
Handler using the same template in different template files
func process(w http.ResponseWriter, r *http.Request) {
rand.Seed(time.Now().Unix())
var t *template.Template
if rand.Intn(10) > 5 {
t, _ = template.ParseFiles("layout.html", "red_hello.html")
} else {
t, _ = template.ParseFiles("layout.html", "blue_hello.html")
}
t.ExecuteTemplate(w, "layout", "")
}
{{ define "content" }}
<h1 style="color: blue;">Hello World!</h1>
{{ end }}