Skip to content

Instantly share code, notes, and snippets.

@tux21b
tux21b / banking1.go
Created September 14, 2011 15:03
Shared vs. Isolated Mutability
// Fictional accounting example #1 - "Shared Mutability"
package main
import (
"fmt"
"sync"
)
type Account struct {
id string
@tux21b
tux21b / disruptor.go
Created September 15, 2011 02:22
Disruptor
// Copyright (C) 2011 by Christoph Hack. All rights reserved.
// Use of this source code is governed by the New BSD License.
/*
This program contains a simple micro-benchmark for a Disruptor [1] like
event buffer (or at least what I think that Disruptor might be). There
isn't any kind of API yet and this test is currently limited to a
single producer - single consumer architecture, but generally the
architecture of Disruptor is also well suited for multiple producers and
consumers.
@tux21b
tux21b / smile.go
Created December 10, 2011 12:52
Go-Port of an old Plan9 snippet featuring smileys
package main
import (
"fmt"
"os"
"unsafe"
)
type ʘᴗʘ int32
type Θ_Θ struct{}
@tux21b
tux21b / id_rsa.pub
Created January 23, 2012 10:01
SSH Public Key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCxXRA2PXooQhMcqVJYBe4pjeGJyFdDLmV5LcxF8C/iSDAFhIEOxz8o/g6L7kuMPMd+UPiJwZNkUECsgrHJM0RUMa8rcePM5/nN9RxLfQWmI45RAf2pxTqyndeOGmWr2xkHvd3KQqskC9wyQSjDvajG+V28fvmG/AewtZNt0C+n+6KumqtAqCUw/c3Sol7IthVtngsLkyEbEYDmGBqATWclX4J6nfyFHIC2qL42HX4SU2rDXMloMEkneZA75rsSI57KpvzmQNl0RCb7YOrbwxMMRShWdXlmG53z1xMBVPCSuLl6q/bTataJxt2Z91ERyqqmx7Y2+0b0n0NYsZsmf+X/ christoph@tuxmobil
@tux21b
tux21b / chess
Created March 22, 2012 06:42
unicode rocks!
8 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
6 · · · · · · · ·
5 · · · · · · · ·
4 · · · · · · · ·
3 ♙ · · · · · · ·
2 · ♙ ♙ ♙ ♙ ♙ ♙ ♙
1 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
a b c d e f g h
package main
import (
"database/sql"
"fmt"
_ "github.com/bmizerany/pq"
"log"
)
func QueryMap(db *sql.DB, query string) (map[string]interface{}, error) {
#include <iostream>
#include <typeinfo>
struct Game;
struct Command
{
void execute(Game& game);
};
@tux21b
tux21b / tc08.in
Created June 2, 2012 08:30
Ganz gemeiner TC (Entwurf)
a b c d e f g h
8 . . r . . . . . 8
7 . . . . . . . . 7
6 . . . . . . . . 6
5 . . . k . . . . 5
4 . . . . . . . . 4
3 . . . . . N . r 3
2 . K . . . P . . 2
1 . . . . . . . q 1
a b c d e f g h
@tux21b
tux21b / CQL 3
Created August 26, 2012 19:47
LIMIT isn't working as expected...
DROP KEYSPACE gocql_wiki;
CREATE KEYSPACE gocql_wiki
WITH strategy_class = 'SimpleStrategy'
AND strategy_options:replication_factor = 1;
USE gocql_wiki;
CREATE TABLE page (
title varchar,
@tux21b
tux21b / weierbot.go
Created September 30, 2012 13:26
Weierbot
package main
import (
"fmt"
irc "github.com/fluffle/goirc/client"
"html/template"
"io/ioutil"
"log"
"net/http"
"net/url"