Skip to content

Instantly share code, notes, and snippets.

View awalterschulze's full-sized avatar
🇿🇦
PhD Informatics Student

Walter Schulze awalterschulze

🇿🇦
PhD Informatics Student
View GitHub Profile
@awalterschulze
awalterschulze / .bash_profile
Created February 25, 2016 13:31
view graph from selected text in iterm
alias viewgraph='pbpaste | dot -Tpdf | open -f -a /Applications/Preview.app'
@awalterschulze
awalterschulze / link
Created May 30, 2016 12:33
memory profiling and looking for escapes to heap
@awalterschulze
awalterschulze / main.go
Last active June 1, 2016 08:18
golang flag library
package "main"
import "somelibrary"
import "flags"
func main() {
someFlag := somelibrary.Impls.Flag()
flags.Parse()
someImpl := somelibrary.GetImpl(someFlag)
run(someImpl)
@awalterschulze
awalterschulze / wait.js
Created August 22, 2016 07:19
benchmark html page render - javascript
var start = Date.now();
$.ajax({
method: 'GET',
url: 'someurl'
})
.done(function () {
$someElement.html('<div id="results"></div>');
console.log("done", Date.now() - start);
})
.fail(function () {
@awalterschulze
awalterschulze / Makefile
Created February 2, 2017 13:27
golang: How to check whether a function is inlined
all:
make build
make objdump
build:
go build -gcflags -m main.go
objdump:
go tool objdump -s "main.main" main | grep CALL
@awalterschulze
awalterschulze / Makefile
Created June 15, 2017 11:30
when docker-compose is not installed by docker is
DOCKER_COMPOSE := $(shell command -v docker-compose 2>/dev/null)
ifndef DOCKER_COMPOSE
DOCKER_COMPOSE = docker run --rm -i --volume /var/run/docker.sock:/var/run/docker.sock --volume $(shell pwd):/composefile -w /composefile docker/compose:1.8.1
endif
@awalterschulze
awalterschulze / goexperiencereport.md
Last active September 24, 2017 14:47
Go Experience Report: Generic functions cannot be passed as values

Generic functions cannot be passed as values

While developing GoDerive, a code generator for Go, I ran into the following problem.

I could not infer the type of the input arguments of a function, if that function's input argument types are not specified and the function is not being called right away.

I wanted to write:

func TestCurriedEqualCompileError(t *testing.T) {
@awalterschulze
awalterschulze / goexperiencereport.md
Last active March 19, 2018 18:04
For Sum Types: Multiple return parameters are overrated

For Sum Types: Multiple return parameters are overrated

In this Go Experience Report I am going to make a case for sum types over multiple return parameters.

Analysis of multiple return parameters

I wrote a little tool which does some analysis of Go source code:

https://github.com/awalterschulze/goanalysis

@awalterschulze
awalterschulze / Dockerfile
Created October 6, 2017 13:09
Run a cassandra in a docker with preloaded data
FROM cassandra:3.1.1
RUN mkdir -p /tmp/var/lib/cassandra /etc/cassandra \
&& chown -R cassandra:cassandra /tmp/var/lib/cassandra /etc/cassandra \
&& chmod 777 /tmp/var/lib/cassandra /etc/cassandra
RUN sed -i "s~/var/lib/cassandra~/tmp/var/lib/cassandra~g" /etc/cassandra/cassandra.yaml
COPY *.cql /tmp/
@awalterschulze
awalterschulze / Makefile
Created October 20, 2017 08:39
building go with a docker
GODOCKER = docker run --network host --rm --user $(shell id -u):$(shell id -g) -v $(PWD):/go/src/path/to/project -w /go/src/path/to/project golang:1.8.3-alpine3.6
GOFLAGS = -ldflags '-d' -tags netgo -installsuffix netgo
build:
$(GODOCKER) go build $(GOFLAGS) -o ./cmd/mycmd/mycmd ./cmd/mycmd
test:
$(GODOCKER) go test -test.v ./...