Skip to content

Instantly share code, notes, and snippets.

View collinvandyck's full-sized avatar
🏠
Working from home

Collin Van Dyck collinvandyck

🏠
Working from home
View GitHub Profile
@collinvandyck
collinvandyck / deepequal_test.go
Created January 29, 2014 00:32
damn reflect you slow but i still <3 you
package main
import (
"reflect"
"testing"
)
func BenchmarkMapsEqualsManual(b *testing.B) {
m1 := newMap()
m2 := newMap()
@collinvandyck
collinvandyck / gist:8813404
Created February 4, 2014 22:12
lol what the fuck javascript developers
controller('MainCtrl', function(
$window,
$location
){
this.switch = function() {
$location.path('/alt' === $location.path() ? '/' : '/alt');
};
});
@collinvandyck
collinvandyck / alloc_test.go
Created February 13, 2014 03:27
pass by value vs pass by reference
package main
import "testing"
type Stuff struct {
Hello string
Goodbye string
Slice []string
}
import (
"fmt"
"reflect"
"strings"
)
type ToStringer struct {
pieces []string
}
package main
import "testing"
type Foo struct {
}
func (f *Foo) Hi() {
}
// helper methods for testing
package test
import (
"fmt"
"path/filepath"
"runtime"
"testing"
)
for _, foo := range foos {
// is there a valid reason for ever taking the address of a
// variable written to by range?
process(&foo)
}
@collinvandyck
collinvandyck / run-until-failure.sh
Created September 4, 2014 17:18
repeat some task until it has a non-zero exit
#!/bin/bash
while :; do
run_something # we want to run this thing until it fails
if [[ "$?" -ne "0" ]]
then
# we detected a failure, quit
exit
fi
done
query := req.URL.Query()
query.Set("user_id", 1)
req.URL.RawQuery = query.Encode()
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/microservices", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "lol no\n")