Skip to content

Instantly share code, notes, and snippets.

View jordanorelli's full-sized avatar
🎴

Jordan Orelli jordanorelli

🎴
View GitHub Profile
@jordanorelli
jordanorelli / main.go
Created March 17, 2012 20:21
mysql test (golang)
package main
import (
"io"
"fmt"
"net/http"
"github.com/ziutek/mymysql/mysql"
_ "github.com/ziutek/mymysql/thrsafe"
"runtime"
)
@jordanorelli
jordanorelli / main.go
Created March 17, 2012 22:00
pissing contest
package main
import (
"fmt"
"github.com/ziutek/mymysql/mysql"
"io"
"net/http"
// "runtime"
_ "github.com/ziutek/mymysql/thrsafe"
)
#!/usr/bin/env python
import collections
import string
from string import ascii_lowercase
from sys import stderr
pair_counts = {}
# the pair_counts dict will have a key for each character that we've seen. The
# values associated to these keys will themselves be dictionaries, whose keys
# are also characters, such that pair_counts['a']['k'] would be the number of
package main
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"net/http"
"net/url"
"os"
@jordanorelli
jordanorelli / inner.go
Created April 7, 2012 17:08
inner function call
package main
import "fmt"
func main() {
var fn func(int)
fn = func(x int) {
fmt.Println(x)
fn(x+1)
}
@jordanorelli
jordanorelli / needless.go
Created April 7, 2012 18:11
golang tour exercise 68
package main
import (
"fmt"
"sort"
"tour/tree"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
@jordanorelli
jordanorelli / example.go
Created April 7, 2012 19:22
a regex router in go.
package main
import (
"fmt"
"io"
"log"
"routes"
"net/http"
)
@jordanorelli
jordanorelli / philosophers.go
Created April 7, 2012 21:56
dining philosophers
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
type Philosopher struct {
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
type Timestamp int
func (t *Timestamp) UnmarshalJSON(b []byte) error {
if len(b) < 2 { // empty string
*t = Timestamp(0)
return nil
}
i, err := strconv.Atoi(string(b[1 : len(b)-1]))
if err != nil {
return err