Skip to content

Instantly share code, notes, and snippets.

include $(GOROOT)/src/Make.$(GOARCH)
all : webirc
TARG=webirc
GOFILES=main.go
include $(GOROOT)/src/Make.cmd
POST /accounts/OAuthGetRequestToken HTTP/1.1
Host: www.google.com
User-Agent: Go http package
Connection: close
Transfer-Encoding: chunked
Authorization: OAuth oauth_callback="http%3A%2F%2Flocalhost%3A8080%2Fcallback%2Foauth", oauth_consumer_key="cetico.org", oauth_nonce="5577006791947779410", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1282521243", oauth_version="1.0", oauth_signature="pVrdPTu2u5nYy2x5UgJZCTeKF6w%3D"
Content-Type: application/x-www-form-urlencoded
0
@nictuku
nictuku / gist:997386
Created May 29, 2011 01:47
golang union types.
// Objective: demonstrate that there are more use cases
// for union types than previously thought.
// http://groups.google.com/group/golang-nuts/browse_thread/thread/fbde059a7cfd2fa9
//
// Interface inference.
// We already have type inference, so this would be very Go-like:
type typeA int
func (x typeA) A() {}
func (x typeB) C() {}
@nictuku
nictuku / gist:1341049
Created November 5, 2011 03:17
go snippet: Using the rand package to randomize access to a slice.
package main
import (
"fmt"
"rand"
"time"
)
func main() {
a := []int64{0, 1, 2, 3, 4, 5, 6}
@nictuku
nictuku / hello.go
Created February 25, 2012 19:38
Testing cocode
// You can edit this code!
// Click here and start typing.
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
@nictuku
nictuku / gist:2073020
Created March 18, 2012 13:51
memcache read from file
package main
import (
"bufio"
"bytes"
"encoding/base64"
"flag"
"fmt"
"io"
"os"
@nictuku
nictuku / sshd.go
Created April 8, 2012 15:43
Go SSH server complete example
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"code.google.com/p/go.crypto/ssh"
"code.google.com/p/go.crypto/ssh/terminal"
@nictuku
nictuku / ping.go
Created July 30, 2012 23:40
pingmeplz
package main
import (
"fmt"
logpkg "log"
"log/syslog"
"net"
"net/http"
"os"
"os/exec"
@nictuku
nictuku / gist:4052652
Created November 10, 2012 21:51
supernode (incomplete)
// this is not complete and doesn't compile, but hopefully it's a useful guideline.
randInfoHash := false
if infoHash != "" {
if infoHash == "rand" {
randInfoHash = true
// No need to insist in getting peers for a specific infohash,
// since we're probing the address space.
numTargetPeers = 1
@nictuku
nictuku / randmatmul.go
Last active January 4, 2016 13:59
Improving the Julia microbench for Go
package main
import (
"fmt"
"math/rand"
"time"
"github.com/gonum/matrix/mat64"
// Switch to cblas for the C implementation of BLAS.
blas "github.com/gonum/blas/goblas"
)