Less Moose more Elk

Well back to clean up mode in the old Moose-pen today as I have completed my first round of changes to my Database::Accessor embedded classes. Just taking a quick peed at what might attributes might be missing from my I see that my Predicate is missing something important at least to any logical predicate. That is the ability to add parentheses to a predicate.

Well the way I see it I can just make this a Boolean flag attributes such as 'parentheses' but that takes a good deal of flexibility from the system. So what I am going to go for is two flags one for open and one from close, like this

Dancer 0.200003 Released

Dancer 0.200003 is on its way to a CPAN mirror near you. I'd like to give a big shout out to the rest of the Dancer core team and our awesome community members for their work in bringing this release to fruition.

There are several changes in particular worth noting:

- There is a security fix for Dancer2::Session::YAML that prevents accepting a bad session cookie value from the client. Thanks SysPete!

- There was a swift response to the breakage caused by YAML 1.16. Originally, we patched Dancer2 to require a minimum version of 0.86 and a maximum version of 1.15. Thankfully, YAML was patched and updated, and Dancer2 will again work with the latest YAML.pm.

For your convenience, here's the full changelog:

Dist::Zilla - Why you should use @Starter instead of @Basic

I posted previously about a new "starter" bundle for Dist::Zilla, the CPAN author's automation tool. I'd like to briefly try to answer the question: "Why should I care?"

If you're already happily using Dist::Zilla with an extensive configuration or plugin bundle of your own, this bundle isn't for you. But maybe you can get some ideas from the included plugins, I added a few to my author bundle!

If you're looking to get started in Dist::Zilla, the [@Starter] bundle makes a great starting point. Usage is similar to [@Basic] and all of the same information in the dzil.org tutorial applies.

Sparrowdo automation. Part 1. Installing cpan packages.

Here I start a series of posts on sparrowdo configuration management tool usage.

Installing sparrowdo

Sparrowdo implies installing software on both master and target host. Following "push" approach one should install a sparrowdo on master host where from he starts a ssh sessions against target hosts to be configurable:

$ ssh master.host 
$ panda install Sparrowdo

Once you install a sparrowdo you need to install a sparrow client on every host where you want to start deployments. Sparrow acts like client to carry out deployment tasks initiated from master host.

$ ssh target.host 
$ cpanm Sparrow
$ yum install curl

Here is simple schema of master -> target hosts interaction:

Moose on the edge

Now in the Moose-pen we are coming to the home stretch of my Database::Accessor Classes, starting with 'Gather'. This one represents a fields in an in SQL 'Group by' clause, and in Mongo 'Group' stage.

Looking at it it really is just an array of predicate clauses so I think I can just drop this class altogether, which is always a good thing. So out it goes and the test as well. So that was easy.

Next it 'Filter' which is a 'Having' clause in SQL and I not 100% sure what it is in Mongo most likely something to do with group and project or maybe match? I guess it is up to the Mongo DAD writer to come up with that one.

Like 'Gather' this is just an array of predicates or the same as my 'Condition' class so I can just drop that one and its tests as well. So that is two classes I do not really need.

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.

Can a Moose Juggle?

The next class in the Moose-pen is Database::Accessor::Link which would represent a 'Join' in SQL and a I think they call it a 'Pipe Lookup' in Mongo or it could mean a find on a document buried under the parent document. I guess that is a topic for a later post.

The first thing I noticed was this class and the 'Condtion' class I looked at yesterday is they share the same 'predicates' attribute. So being a good Mooser the first thing to day is to pull that attribute out and add it into a role.

So after a few copy and pastes and a little typing I have

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.

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 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.

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);
     ...
 

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:

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.

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.