Skip to content

Instantly share code, notes, and snippets.

View cespare's full-sized avatar

Caleb Spare cespare

View GitHub Profile
@cespare
cespare / keybase.md
Created December 6, 2019 06:38
keybase proof of ownership

Keybase proof

I hereby claim:

  • I am cespare on github.
  • I am cespare (https://keybase.io/cespare) on keybase.
  • I have a public key ASATr7eIIdnBECuIIkhvPi8FqTxIoCZ24fljTvGtRs7IeQo

To claim this, I am signing this object:

@cespare
cespare / learninggo.md
Created September 17, 2018 21:16
My recommended resources for learning Go

Go is a fairly simple language and the best resources for learning it are online.

For a very gentle (if slow) introduction, you can go through the Go tour (you may wish to skip around).

The fastest way to ramp up on Go, though, is probably to read Effective Go end-to-end. This describes most of the language as well as common patterns and best practices.

@cespare
cespare / log.txt
Last active October 5, 2016 17:01
Log output for https://github.com/golang/go/issues/17341 reproducer
gc 1 @0.153s 0%: 0.067+1.3+0.22 ms clock, 0.20+0.026/1.2/3.4+0.67 ms cpu, 4->4->2 MB, 5 MB goal, 4 P
gc 2 @0.185s 0%: 0.050+2.0+0.064 ms clock, 0.15+0.011/1.9/5.2+0.19 ms cpu, 5->5->4 MB, 6 MB goal, 4 P
gc 3 @0.238s 0%: 0.011+2.8+0.19 ms clock, 0.044+0/2.8/8.4+0.78 ms cpu, 9->9->8 MB, 10 MB goal, 4 P
gc 4 @0.316s 1%: 0.077+4.4+0.22 ms clock, 0.23+1.1/4.3/11+0.67 ms cpu, 15->15->13 MB, 16 MB goal, 4 P
gc 5 @0.424s 1%: 0.009+6.7+0.18 ms clock, 0.039+0/6.6/19+0.75 ms cpu, 27->27->24 MB, 28 MB goal, 4 P
gc 6 @0.611s 1%: 0.011+13+0.20 ms clock, 0.045+0.010/13/39+0.81 ms cpu, 47->47->42 MB, 48 MB goal, 4 P
gc 7 @0.943s 1%: 0.031+21+0.19 ms clock, 0.12+0/21/63+0.78 ms cpu, 83->83->75 MB, 85 MB goal, 4 P
gc 8 @1.527s 1%: 0.043+39+0.084 ms clock, 0.17+0.019/38/113+0.33 ms cpu, 146->146->132 MB, 150 MB goal, 4 P
2016/10/05 09:59:31 NOOP: QPS: 10000
gc 9 @2.554s 2%: 0.056+79+3.2 ms clock, 0.22+44/75/152+13 ms cpu, 259->263->239 MB, 265 MB goal, 4 P
@cespare
cespare / wtf.js
Created April 18, 2016 01:07
vanguard's crappy broken password validation javascript
function PasswordOnLoad()
{
}
//------------------ EscapeClick --------------///
function EscapeClick()
{
if (document.all)
{
no ssa:
"".avgSliceValue t=1 size=80 value=0 args=0x20 locals=0x0
0x0000 00000 (ssa_test.go:24) TEXT "".avgSliceValue(SB), $0-32
0x0000 00000 (ssa_test.go:24) NOP
0x0000 00000 (ssa_test.go:24) NOP
0x0000 00000 (ssa_test.go:24) MOVQ "".s+16(FP), DX
0x0005 00005 (ssa_test.go:24) FUNCDATA $0, gclocals·2fccd208efe70893f9ac8d682812ae72(SB)
0x0005 00005 (ssa_test.go:24) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
@cespare
cespare / foo_test.go
Created January 22, 2015 22:37
Example of excluding tests with build tags
package foo
import "testing"
func TestFoo(t *testing.T) {
t.Log("A")
}
@cespare
cespare / md.html
Last active August 29, 2015 14:10
rendered markdown exmaple
<h1>Reflex</h1>
<p>Reflex is a small tool to watch a directory and rerun a command when certain files change. It's great for
automatically running compile/lint/test tasks and for reloading your application when the code changes.</p>
<h2>A simple example</h2>
<div class="highlight"><pre># Rerun make whenever a .c file changes
reflex -r &#39;\.c$&#39; make
</pre></div>
@cespare
cespare / example.conf
Created September 27, 2014 23:08
example nginx reverse proxy config
server {
listen 80;
server_name mysite.example.com;
access_log /path/to/mysite.example.com.log;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# app server listens on localhost:9876

Dump redis rdb files to json. Many limitations, including:

  • Only one DB allowed
  • Only plain key/vals and hashes allowed (no sets, lists, zsets for now)

3x faster than rdbtool for my test dump:

$ time rdb --command json dump.rdb > rdbtool.json 
rdb --command json  > rdbtool.json  264.65s user 0.80s system 99% cpu 4:25.93 total
@cespare
cespare / results.txt
Created March 20, 2014 19:03
Print out stdlib packages not used within the stdlib.
$ go run unused.go
container/ring
debug/gosym
debug/pe
encoding/ascii85
encoding/csv
expvar
go/build
hash/crc64
hash/fnv