Navigation Menu

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 / 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 / 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
@melo
melo / cpanfile
Last active December 2, 2016 15:29
Benchmark ZADD's over the network to a low-powered server
# Use `carton install` to install these deps
requires 'Redis::Fast';
requires 'Data::UUID::LibUUID';
requires 'Time::HiRes';
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 / keybase.md
Created September 2, 2016 22:03
keybase.md

Keybase proof

I hereby claim:

  • I am melo on github.
  • I am pedromelo (https://keybase.io/pedromelo) on keybase.
  • I have a public key whose fingerprint is C3BA 5291 133A 3116 9FB7 5DA7 6112 28B7 2371 312C

To claim this, I am signing this object:

@melo
melo / sanity.pl
Created August 3, 2016 16:33
Carton local dir inspection tool
#!/usr/bin/env perl
#
# Checks "provides" list in install.json files with the actual files
# installed by Carton on your local dir
#
use strictures 2;
use File::Find;
use Path::Tiny;
use JSON::MaybeXS 'decode_json';
@melo
melo / gist:64e10f195834b20a0085f26315abcbe6
Created August 2, 2016 09:55
Hugo not that fast, or I need a new Mac
Started building site
0 of 4 drafts rendered
0 future content
0 expired content
976 pages created
0 non-page files copied
700 paginator pages created
494 tags created
in 40914 ms
@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