Skip to content

Instantly share code, notes, and snippets.

@dpetrov
dpetrov / join_and_reverse.py
Created October 24, 2019 14:27
Joing pages from a a collection of PDF files into a single PDF file
#! /usr/bin/python
#
# join
# Joing pages from a a collection of PDF files into a single PDF file.
#
# join [--output <file>] [--shuffle] [--reverse] [--verbose]"
#
# Parameter:
#
# --shuffle
SELECT
total.count,
detail.basetag,
detail.alarms_id
FROM
(
SELECT
basetag,
count(*)
FROM
@dpetrov
dpetrov / cpan_favorites.pl
Created November 7, 2012 08:24
Install all favorited distributions
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Mojo::UserAgent;
my $url = shift @ARGV or die "Usage: $0 metacpan_author_url";
my $ua = Mojo::UserAgent->new;
my $dom = $ua->get($url)->res->dom;
@dpetrov
dpetrov / gist:1423428
Created December 2, 2011 14:32
CPAN-API tests
[dpetrov@pc335: ~/catalyst/cpan-api]$ prove -lvr t
t/document/author.t ..................
ok 1 - perlmongers ok
1..1
ok
t/document/file.t ....................
ok 1
ok 2
ok 3
ok 4
diff --git a/lib/MetaCPAN/Web/Controller/Module.pm b/lib/MetaCPAN/Web/Controller/Module.pm
index 0ef1d03..27a7be6 100644
--- a/lib/MetaCPAN/Web/Controller/Module.pm
+++ b/lib/MetaCPAN/Web/Controller/Module.pm
@@ -6,7 +6,15 @@ use namespace::autoclean;
BEGIN { extends 'MetaCPAN::Web::Controller' }
sub index : PathPart('module') : Chained('/') : Args {
- my ( $self, $c, @module ) = @_;
+ my ( $self, $c, $id, @module ) = @_;
@dpetrov
dpetrov / gist:1286444
Created October 14, 2011 07:02
redirect lc author to uc author
diff --git a/lib/MetaCPAN/Web/Controller/Module.pm b/lib/MetaCPAN/Web/Controller/Module.pm
index 0ef1d03..e01c51d 100644
--- a/lib/MetaCPAN/Web/Controller/Module.pm
+++ b/lib/MetaCPAN/Web/Controller/Module.pm
@@ -6,7 +6,15 @@ use namespace::autoclean;
BEGIN { extends 'MetaCPAN::Web::Controller' }
sub index : PathPart('module') : Chained('/') : Args {
- my ( $self, $c, @module ) = @_;
+ my ( $self, $c, $id, @module ) = @_;
@dpetrov
dpetrov / gist:1284673
Created October 13, 2011 16:18
that pass all tests
diff --git a/lib/MetaCPAN/Web/Controller/Module.pm b/lib/MetaCPAN/Web/Controller/Module.pm
index 0ef1d03..9831aff 100644
--- a/lib/MetaCPAN/Web/Controller/Module.pm
+++ b/lib/MetaCPAN/Web/Controller/Module.pm
@@ -13,7 +13,7 @@ sub index : PathPart('module') : Chained('/') : Args {
: $c->model('API::Module')->get(@module)->recv;
$c->detach('/not_found') unless ( $data->{name} );
- my $pod = $c->model('API')->request( '/pod/' . join( '/', @module ) );
+ my $pod = $c->model('API')->request( '/pod/' . join( '/', (@module > 1 ? uc shift @module : ()), @module ) );
diff --git a/lib/MetaCPAN/Web/Model/API/File.pm b/lib/MetaCPAN/Web/Model/API/File.pm
index eaa4d1f..cada94a 100644
--- a/lib/MetaCPAN/Web/Model/API/File.pm
+++ b/lib/MetaCPAN/Web/Model/API/File.pm
@@ -4,12 +4,12 @@ extends 'MetaCPAN::Web::Model::API';
sub get {
my ( $self, @path ) = @_;
- $self->request( '/file/' . join( '/', @path ) );
+ $self->request( '/file/' . join( '/', uc shift @path, @path ) );
[dpetrov@pc335: /tmp/metacpan-web]$
[dpetrov@pc335: /tmp/metacpan-web]$ prove -lvr t/
t/controller/activity.t ............. You are running Catalyst::Engine::PSGI, which is considered a legacy engine for
this version of Catalyst. We will continue running and use your existing psgi
file, but it is recommended to perform the trivial upgrade process, which will
leave you with less code and a forward path.
Please review Catalyst::Upgrading
env as a writer is deprecated, you probably need to upgrade Catalyst::Engine::PSGI at /usr/local/share/perl/5.10.1/Catalyst/Engine.pm line 27.