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 / actual-differences.diff
Last active December 29, 2015 12:41
h2-fileserver coverage test
# cat coverage.diff | grep '^\(-\|+\)' > actualDifferences.diff
--- h2-fileserver-coverage 2015-12-29 05:13:58.000000000 -0700
+++ master-coverage 2015-12-29 05:13:29.000000000 -0700
@@ -196,7 +196,7 @@
-net/http/h2_bundle.go:2423: state 66.7%
+net/http/h2_bundle.go:2423: state 0.0%
@@ -222,10 +222,10 @@
-net/http/h2_bundle.go:3016: processFrame 50.0%
+net/http/h2_bundle.go:3016: processFrame 45.5%
-net/http/h2_bundle.go:3095: processResetStream 62.5%
@odeke-em
odeke-em / README.md
Created January 19, 2016 12:11
Fetch a URL and consume its body, useful for testing bandwidth limiting

Usage

$ # go run dlMulti.go urls...
$ go run dlMulti.go https://google.ca https://blog.golang.org https://twitter.com
@odeke-em
odeke-em / gifURIContentValidator.go
Created February 16, 2016 19:58
Util for validating GIF resources.
package main
import (
"fmt"
"image/gif"
"net/http"
"os"
)
func decodeGIF(url string) (*gif.GIF, error) {
@odeke-em
odeke-em / diff.md
Last active April 11, 2016 09:09
encoding/json: cache same named fields since they are already sorted by name to ensure a constant lookup for fields of the same name
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go
index 927f47b..0afa561 100644
--- a/src/encoding/json/encode.go
+++ b/src/encoding/json/encode.go
@@ -1123,29 +1123,33 @@ func typeFields(t reflect.Type) []field {
 
        sort.Sort(byName(fields))
 
+       nameCache := map[string][]field{}
@odeke-em
odeke-em / client.go
Last active May 19, 2016 23:49
Investigating Go issue #15425
package main
import (
"crypto/tls"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
@odeke-em
odeke-em / client.go
Created May 13, 2016 03:23
Code to setup reproduction to try to fix https://github.com/golang/go/issues/15664
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
@odeke-em
odeke-em / dcrypto-cli.go
Created May 22, 2016 23:02
CLI for testing out our new Pure Go file encrypter/decrypter
package main
import (
"flag"
"fmt"
"io"
"os"
"github.com/odeke-em/drive/src/dcrypto"
)
@odeke-em
odeke-em / requester.go
Last active July 6, 2016 19:39
Make nparallel connections to a URI, nreq times. Sample for challenge https://twitter.com/indutny/status/738573179229249537
package main
import (
"crypto/tls"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
@odeke-em
odeke-em / ioVsos_test.go
Created June 26, 2016 22:22
io-vs-os:Pipe-comparisons to see which is better for use
package io_vs_os_test
import (
"io"
"io/ioutil"
"os"
"testing"
)
var (
@odeke-em
odeke-em / mcopy.go
Last active July 30, 2016 19:15
Duplicate a stream n times, and have a notifier to tell you when it is done.
package mcopy
import (
"io"
)
func DuplicateToManyStreams(r io.Reader, n uint) ([]io.Reader, chan bool) {
var readers []io.Reader
var writers []io.Writer