Skip to content

Instantly share code, notes, and snippets.

View melo's full-sized avatar

Pedro Melo melo

View GitHub Profile
@melo
melo / gist:4484184
Last active December 10, 2015 19:48 — forked from anonymous/gist:4484023
use strict;
use Test::More;
use Test::TCP;
use Proc::Guard ();
use ZMQ::LibZMQ3;
use ZMQ::Constants ':all';
sub start_proxy {
my @ports = map { Test::TCP::empty_port() } 1..3;
@melo
melo / merge.pl
Created January 9, 2013 17:22
Merge the content of two single page PDFs, on a pretty template, the other an invoice, into a new *single* page PDF, using Perl PDF::API2
#!/usr/bin/env perl
use strict;
use warnings;
use PDF::API2;
my ($template_pdf, $data_pdf) = @ARGV;
my $t_pdf = PDF::API2->open($template_pdf);
my $page = $t_pdf->openpage(1);
@melo
melo / compile_nginx_spdy
Last active December 11, 2015 15:49
Script to compile nginx 1.3.11 with SPDY enabled: includes all dependencies (PCRE and latest OpenSSL) - see config file at the end
#!/bin/sh
PACKAGE="nginx"
NGINX_VERSION="1.3.11"
NGINX_SPDY_PATCH_VERSION="58_1.3.11"
NGINX_NAME="${PACKAGE}-${NGINX_VERSION}"
NGINX_TARBALL="${NGINX_NAME}.tar.gz"
NGINX_URL=http://nginx.org/download/${NGINX_TARBALL}
NGINX_SPDY_PATCH_NAME="patch.spdy-${NGINX_SPDY_PATCH_VERSION}.txt"
#!/bin/bash --login
#
# Notice the --login up there, to make sure my heavily modified .bashrc is read
# and I have a sane PATH
echo -ne "\033]1;catalog website supervise\007"
## remove all the --login stuff I don't care about
clear
exec ./dev/daemons/e1-catalog-website
@melo
melo / C1.pm
Last active December 15, 2015 11:19
Roles check the require's a bit too soon for my taste
## This one is ok, sub is defined at compile time
package C1;
use Moo;
with 'R';
sub m {}
@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} );
@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 / 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 / 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 / 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);