Skip to content

Instantly share code, notes, and snippets.

View icub3d's full-sized avatar

Joshua Marsh icub3d

  • Optum
  • USA
View GitHub Profile
@icub3d
icub3d / ComplexCubeRoots.go
Created June 23, 2012 16:27
My solutions to "A Tour of Go"
package main
import (
"fmt"
"math/cmplx"
)
func Cbrt(x complex128) complex128 {
z := complex128(1.0)
@icub3d
icub3d / fibonacci.go
Created August 3, 2012 06:09
Determinism Counts! (Memoization)
package main
import (
"fmt"
"time"
)
func Fibonacci(n int64) int64 {
var f int64
@icub3d
icub3d / config.go
Created January 17, 2013 07:29
A complete example of creating a service in go using RPC.
// greeter/config.go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"sync"
)
@icub3d
icub3d / main.go
Created July 29, 2013 23:46
First stab at groupcache.
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"github.com/golang/groupcache"
"io"
"net"
@icub3d
icub3d / addressbook.proto
Created July 31, 2013 13:20
Protobuf in Go
package main;
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
@icub3d
icub3d / main.go
Created August 7, 2013 21:56
An example of how to use mgo, the MongoDB driver for Go.
package main
import (
"bufio"
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"os"
"strings"
)
@icub3d
icub3d / main.go
Created August 8, 2013 00:33
An example of using GridFS in MongoDB.
package main
import (
"bufio"
"fmt"
"io"
"labix.org/v2/mgo"
"os"
"path"
"strings"
@icub3d
icub3d / main.go
Last active October 11, 2016 14:59
An example of using doozer to keep track of your groupcache instances. If you want to run it yourself, you'll want to: go get github.com/golang/groupcache go get github.com/ha/doozer
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"github.com/golang/groupcache"
"github.com/ha/doozer"
"io"
@icub3d
icub3d / mysort.go
Created December 4, 2013 19:59
Interface Performance
package mysort
func min(a, b int) int {
if a < b {
return a
}
return b
}
func insertionSort(data []int, a, b int) {
@icub3d
icub3d / example_wrapio.go
Created January 25, 2014 01:49
An example of wrapio
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"github.com/icub3d/wrapio"
"io"