Skip to content

Instantly share code, notes, and snippets.

View acsellers's full-sized avatar

Andrew Sellers acsellers

View GitHub Profile
@acsellers
acsellers / go-gtk_vs_gg.go
Created July 13, 2012 03:46
A gtk interface for Go that feels right
//go-gtk
func on_window_resize(){
window := gtk.WidgetFromObject(builder.GetObject("main_window"))
switcher := gtk.WidgetFromObject(builder.GetObject("main_switcher"))
vline := gtk.WidgetFromObject(builder.GetObject("vline"))
win_alloc := new(gtk.GtkAllocation)
window.GetAllocation(win_alloc)
sw_alloc := new(gtk.GtkAllocation)
switcher.GetAllocation(sw_alloc)
@acsellers
acsellers / scopes.go
Created July 13, 2012 04:45
Scopable Go structs
package main
import "fmt"
type Scope struct {
Minimum, Maximum, Current int
Transformer func(inst *int)
}
func (s *Scope)Find(min int, interval int){
s.Current, s.Minimum = min,min
@acsellers
acsellers / myprox.go
Created May 15, 2013 21:47
Mysql Query Proxy
package main
import (
"log"
"net"
"time"
)
const (
comQuit byte = iota + 1
@acsellers
acsellers / reflect.go
Created September 30, 2013 21:45
TypesThatResemble
// TypesThatResemble returns all types that (directly or indirectly) embed a
// type that has the same name as the t arget type, but have a different
// import path
// e.g. "github.com/acsellers/yield.Controller" vs "github.com/robfig/revel.Controller"
func (s *SourceInfo) TypesThatResemble(targetType string) (filtered []*TypeInfo) {
var (
nodeQueue = []string{}
processed []string
targetTypeName = targetType[strings.LastIndex(targetType, "."):]
@acsellers
acsellers / server.go
Last active December 26, 2015 16:09
package paintserver
import (
"net/http"
"code.google.com/p/go.net/websocket"
"image/color"
"image"
"image/png"
)
@acsellers
acsellers / main.go
Created February 28, 2014 15:19
Round Robin
package main
import (
"fmt"
"github.com/acsellers/round"
)
func main() {
people := []string{"p1", "p2", "p3", "p4", "p5", "p6"}
@acsellers
acsellers / main.go
Last active August 29, 2015 13:56
Short Round
package main
import "github.com/acsellers/round"
func main() {
round.PrintMatchups([]string{"abba", "bards", "cats", "ducks", "elephants"})
}
@acsellers
acsellers / app:views:layouts:app.html
Last active August 29, 2015 13:57
Revel booking layout in multitemplate
{{ extends "layouts/base.html" }}
{{ block "head" }}
<title>{{.title}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" media="screen" href="/public/css/main.css">
{{range .moreStyles}}
<link rel="stylesheet" type="text/css" href="/public/{{.}}">
{{end}}
<script src="/public/js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
@acsellers
acsellers / gooddoc-v0.1.txt
Created May 6, 2014 15:48
GoodDoc for Ruby
GoodDoc for Ruby
Purpose
Provide a code documentation specification for Ruby that doesn't faff about.
Method documentation
The first sentence should be a one-sentence summary that starts with the name being declared.
This is the only part of the documentation that is required. If the public or private status
of the function would be in question, you should work it into this summary. Use the active
voice when possible, for instance returns or checks is better than will return or will check.
@acsellers
acsellers / reverse.go
Created August 3, 2017 19:11
Golang Reverse String preserving Combining Characters
package main
import (
"fmt"
"unicode"
)
var combining = &unicode.RangeTable{
R16: []unicode.Range16{
{0x0300, 0x036f, 1}, // combining diacritical marks