start new:
tmux
start new with session name:
tmux new -s myname
| var cowPool sync.Pool | |
| func acquireCow(r io.Reader) *cow { | |
| if c, ok := cowPool.Get().(*cow); ok { | |
| c.r = r |
| package main | |
| import ( | |
| "fmt" | |
| "runtime" | |
| "sync" | |
| "sync/atomic" | |
| "time" | |
| ) |
| package main | |
| import ( | |
| "encoding/binary" | |
| "flag" | |
| "fmt" | |
| "log" | |
| "os" | |
| "reflect" | |
| "runtime" |
| // This example shows how interfaces could be used without | |
| // pushing inner data to heap. | |
| // | |
| // Note that it was checked with Go 1.8.3 and may become unuseful | |
| // in the future releases of Go. | |
| package main | |
| import ( | |
| "encoding/binary" | |
| "testing" |
| func log2(n uint) uint { | |
| const uintBits = 32 << (^uint(0) >> 63) | |
| var ( | |
| seen, bit uint | |
| m, l, r uint | |
| ) | |
| r = uintBits | |
| for l < r { | |
| m = l + (r-l)/2 |
| // Say you want to search 0x22 symbol in two bytes of 0x2122 | |
| // you make mask for your search as 0x2222 | |
| // then: | |
| // | |
| // 00100001 00100010 | |
| // ^ 00100010 00100010 | |
| // ------------------- | |
| // 00000011 00000000 00000011 00000000 | |
| // & 01111111 11111111 (cut topmost bit) & 10000000 10000000 (save restore mask) | |
| // ------------------- ------------------- |
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "sync" | |
| "time" | |
| ) | |
| var withLock = flag.Bool("lock", false, "use lock on resets") |
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func main() { | |
| l := []int{1, -20, 7, 6, 0, 9} | |
| quicksort(l, 0, 6) | |
| fmt.Println(l) |
| func loop(v []int, r func([]int)) { | |
| var i, j, n uint | |
| n = uint(len(v)) | |
| a := make([]int, 0, len(v)) | |
| for ; i < (1 << n); i++ { | |
| a = a[:0] | |
| for j = 0; j < n; j++ { | |
| if i&(1<<j) != 0 { | |
| a = append(a, v[j]) |