Skip to content

Instantly share code, notes, and snippets.

import json
import sys
import subprocess
REGIONS = "us-west-1 us-west-2 us-east-1".split()
PROFILES = "default".split()
for region in REGIONS:
for profile in PROFILES:
status = json.loads(subprocess.check_output(
[nelhage@anarchique:~]$ t=$(TZ=UTC date +"%y%m%d%H%M"); echo $t
1410070128
[nelhage@anarchique:~]$ t=$(TZ=UTC date --date=@$t +"%y%m%d%H%M"); echo $t
1409070608
[nelhage@anarchique:~]$ t=$(TZ=UTC date --date=@$t +"%y%m%d%H%M"); echo $t
1408261630
[nelhage@anarchique:~]$ t=$(TZ=UTC date --date=@$t +"%y%m%d%H%M"); echo $t
1408170747
[nelhage@anarchique:~]$ t=$(TZ=UTC date --date=@$t +"%y%m%d%H%M"); echo $t
1408160632
#!/usr/bin/env python
import imaplib
import os
import logging
import optparse
# LABEL = 'support'
# QUERY = 'before:2015-06-01 -label:to-delete'
# DEST = 'to-delete'
LABEL = 'to-delete'

bench_socket.py

recvfrom(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 16384, 0, NULL, NULL) = 16384
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 4096
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 12288) = 12288

bench_httplib.py

@nelhage
nelhage / left-pad.txt
Created April 7, 2016 04:38
node left-pad
[nelhage@monomorphique:~/code/accidentallyquadratic]$ perf stat node data/left-pad-npm.js 500000
Performance counter stats for 'node data/left-pad-npm.js 500000':
7294.942072 task-clock (msec) # 0.951 CPUs utilized
1,010 context-switches # 0.138 K/sec
15 cpu-migrations # 0.002 K/sec
446,352 page-faults # 0.061 M/sec
19,765,021,583 cycles # 2.709 GHz
<not supported> stalled-cycles-frontend
sqlite> select id, winner, player1, player2, result, moves from games where (player1='TakticianBot' and winner='black') OR (player2='TakticianBot' and winner='white');
6450|white|BenWo|TakticianBot|R-0|33
6454|white|BenWo|TakticianBot|R-0|27
6459|white|BenWo|TakticianBot|R-0|27
6469|white|BenWo|TakticianBot|R-0|27
6514|white|pythoner6|TakticianBot|F-0|61
6522|white|pythoner6|TakticianBot|R-0|81
6552|white|asgardiator|TakticianBot|1-0|73
6584|white|Archerion|TakticianBot|R-0|39
6979|white|Simmon|TakticianBot|F-0|54
2016/05/04 10:46:26 < GameList Add Game#309 TakticianBot vs onewhohides, 5x5, 1200, 0 half-moves played, TakticianBot to move
2016/05/04 10:46:26 > Observe 309
2016/05/04 10:46:26 < Observe Game#309 TakticianBot vs onewhohides, 5x5, 1200, 1 half-moves played, onewhohides to move
2016/05/04 10:46:26 < Game#309 P A1
2016/05/04 10:46:26 < Game#309 Time 1200 -2216321
2016/05/04 10:46:26 < Game#309 P A1
2016/05/04 10:46:26 < Game#309 Time 1200 -2216321
2016/05/04 10:46:26 < GameList Remove Game#309 TakticianBot vs onewhohides, 5x5, 1200, 1 half-moves played, onewhohides to move
2016/05/04 10:46:26 < Game#309 Over 1-0
2016/05/04 10:46:26 < GameList Remove Game#309 TakticianBot vs onewhohides, 5x5, 1200, 1 half-moves played, onewhohides to move
2016/06/02 07:26:43 their-move game-id=44170 ply=21 ptn=11.B move="Sa1"
2016/06/02 07:26:43 seed=1464852403
2016/06/02 07:26:43 [minimax] deepen: depth=1 val=1495 pv=[5b1>14] time=116.247µs total=116.736µs evaluated=71 tt=0 branch=71
2016/06/02 07:26:43 [minimax] stats: visited=1 scout=0 evaluated=71 null=0/0 cut=0 cut0=0(0.00) cut1=0(0.00) m/cut=0.00 m/ms=619.370822 all=0 research=2
2016/06/02 07:26:43 [minimax] deepen: depth=2 val=1475 pv=[5b1>14 c2] time=214.212µs total=381.572µs evaluated=109 tt=1 branch=1
2016/06/02 07:26:43 [minimax] stats: visited=70 scout=68 evaluated=109 null=0/0 cut=67 cut0=67(0.99) cut1=0(0.99) m/cut=0.00 m/ms=835.620787 all=0 research=2
2016/06/02 07:26:43 [minimax] deepen: depth=3 val=1575 pv=[5b1>14 c2 e1] time=4.828232ms total=5.239369ms evaluated=4445 tt=9 branch=40
2016/06/02 07:26:43 [minimax] stats: visited=184 scout=181 evaluated=4445 null=0/0 cut=105 cut0=83(0.78) cut1=14(0.92) m/cut=9.67 m/ms=958.736034 all=67 research=2
2016/06/02 07:26:43 [minimax] deepen: depth=4 v
[white to play]
5. [B] [B] [B] [W] [W]
4. [] [] [B] [W] [B]
3. [] [] [] [W B] []
2. [] [] [] [W B W] []
1. [W] [] [] [BC] []
a. b. c. d. e.
stones: W:14 B:14

honey-go feedback

  • Having to initialize it globally is weird. Having an implicit global client would be fine, but it's much more idiomatic for Go libraries to be able to launch your own client that maintains state completely independently for a while. That tripped me up at first – I tried to instantiate a Builder without init'ing globally, and it didn't work.
  • relatedly, I expected NewBuilder should take a Config so I could configure it without having to mutate separately. It's unclear from the docs whether I have to call NewBuilder or whether &Builder{} is a valid Builder
  • The implicit global keys and func()s is convenient but also scares me a little because ew global state. An interesting compromise might be to have
 func AddContextField(key string, value func(context.Context)interface{})
 func (b *Builder) NewEventContext(context.Context) *Event