Skip to content

Instantly share code, notes, and snippets.

@nikhan
nikhan / go websocket client
Created March 4, 2014 01:31
go websocket client
package main
import (
"fmt"
"code.google.com/p/go.net/websocket"
)
func main() {
ws, err := websocket.Dial("ws://localhost:80/ws/", "", "http://localhost")
if err != nil {
package main
import (
"fmt"
"github.com/gorilla/websocket"
"net/http"
"time"
)
func main() {
package main
import(
"net"
"fmt"
"bufio"
"time"
)
var emit chan []byte
package main
import (
"fmt"
"math/rand"
"time"
)
type Stream chan interface{}
type StreamMap func(interface{}) interface{}
@nikhan
nikhan / main.go
Last active August 29, 2015 14:05
global server state, individual client state, websocket, go
package main
import (
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
"log"
"net/http"
"sync"
@nikhan
nikhan / main.go
Created September 11, 2014 03:07
simple data pipeline
package main
import (
"time"
"fmt"
)
type Task func(interface{}) interface{}
type Sink func(interface{})
curl localhost:7071/blocks -d '{"type":"delay"}' #1
curl localhost:7071/blocks -d '{"type":"log"}' #2
curl localhost:7071/blocks -d '{"type":"kvGet"}' #3
curl localhost:7071/sources -d '{"type":"key-value"}' #4
curl localhost:7071/blocks -d '{"type":"isError"}' #5
curl localhost:7071/blocks -d '{"type":"latch"}' #6
curl localhost:7071/blocks -d '{"type":"kvSet"}' #7
curl localhost:7071/blocks -d '{"type":"gate"}' #8
curl localhost:7071/blocks -d '{"type":"+"}' #9
curl localhost:7071/blocks -d '{"type":"sink"}' #10
curl localhost:7071/blocks -d '{"type":"+"}' #1
curl localhost:7071/blocks -d '{"type":"first"}' #2
curl localhost:7071/blocks -d '{"type":"sink"}' #3
curl localhost:7071/blocks -d '{"type":"latch"}' #4
curl localhost:7071/blocks -d '{"type":"log"}' #5
curl localhost:7071/blocks -d '{"type":"identity"}' #6
curl -X PUT localhost:7071/blocks/2/routes/0 -d '{"type":"const","value":true}'
curl -X PUT localhost:7071/blocks/4/routes/0 -d '{"type":"const","value":0}'
curl -X PUT localhost:7071/blocks/1/routes/1 -d '{"type":"const","value":1}'
@nikhan
nikhan / gist:78e54c9cef19b82dc85d
Created February 15, 2015 01:24
pusher testing
curl localhost:7071/sources -d '{"type":"value"}'
curl -X PUT localhost:7071/sources/1/value -d '"Hello world"'
curl localhost:7071/blocks -d '{"type":"pusher"}'
curl localhost:7071/blocks -d '{"type":"log"}'
curl localhost:7071/blocks -d '{"type":"valueGet"}'
curl localhost:7071/links -d '{"source":1}'
curl localhost:7071/links -d '{"source":1,"block":4}'
curl localhost:7071/connections -d '{"source":{"id":2,"route":0},"target":{"id":4,"route":0}}'
curl localhost:7071/connections -d '{"source":{"id":4,"route":0},"target":{"id":3,"route":0}}'
@nikhan
nikhan / gist:96ff755cb129334c2145
Created March 16, 2015 23:47
recursive dot_clean
If you need a recurisve dot clean and your folders have spaces in them:
find . -type d | sed 's/^/"/g' | sed 's/$/"/g' | xargs dot_clean -m