Late Night Moose

In today's Moose-pen we are going to have a look on one of the first my compound Database::Accessor classes 'Database::Accessor::Condition'. By compound I simply mean a class that holds other classes.

The Condition class is just as it sounds a class to add a logical condition to an Accessor. In SQL it would be a 'where' clause and Mongo some of the 'Aggregate' clauses. So basically this is a class that holds a number of 'Predicate' classes. So all I need to add is;

Perl 5 Porters Mailing List Summary: June 30th - July 5th

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week. Enjoy!

PRC 2016 - Second Trimester

This second semester got me modules owned by well known community members. I expected that to make my life easier, namely to prepare more relevant PRs, but unfortunately it did not work that way.

For April, I got Dist::Zilla. My PR was the documentation of 'Dist::Zilla::App::Tester', but I never got any comment: https://github.com/rjbs/Dist-Zilla/pull/543

For May, I got WWW::xkcd. For this I could get an answer about what might be a relevant PR. I added a method to fetch random comic strips. I even got some comments, and I adapted my PR. But it not got merged: https://github.com/xsawyerx/www-xkcd/pull/5

5 Things I Learned at YAPC

Last week, I attended my very first YAPC (Yet Another Perl Conference) at Orlando. While I feel I can write for pages, I want to talk only about several things, following the newest format "online newspapers" are using.

1) USA is huge.

I remember stories on Quora about tourists who tried to make a day trip to California all the way from New York, and I actually laughed at them too. So I knew the continent is big, I guess I never realized it is "that" big. I was at San Jose, California. I took a flight to Orlando with a stop at Dallas. These were almost 3 hours each. To top it all, Orlando is 3 hours ahead of California, so I also experienced a slight jetlag (not being able to fall asleep even if it's pretty late etc). But we made it safe and sound, so it was fine.

More Than One?

Well today in the Moose-pen I am going to have a look at my Database::Accessor::Parm. Now this is one of the more use full of my classes, This is the one that is used to supply data to a DB query. So in DBI you may have something like this

 sub some_sql{
     my ($in) = @_;
     my $sql =  'SELECT * FROM person where person.id=?'
     my $sth -= $dbh->prepare($sql);
     my $person =   $sth->execute($in);
     ...
 

REST API with Mojolicious

Buidling an API with Mojolicious is fun. Below is an attempt at a very small REST API that outpus the time in JSON. There are several pieces:

  • Mojolicious::LIte App
  • App instructions route
  • Authentication
  • API routes
  • Instruction template

We start with a Mojolicious::Lite app that uses three routes and an under. The under is a significant piece, because we use that for the authentication. If the proper HTTP BASIC credentials are passed in, then we continue; if not, we get a error in JSON.

After the under, we have a couple routes that comprise our API. The first supports GET and POST, and will will output a string for the current time. The next one outputs an epoch for given the correct GET request.

sparrowdo sandbox

Hi all!

Sparrowdo is a new born #perl6 project for configuration management automation. It based on sparrow plugin system.

A user unfamiliar with sparrow or sparrowdo may check out a sparrowdo-test repository containing a ready to use sparrowdo scenarios for some typical cases , like installing packages, checking linux process and so on ...

So to start use it:

  • install sparrowdo on your "master" host
  • install sparrow ( vers >= 0.1.11 ) on your "target" host

On your "master" host:

  • git clone https://github.com/melezhik/sparrowdo-test
  • cd ./sparrow-test/example/dir
  • sparrowdo --host=target-host # see other options in sparrowdo documentation

Basically I have tested it on some ubuntu/centos/debian boxes, if you have any issues let me know ...

Regards.

Alexey

Learning from other/experienced speakers

For this year's London Perl Workshop (LPW) I've suggested that one of the themes could be "first-time speakers", which means we need to do things to encourage and help new people to speak.

I've some ideas for how we might do that, and am hoping others will have ideas too. This post is about one of those ideas.

The Moose Collective

Well in my last post I added a few new attributes to my Database::Accessor::Element class and when playing about bout today I think I will have to revisit one of them 'aggregate'.

If I just leave it as it is

 has 'aggregate' => (
        is  => 'rw',
        isa => 'Str',
     );
 
It will begin to break-down my API as a programmer could come along and enter a very specific Mongo item such as 'mergeObjects' or something odd from an SQL DB like 'DENSERANK' and that makes for a very inconstant API.

So I am just going to bite the bullet and add in a 'Type' for this attribute so lets have a look at that.

Perl 5 Porters Mailing List Summary: June 22nd-29th

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week. Enjoy!

Retraction of Geo::Coder::Geocoder::US

Geo::Coder::Geocoder::US is a Perl module that interfaces to the Geocoding API of geocoder.us. Unfortunately that disappeared late 2015. Since this module is therefore useless, I am deleting it from CPAN.

The Fifth Element (of YAPC)

This year I attended my fifth YAPC and, as usual, I’ve decided to reflect a bit on the venue, the talks, and the general mood.  Since I just did a (roughly) half-post in my date module series, I figured I’d go ahead and do another (roughly) half-post this week instead of waiting for next week.

A Few Moose Never Hurt

So continuing on with the attribute fun today in the Moose-pen I am going to have a look at my 'Element' Database::Accessor class. So far like View there is not much to it only 'alias' and 'name'

Now putting my fore-ward looking Moose glasses you can see that I am going to need some more attributes. Well in SQL this class is being used as a field so I will need at least a 'table name' but then again I do not have a table in Classes so I guess I need a 'View' object now I could do this.

has 'view' => (
        is  => 'rw',
        isa => 'View',
    );

Easy OAuth Integration with Runkeeper and Spotify

I've been tooling around with a fun little app that I'm building on evenings and weekends. As part of that work I figured I'd let users authenticate via Runkeeper. Luckily Runkeeper uses OAuth2 and it's all pretty easy to get going with. I've published my very small contribution as Mojolicious::Plugin::Web::Auth::Site::Runkeeper

On a similar note, earlier this year I also released Mojolicious::Plugin::Web::Auth::Site::Spotify

If you're already using Mojolicious::Plugin::Web::Auth, then these modules will make it trivial for you connect with the Runkeeper and/or Spotify web services.

Exploiting Perl 6 Code From Down The Dependency Chain

Read this article on Perl6.Party

DISCLAIMER: data theft is a serious crime in many jurisdictions. The author does not condone or encourage anyone to break laws. The information provided here is for educational purposes only.

Back when I wrote about exploiting operators made of invisible Unicode characters, a bunch of folks pointed out the module containing rogue code would actually have to be imported by the victim and it's not that easy to convince them. Fair enough. Today, we'll play a new game and crank it up a notch!

The Game Plan

We all worked on codebases that relied on a dozen of open-sourced modules, each of which relied on a few more, which in turn relied on... well, you get the point. Somewhere, a gazillion levels deep, there's some type of a leftpad in use that you never reviewed for sanity. Right?

So here's our setup:

By the Numbers - YAPC::NA::2016 - Wednesday Night Pull Request Challenge

As YAPC ... TPC::NA draws to a close, there was one final hurrah. About 25 (+/- a few) brave souls partook in the Wednesday Night Pull Request Challenge.

There were:
  • 28 pull requests issued
  • 4 modules release
  • many more "person hours" spent coding, rewriting, and debugging
  • 50 peoples worth of food eaten
  • 1 budding cross-continental collaboration (App::DBCritic)
  • a metric ton of community enjoyments had all around

Thank you to craigslist for sponsoring the event. And thank you to both the hard working YAPC organizers and PRC participants for coming together for something that I hope will become continued in the future.

I would be remiss if I did not greatly encourage anyone (no matter your skill level) to get involved in the monthly CPAN PRC Challenge run by Neil Bowers. It is his effort that gave me my first real opportunity to contribute to the Perl community through pull requests; but moreover it inspired me to take a role in introducing the fun to attendees of YAPC::NA::2016.

Cool Moose

In yesterday's Moose-pen I hinted that I would be getting all my test in order. Well I did that and checked them in but there really was not that much to report on. Just a lot of repetitive code. I suppose I could write one test case to check all of my Database::Accessor classes using some simpler iteration over a list but I really like having a separate test case for all my classes as there really is only a small part that is common between them, so onto something different today.

I am going to start filling in the attributes of my various embedded Database::Accessor classes and I guess the best place to start in with Database::Accessor::View.

A Date with CPAN, Part 11: Sweet Release

[This is a post in my latest long-ass series.  You may want to begin at the beginning.  I do not promise that the next post in the series will be next week.  Just that I will eventually finish it, someday.  Unless I get hit by a bus.

IMPORTANT NOTE!  When I provide you links to code on GitHub, I’m giving you links to particular commits.  This allows me to show you the code as it was at the time the blog post was written and insures that the code references will make sense in the context of this post.  Just be aware that the latest version of the code may be very different.]


Last time I cleaned up most of the remaining CPAN Testers failures.  This time I’m getting ready for the first official release.  There isn’t a lot to talk about here, so this will be (uncharacteristically) a short entry in the series.

Why do I like simple object system? Object::Simple story.

Do you like simple object system or lerge object system? I like simple object system.

In old days, I believed Perl would need complete object system, which has meta object protocol and class syntax.
Many perl programmers sought a good way to write object oriented programing.

A famouse lerge object system is Moose.
This module has many features, for example,
has, extends, with, is, isa, corce, dose, required, traits, builder, BUILD, DEMOLISH, etc.

A famouse simple object system is Mojo::Base.
This module is a part of Mojolicious.
Mojo::Base only has "has" method and a option to set default attribute value.

Do you know Mojo::Base was a little more complex at first?
Gradually, Mojo::Base removed the features except only really needed ones.

Mojolicious source codes is very clean. Mojolicious only use single inheritance and delegation.
Simple object system and single inheritance produce very clean codes.

I was surprised because I had believed Perl would need complete object system to produce good codes.

Perl 5 Porters Mailing List Summary: June 16th-21st

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week. Enjoy!

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.