Skip to content

Instantly share code, notes, and snippets.

@berekuk
berekuk / moo-false-default.txt
Created April 16, 2013 16:33
Moo and false defaults
$ perl -MData::Dumper -E 'use Moo; has "foo" => (is => "ro", default => sub { 0 }); has "bar" => (is => "ro", default => 0); say Dumper(main->new)'
$VAR1 = bless( {
'foo' => 0
}, 'main' );
sub custom_commands {
my $self = shift;
return ($self->custom_commands, "helloworld";
}
sub do_custom_command {
my $self = shift;
my $command = shift;
if ($command eq 'helloworld') {
@berekuk
berekuk / stacktrace
Created February 1, 2013 14:23
MetaCPAN::Server::Controller::Login::Google requires consumer_key
Couldn't instantiate component "MetaCPAN::Server::Controller::Login::Google", "Attribute (consumer_key) is required at /usr/local/lib/perl/5.14.2/Moose/Meta/Attribute.pm line 514.
Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0x61eee10)', 'Moose::Meta::Instance=HASH(0x61ef5d8)', 'MetaCPAN::Server::Controller::Login::Google=HASH(0x8690580)', 'HASH(0x841d9c8)') called at /usr/local/lib/perl/5.14.2/Class/MOP/Class.pm line 525
Class::MOP::Class::_construct_instance('Moose::Meta::Class::__ANON__::SERIAL::11=HASH(0x619a978)', 'HASH(0x841d9c8)') called at /usr/local/lib/perl/5.14.2/Class/MOP/Class.pm line 498
Class::MOP::Class::new_object('Moose::Meta::Class::__ANON__::SERIAL::11=HASH(0x619a978)', 'HASH(0x841d9c8)') called at /usr/local/lib/perl/5.14.2/Moose/Meta/Class.pm line 274
Moose::Meta::Class::new_object('Moose::Meta::Class::__ANON__::SERIAL::11=HASH(0x619a978)', 'HASH(0x841d9c8)') called at /usr/local/lib/perl/5.14.2/Moose/Object.pm line 28
Moose::Object::new('MetaCPAN::
@berekuk
berekuk / gist:4396921
Created December 28, 2012 11:20
cpan-api/metacpan-web broken-pipe bug
# bad response in MetaCPAN::Web::Model::API->request
headers: $VAR1 = {
'Reason' => 'Broken pipe',
'URL' => 'http://127.0.0.1:5000/release/_search',
'Status' => 596
};
@berekuk
berekuk / vagrant-provision.log
Created October 14, 2012 21:23
issue with :notifies for in-line resources in lightweight provider
...
[2012-10-14T21:18:39+00:00] INFO: Processing ubic_service[dancer] action install (play-perl::default line 50)
[2012-10-14T21:18:39+00:00] INFO: Processing ubic_service[dancer] action start (play-perl::default line 50)
[2012-10-14T21:18:39+00:00] INFO: Processing template[/etc/ubic/service/dancer] action create (/tmp/vagrant-chef-1/chef-solo-1/cookbooks/ubic/providers/service.rb line 22)
[2012-10-14T21:18:40+00:00] INFO: template[/etc/ubic/service/dancer] backed up to /var/chef/backup/etc/ubic/service/dancer.chef-20121014211840
[2012-10-14T21:18:40+00:00] INFO: template[/etc/ubic/service/dancer] removed backup at /var/chef/backup/./etc/ubic/service/dancer.chef-20121014205215
[2012-10-14T21:18:40+00:00] INFO: template[/etc/ubic/service/dancer] updated content
[2012-10-14T21:18:40+00:00] INFO: template[/etc/ubic/service/dancer] owner changed to 0
[2012-10-14T21:18:40+00:00] INFO: template[/etc/ubic/service/dancer] group changed to 0
[2012-10-14T21:18:40+00:00] INFO: template[/etc/ubic/service/dancer] mode ch
mmcleric@mmcleric:~/build$ cat Devel-CheckLib-0.98/debian/rules
#!/usr/bin/make -f
%:
dh $@
override_dh_perl:
dh_perl
dh_perldeps
package Ubic::Service::SimpleDaemon::WithMemoryUsage;
use strict;
use warnings;
use parent qw(Ubic::Service::SimpleDaemon);
use Ubic::Daemon qw(check_daemon);
use Ubic::Result qw(result);
sub custom_commands {
my $self = shift;
mass(universe) = 3e52 kg # http://en.wikipedia.org/wiki/Observable_universe#Estimation_based_on_the_measured_stellar_density
mass(sun) = 2e30 kg
diameter(sun) = 1.3e6 km
radius(sun) = 6e5 km
orbit(earth) = 1.5e8 km
density(neutron star) = 4e14 * density(sun) # http://en.wikipedia.org/wiki/Neutron_star
mass(neutron star with the size of sun) = 2e30 * 4e14 = 8e44
mass(neutron star with the size of earth orbit) = (1.5e8 / 6e5)^3 * 8e44 = 1.2e52
orbit(mars) ~ 1.5 * orbit(earth)
mass(neutron star with the size of mars orbit) = 1.2 * 10^52 * 1.5**3 = 4.2e52 > mass(universe)
package R;
use Moose::Role;
has "foo" => (
is => "ro",
required => 1,
default => 5
);
package X;
use Moose;
s kkq spbhjd ap hbqcp jhp ar pdph bidprs
|q nprafp pa rhepd algthdb abd hacjabhnkee
s//q spbhjd ap hbqcp jhp ar pdph bidprs
|q nprafp pa rhepd algthdb abd hacjabhn/ee
eval eval "q spbhjd ap hbqcp jhp ar pdph bidprs
|q nprafp pa rhepd algthdb abd hacjabhn"
eval eval "q {pbhjd ap hbqcp jhp ar pdph bidpr}