Skip to content

Instantly share code, notes, and snippets.

View abraithwaite's full-sized avatar
:shipit:
:(){ :|:& };:

Alan Braithwaite abraithwaite

:shipit:
:(){ :|:& };:
View GitHub Profile
20:57:08 $ curl -v 'http://www.google.com/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36' --compressed > /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 172.217.6.36...
* TCP_NODELAY set
* Connected to www.google.com (172.217.6.36) port 80 (#0)
> GET / HTTP/1.1
> Host: www.google.com
> Accept: */*
@abraithwaite
abraithwaite / play.go
Created November 8, 2017 22:28
Neat way to do configuration in Golang
package main
import (
"encoding/json"
"errors"
"fmt"
"reflect"
"github.com/tidwall/gjson"
)
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
@abraithwaite
abraithwaite / 40305.patch
Created June 13, 2017 18:13
ZSH Patch without ChangeLog
From 34656ec2f00d6669cef56afdbffdd90639d7b465 Mon Sep 17 00:00:00 2001
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
Date: Tue, 10 Jan 2017 19:18:52 +0000
Subject: [PATCH] 40305: fix some problems redisplaying command line after
interrupt.
Back off previous fix as this only covered some subset of problems.
Remaining problems happend after reset-prompt in TRAPINT.
@abraithwaite
abraithwaite / config.go
Created March 15, 2017 03:03
Awesome way to do configuration in go. Taken from https://github.com/influxdata/telegraf
package main
import (
"io/ioutil"
"log"
"github.com/naoina/toml"
"github.com/naoina/toml/ast"
)
@abraithwaite
abraithwaite / flagsexample.go
Created January 24, 2017 22:13
flags dragons
package main
import (
"fmt"
"flag"
)
var (
flagName = flag.String("name", "default", "myname")
flagPlace = flag.String("place", "france", "myname")
type ErrorSet []error
func (es ErrorSet) Error() string {
return errors.New("Error(s) encountered while processing. First error encountered was: %v")
}
func (s NodeName) FieldName(errs ErrorSet) FieldType {
...
if err != nil {
errs = append(errs, err)
vagrant at local in ~GOPATH/src/github.com/alecthomas/go_serialization_benchmarks (vendor●●)
21:21:28 $ go test -cpuprofile=cpu.out -bench='.*' ./
A test suite for benchmarking various Go serialization methods.
See README.md for details on running the benchmarks.
BenchmarkCapNProtoMarshal-4 3000000 522 ns/op 56 B/op 2 allocs/op
BenchmarkCapNProtoUnmarshal-4 3000000 477 ns/op 200 B/op 6 allocs/op
BenchmarkCapNProto2Marshal-4 2000000 851 ns/op 244 B/op 3 allocs/op
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abraithwaite
abraithwaite / flags_pattern.go
Created June 16, 2016 21:18
Idea to use define common flags in go libraries.
package main
import (
"flag"
"fmt"
)
type Config struct {
A *string
B *int