Skip to content

Instantly share code, notes, and snippets.

View rafrombrc's full-sized avatar

Rob Miller rafrombrc

  • Mozilla Corp
  • Oakland, CA
View GitHub Profile
@rafrombrc
rafrombrc / gist:9142016
Created February 21, 2014 19:47
When nil != nil, or lolgo
Code that's running:
outputError <- err
fmt.Println("t.connection (pre): ", t.connection)
if t.connection != nil {
fmt.Println("t.connection (post): ", t.connection)
fmt.Println("err: ", err)
t.connection.Close()
t.connection = nil
@rafrombrc
rafrombrc / dice.go
Created July 2, 2014 22:12
throwing dice through a tcp socket
package main
import (
"flag"
"log"
"math/rand"
"net"
"strconv"
"strings"
)
require("circular_buffer")
require("cjson")
-- 300 rows, 11 cols, 1s per row
cbuf = circular_buffer.new(300, 11, 1)
cbuf_idxs = {}
for i=2, 12, 1 do
cbuf_idxs[i-1] = cbuf:set_header(i-1, tostring(i), "sum")
end
panic: runtime error: send on closed channel
goroutine 26 [running]:
runtime.panic(0x854940, 0x1017efe)
/usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/thoj/go-ircevent.(*Connection).Privmsg(0xc210050640, 0x0, 0x0, 0x0, 0x0)
/heka/build/heka/src/github.com/thoj/go-ircevent/irc.go:226 +0x13f
github.com/mozilla-services/heka/plugins/irc.(*IRCOutput).Privmsg(0xc210090320, 0x0, 0x0, 0x0, 0x0, ...)
/heka/build/heka/src/github.com/mozilla-services/heka/plugins/irc/irc_output.go:102 +0xab
github.com/mozilla-services/heka/plugins/irc.SendFromOutQueue(0xc210090320, 0x7f1195bf5060, 0xc21000fbe0, 0x0, 0x0, ...)
@rafrombrc
rafrombrc / statsd_graph
Created July 16, 2014 22:54
Sample Lua code for graphing statsd data
require("circular_buffer")
require("string")
require("cjson")
local idx_num
local stat_value
local debug
-- # rows, # cols, # seconds per row
cbuf = circular_buffer.new(300, 1, 1)
require("circular_buffer")
require("cjson")
-- 300 rows, 11 cols, 1s per row
cbuf = circular_buffer.new(300, 11, 1)
cbuf_idxs = {}
for i=2, 12, 1 do
cbuf_idxs[i-1] = cbuf:set_header(i-1, tostring(i), "sum")
end
/***** BEGIN LICENSE BLOCK *****
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# The Initial Developer of the Original Code is the Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2014
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
/***** BEGIN LICENSE BLOCK *****
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# The Initial Developer of the Original Code is the Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2012-2014
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
@rafrombrc
rafrombrc / infile.toml
Last active August 29, 2015 14:06
env var substitution prototype
[hekad]
maxprocs = 4
base_dir = "/home/rob/go/heka/var/cache/hekad"
#max_pack_idle = 2
#cpuprof = "cpu.prof"
memprof = "mem.prof"
[TcpInput]
address = "127.0.0.1:5565"
parser_type = "message.proto"
@rafrombrc
rafrombrc / stdout.toml
Last active August 29, 2015 14:06
simplest file in -> stdout example heka toml file
[LogstreamerInput]
log_directory = "/var/log"
file_match = 'auth\.log'
[PayloadEncoder]
append_newlines = false
[LogOutput]
message_matcher = "TRUE"
encoder = "PayloadEncoder"