Skip to content

Instantly share code, notes, and snippets.

@cxreg
cxreg / gist:4b930a5fb50dd82934e1edaecb26c1dd
Created August 17, 2016 18:48
Downsampling Influxdb data while converting tags to fields
# Insert some data
> insert foo,bar=baz,biff=buzz numvalue=1,strvalue="some string"
> insert foo,bar=baz,biff=buzz numvalue=1,strvalue="some string"
> insert foo,bar=baz,biff=buzz numvalue=1,strvalue="some string"
> insert foo,bar=baz,biff=buzz numvalue=1,strvalue="some string"
> insert foo,bar=baz,biff=buzz numvalue=1,strvalue="some string"
> show series
key
foo,bar=baz,biff=buzz
@cxreg
cxreg / gist:d2b9b5e35019b0fb05dbfc8853f9896c
Created October 27, 2016 19:12
zmq crash, without curve
::::::::::::::
server.c
::::::::::::::
// invoked as valgrind ./server
#include <zmq.h>
void main(void) {
void *ctx = zmq_ctx_new();
void *socket = zmq_socket(ctx, ZMQ_XPUB);
zmq_bind(socket, "tcp://*:9999");
@cxreg
cxreg / gist:806f2e51b8cce4a67e362d3dce86cfbc
Created October 27, 2016 19:01
zmq set_metadata crash repro
daveo@abraxas:~/zmq-crash-repro$ more server.c client.c
::::::::::::::
server.c
::::::::::::::
// invoked as valgrind ./server
#include <zmq.h>
void main(void) {
void *ctx = zmq_ctx_new();
void *socket = zmq_socket(ctx, ZMQ_XPUB);
@cxreg
cxreg / gist:060812ee5d4372002d074ec597cc2b81
Created October 27, 2016 18:09
zmq set_metadata memory corruption
==24817== Invalid read of size 4
==24817== at 0x1003769: zmq::metadata_t::add_ref()
==24817== by 0x10041AF: zmq::msg_t::set_metadata(zmq::metadata_t*)
==24817== by 0x102A25A: zmq::xpub_t::xrecv(zmq::msg_t*)
==24817== by 0x100FCBB: zmq::socket_base_t::recv(zmq::msg_t*, int)
==24817== by 0xFF3EE5: zmq_msg_recv
==24817== Address 0x636beb0 is 0 bytes inside a block of size 56 free'd
==24817== at 0x4C2E26B: operator delete(void*)
==24817== by 0x1004DF6: zmq::msg_t::close()
==24817== by 0x102C221: zmq::xpub_t::xread_activated(zmq::pipe_t*)
dolszewski@blackheat:~$ echo test | read somevar
dolszewski@blackheat:~$ echo $somevar
dolszewski@blackheat:~$ read somevar < <(echo test)
dolszewski@blackheat:~$ echo $somevar
test
@cxreg
cxreg / gist:5435752
Created April 22, 2013 15:02
Rakudo make asplode
$ make -j5
/usr/bin/perl /home/count/src/ext/perl/perl6/local/lib/parrot/5.2.0-devel/tools/build/pmc2c.pl --no-lines --dump --include src/vm/parrot/pmc --include /home/count/src/ext/perl/perl6/local/src/parrot/5.2.0-devel --include /home/count/src/ext/perl/perl6/local/src/parrot/5.2.0-devel/pmc src/vm/parrot/pmc/perl6lexinfo.pmc src/vm/parrot/pmc/perl6lexpad.pmc.
/usr/bin/perl /home/count/src/ext/perl/perl6/local/lib/parrot/5.2.0-devel/tools/build/pmc2c.pl --no-lines --c --include src/vm/parrot/pmc --include /home/count/src/ext/perl/perl6/local/src/parrot/5.2.0-devel --include /home/count/src/ext/perl/perl6/local/src/parrot/5.2.0-devel/pmc src/vm/parrot/pmc/perl6lexinfo.pmc src/vm/parrot/pmc/perl6lexpad.pmc.
/usr/bin/perl /home/count/src/ext/perl/perl6/local/lib/parrot/5.2.0-devel/tools/build/pmc2c.pl --no-lines --library perl6_group --c src/vm/parrot/pmc/perl6lexinfo.pmc src/vm/parrot/pmc/perl6lexpad.pmc.
cc -c -o perl6_group.o -Isrc/vm/parrot/pmc -I/home/count/src/ext/perl/perl6/local/include/parrot/5.2.0-d
@cxreg
cxreg / gist:5418654
Created April 19, 2013 07:17
SIPp scenario to trigger modesl unicode parser bug
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
How I invoked this test:
sipp 10.104.11.81 -p 2048 -sf repro.sipp -m 1 -nd -nr
-->
<scenario name="utf8 in caller id">
<send>
@cxreg
cxreg / gist:5311075
Last active December 15, 2015 19:28
benchmarking node binary-to-url-encoding
var fs = require('fs');
var re = /(..)/g;
var methods = {
with_escape: function(data, cb) {
cb(escape(data.toString('binary')));
},
with_loop: function (data, cb) {
var buf = '';
for (var n = 0; n < data.length; n++) {
@cxreg
cxreg / gist:5306528
Created April 3, 2013 23:50
Fix %% in JSON in FS
diff --git a/src/switch_json.c b/src/switch_json.c
index 3819cda..3b7a603 100644
--- a/src/switch_json.c
+++ b/src/switch_json.c
@@ -220,7 +220,7 @@ static char *print_string_ptr(const char *str)
const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
if (!str) return cJSON_strdup("");
- ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
+ ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t%",token)) len++; else if (token<32) len+=5;ptr++;}