Skip to content

Instantly share code, notes, and snippets.

@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 <code@christophberger.com>
@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 <code@christophberger.com>
@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