Skip to content

Instantly share code, notes, and snippets.

@alphazero
alphazero / gist:218244ace3b167ef1de8
Last active August 29, 2015 14:20
Initial sketch of /.go tool chain meta-data files
# ----------------------------------
# general layout of the land
# ----------------------------------
$GOPATH/src/.go
$GOPATH/src/.go/config
$GOPATH/src/.go/vendors # for all projects
# ----------------------------------
# $GOPATH/.go/vendors sketch
# ----------------------------------
package main
import (
"flag"
)
var option = struct {
knob uint
}{
knob: 4096,
@alphazero
alphazero / gist:dd1ad2ae7f6c91c06c79
Last active August 29, 2015 14:19
ascii art 04132015.0
0x---1000 0x---2000 # v.mem address space and v.mem page alignments
| 0x---1080 | 0x--------2080 # ~ and allocated [512]uint64 page bucket array
| | r1 r2 | r3|
----|-------------*-- /.../ -*----|-*------
| |
bucket[n] bucket[n+1] # Go d.s. as allocated - word aligned
- swap bucket[n][r1] with bucket[n][r3]
[19]--bkts: 524288 108869352 0.814 | prob% (99.9985 0.0015 0.0000 0.0000) max (21 0 0) o/f (n 1644 pgs 6) PIT-pages:256
so 99.9985 primary page, 0.0015% 2nd, etc.
1644 is the total number of keys that missed their primary (out of 524288 * 255).
± ./wot master
panic: n:1152066 now:1407851832361738000 t0:1407851832361738425 dt:-425
goroutine 23 [running]:
runtime.panic(0x97380, 0x2081ec020)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
main.func·004()
/Users/alphazero/go/src/lsf/exp/wot.go:38 +0x1fa
created by main.main
-- initial state of ContactInfo --
actor: root - Joubin - address: 321 Infinity Unloop - email: alphazero@sensesay.net
-- run the parallel tasks --
-- merge beings --
actor: actor-1 - Joubin - address: 321 Infinity Unloop - email: joubin@inch.com
actor: actor-2 - Joubin - address: 123 Main Street - email: alphazero@sensesay.net
-- merge end --
@alphazero
alphazero / gist:3881643
Created October 12, 2012 21:32
explicit selection semantics - priority selector
package main
import (
"fmt"
"math/rand"
"time"
)
const clen = 3 // knob - needs to match parr below
// a very thin convenience wrapper over go's log package
// that also alters the semantics of go log's Error and Fatal:
// none of the functions of this package will ever panic() or
// call os.Exit().
//
// Log levels are prefixed to the user log data for each
// eponymous function i.e. logger.Error(..) will emit a log
// message that begins (after prefix) with ERROR - ..
//
// Package also opts for logger.Lmicroseconds prefix in addition
@alphazero
alphazero / gist:2500494
Created April 26, 2012 15:46
Generics in Java
package oss.alphazero.temp;
import java.util.Map;
public class GenericFoo<K, V, T extends Map<K, V>> {
}
-- javap --
Compiled from "GenericFoo.java"
@alphazero
alphazero / lacking_generics.go
Created April 21, 2012 19:41
considering the maximal ugliness of not having generics
/* Main concern for me is lack of generic functions
* it really isn't that bad. 2 (un-necessary given the information at hand) casts occur.
* - One category e.g. C#Add(..) entails casts by the provider,
* so that is not a huge concern. Note that the body of text typed remains effectively the same with or without generics.
*
* - other category e.g. call site casts remains. That is a concern that can't be addressed by the provider of the library,
* but I suppose it is ultimately partially the responsibility of the
package main
import "fmt"