Skip to content

Instantly share code, notes, and snippets.

View odeke-em's full-sized avatar

Emmanuel T Odeke odeke-em

View GitHub Profile
@odeke-em
odeke-em / uberhook.go
Created June 10, 2017 07:46
Server to receive, verify and process webhooks from Uber
package main
import (
"flag"
"fmt"
"log"
"net/http"
"golang.org/x/crypto/acme/autocert"
@odeke-em
odeke-em / rsp-sample.js
Last active July 5, 2017 23:30
Sample usage of rsp for instant/realtime search
<script type="text/javascript" src="https://storage.googleapis.com/realsp/rsp.min.js"></script>
var resp = new Resp({
"itemId": "searchInput",
"apiKey": "fe4123b3-ad36-44f7-9a5b-0ea8c3abc813",
"initialSearch": initialKeyword,
"onMessage": handleNewData,
"onDisconnected": turnOnSpinnerGIF,
"onConnected": turnOffSpinnerGIF,
"onError": function(err) {
@odeke-em
odeke-em / uberpromo.go
Created July 1, 2017 06:43
Applying a promo code to your Uber account
package main
import (
"fmt"
"log"
"os"
"github.com/orijtech/uber/v1"
)
@odeke-em
odeke-em / ubercreds.go
Last active July 5, 2017 23:30
Uber OAuth2.0 credentials retrieval
package main
import (
"encoding/json"
"log"
"os"
"path/filepath"
"github.com/orijtech/uber/oauth2"
)
2017/07/11 01:25:03 http2: Transport failed to get client conn for precious.jp:443: http2: no cached connection was available
2017/07/11 01:25:04 http2: Transport creating client conn 0xc42014c1a0 to 202.238.151.220:443
2017/07/11 01:25:04 http2: Framer 0xc42044d0a0: wrote SETTINGS len=18, settings: ENABLE_PUSH=0, INITIAL_WINDOW_SIZE=4194304, MAX_HEADER_LIST_SIZE=10485760
2017/07/11 01:25:04 http2: Framer 0xc42044d0a0: wrote WINDOW_UPDATE len=4 (conn) incr=1073741824
2017/07/11 01:25:04 http2: Transport encoding header ":authority" = "precious.jp"
2017/07/11 01:25:04 http2: Transport encoding header ":method" = "GET"
2017/07/11 01:25:04 http2: Transport encoding header ":path" = "/"
2017/07/11 01:25:04 http2: Transport encoding header ":scheme" = "https"
2017/07/11 01:25:04 http2: Transport encoding header "accept-encoding" = "gzip"
2017/07/11 01:25:04 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
@odeke-em
odeke-em / cmp_test.go
Created August 10, 2017 00:51
comparing var big.NewInt(0) vs allocating big.NewInt(0) everytime
package main
import (
"math/big"
"testing"
)
var bns = []*big.Int{
big.NewInt(0),
big.NewInt(10),
@odeke-em
odeke-em / deferbench_test.go
Last active March 2, 2018 20:51
Benchmarking invoking defer fn() vs fn()
package main
import (
"sync"
"testing"
)
type st struct {
sync.Mutex
@odeke-em
odeke-em / README.md
Created August 22, 2017 10:51
Uber Driver API implemented in Go

Go get it

go get -u -v github.com/orijtech/uber/v1

Requirements

You just need to have a serialized OAuth2.0 JSON configuration file saved in in $HOME/.uber/credentials.json

Running them

For each file, just do:

package main
import (
"flag"
"fmt"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
@odeke-em
odeke-em / README.md
Created September 3, 2017 10:31
GDAX/Coinbase Websocket Feed