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

Perl Weekly Challenge 57: Tree Inversion and Shortest Unique Prefix

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

Spoiler Alert: This weekly challenge deadline is due in a couple of hours. 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: Tree Inversion

You are given a full binary tree of any height, similar to the one below:

    1
   /  \
  2    3
 / \  / \
4   5 6  7

Write a script to invert the tree, by mirroring the children of every node, from left to right. The expected output from the tree above would be:

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

22nd German Perl Workshop 2020 in Erlangen from 4th to 6th March 2020

The German Perl Workshop is an Open Source conference for everyone, organized by community of the Perl Programming Language and its sister language Raku yearly in Germany. The 2020 edition will be from Wednesday, March 4th, 09:00 to Friday, March 6th, 16:00 in Erlangen.

Most of the talks will be held in German, German talks will have English slides at least. English talks are welcome as well.

The website already is open for talk submissions, so if you want to present something in addition to attending, please submit a proposal!

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;

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:

berrybrew, the Perlbrew for Windows 1.30 released

Merry Christmas fellow Perlers!

I have been working tirelessly on the newest version of berrybrew, and thought there's no better day to release it.

It brings significant new features:

New Features

  • Added a UI, runs out of the System Tray, allows installing, removing and switching Perls using a button
  • Added new associate command, allowing berrybrew to manage .pl file associations
  • Added berrybrew-refresh command, to be run after switching perls. No more having to re-open command line windows
  • If a newer point release of a major version is introduced, we now seamlessly integrate installed previous point-releases into the Perls available
  • Configuration options are now based in the Windows Registry
  • Added new options command, allows changing configuration options at runtime
  • We now supply a bb command, which is simply a short-hand form for berrybrew
  • Greatly enhanced the self-extracting installer
  • Much more precise handling of the PATH environment variable
  • More graceful handling of exceptions
  • Added info command which displays various internal directory path information
  • Added new hidden/developer commands

UI

Merry Christmas & Happy New Year




From the team of "Perl Weekly Challenge", we wish you all
Merry Christmas & Happy New Year

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'!

Perl Weekly Challenge # 56: Diff-k and Path Sum

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (April 19, 2020). 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: Diff-k

You are given an array @N of positive integers (sorted) and another non negative integer k.

Write a script to find if there exists 2 indices i and j such that A[i] - A[j] = k and i != j.

It should print the pairs of indices, if any such pairs exist.

Example:

@N = (2, 7, 9)
$k = 2

Output : 2,1

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

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.

Paws XXXX (A new Start)

The next chapter in the 'Book of PAWS' is to the S3 control working.

I do not see this project to go on to long as the S3 as there are only eight actions that are exposed by the S3control API. Given this, the many fixes I have made to the XML Rests side of the perl code my full test suite and my handy test generating caller. I think I can get this control working very quicky.

Well to start out I decided to have a quick look at the Documentation for AWS S3 Control
https://docs.aws.amazon.com/AmazonS3/latest/API/API_Operations_AWS_S3_Control.html and looking there I notices there where some sixteen calls not the eight that I found when I was poking about in the boto and perl code.

Revisiting the Collatz Sequence (PWC 54)

In my blog post related to Perl Weekly Challenge 54 posted on April 4, 2020, the section about the "extra credit" task concerning the Collatz conjecture described in some details the difficulties encountered when trying to cache the data: the volume of data is very large. I'm blogging again on the subject because of new findings.

The Collatz conjecture concerns a sequence defined as follows: start with any positive integer n. Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. For example, the Collatz sequence for 23 is this:

23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1

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 XXXIX (The Paws is Dead. Long Live the Paws)

S3 is a wrap was quite the journey since September.

The end result

  • All non depreciated S3 actions on API work
  • A new test case 09_requests.t and test for each action was created
  • All none deprecated action now have a 10_response test as well
  • A new Caller that generates both 09 and 10 test case
  • NO changes needed to BOTO

The most important aspect of my changes in my opinion is figuring out how to handle the botocode correctly to cover all the use cases. It was a slow iterative process and what really saved my but was creating the test cases as I went along as I quickly found out if a change that fixed one thing broke something.

There was a combination of changes to the class templates to get the the correct perl class out of the Boto JSON, a number of changes to RestXmlCaller..pm convert those classes into the correct request XML content and a few changes to how the URL and URI where generated.

Perl Weekly Challenge 55: Binary Numbers and Wave Arrays

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

Task # 1: Flipping Binary Numbers

You are given a binary number B, consisting of N binary digits 0 or 1: s0, s1, …, s(N-1).

Choose two indices L and R such that 0 ≤ L ≤ R < N and flip the digits s(L), s(L+1), …, s(R). By flipping, we mean change 0 to 1 and vice-versa.

For example, given the binary number 010, the possible flip pair results are listed below:

L=0, R=0 the result binary: 110
L=0, R=1 the result binary: 100
L=0, R=2 the result binary: 101
L=1, R=1 the result binary: 000
L=1, R=2 the result binary: 001
L=2, R=2 the result binary: 011

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.

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 with a graphic design donated by Six Apart, Ltd.