Skip to content

Instantly share code, notes, and snippets.

View melo's full-sized avatar

Pedro Melo melo

View GitHub Profile
@melo
melo / intro.md
Last active February 18, 2016 18:02 — forked from anonymous/intro.md
Compare VPack to Sereal - *Size* only

At $work, we are looking to replace JSON encoding with another format, to increase encode/decode speed and required storage size.

Requirements, in order of importance for our use case, YMMV:

  • no schema requirement: data is JSON-compatible, deeply nested in cases, but we don't have a schema to start from;
  • smallest size: we store the objects in memory on Redis DB's, so size is the main factor;
  • fast decode: we can trade slower encode speed for size, but decode should be fast;
  • language support: stack is Perl, Go, and JavaScript. PHP is a plus, but not required.

We are testing msgpack, cbor, sereal, and others,

@melo
melo / Dockerfile
Created August 14, 2015 05:00
Simple Dockerfile base for Perl project
FROM our/base
COPY *.patch /build/
## Replicate std perl image but on top of our base image
RUN cd /build \
&& mkdir src \
&& curl -SL https://cpan.metacpan.org/authors/id/S/SH/SHAY/perl-5.20.2.tar.bz2 -o perl-5.20.2.tar.bz2 \
&& echo '63126c683b4c79c35008a47d56f7beae876c569f *perl-5.20.2.tar.bz2' | sha1sum -c - \
&& tar --strip-components=1 -xjf perl-5.20.2.tar.bz2 -C src \
sub _merge_cpanfile {
my @cpanfiles = map { $_ = Module::CPANfile->load($_)->prereqs } _find_cpanfiles($_[0]);
my $reqs = CPAN::Meta::Prereqs->new->with_merged_prereqs(\@cpanfiles);
return Module::CPANfile->from_prereqs($reqs->as_string_hash)->to_string;
}
my $p = path(`$FindBin::Bin/orc-project-root`);
my @cpanfiles = map { $_ = Module::CPANfile->load($_)->prereqs } _find_cpanfiles($p);
my $reqs = CPAN::Meta::Prereqs->new->with_merged_prereqs(\@cpanfiles);
@melo
melo / .tidyallrc
Created December 16, 2014 20:59
My .tidyallrc
[PerlTidy]
select = **/*.{pl,pm,t}
[PodTidy]
argv = --column=100
select = **/*.{pm,pod}
[Perl::AlignMooseAttributes]
select = **/*.pm
@melo
melo / x-hipchat
Last active August 29, 2015 14:09
hipchat send
#!/usr/bin/env perl
use strict;
use warnings;
use JSON 'encode_json';
use HTTP::Tiny;
use Getopt::Long;
use Encode 'decode';
my %opts = (room => $ENV{HIPCHAT_ROOM}, notify => 1);
@melo
melo / gist:9cc6bae89f608d779820
Created October 4, 2014 14:06
redis 2.8.17 fails to compile with brew on Mac OS X 10.8.5..
LINK redis-server
Undefined symbols for architecture x86_64:
"___atomic_add_fetch", referenced from:
_zmalloc in zmalloc.o
_zcalloc in zmalloc.o
_zrealloc in zmalloc.o
_zmalloc_used_memory in zmalloc.o
"___atomic_sub_fetch", referenced from:
_zrealloc in zmalloc.o
_zfree in zmalloc.o
@melo
melo / coro_channel_multiget.pl
Created October 20, 2013 07:47
Coro::Channel will round-robin between threads, nice...
#!/usr/bin/env perl
use common::sense;
use Coro;
my $req = Coro::Channel->new;
my $rep = Coro::Channel->new;
sub start_worker {
my $name = shift;
@melo
melo / eheh.pl
Created August 8, 2013 07:49
Make up your mind, please...
if ($config->{sms_notifications_enabled}) {
$log->warn("SMS notifications are disabled, use ENV ENABLE_SMS_NOTIFICATIONS to enable")
unless $config->{i_know_sms_notifications_are_disabled_please_leave_me_alone};
return;
}
@melo
melo / WorkerRole.pm
Created April 18, 2013 06:49
A Role for Gearman workers that uses Moose MOP to find out which queues it should listen to... I love Moose...
package E6::Queue::Legacy::WorkerRole;
## Role for all the Gearman Legacy Workers out there: provides run, run_once, and startup logic
use E6::Setup::Role;
with 'E6::Queue::Legacy::HasQueueRole';
has 'is_started' => ( is => 'rw', writer => '_is_started', default => sub {0} );