Skip to content

Instantly share code, notes, and snippets.

View melo's full-sized avatar

Pedro Melo melo

View GitHub Profile
@melo
melo / git-find-blob.pl
Created March 12, 2018 19:48 — forked from DaveMessina/git-find-blob.pl
git-find-blob: pass a blob SHA1 and find commits which contain it
#!/usr/bin/perl
use 5.008;
use strict;
use Memoize;
# by Aristotle Pagaltzis <http://stackoverflow.com/users/9410/aristotle-pagaltzis>
# taken from thread http://stackoverflow.com/questions/223678/git-which-commit-has-this-blob
# on 6 june 2010
my $usage =
@melo
melo / redis_cluster_notes.mmd
Created October 18, 2011 11:19
Notes about the Redis Cluster specification
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@melo
melo / Explanation.txt
Created May 16, 2012 17:17
strange nginx behaviour with error_page + proxy_pass
I expected the first configuration below, simple.conf, to work just fine.
But it doesn't. My app server receives the second hit with the same URI as the first hit.
On the second config, wtf.conf, I keep the original URL on a variable to use in the error redirect.
My question is this: why doesn't the first simple.conf configuration works?
@melo
melo / ULID.pm
Last active March 12, 2018 10:10
Improvements on ULID generation (perl)
package ULID;
use strict;
use warnings;
use Exporter;
use Crypt::PRNG 'random_bytes';
use Time::HiRes 'time';
use bytes;
our @ISA = qw( Exporter );
@melo
melo / MyClass.pm
Last active July 7, 2017 23:36
Perl setup
package MyClass;
use MySetup;
use Function::Parameters ();
use Moo ();
use namespace::sweep ();
use Scalar::Util ();
use Try::Tiny ();
use Import::Into;
@melo
melo / .bash_prompt
Created October 22, 2011 21:44
uber git PS1
#!/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 / aws.md
Last active April 20, 2017 04:15
AWS ElasticBeanstalk inconsistency...

** found it ** - I was running an old version of AWS CLI :)

I was able to create a ElasticBeanstalk environment with a EnvironmentName that is longer than what the API's allows...

I can describe the environment, but I can't find the options for it, describe-configuration-options doesn't accept --environment-id... :(

$ env_name=`aws elasticbeanstalk describe-environments --environment-id e-XXXXXXXX | jq .Environments[0].EnvironmentName`
$ echo $env_name
"XXXXXXXX-XXXXXXX-XXX-XXX"

$ aws elasticbeanstalk describe-environments --environment-name $env_name

@melo
melo / TLS.pm
Last active February 22, 2017 15:32
Package MIME::Lite::TLS - **DEPRECATED** - look at Net::SMTPS at https://metacpan.org/release/Net-SMTPS
package MIME::Lite::TLS;
use strict;
use warnings;
use Net::SMTP::TLS;
use parent 'MIME::Lite';
=head1 NAME
FROM perl
WORKDIR /perl
ENTRYPOINT ["carton", "exec"]
RUN cpanm -n Carton
COPY tarball.tgz /perl
RUN cd /perl && tar zxf tarball.tgz && carton install --deployment
@melo
melo / git-build
Created December 6, 2016 16:11
Trigger a Gitlab CI build with 'git build'
#!/bin/sh
project_id=`git config gitlab.project-id`
if [ -z "$project_id" ] ; then
echo "FATAL: could not find gitlab.project-id on your config"
echo "To fix: use 'git config gitlab.project-id ID'"
echo " find the project ID in the Settings > Triggers page,"
echo " in the examples, it is the number in the URL"
exit 1
fi