Recently in Programming Category

Now also Ubuntu Perl packages indexed. For example Moose::Meta::Class

Package: libmoose-perl
Package version: 0.31-1
Module version: 0.16
Arch: all
Dist: hardy
Component: universe

Package: libmoose-perl
Package version: 0.94-1
Module version: 0.94
Arch: amd64
Dist: lucid
Component: universe

Package: libmoose-perl
Package version: 1.23-1
Module version: 1.23
Arch: amd64
Dist: natty
Component: universe

Package: libmoose-perl
Package version: 2.0200-1
Module version: 2.0200
Arch: amd64
Dist: oneiric
Component: universe

Package: libmoose-perl
Package version: 2.0401-1
Module version: 2.0401
Arch: amd64
Dist: precise
Component: universe

Package: libmoose-perl
Package version: 2.0603-1
Module version: 2.0603
Arch: amd64
Dist: quantal
Component: universe

Package: libmoose-perl
Package version: 2.0604-1
Module version: 2.0604
Arch: amd64
Dist: raring
Component: universe

To make the Debian-Perl module look-up more useful, there are now install instructions included. That means that all non-packaged CPAN dependencies and also all packaged ones are listed and it's clear what can be installed from packages and what needs to be installed from CPAN. Here's an example for App::TimeTracker:

sudo apt-get install libexception-class-perl libclass-accessor-perl libmoosex-role-parameterized-perl libjson-perl libnamespace-autoclean-perl libtry-tiny-perl libtest-trap-perl libtest-most-perl libtest-file-perl librt-client-rest-perl libpath-class-perl libmoosex-types-path-class-perl libmoosex-storage-perl libmoosex-getopt-perl libmoose-perl libmodule-build-perl libtest-mock-lwp-perl libjson-xs-perl libio-capture-perl libhash-merge-perl libgit-repository-perl libfile-homedir-perl libfile-find-rule-perl r-base-core-ra perl-modules libdigest-sha1-perl libdatetime-format-iso8601-perl libdatetime-format-duration-perl libdatetime-perl perl perl-base

sudo cpan -i Iterator Path::Class::Iterator MooseX::Storage::Format::JSONpm App::TimeTracker

deb-perl-it-install-example.png

Just a note that this works fine for Debian stable+testing+unstable. Which is not so common. Most installations will be stable or testing+unstable. Once Debian Wheeze (7.0) will become stable (hopefully soon) I'll split that search to two - one for Debian stable and one for Debian testing+unstable.

After more then a year of silence I've managed to resurrect the Debian::Apt::PM and new Perl indexes are available for both i386 and amd64 platforms.

For now the web site can be used to find out if a Perl module is packaged for Debian with which version or not at all. Ex.:

cpan-debian-CPAN-pm.png
http://deb.perl.it/debian/cpan-deb/#q=CPAN

In the future I can add Ubuntu repositories too, but those are quite huge to process.

Greetings to Perl - Italy and big thank you for providing hostname for this project!

Password Hashes Web Tool

| No Comments

Today I've created tool to generate and/or validate different password hashes

For security reasons, you may want to store passwords in hashed form. This guards against the possibility that someone who gains unauthorized access to the database can retrieve the passwords of every user in the system. Hashing performs a one-way transformation on a password, turning the password into another String, called the hashed password. "One-way" means that it is practically impossible to go the other way - to turn the hashed password back into the original password. There are several mathematically complex hashing algorithms that fulfill these needs.

--ATG Personalization Programming Guide

Here's a screenshot:

passphrase-secret.png

EU VAT Number checker

| No Comments

Just finished EU VAT Number checker that combines VIES - "VAT Information Exchange System" and Google Maps allowing easy verification of European VAT number. Ex. ATU67038724

Besides web version there is also JSON API version - http://www.tools.meon.eu/eu-vat-json/ATU67038724?cb=call_back_fn.

My goal was to have a single command to use to install Perl modules that will prefer distribution packages over installing from CPAN.

Combining 02packages.details.txt.gz with data from MetaCPAN::API I've generated 02packages.dependencies.txt.gz. This file has similar structure, basically it is a list of module names with all the dependencies it has. Here are example lines:

DBI     1.616   Clone/0.31 DBD::AnyData/0.09 DBD::CSV/0.29 DBD::PO/2.10 DBD::RAM/0.072 DB_File ExtUtils::MakeMaker ExtUtils::MakeMaker/6.48 MLDBM Net::Daemon RPC::PlServer/0.2001 SQL::Statement/1.27 SQL::Statement/1.28 Test::Simple/0.90 perl/5.008
Moose   2.0205  Algorithm::C3 DBM::Deep Data::OptList/0.107 Data::Visitor DateTime DateTime::Calendar::Mayan DateTime::Format::MySQL Declare::Constraints::Simple Devel::GlobalDestruction Devel::PartialDump/0.14 Dist::CheckConflicts/0.02 Eval::Closure/0.04 ExtUtils::MakeMaker/6.30 File::Find::Rule HTTP::Headers IO::File IO::String List::MoreUtils/0.28 Locale::US MRO::Compat/0.05 Module::Info Module::Refresh Package::DeprecationManager/0.11 Package::Stash/0.21 Package::Stash::XS/0.18 PadWalker Params::Coerce Params::Util/1.00 Regexp::Common Scalar::Util/1.19 Sub::Exporter/0.980 Sub::Name/0.05 Task::Weaken Test::Deep Test::DependentModules/0.09 Test::Fatal/0.001 Test::Inline Test::LeakTrace Test::More/0.88 Test::Output Test::Requires/0.05 Try::Tiny/0.02 URI perl/v5.8.3
MetaCPAN::API   0.33    Any::Moose Carp ExtUtils::MakeMaker/6.30 File::Find File::Temp HTTP::Tiny JSON Module::Build/0.3601 Test::Fatal Test::More Test::TinyMocker Try::Tiny URI::Escape
Pod::POM::Web   1.17    Alien::GvaScript/1.021 AnnoCPAN::Perldoc::Filter Config Encode::Guess HTTP::Daemon List::MoreUtils List::Util MIME::Types Module::Build/0.38 Module::CoreList POSIX PPI::HTML Pod::POM/0.25 Pod::POM::View::HTML Search::Indexer/0.75 Test::More Time::HiRes URI URI::QueryParam
Pod::POM::Web::Indexer  0       Alien::GvaScript/1.021 AnnoCPAN::Perldoc::Filter Config Encode::Guess HTTP::Daemon List::MoreUtils List::Util MIME::Types Module::Build/0.38 Module::CoreList POSIX PPI::HTML Pod::POM/0.25 Pod::POM::View::HTML Search::Indexer/0.75 Test::More Time::HiRes URI URI::QueryParam
Pod::POM::Web::PSGI     0.002   CGI::Emulate::PSGI/0.12 ExtUtils::MakeMaker/6.30 Pod::POM::Web/1.17

So basically it's possible to download this file and find out offline the dependency chain of a module.

Which I did in apt-cpan. With help of Debian::Apt::PM if is possible to preferably install packages from Debian distribution repositories and only the missing modules via CPAN shell.

Here is an example:

$ apt-cpan -n install Nagios::Plugin::OverHTTP
sudo apt-get install libdata-validate-domain-perl libdata-validate-uri-perl libenv-path-perl libhtml-strip-perl libmoosex-clone-perl
sudo cpan -i Nagios::Plugin::OverHTTP Const::Fast

Slides from YAPC::EU 2011

| No Comments
yapceu-logo80.gif

Slides from my yesterdays talk are here, uploaded to Bratislava.pm.org page.

My thanks go to everyone who participated on this great conference and helped this event happen!

Acme::KnowledgeWisdom

| No Comments

Let this blog post be also an invitation to my talk that I'll have on this years YAPC::EU::2011 in Riga and a reason "Why?" there will be more questions then answers.

There is one question that keeps me busy for quite some months now already and that is: What if the knowledge and wisdom is not in answers, but in questions?

As it kept me busy for just too long and as I'm a full-time Perl programmer, I've decided to write a code to help me answer "Why?".


package Acme::KnowledgeWisdom;

our $VERSION = '0.01';

use Moose;
use warnings FATAL => 'all';

has 'in_questions' => ( isa => 'Bool', is => 'ro', default => 1);
has 'has_already'  => ( isa => 'Bool', is => 'ro', default => 0);

sub get {
    my $kw = shift;
    
    return $kw->ask
        if $kw->in_questions;

    return 42;
}

sub ask {
    my $self = shift;
    
    return 42
        if $self->has_already;
    
    my $kw = Acme::KnowledgeWisdom->new;
    return $kw->get;
}

1;

The module is well tested ;-) and is of course on CPAN.

After the theory, first wrong solution, here comes the second wrong solution. It's easier one and the JavaScript is used only for iPhone-s where it was also tested. The problem with iPhone 3 and 4 is that both hardware versions are using the same OS and because of that the same user-agent string. So there is no way of knowing which resolution does the device have when the HTTP request comes to the server.

Following two meta viewport tags works fine for all phones besides the iPhone. The first one is when scaling should be disabled, the other when enabled.

<meta name="viewport" content="width=device-width, minimum-scale=0.5, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi"/>
<meta name="viewport" content="width=device-width, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes, target-densitydpi=device-dpi"/>

To get the native resolution for the iPhone 4 I had to create a JavaScript that detects 320px vs 640px resolution, sets the cookie and makes a refresh while setting the url parameter so that it also works when cookies are disabled. Then our server-side code has to resize the images properly and update the "width=640" in the viewport meta tag. Still a little complex, right? But works! :-)

Now what are the problems.The fonts can get pretty small as iPhone 4 applies the 0.5 scale and the Androids with high resolution uses the high-densitydpi. And it doesn't work so well for Opera too.

Here is the JavaScript code (much less lines then the previous one):

The part1 described some troubles with the screen sizes of the mobile devices. Since then I spend some time playing around with the problem and I found 2 wrong solutions until I got the (hopefully) right one. So let's start with the first of the wrong ones.

The solution relies on the fact that we have the device screen width and height in our DMS (Device-Management-System) database and this is compared with the real width of the device using JavaScript, then if there is a difference a cookie is set and via this cookie our Renedering-Engine on the web server is instructed to resize the images using the zoom level. It requires refresh, lot of "junk" in the HTML header and all the "machinery" on the server side. But the images are properly fit even for Opera browser that has the same user-agent string for different devices with different screen sizes.

See the code below, it's a nice example of a working-complex-bad solution :-)

Updates

Subscribe to the blog updates with an email:

If you like it, share it.

Pages

About this Archive

This page is an archive of recent entries in the Programming category.

Perl is the previous category.

Questions is the next category.

Find recent content on the main index or look in the archives to find all content.