Skip to content

Instantly share code, notes, and snippets.

@tj
tj / ast.js
Created October 26, 2015 19:09
{ type: 'Program',
body:
[ { type: 'FunctionDeclaration',
id: { type: 'Identifier', name: 'main' },
params: [],
kind: { type: 'Identifier', name: 'int' },
body:
{ type: 'BlockStatement',
body:
[ { type: 'VariableStatement',
@tj
tj / ast.js
Created October 26, 2015 17:26
{ type: 'Program',
body:
[ { type: 'FunctionDeclaration',
id: { type: 'Identifier', name: 'count' },
params:
[ { type: 'FormalParameter',
id: { type: 'Identifier', name: 'n' },
kind:
{ type: 'VariableType',
kind: { type: 'Identifier', name: 'int' } } } ],
console.log('starting with node %s', process.version)
setInterval(function(){ console.log('running') }, 5000)
avg-cpu: %user %nice %system %iowait %steal %idle
21.28 0.00 1.28 0.00 0.00 77.44
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
xvda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdb 0.00 5271.00 1163.00 2835.00 4652.00 37240.00 20.96 3.20 0.80 0.27 1.02 0.06 24.80
avg-cpu: %user %nice %system %iowait %steal %idle
21.23 0.00 1.02 0.26 0.26 77.24
type Worker struct {
*context.Context
}
func (w *Worker) SomeMethod(){
...
w.Stats.IncrBy(n, "events", "published")
w.Log.Info("parsed %s in %s (size=%s) (events=%d)", file, time.Since(start), size, n)
}
ctx, err := context.New("red-extract", Version, args["--apex"].(string))
@tj
tj / client.go
Last active October 30, 2018 13:08
package main
import "github.com/segmentio/rpc"
import "fmt"
type Args struct {
A int
B int
}
2015/02/10 08:12:33 [pub] clear events topic
2015/02/10 08:12:33 [sub] [events:example] clear
2015/02/10 08:12:33 [pub] publish events hello 0
2015/02/10 08:12:34 [pub] publish events hello 1
2015/02/10 08:12:34 [pub] publish events hello 2
2015/02/10 08:12:34 [pub] publish events hello 3
2015/02/10 08:12:34 [pub] publish events hello 4
2015/02/10 08:12:34 [pub] publish events hello 5
2015/02/10 08:12:34 [pub] publish events hello 6
2015/02/10 08:12:34 [pub] publish events hello 7
# FoundationDB server
#
# Run this file, then on one machine run:
# $ sudo /usr/lib/foundationdb/make_public.py
#
# Copy /etc/foundationdb/fdb.cluster to each node and run:
# $ sudo service foundationdb restart
#
set -e
@tj
tj / hackpad.css
Created January 15, 2015 12:33
Hackpad theme
body {
background-color: white;
color: rgba(0,0,0,0.8);
}
#editor {
box-shadow: none
}
ul.listtype-hone {