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
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:
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
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!
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;
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: [ ! ? £ $ % ^ & * ]
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.
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'!
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.
"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.
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.
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.
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:
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:
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.
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
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.