Paws XXXXVI (The game she is over)

Well I left off on form my last post with this Moose error;

Attribute (Items) does not pass the type constraint because: Validation failed for 'ArrayRef[Str|Undef]' with value [ { Method: ARRAY(0x5184cf0) } ] at /wwwveh/lib/x86_64-linux-thread-multi/Moose/Object.pm line 24

but before I tackle that on I wanted to have a closer look at my changes I did to the callresult_class.tt template; I wanted to clean that up nicely and then my plan is to see if my changes have Borden anything else.

So in cleaning it up I found what might be a bug.

It seems that this call


[%- IF (stream_param or shape.payload == param_name) %]

is now out of the attributes foreach loop so I change things about a bit and now I just set a var in the template and apply the new trait if the var has a value;

Perl Weekly Challenge 039: Guest Book and Reverse Polish Notation

Guest Book

A guest house had a policy that the light remain ON as long as the at least one guest is in the house. There is guest book which tracks all guest in/out time. Write a script to find out how long in minutes the light were ON.
1) Alex    IN: 09:10 OUT: 09:45
2) Arnold  IN: 09:15 OUT: 09:33
3) Bob     IN: 09:22 OUT: 09:55
4) Charlie IN: 09:25 OUT: 10:05
5) Steve   IN: 09:33 OUT: 10:01
6) Roger   IN: 09:44 OUT: 10:12
7) David   IN: 09:57 OUT: 10:23
8) Neil    IN: 10:01 OUT: 10:19
9) Chris   IN: 10:10 OUT: 11:00

Perl Weekly Challenge 40: Multiple Arrays Content and Sublist Sorting

These are some answers to the Week 40 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a couple of days (December 29, 2019). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.

Challenge # 1: Multiple Arrays Content

You are given two or more arrays. Write a script to display values of each list at a given index.

For example:

Array 1: [ I L O V E Y O U ]
Array 2: [ 2 4 0 3 2 0 1 9 ]
Array 3: [ ! ? £ $ % ^ & * ]

We expect the following output:

Larry said "No one sews a patch of unshrunk cloth on an old garment"

When he aproved Raku naming change, Larry said .

"No one sews a patch of unshrunk cloth on an old garment, for the patch will pull away from the garment, making the tear worse. Neither do people pour new wine into old wineskins. If they do, the skins will burst; the wine will run out and the wineskins will be ruined. No, they pour new wine into new wineskins, and both are preserved."

This is a Bible quotation, but needs some explanation.

Larry said "No one sews a patch of unshrunk cloth on an old garment" - Subrutine signatures opinion blog

PAWS XXXXV (You are now leaving S3. Please have your customs forms ready.)

Well I manages to plow though the final few S3Control actions the other day so today I move into the much more complex CloudFront API.

This one was to say the least a little daunting as the XML calls are massive some with as many as 60 nodes. Well as usually I just blundered right into it without any sort of plan except I figured I better do the harderst one first CreateDistribution.

Well as usual the first thing I ran into was someting I have not seen before.

Invalid Iteration

on the XML.

It took a little while to figure out that I was sending blocks like this

Dancer2 0.300000 released

The Dancer Core Team has one more holiday treat in store for you: Dancer2 0.300000 is headed to CPAN, and it's a good one: Dancer now offers typed route parameters!

To be clear, all of the existing route syntax is unaffected. You don't have to use types, and typed parameters might not be good for all situations. There is a lot to be gained from having them though, and we're excited to bring them to you!

Using them in your own code is simple:

get '/thing/:id[Int]' => sub {};

# if not Int then perhaps a Num...
get '/thing/:id[Num]' => sub {};

The default type checking library is Type::Tiny, but you can also specify your own type checking library too. See the manual for more information.

A big thanks to SysPete for making this long-standing request a reality.

I'd also like to apologize to Tom Hukins. I erroneously listed a PR of his in the last release that didn't seem to make it in. I believe that I have made things better in this release.

Happy holidays from your friends at Dancer! See you in 2020.

Sympa 6.2.50 released

The Sympa Community is proud to release the newest version of Sympa.

Sympa 6.2.50 is the newest stable version of Sympa 6.2.

This version fixes several bugs, introduces some enhancements and made refactoring on some internal code. Translations to several languages have been mostly completed. Administrators are encouraged to upgrade Sympa to this version.

Highlight of this version

Significant changes

  • Some scenarios and list creation templates for "intranet" use cases were made optional: They have been moved into samples/ #119. See also "upgrading notes" for details.

Internationalization

Thanks to heavy works by translators on translation site, Sympa almost completely supports following languages:

  • Russian (Русский)
  • German (Deutsch)
  • Spanish (Español)
  • Galician (Galego)
  • French (Français)
  • Japanese (日本語)
  • Italian (Italiano)
  • US English

Along with languages above, help documents for users are provided in following languages:

  • Catalan (Català)
  • Basque (Euskara)
  • Polish (Polski)

Have a great new year with Sympa!

The Sympa Community

Type Constraints using Type::Tiny and attribute handler of subroutine signatures

If you can perform type checking with an attribute handler and Type::Tiny, Perl will be more attractive.

For example.

use Type::Tiny::Signatures;

sub foo ($str : Str, $num : Int) {
  
}

Type Constraints using Type::Tiny and attribute handler - Perl Subroutine Signatures Opinion Blog

Paws XXXXIV (More Boto Fun)

So I was quickly knocking off the various S3Control actions until I ran in to 'ListJOBS' which I though would be an easy one as there is no XML content on this call. I kept on getting

InvalidRequest

The call cannot be any simpler a GET with this URL;

'https://985173205561.s3-control.us-east-1.amazonaws.com/v20180820/jobs?nextToken=dddd& jobStatuses=Active,Cancelled,Cancelling,Complete,Completing,Failed,Failing, New,Paused,Pausing,Preparing,Ready,Suspended &maxResults=5'

So I had a look on the API doc and this is what I found;

/v20180820/jobs?JobStatuses=JobStatuses&MaxResults=MaxResults&NextToken=NextToken

Hmm all upper case!. So I checked the generated class and they where all like this one;

The times you want to avoid the short cuts. PWC-39

No spoilers here, just a rambling. There are probably countless times when one relies on the genius of others to complete tasks. If PerlWeeklyChallenges has shown me one thing, it is that there is probably nothing I can do that someone else can not do better, more efficiently, and more robustly. The key to good coding, one imagines, is to have code that survives not just the scenario presented in the challenge, but also accommodates other scenarios

The Hotel lights

Take the lights on puzzle. A first glance at the puzzle show that the times are all overlapping, so technically the lights should be on continuously from the first guest entry to last exit. So the simplest way to extract the time the lights were on is to get the earliest time and the latest time mentioned in the log. These can be extracted using four steps: load the log, extract the earliest and the last time; convert to minutes and subtract.

It's beginning to look a lot like k-Means 🎵

... every where you go!

Continuing on from the intention of clustering data in Perl (a form of unsupervised learning), I'm going to start with PDL::Stats::Kmeans and see how far I can get.

Let's just plunge in and use the module and read the documentation after to figure out what it all k-means. (sorry)

The way that CPAN authors use subroutine signatures in natural

Perl's new feature is for the new Perl, but when it comes to subroutine signatures, CPAN Author also maybe wants to use it.

If CPAN authors can use subroutine signatures, both application code and CPAN module code can be written in one source.

I think new features should work with the new Perl, but I'm happy that only the subroutine signature feature can be backported.

Wouldn't it be nice if you could use subroutine signatures with tens of thousands of CPAN modules?

But is there such a way?

The way that CPAN authors use subroutine signatures in natural

Paws XXXXIII (More fun with XML)

he first order of the day was to clean up all the debugging code I peppered across my perl trying to find an answer to my 'Failed Signature' bug.

This did take a while and in the end the changes that I am sticking with are;



  if ( my $xml_body = $self->_to_xml_body($call) ) {
        $request->content($xml_body);
++      $request->header( 'content-type' => 'application/xml');  #this is an XML interface so it should have this header
     }
and

Long time no see

Perl Weekly Challenge # 39: Guest House and Reverse Polish Notation

These are some answers to the Week 39 of the Perl Weekly Challence organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a couple of days (December 22, 2019). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.

Task # 1: Guest House

A guest house had a policy that the light remain ON as long as the at least one guest is in the house. There is guest book which tracks all guest in/out time. Write a script to find out how long in minutes the light were ON.

The guest book looks as follows:

Is the new grammar easy to google search?

Is the new grammar of subroutine signatures easy to google search?

One of the criticisms of Perl is that "it cannot search google because it has many symbols".

Increasing the number of difficult-to-search symbols also increases the blame for Perl.

Is the new grammar easy to google search?

Paws XXXXII (A little help from my friends)

Now that I have at least one call working 'ListJobs' I reran the full test suit and to my surprise I got no fails. So maybe it is going to be an easy ride?

Well I was dead wrong.

Just spent the last few days banging my head against the AWS servers thinking that if the first 825 attempts to get 'CreateJob' to work, the 826th would of work.

I think I got sucked into the gambler's fallacy.

Well lets just say 826 attempt is most likely an order of magnitude under the number of differing combinations and iterations I went though on getting the call working all with the same failed of '403' status and the error 'SignatureDoesNotMatch'!

Can't post a comment here -- dunno why

Why, oh why, can't I post a comment on blogs.perl.org? I'm properly signed in. I read a post, 30 seconds later. 30 seconds later, I click the button at the bottom of the post in order to post a reply. I fill in the form with my post. Then I get this error:

---

Comment Submission Error

Your comment submission failed for the following reasons: Your session has expired. Please sign in again to comment.

Return to the original entry.

---

And there is no avoiding it, even after signing in again.

Thanks very much for any help you can provide.

Rewriting Perl Code for Raku Part V is out

Part V of the series is out, this time more in-depth discussions of the pack() method in Raku and Perl

Default value expression in subroutine signatures

In first proposal of subroutine signatures, default value is the following.

sub func($foo //= 0, $bar ||= 0) {
  
}

I think this can use only "=" as same as many ohter languages. and "||" is in body if needed.

sub func($foo = 0, $bar) {
  $bar ||= 0;
}

Default value expression - subroutine signatures opinion blog

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.