Skip to content

Instantly share code, notes, and snippets.

View melo's full-sized avatar

Pedro Melo melo

View GitHub Profile
@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 {}
#!/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 / 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"
@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 / 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;
#!/bin/bash
#
# PS1 magic
#
# Mostly copied from YUVAL KOGMAN version, added my own __git_ps1 stuff
# Original: http://gist.github.com/621452
#
# See video demo of this at http://vimeo.com/15789794
#
# To enable save as .bash_prompt in $HOME and add to .bashrc:
@melo
melo / C1.pm
Created September 24, 2012 14:19
Open-ended role exclusion
package C1;
use Moose;
with 'R1'; ## this works
with 'R2'; ## this also works
with 'R1', 'R2'; ## this will fail
1;
#!/usr/bin/env perl
#
# Filesystem changes trigger
use v5.14;
use FindBin;
use lib "$FindBin::Bin/../lib";
use E1::Setup::Perl;
use Filesys::Notify::Simple;
@melo
melo / test.c
Created August 21, 2012 16:11
Strange problem with ZeroMQ perl bindings + fork
//
// Demonstrate that zmq_init followed by fork does not die
//
// Compile/run:
//
// cc -lzmq -o test test.c ; ./test
//
#include <zmq.h>
#include <stdio.h>
#include <unistd.h>
@melo
melo / smzp_sinopsys.md
Created August 1, 2012 11:37
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. Works fine for line- based streams.

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