Skip to content

Instantly share code, notes, and snippets.

package RG::BackendConfig;
use strict;
use warnings;
use Moo;
extends 'RG::Config';
has '+name' => ( is => 'ro', default => 'reisegigantenadmin');
@nicomen
nicomen / gist:2d6c10228197de55740a092e90fc1acc
Created October 10, 2016 10:12
Open sourcing material ABC Startsiden
---------- Forwarded message ----------
From: Andreas Marienborg <[email protected]>
Date: 2015-06-02 16:42 GMT+07:00
Subject: Re: Forespørsel om å utgi utvalgte biblioteker som åpen kildekode
To: Nicolas Mendoza <[email protected]>
Cc: [email protected]
Hey,
@nicomen
nicomen / gist:bf527b8085f4986eed71fafaf9bca709
Last active October 6, 2016 11:56
Move cache driver setup to config and allow forcing no cache with envvar
diff --git a/lib/Reisegiganten.pm b/lib/Reisegiganten.pm
index 31fd492..5614df3 100644
--- a/lib/Reisegiganten.pm
+++ b/lib/Reisegiganten.pm
@@ -188,7 +188,7 @@ sub setup_attrs {
my ($self) = @_;
$self->attr( 'db_config' => sub { RG::Config->new; });
- $self->attr( 'cache' => sub { CHI->new( driver => 'FastMmap', cache_size => '10m', root_dir => '/tmp/mmap_' . __PACKAGE__, expire_time => '10m', expires_in => '10 min', expires_variance => 0.1 )});
+ $self->attr( 'cache' => sub { CHI->new( $ENV{NO_CACHE} ? ( Driver => 'Null' ) : $self->config->{cache} ) });
@nicomen
nicomen / test_fn.pl
Created September 12, 2016 11:52 — forked from simonamor/test_fn.pl
package MyApp::Base;
use Moose;
has 'abc' => ( is => 'ro', lazy => 1, default => 'def', reader => 'get_abc' );
has 'xyz' => ( is => 'ro', lazy => 1, default => 123, reader => 'get_xyz' );
around [qw/get_abc get_xyz/] => sub {
my ($orig, $self) = shift;
return "base: " . $self->$orig;
autocmd BufWritePre *.{pm,t,pl} call StripTrailingWhite()
function! StripTrailingWhite()
let l:winview = winsaveview()
silent! %s/\s\+$//
call winrestview(l:winview)
endfunction
#!/usr/bin/perl
use v5.10;
=o_O=
.__.
=cut
say "funpod";
$ perl -wlE 'say $]; &CORE::warn(1)'
5.022002
1 at -e line 1.
$ perl -wlE 'say $]; &CORE::warn(1)'
5.014002
Undefined subroutine &CORE::warn called at -e line 1.
@nicomen
nicomen / gist:d7cb55040d1bab21460a7773c88bbe28
Created August 4, 2016 13:32
__FILE__ does not do what I want
nicolasm@tipsy:/tmp $ cat Foo.pm
package Foo;
use Moo;
has 'path' => ( is => 'lazy', default => sub { return __FILE__ } );
1;
nicolasm@tipsy:/tmp $ cat SubFoo.pm
package SubFoo;
use Moo;
extends 'Foo';
#!/usr/bin/perl
use Data::Dumper;
local $Data::Dumper::Indent = 0;
package A;
use Moo;
has a => (is => "ro");
has b => (is => "ro", lazy => 1, default => sub { shift->a + 1 });
@nicomen
nicomen / block-syntax.pl
Created July 12, 2016 15:59
Block syntax question
$ perl -wle 'sub foo (&$*) { print "@_"; } foo(sub {*STDOUT},"a", "b");'
CODE(0x2561da8) a b
$ perl -wle 'sub foo (&$*) { print "@_"; } foo {*STDOUT} "a", "b";'
CODE(0x184ed68) a b
# How can I from inside the sub distinguish the calls?
# print example:
$ perl -wle 'print sub{*STDOUT},"a", "b";'