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
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
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:
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.
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;
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:
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.
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
}
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)
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.
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.
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:
My morning started today with a cup of cold tea and an IRC request. The latter was coming from Elizabeth Mattijsen asking to write a paragraph on my recently merged work on Raku roles. There was a little problem though: I have no idea how to fit it into a single paragraph! And so I was left with no choice but to start blogging for the first time in many years.
Note. For those of you who consider themselves Raku experts I'd rather recommend skipping the next two sections and proceed directly to the technical details in Changes.
Once upon a time...
... there was a project which I was implementing to support a my boss' project. The structure of the code was heavily based on roles. This is the pattern I tend to use: split functionality into manageable as small as possible pieces and compose them into final code.
In my previous post I added a footnote that "use.perl.org is difficult to get info out of now, it's basically dead. A lot of content is lost". That turned out to be not entirely true, it just needed some work to get to it
In the reddit comments, brian d foy mentioned Léon's WWW::UsePerl::Server, a module to host the use.perl.org archive.
I grabbed the archive, Léon's module, installed all the deps, got it up and running after hacking the module to work with the latest Catalyst, then combined some sed, awk, perl, SQL to create a static version of the site with URLs that allow it to function correctly: https://use-perl.github.io/. Note that the change in the URL structure to get it to work a) as a static site, and b) on github pages, means that any "permalinks" that might exist elsewhere in reference to it will need manual fiddling to get to the page in question - the URL structure should be relatively obvious however.