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 / mux-demo.go
Last active December 21, 2015 06:37
Demonstrating blocking and non-blocking channels in Go
package main
import (
"fmt"
"math/rand"
"time"
)
func fillUp(id int) chan string {
content := make(chan string)
$ go test --cover
2015/12/04 14:37:37 http: TLS handshake error from 127.0.0.1:63573: remote error: bad certificate
--- FAIL: TestTransportConnectionCloseOnRequestDisableKeepAlive_h2 (0.00s)
	transport_test.go:282: Get https://127.0.0.1:63572: x509: certificate signed by unknown authority
FAIL
coverage: 77.3% of statements
exit status 1
FAIL	net/http	22.478s
diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go
index e59ab2c..ba0beff 100644
--- a/src/net/http/client_test.go
+++ b/src/net/http/client_test.go
@@ -65,12 +65,15 @@ func (w chanWriter) Write(p []byte) (n int, err error) {
return len(p), nil
}
-func TestClient(t *testing.T) {
+func TestClient_h1(t *testing.T) { testClient(t, false) }
@odeke-em
odeke-em / env-load.go
Created November 30, 2015 00:20
Env vars don't change within running program in various langs
package main
import (
"fmt"
"os"
)
func cwd() string {
wd, _ := os.Getwd()
return wd

Keybase proof

I hereby claim:

  • I am odeke-em on github.
  • I am emmtodeke (https://keybase.io/emmtodeke) on keybase.
  • I have a public key whose fingerprint is B4C1 3DEC 5C12 70DF ECFA 4F93 638B AA7D 15E5 9951

To claim this, I am signing this object:

const crypto = require('crypto');
function hexSha256ify(password) {
var sha256sum = crypto.createHash('sha256');
sha256sum.update(password + '');
return sha256sum.digest('hex');
}
function createNewUser(data) {
data = data || {};
#include <stdio.h>
int main() {
FILE *ifp = fopen(__FILE__, "r");
if (ifp == NULL)
return -1;
char c;
while ((c = getc(ifp)) != EOF) putchar(c);
fclose(ifp);
return 0;
#!/bin/bash
target_name="foo" # Remember to set your name here
target_email="[email protected]" # Set the new email here
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = $target_name ];
then export GIT_AUTHOR_EMAIL=$target_email;
fi; git commit-tree "$@"'
var bucket = new AWS.S3({params: {Bucket: 'foo'}});
var callback = function(err, data) { if (err) console.log(err); else console.log(data);}
// Objects since 2015-02-23
bucket.listObjects({Prefix: '2015-02', Marker: '2015-02-23-00:00:00'}, callback);
// Objects after 4:00 p.m on 2015-02-23
bucket.listObjects({Prefix: '2015-02-23', Marker: '2015-02-23-16:00:00'}, callback);
@odeke-em
odeke-em / expected.c
Created February 25, 2015 22:49
const+spillover: A trivial reproduction of what tripped me out with using const within a for loop.
#include <stdio.h>
#include <string.h>
int main() {
char *lang = "c_language";
size_t len = strlen(lang);
size_t i;
for (i = 0; i < len; ++i) {
const char c = lang[i];