Skip to content

Instantly share code, notes, and snippets.

View christophberger's full-sized avatar

Christoph Berger christophberger

View GitHub Profile
@christophberger
christophberger / container.go
Created October 30, 2016 15:41
A container in less than 60 lines of Go
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {

Keybase proof

I hereby claim:

  • I am christophberger on github.
  • I am christophberger (https://keybase.io/christophberger) on keybase.
  • I have a public key ASC8b-gcdQzzyAjieAUZNehGbw2z1Fd2V2xp8SduLfHYxAo

To claim this, I am signing this object:

@christophberger
christophberger / typecast.go
Last active April 25, 2016 08:37
Approach to accessing struct-specific attributes through an interface using typecast in Go
package main
import "fmt"
// The interface.
type interf interface {
Method(string) string
}
// A struct.
@christophberger
christophberger / GoAndWait.md
Last active August 29, 2015 14:18
GoAndWait (go generate test, using reusee/ccg)

GoAndWait

  • Tests code generation using ccg (reusee/ccg).
  • Encapsulates a concurrency pattern.

GoAndWait wraps a common concurrency pattern into a generic function:

  • The items of a list shall be processed concurrently
  • The main routine must wait until all items have been processed
@christophberger
christophberger / winsetmousespeed.go
Created February 5, 2015 21:47
Switch Mouse Speed in Windows 7 (Go source)
/*A command-line tool for setting the mouse speed on Windows machines.
This comes in handy when using different mouses (e.g. at work and at home)
that require different speed settings.
Dependencies: sys package (go get golang.org/x/sys/...)
License:
Copyright (c) 2015, Christoph Berger <[email protected]>
@christophberger
christophberger / windisablesnaptodefaultbutton.go
Created February 5, 2015 21:40
Disable Snap To Default Button behavior in Windows (Go source)
/*A command-line tool for setting the mouse speed on Windows machines.
This comes in handy when using different mouses (e.g. at work and at home)
that require different speed settings.
Dependencies: sys package (go get golang.org/x/sys/...)
License:
Copyright (c) 2015, Christoph Berger <[email protected]>
@christophberger
christophberger / functionaloptions.go
Created October 15, 2014 21:15
Functional Options in Go
// Functional Options
// Written to help me wrapping my brains around Functional Options - see this
// blog post about a speech by Dave Cheney:
// http://dotgo.sourcegraph.com/post/99643162983/dave-cheney-functional-options
//
// The idea behind Functional Options:
// How to add options to an API later without breaking the API?
// Solution:
package main