Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am kchau on github.
  • I am kafu (https://keybase.io/kafu) on keybase.
  • I have a public key whose fingerprint is 368F C5A5 1A5B 6742 F56A BB82 682B 81A0 3745 ED1F

To claim this, I am signing this object:

@kchau
kchau / test_channels.go
Last active December 22, 2015 11:28
Figuring out one channel, multiple receivers in Go...
package main
import (
"fmt"
"log"
"time"
)
func main() {
commands := make(chan string)
@kchau
kchau / gist:5008255
Last active December 14, 2015 01:39
#chunk_lines sample
# Break the IO stream into manageable chunks.
# @param [io] io to read input. Usually File based, but can be any Ruby IO.
# @yieldparam [block] the block that the chunk is yielded to.
#
def chunk_lines(io, &block)
chunk= []
io.each_line do |line|
chunk << line.strip
if chunk.size == DEFAULT_SIZE