Skip to content

Instantly share code, notes, and snippets.

Nicolas Mendoza nicomen

Block or report user

Report or block nicomen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nicomen
nicomen / gist:044d58f7444762412d91e98aae8f84e6
Last active Sep 10, 2018
' allowed as package delimiter vs. syntax error, passing a string into foo and correct interpolation
View gist:044d58f7444762412d91e98aae8f84e6
✔ 18:00 /projects/perl-git [ blead | ✚ 14 …2 ] $ perl -wle "package foo'bar; sub lol { print 'lol'; }; foo'bar::lol()"
lol
✔ 18:00 /projects/perl-git [ blead | ✚ 14 …2 ] $ ./perl -wle "package foo'bar; sub lol { print 'lol'; }; foo'bar::lol()"
Bareword found where operator expected at -e line 1, near "'bar; sub lol { print 'lol"
(Missing operator before lol?)
Unquoted string "lol" may clash with future reserved word at -e line 1.
String found where operator expected at -e line 1, near "lol'; }; foo'"
Bareword found where operator expected at -e line 1, near "'; }; foo'bar::lol"
(Missing operator before bar::lol?)
@nicomen
nicomen / gist:402a091149bfc81cb8df1a9d9f3d0ba3
Created Sep 5, 2018
getting correct versions of possible valid dependencies
View gist:402a091149bfc81cb8df1a9d9f3d0ba3
sub _get_deb_candidates {
my ( $self, $wanted_pkgs) = @_;
$self->log('._deb_deb_candidates')->logdie("Please provide packages to search for") unless $wanted_pkgs;
my $candidates;
for my $wanted_pkg (keys %{$wanted_pkgs}) {
my $pkg_pattern = $self->_get_pkg_alternatives_pattern($wanted_pkg);
@nicomen
nicomen / gist:09c98a8b413d1160a902d205ae72c671
Created Sep 5, 2018
jerry builder tests for version comparison
View gist:09c98a8b413d1160a902d205ae72c671
is(Build::Debian::Dpkg->cmp_fileversion('test_1.10_amd64.deb','1.2'), 1,'cmp_fileversion: test_1.10_amd64.deb > 1.2');
is(Build::Debian::Dpkg->cmp_fileversion('cpan-libfiltered-perl_0.0.7-1355404556_all.deb','v0.0.4'), 1,'cmp_fileversion: cpan-libfiltered-perl_0.0.7-1355404556_all.deb > v0.0.4');
is(Build::Debian::Dpkg->cmp_fileversion('libdatetime-timezone-perl_1.58-1+2013b_all.deb', '1.09'), 1, 'cmp_fileversion: libdatetime-timezone-perl_1.58-1+2013b_all.deb > 1.09');
is(Build::Debian::Dpkg->cmp_fileversion('libtest-perl_1.10_amd64.deb','1.2'), -1, 'cmp_fileversion: libtest-perl_1.10_amd64.deb < 1.2');
is(Build::Debian::Dpkg->cmp_fileversion('libc6_2.13-38_amd64.deb','2.13'), 1, 'cmp_fileversion: libc6_2.13-38_amd64.deb > 2.13');
is(Build::Debian::Dpkg->cmp_fileversion('libc6_2.13_amd64.deb','2.13'), 0, 'cmp_fileversion: libc6_2.13_amd64.deb == 2.13');
is(Build::Debian::Dpkg::version_compare('0.0.7','v0.0.4' ), 1, 'Comparing versio
View gist:312fb3ceea10aac3cc3e7af2693faede
package MojoCarpAlways;
use Mojo::Base -strict;
use Mojo::Exception;
*Mojo::Exception::to_string = sub {
my $self = shift;
my $str = $self->message;
$str .= join "\n", map { " $_->[1]: " . $_->[2] } @{ $self->frames };
View gist:6c216644be4b3c877d292fdc849432f0
# Failed test 'query that remove defaults'
# at t/Solr.pm line 20.
# Comparing $data->{"allowed_supplier_ids"} as a SubBag
# Extra: '66'
# {
# 'adults' => 2,
# 'allowed_supplier_ids' => '***masked***',
# 'children' => 0,
# 'collapse_field' => 'hotel_id',
# 'facet_min_count' => 0,
View gist:76239cf63f812f33cd2ac73c70a350d4
$ perl -Ilib -wle 'use Mojo::Promise; for my $die (qw/0 1/) { warn "$die\n"; my $p = Mojo::Promise->new; $p->then(sub { die if $die; })->then(sub { return "survived"; }, sub { return "died"; })->then(sub { print shift . " but recovered" }); $p->resolve; $p->wait; }'
0
survived but recovered
1
died but recovered
vs
$ perl -Ilib -wle 'use Mojo::Promise; for my $die (qw/0 1/) { warn "$die\n"; my $p = Mojo::Promise->new; $p->then(sub { die if $die; })->then(sub { return "survived"; }, sub { die "died"; })->then(sub { print shift . " but recovered" }, sub { print "died but not recovered" }); $p->resolve; $p->wait; }'
0
@nicomen
nicomen / db_proxy.pm
Last active Dec 6, 2017
Simple db proxy class
View db_proxy.pm
package Supplier;
use strict;
use warnings;
use Moo;
use Carp qw/croak/;
has 'code' => ( is => 'ro', required => 1 );
has 'db_row' => ( is => 'lazy', builder => 1 );
@nicomen
nicomen / gist:8c01cc4e2c72af6c90cc580048c50d04
Created Oct 30, 2017
max 4 parallell jobs while testing syntax
View gist:8c01cc4e2c72af6c90cc580048c50d04
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use Test::Strict;
use Test2::AsyncSubtest;
use POSIX ":sys_wait_h";
View gist:1bceaaf0a7d12d9bb0f432cb2a9e88c9
arne@aBook ~/S/r/legacy-cronjobs> moo-outdated
dyld: lazy symbol binding failed: Symbol not found: _Perl_xs_handshake
Referenced from: /Users/arne/perl5/lib/perl5/darwin-thread-multi-2level/auto/Sub/Name/Name.bundle
Expected in: flat namespace
dyld: Symbol not found: _Perl_xs_handshake
Referenced from: /Users/arne/perl5/lib/perl5/darwin-thread-multi-2level/auto/Sub/Name/Name.bundle
Expected in: flat namespace
| fish: 'moo-outdated' terminated by signal SIGABRT (Abort)
View gist:3dcf98d21cf497e50902b4dec8cfe195
Role::Tiny
/Users/arne/perl5/lib/perl5/Role/Tiny.pm: 2.000005
Moo
/Users/arne/perl5/lib/perl5/Moo.pm: 2.003002
Moo::_mro
/Users/arne/perl5/lib/perl5/Moo/_mro.pm: ?
You can’t perform that action at this time.