Skip to content

Instantly share code, notes, and snippets.

#!/usr/local/bin/perl -w
use common::sense;
use Benchmark qw(:all);
use YAML::Syck qw();
use YAML::XS qw();
my $yaml = `cat foo.yaml`;
AnyEvent-5.271
AnyEvent::Handle-5.271
AnyEvent::Socket-5.271
AnyEvent::TLS-5.271
Apache2::Const-2.000004
CGI-3.43
Carp-1.11
Crypt::OpenSSL::RSA-0.26
Crypt::OpenSSL::X509-1.4
Data::Dumper-2.124
@nrh
nrh / comp.pl
Created November 8, 2010 04:36
#!/usr/local/bin/perl -w
use Benchmark qw(:all);
use YAML::Syck qw();
use YAML::XS qw();
my @files = ( 'large.yaml', 'medium.yaml', 'small.yaml' );
my $count = $ARGV[0] || 1000;
[nrh@toki projects/pogo/t] perl -I../lib ../bin/pogo-dispatcher -f conf/dispatcher.conf
[89418] DEBUG ZooKeeper.new:73 serverlist=localhost:18121
[89418] INFO ZooKeeper.new:79 Connected to 'localhost:18121'
[89418] DEBUG ZooKeeper.new:80 Everything is OK
[89418] DEBUG ZooKeeper.new:81 Session timeout is 10.00 seconds.
[89418] INFO AuthStore.AE:cb:prepare_cb:134 Accepting authstore peer connections on 0.0.0.0:7656
[89418] DEBUG AuthStore.start_client:145 Initiating connection to authstore peer localhost in 4.63 secs
[89418] INFO Dispatcher.AE:cb:prepare_cb:71 Accepting worker connections on 0.0.0.0:7654
[89418] INFO Dispatcher.AE:cb:prepare_cb:79 Accepting RPC connections on 127.0.0.1:7655
[89418] DEBUG Dispatcher._poll:105 task waiting but no idle workers connected...
#!/usr/local/bin/perl -w
use Perl6::Slurp;
my $status = slurp '-|', 'git status';
# only want what is going to be commited
$status =~ s/Changed but not updated.*$//s;
my @dirty =
[nrh@plotz projects/pogo/build] git log -1
commit 2cd6a7b5f371618830dd5ad2bf4a1d39d35ecc2a
Merge: b0ae16b 1cf3221
Author: Michael S. Fischer <michael+github@dynamine.net>
Date: Wed Dec 22 00:21:28 2010 -0800
Merge branch 'master' of github.com:nrh/pogo
[nrh@plotz projects/pogo/build] git status
# On branch master
nothing to commit (working directory clean)
tcp_connect 'localhost','18121', sub {
my ($fh) = @_;
sleep 10;
my $res;
ok( defined @_, "connect" );
ok( write($fh, "ruok\n"), "send ruok ". int($!) );
ok( read($fh, $res, 4), "recv ruok". int($!) );
print Dumper [ $!, $res ];
chomp($res);
ok($res eq "imok", "imok");
@nrh
nrh / gist:755131
Created December 26, 2010 00:56
pogofail1
[nrh@toki projects/pogo/t] POGO_PERSIST=1 perl -Ilib -e 'use PogoTester; PogoTester::start_zookeeper(); sleep 2; PogoTester::start_dispatcher(); PogoTester::start_worker();'
[10234] DEBUG PogoTester::start_zookeeper:109 using 'java -Dzookeeper.log.dir="." -Dzookeeper.root.logger="INFO,CONSOLE" -cp "/Users/nrh/projects/pogo/t/../build/zookeeper/bin/../build/classes:/Users/nrh/projects/pogo/t/../build/zookeeper/bin/../build/lib/*.jar:/Users/nrh/projects/pogo/t/../build/zookeeper/bin/../zookeeper-3.3.1.jar:/Users/nrh/projects/pogo/t/../build/zookeeper/bin/../lib/log4j-1.2.15.jar:/Users/nrh/projects/pogo/t/../build/zookeeper/bin/../lib/jline-0.9.94.jar:/Users/nrh/projects/pogo/t/../build/zookeeper/bin/../src/java/lib/*.jar:/Users/nrh/projects/pogo/t/../build/zookeeper/bin/../conf:" -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain "/Users/nrh/projects/pogo/t/conf/zookeeper.conf"
'
[10234] INFO PogoTester::start_zookeeper:122 spawned
[
{
"status" : "OK",
"version" : "V3",
"action" : "jobsnapshot",
"hostname" : "toki.local"
},
[
40,
"{\"foo10.example.com\":{\"msg\":\"ok\",\"runs\":[{\"e\":1293928572.1374,\"m\":\"ok\",\"x\":\"0\",\"s\":1293928562.18889,\"o\":\"http://localhost:8081/static/p0000000002/foo10.example.com.0.txt\"}],\"state\":\"finished\",\"host\":\"foo10.example.com\"},\"foo2.example.com\":{\"msg\":\"ok\",\"runs\":[{\"e\":1293928584.54668,\"m\":\"ok\",\"x\":\"0\",\"s\":1293928574.18567,\"o\":\"http://localhost:8081/static/p0000000002/foo2.example.com.0.txt\"}],\"state\":\"finished\",\"host\":\"foo2.example.com\"},\"foo1.example.com\":{\"msg\":\"ok\",\"runs\":[{\"e\":1293928572.17602,\"m\":\"ok\",\"x\":\"0\",\"s\":1293928562.21005,\"o\":\"http://localhost:8081/static/p0000000002/foo1.example.com.0.txt\"}],\"state\":\"finished\",\"host\":\"foo1.example.com\"},\"job\":{\"msg\":\"no more hosts to run\",\"target\":\"[\\\"foo[1-10].example.com\\\"]\",\"runs\":[{\"e\":1293928621.46285}],\"s
[
{
"status" : "OK",
"version" : "V3",
"action" : "jobsnapshot",
"hostname" : "pd2.mail.corp.ac4.yahoo.com"
},
[
"13",
"{\"smtp146.mail.ukl.yahoo.com\":{\"msg\":\"exited with status 2\",\"runs\":[{\"e\":1291253951.66542,\"m\":\"exited with status 2\",\"x\":\"2\",\"s\":1291252960.08221,\"o\":\"http://pw1.mail.corp.sp1.yahoo.com/pogo_output/p0000013002/smtp146.mail.ukl.yahoo.com.0.txt\"}],\"state\":\"failed\",\"host\":\"smtp146.mail.ukl.yahoo.com\"},\"smtp147.mail.ukl.yahoo.com\":{\"msg\":\"exited with status 2\",\"runs\":[{\"e\":1291253965.4172,\"m\":\"exited with status 2\",\"x\":\"2\",\"s\":1291252960.21977,\"o\":\"http://pw1.mail.corp.sp1.yahoo.com/pogo_output/p0000013002/smtp147.mail.ukl.yahoo.com.0.txt\"}],\"state\":\"failed\",\"host\":\"smtp147.mail.ukl.yahoo.com\"},\"job\":{\"msg\":\"no more hosts to run\",\"runs\":[{\"e\":1291253966.42493,\"s\":1291252959.34947,\"o\":null}],\"range\":[\"smtp146.mail.ukl.yahoo.com,smtp147.mail.ukl.yahoo.com\"],\"state\":\"fin