Skip to content

Instantly share code, notes, and snippets.

@manveru
manveru / crypto_block.go
Created April 12, 2010 08:19
Simple example of stream encryption using AES and CTR
package main
import(
. "bytes"
"crypto/aes"
"crypto/rand"
. "crypto/block"
"os"
"io"
"io/ioutil"
package main
import "fmt"
type Point struct {
a, b, c, d, e int
}
func main(){
points := newPoints(
package main
import "fmt"
import "exp/iterable"
func main(){
a := iterable.IntArray{1,2,3,4}
fmt.Println(a)
iter := iterable.Map(a, func(i interface{})(interface{}){ return i.(int) * 3 })
for e := range iter.Iter() {
@manveru
manveru / rbeautify.rb
Created April 15, 2010 11:57
rbeautify.rb patched for 1.9
#!/usr/bin/ruby -w
=begin
/***************************************************************************
* Copyright (C) 2008, Paul Lutus *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
type Vector struct {
y, x float64
}
func (self *Vector) Normalize() {
length := self.Length()
self.y /= length
self.x /= length
}
@manveru
manveru / pong.go
Created April 26, 2010 18:52
A simple game of Pong written in Go.
package main
import (
"sdl"
"math"
"time"
"rand"
"flag"
"fmt"
)
import "math"
type Float float64
var Infinity = Float(math.Inf(0))
func (f Float) Abs() Float {
return Float(math.Fabs(float64(f)))
}
package chipmunk
import "fmt"
type Vect struct {
X, Y Float
}
func vect(x, y Float) *Vect {
return &Vect{x, y}
@manveru
manveru / life.go
Created May 1, 2010 12:40
Conway's Game of Life in Go
// Conway's Game of Life.
package main
import (
"sdl"
"rand"
"time"
"strings"
"strconv"
@manveru
manveru / gotags.go
Created May 5, 2010 08:22
Generate tags file for Go in exuberant-ctags format
// Generate a tags file for the Go Programming Language in the format used by
// exuberant-ctags. Can be used with the VIM editor to navigate Go source code
// files.
//
// usage: gotags filename [ filename... ] > tags
//
// Authors: [email protected], [email protected]
// Date: 2010-05-17
package main