Skip to content

Instantly share code, notes, and snippets.

View pwaller's full-sized avatar
🔢
🔨

Peter Waller pwaller

🔢
🔨
  • Manchester, UK
View GitHub Profile
package main
import "reflect"
func main() {}
var types = map[reflect.Kind]reflect.Type{
reflect.Bool: reflect.ValueOf(bool(false)).Type(),
reflect.Int: reflect.ValueOf(int(0)).Type(),
reflect.Int8: reflect.ValueOf(int8(0)).Type(),
@pwaller
pwaller / Dockerfile
Created January 8, 2019 11:12
Attempt at doing fast cached rebuilds with stack.
# syntax = docker/dockerfile:experimental
# Build with DOCKER_BUILDKIT=1 while support for caching features is not 'on by default' in Docker.
FROM ubuntu:18.04
ENV STACK_VERSION=1.9.3 STACK_SHA256SUM=c9bf6d371b51de74f4bfd5b50965966ac57f75b0544aebb59ade22195d0b7543
RUN wget --no-verbose https://github.com/commercialhaskell/stack/releases/download/v${STACK_VERSION}/stack-${STACK_VERSION}-linux-x86_64-static.tar.gz \
&& echo ${STACK_SHA256SUM} stack-${STACK_VERSION}-linux-x86_64-static.tar.gz | sha256sum --check --strict \
&& tar \
token := make(chan struct{}, 1)
token <- struct{}{} // A goroutine must have the token to print
for test := range readTests(os.Stdin) {
gate <- struct{}{}
next := make(chan struct{}, 1) // where to send the token to.
go func(test Test, in, out chan struct{}) {
defer func() { <-gate }()
// Asynchronous work.
@pwaller
pwaller / Dockerfile
Created July 11, 2016 12:58
go build -race failing on go1.7rc1-alpine
# Build with:
# docker build -t race-build-failure https://gist.github.com/7b8c73a84b4c5bef5ce107fe009eb8d8.git
FROM golang:1.7rc1-alpine
RUN apk add --no-cache musl-dev gcc
WORKDIR /go/src/testrace
RUN echo $'package main\nfunc main() {}' > main.go
@pwaller
pwaller / nongnu.patch
Created June 1, 2016 12:59
Make clang sanitizers work under musl
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
index e26b400..9618933 100644
--- a/lib/asan/asan_linux.cc
+++ b/lib/asan/asan_linux.cc
@@ -39,7 +39,7 @@
#include <sys/link_elf.h>
#endif
-#if SANITIZER_ANDROID || SANITIZER_FREEBSD
+#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_NONGNU
Useful series of blog posts for understanding how nix works:
* http://lethalman.blogspot.co.uk/search/label/nixpills
@pwaller
pwaller / docker-compose.yml
Last active February 20, 2018 01:07
selenium hub docker-compose file
hub:
image: selenium/hub
ports:
- "127.0.0.1:4444:4444"
chrome:
image: selenium/node-chrome-debug
links: [hub]
external_links:
- myapplication_frontend_1:pdftables
@pwaller
pwaller / vmdk.go
Created December 8, 2015 16:41
Experimental code for reading/writing VMDK files directly
package main
import (
"encoding/binary"
"fmt"
"io"
"log"
"os"
"reflect"
)
@pwaller
pwaller / dockerclient-bug.go
Last active October 20, 2016 15:58
Dockerclient binary stdout bug
package main
import (
"fmt"
"io"
"log"
"os"
docker "github.com/fsouza/go-dockerclient"
)
@pwaller
pwaller / DockerRun.go
Created November 12, 2015 17:42
Docker attach bug.
func DockerRun(c *docker.Client, imageName string) (io.ReadCloser, error) {
log.Printf("Create container...")
cont, err := c.CreateContainer(docker.CreateContainerOptions{
Config: &docker.Config{
Hostname: "generateruntimecontext",
AttachStdout: true,
AttachStderr: true,
Image: imageName,
Labels: map[string]string{
"orchestrator": "hanoverd",