Skip to content

Instantly share code, notes, and snippets.

View davidbirdsong's full-sized avatar

david birdsong davidbirdsong

  • san francisco, ca
View GitHub Profile
@davidbirdsong
davidbirdsong / go_x509_error
Created May 16, 2016 01:12
go errors rarely do what i expect
package main
import (
"crypto/x509"
"fmt"
"net/http"
)
func main() {
if req, err := http.NewRequest("GET", "https://too.long.s3.amazonaws.com/index.html ", nil); err != nil {
@davidbirdsong
davidbirdsong / tls_byte_buffer
Created May 3, 2016 21:17
tls allocations
[david@sjc1-b4-8 ~]$ go tool pprof $HOME/bin/hwy-fetcher http://localhost:6060/debug/pprof/heap
Fetching profile from http://localhost:6060/debug/pprof/heap
Saved profile in /home/david/pprof/pprof.hwy-fetcher.localhost:6060.inuse_objects.inuse_space.062.pb.gz
Entering interactive mode (type "help" for commands)
(pprof) top
12612.08MB of 14824.44MB total (85.08%)
Dropped 799 nodes (cum <= 74.12MB)
Showing top 10 nodes out of 87 (cum >= 201.56MB)
flat flat% sum% cum cum%
6202.85MB 41.84% 41.84% 6202.85MB 41.84% crypto/tls.(*block).reserve
events { worker_connections 10240; }
worker_processes 1;
daemon off;
pid /tmp/ngx/n.pid;
error_log /dev/stderr debug;
worker_rlimit_nofile 10240;
http {
@davidbirdsong
davidbirdsong / log.go
Created January 8, 2016 00:06
write to native heka protobuf
package server
import (
"code.google.com/p/go-uuid/uuid"
"github.com/zebrafishlabs/heka/client"
"github.com/zebrafishlabs/heka/message"
"fmt"
"net/url"
"os"
@davidbirdsong
davidbirdsong / ngx_server
Created December 29, 2015 21:45
nginx_server
server {
listen 127.0.0.10:9001;
location / { return 404; }
}
@davidbirdsong
davidbirdsong / munchery_chili
Created December 11, 2015 00:16
munchery_chili
SUPER PROTEIN CHILI
three beans, quinoa, rice blend, pickled cabbage
Add to Cart
$9.95
Ingredients
Brown rice
Black Beans
@davidbirdsong
davidbirdsong / vanilla.consul.fd_leak
Created October 27, 2015 19:43
vanilla.consul fd leak
import vanilla, vanilla.consul
import consul
c = consul.Consul()
_, d = c.health.service('mogtracker', passing=1)
for row in d:
print '%s:%d' % (row['Node']['Address'], row['Service']['Port'])
h = vanilla.Hub()
@davidbirdsong
davidbirdsong / socklog_test_udp
Created July 16, 2015 05:18
socklog over udp
[david@foulplay ~]$ sudo socklog -R inet 0 5112
listening on 0.0.0.0:5112, starting.
<134>2015-07-16T03:43:13Z cache-lax1420 flog-tls[406151]: foo bar
[david@foulplay ~]$ echo "<134>2015-07-16T03:43:13Z cache-lax1420 flog-tls[406151]: foo bar" | nc -u localhost 5112
@davidbirdsong
davidbirdsong / socklog_test.sh
Last active August 29, 2015 14:25
socklog over tcp
[david@foulplay ~]$ sudo tcpsvd -c 300 -u log 0 5112 socklog -R ucspi
local0.info: 2015-07-16T03:43:13Z cache-lax1420 flog-tls[406151]: foo bar
# in another shell
[david@foulplay ~]$ echo "<134>2015-07-16T03:43:13Z cache-lax1420 flog-tls[406151]: foo bar" | nc localhost 5112
@davidbirdsong
davidbirdsong / lua_cjson
Created July 9, 2015 20:44
cjson is provided by heka sandbox by default
local cjson = require('cjson')
local data = cjson.decode(json_string)