Skip to content

Instantly share code, notes, and snippets.

View kortschak's full-sized avatar

Dan Kortschak kortschak

View GitHub Profile
type Kmer uint32
func (self *Index) GetPositionsKmer(kmer Kmer) (positions []int, err os.Error) {
if kmer > self.kMask {
return nil, bio.NewError("Kmer out of range", 0, []Kmer{kmer, self.kMask})
}
i := Kmer(0)
if kmer != 0 { // special case: An has no predecessor
i = self.finger[kmer-1]
{
// preprocessing
dp := make(chan *DP, self.cores)
for i := 0; i < self.cores; i++ {
dp <- &DP{
a: self.a,
b: self.b,
minLen: minLen,
maxDiff: maxDiff,
func (self *Morass) write(writing sortable) (err os.Error) {
defer func() {
self.error <- err
self.done <- writing[:0]
}()
select {
case <-self.error:
default:
}
@kortschak
kortschak / Makefile
Created December 12, 2011 22:12
test the gocheck.Panics checker
include $(GOROOT)/src/Make.inc
TARG=testtest
GOFILES=\
test.go\
include $(GOROOT)/src/Make.pkg
@kortschak
kortschak / 0001-time-changes-weekly.2011-12-01.patch
Created January 14, 2012 07:58
Patch for DevTodo2 weekly.2011-12-01
From f5cc658536f716b5686a8cd158ad556b77a023c9 Mon Sep 17 00:00:00 2001
From: kortschak <dan.kortschak@adelaide.edu.au>
Date: Sat, 14 Jan 2012 18:00:49 +1030
Subject: [PATCH] time changes - weekly.2011-12-01
---
consoleview.go | 9 ++++-----
jsonio.go | 18 +++++++++---------
legacyio.go | 8 ++++----
main.go | 4 +++-
@kortschak
kortschak / dirmod.go
Created February 5, 2012 20:54
attempt at unsafe manipulation of chan dir
package main
import (
"fmt"
"reflect"
"runtime"
"unsafe"
)
type commonType struct {
@kortschak
kortschak / peers.go
Created February 20, 2012 00:45
Example PeerCertificates empty
package main
import (
"bufio"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
//Use morass when you don't want your data to be a quagmire.
//
//Sort data larger than can fit in memory.
//
// morass məˈras/
// 1. An area of muddy or boggy ground.
// 2. A complicated or confused situation.
package morass
// Copyright ©2011 Dan Kortschak <dan.kortschak@adelaide.edu.au>
@kortschak
kortschak / offset.go
Created March 14, 2012 02:16
Offset slice benchmark
package main
import (
"fmt"
"testing"
)
// An offset slice seems to be the only way to implement the C idiom to
// an offset (by o) a view (v) on an array (a):
// int *v, o;
@kortschak
kortschak / collide.go
Created April 12, 2012 21:48
hash collision
package main
import (
"crypto/sha256"
"fmt"
"math/rand"
"os"
"time"
)