Skip to content

Instantly share code, notes, and snippets.

logstash queries graphed with graphite.

Operation: Decouple whisper from graphite.

Method: Create a graphite function that does a date histogram facet query against elasticsearch for a given query string for the time period viewed in the current graph.

Reason: graphite has some awesome math functions. Wouldn't it be cool if we could use those on logstash results?

The screenshot below is using logstash to watch the twitter stream of keywords "iphone" "apple" and "samsung" - then I graph them each, so we get an idea of popularity. As a bonus, I also do a movingAverage() on the iphone curve to show you why this is awesome.

@timbunce
timbunce / gist:7560988
Created November 20, 2013 10:31
Postgis GeoJSON silent massive loss of precision with coordinates specified as string values
This works as expected:
corp=> SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[-48.23456,20.12345]}')) As wkt;
wkt
---------------------------
POINT(-48.23456 20.12345)
but this doesn't:
corp=> SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":["-48.23456","20.12345"]}')) As wkt;
@timbunce
timbunce / gist:5780999
Created June 14, 2013 10:53
Concurrent non-blocking connections in perl
use strict;
use Data::Dumper;
my @hosts = (
'74.125.24.101:80', # google
'74.125.24.101:9999', # google but bad port
'17.172.224.47:80', # apple
'117.53.170.202:80', # www.gov.au
);
@timbunce
timbunce / perl -V
Created May 3, 2013 22:12
warn("%p %s\n", basecop->cop_file, basecop->cop_file);
600c00020180 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020360 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c000204e0 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020540 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c000205a0 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020480 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020600 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c000206c0 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020780 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020300 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
@timbunce
timbunce / gist:5514563
Created May 3, 2013 22:07
warn("%p %s\n", basecop->cop_file, basecop->cop_file); while traversing the op tree of blib::import
600c00020180 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020360 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c000204e0 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020540 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c000205a0 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020480 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020600 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c000206c0 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020780 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
600c00020300 /usr/local/perl5-blead-deb-thr-asan/lib/5.17.11/blib.pm
@timbunce
timbunce / pr.md
Created April 1, 2013 09:25 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@xyz»++ # increment all elements of @xyz
@x = @a »min« @b # @x is smallest of @a and @b
$mean = ([+] @a) / @a # calculate mean of @a
$sumsq = [+] (@x »**» 2) # sum of squares of @x
$fact = [*] 1..$n # $n factorial
@timbunce
timbunce / smzp_sinopsys.md
Created August 1, 2012 14:22 — forked from melo/smzp_sinopsys.md
mzp synopsis

mpz synopsis

mpz is a ZeroMQ-based pipe.

It will read stuff from STDIN and output to ZeroMQ sockets, and read from ZeroMQ sockets and send to STDOUT.

Messages are terminated by newlines, or pairs of newlines in paragraph mode.

Supports 1-to-1, 1-to-N and N-to-1. There is a special mode to start as

@timbunce
timbunce / gist:591718
Created September 22, 2010 14:00
perl 6 method wrapping via a role
role R {
method m() { say 42 }
}
class C does R {
}
my $x = C.new;
log-calls($x, R);
role R {
method m() { say 42 }
}
class C does R {
}
my $x = C.new;
log-calls($x, R);