Skip to content

Instantly share code, notes, and snippets.

@kylelemons
kylelemons / .tmux.conf
Last active August 29, 2015 14:12
TMux Config
#
# General settings
#
# Set terminal titles
set -g set-titles on
# Expect UTF-8
set -g utf8 on
@kylelemons
kylelemons / euler24_brute.go
Created December 9, 2012 05:58
Project Euler #24 in Go - Answer: [2 7 8 3 9 1 5 4 6 0]
package main
import (
"fmt"
)
const Max = 10
const Index = 1000000
func main() {
git reflog expire --expire=1.minute refs/heads/master
git fsck --unreachable
git prune
git gc
@kylelemons
kylelemons / jsonwrap.go
Created April 17, 2012 17:58
Decoding JSON within a wrapper using interface{}
package main
import (
"encoding/json"
"fmt"
"io"
"strings"
)
type ResponseError struct {
@moraes
moraes / gist:2370781
Created April 12, 2012 20:32
GetPage for App Engine datastore (Go)
package foo
import (
"reflect"
"appengine"
"appengine/datastore"
)
var (
@kylelemons
kylelemons / infinite.go
Created January 12, 2012 01:27
Infinite channel buffer without "sync"
// assume the following exist and are set to unbuffered channels:
// var (
// next chan Type
// in chan Type
// )
go func() {
defer close(next)
// pending events (this is the "infinite" part)
@kylelemons
kylelemons / graph.go
Created November 17, 2011 19:01
A fun little graph demo
package main
import (
"fmt"
"sync"
)
type WaitList []*sync.WaitGroup
func (l WaitList) Done() {
for _, wg := range l {
@kylelemons
kylelemons / gencert.sh
Created November 17, 2011 02:55
Generate a key/certificate
#!/bin/bash
# Usage: gencert.sh
# Generates SSL certificates
set -e
PREFIX="my_"
function oops() {
echo "Failed."
exit 1
@djsutherland
djsutherland / example.hmm
Created November 1, 2011 05:10
Code for a Hidden Markov Model, along with some sample data / parameters for testing.
4 # number of states
START
COLD
HOT
END
3 # size of vocab
1
2
3
@kylelemons
kylelemons / Makefile
Created October 20, 2011 18:27
A Makefile for protocol buffers in Go
include $(GOROOT)/src/Make.inc
PROTOFILES=$(wildcard *.proto)
GOPROTOFILES=$(patsubst %.proto,%.pb.go,$(PROTOFILES))
TARG=protopackage
GOFILES=\
$(GOPROTOFILES)\
CLEANFILES+=$(GOPROTOFILES)