Paws XXXIV (Yet more code)

Well after spending a little while trying to create an auto test generator I found the test generator script that came with PAWS.

So I decided to try it out. With only a little fudging of the code internals, no real code changes just changes to libs, I got it to work;

perl script/paws_make_testcase  S3 --region us-east-1 GetBucketLocation Bucket: "dev.cargotel.test"

the test file it generated /0001.response.test.yml;


--
tests:
  - expected: eu-west-2
    op: eq
    path: LocationConstraint

So that is ok.

However when I opened the caller file '0001.response' it contained only JSON;

Perl Weekly Challenge: Smallest Multiple and LRU Cache

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (March 1, 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: Smallest Multiple

Write a script to accept a positive number as command line argument and print the smallest multiple of the given number consists of digits 0 and 1.

For example:

For given number 55, the smallest multiple is 110 consisting of digits 0 and 1.

Constant Platypus

A common challenge in calling C functions from any language other than C or C++ is dealing with constants. In C these are usually implemented using #define pre-processor directives which are lost by the time the code is linked into a dynamic library. (In fact it is lost before the source is even compiled, since it is a pre-processor directive). For example, the libarchive library provides these constants in its header file for dealing with errors:

/*
 * Error codes: Use archive_errno() and archive_error_string()
 * to retrieve details.  Unless specified otherwise, all functions
 * that return 'int' use these codes.
 */
#define ARCHIVE_EOF       1     /* Found end of archive. */
#define ARCHIVE_OK        0     /* Operation was successful. */
#define ARCHIVE_RETRY   (-10)   /* Retry might succeed. */
#define ARCHIVE_WARN    (-20)   /* Partial success. */
/* For example, if write_header "fails", then you can't push data. */
#define ARCHIVE_FAILED  (-25)   /* Current operation cannot complete. */
/* But if write_header is "fatal," then this archive is dead and useless. */
#define ARCHIVE_FATAL   (-30)   /* No more operations are possible. */

Rewriting Legacy Code in Raku III: The Sourceror

Part III in the series talks about functions, prototyping, and some of the tweaks you'll need to make while transferring Perl code to Raku

Paws XXXIII (A little advice please)

Well some-days it would be nice to get a little advice, without asking for it, before one heads down a very long and in the end futile path.

Today that happened to me when I was starting down a path that I dreaded. Namely creating the 'response' test suite for all those S3 requests I have fixed up over the past few weeks. This type of programming ranges from so mind numbingly dull as to cause your ears to bleed to so incredibility repetitive that you consider that career change to line supervisor at the box factory.

Looking at the prospect of coveting some 70+ working S3 units tests by hand was obviously getting me down a little. It took me a good three or four days of rather mindless hacking and re-running just to to the 'request' tests.

Perl Weekly Challenge 48: Survivor and Palindrome Dates

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (February 23, 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: The Survivor

There are 50 people standing in a circle in positions 1 to 50. The person standing at position 1 has a sword. He kills the next person i.e. standing at position 2 and passes on the sword to the immediate next, i.e. person standing at position 3. Now the person at position 3 does the same and it goes on until only one survives.

Write a script to find out the survivor.

This is sometimes called the Josephus Problem, named after Flavius Josephus, a Jewish historian of the 1st century who allegedly escaped collective suicide of defeated Jewish soldiers trapped by Roman soldiers by finding the right position to be the survivor.

Perl Weekly Challenge 036: VIN Validation and the Knapsack Problem

VIN Validation

Write a program to validate given Vehicle Identification Number (VIN).

I followed the description at Wikipedia. Sometimes, it wasn’t exactly clear whether the described rule should be valid everywhere or just in a part of the world; the rules also developed with time, so older vehicles can bear VINs that would be considered invalid for a modern car.

Most of the validation is implemented in a single subroutine validate_vin. It takes two parameters, $vin and $sold: the second one says where the car was sold. "North America" and "China" are two values that trigger a different behaviour of the validator.

Asking for Rakudo.js grant feedback

Work on the Rakudo.js grant has been completed and now I'm add the stage where community feedback is needed. It would be super grateful for Your feedback. You can provide it in blog comments on this post.
The final grant status update is available HERE

Monthly Report - November

November was the quietest month for me. I would give credit to the book Why We Sleep, gifted by Neil Bowers. I haven't finished reading the book yet but whatever I read so far made a big difference. A very big THANK YOU to Neil. I no longer do late nights, technically that means no work after midnight for me. However I do wake up early on weekends and finish the pending work. One more change, I noticed that I don't visit MetaCPAN very often. Earlier I used to checkout every 30 minutes during the day. But now I do it once every couple of days. Having done 160 Pull Requests in October, then doing only 51 Pull Requests in November feels so light. In fact I reached my monthly target of 50+ Pull Requests in the third week of November. Last one week was relaxing, I made conscious efforts not to look for Pull Request.

Perl Weekly Challenge 47: Roman Calculator and Gapful Numbers

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (February 9, 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.

I have really very little time to complete this blog post in time for the deadline. My explanations will be minimal, sorry about that.

Roman Calculator

Write a script that accepts two roman numbers and operation. It should then perform the operation on the give roman numbers and print the result.

For example,

perl ch-1.pl V + VI

It should print

XI

Paws XXXII (80+ paws)

Today's post proves that test suite, even one that uses canned data, requests and responses, is a very valuable asset to have about.

As I was charging though some 80 action calls copying the requests from my successful unit tests into my t/09_request.t test cases I ran into the odd real bug.

The first one I ran into was to do with the 'PutBucketLogging' action; My real unit test case would work with no problem but as I transferred this real world unit test into canned test cases I got a fail on some of the composed XML.

The test parameters for the request where

By Any k-Means Necessary

You want to get to know your data, questions like, can they be broken down into a simple set of classes. You don't know what these classes might be, so your task is clustering and you reach for one of the oldest clustering algorithms around k-means.

k-means is popular because it's simple to understand, converges fast, works in higher dimensions and gives you an answer. It's also usually the wrong choice unless you've already got nicely clustered data just waiting for you to guess k, the most appropriate number of clusters to answer your question. But it is a decent warm up exercise in becoming friends with your data set.

Giblog 1.1 Released - Github Project pages support

Good news!

Giblog 1.1 is released! Giblog is the web site and blog builder for git . It generate static HTML files. You can mange Web site using git.

In this release, Github Project pages are supported.

Deploy website on Github Project page

See the URL "https://yuki-kimoto.github.io/giblog-theme1-public/". This is really Github Project pages.

Config file is the following. "base_path" option is set.

use strict;
use warnings;
use utf8;

{
  site_title => 'mysite😄',
  site_url => 'https://yuki-kimoto.github.io',
  base_path => '/giblog-theme1-public',
}

This site resource repository is

giblog-theme1

This site public repository is

giblog-theme1-public

If you know more, see the Giblog site(Currenty only Japanese).

Perl Weekly Challenge 46: Garbled Message and Room Open

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (February 9, 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.

Garbled Message

The communication system of an office is broken and message received are not completely reliable. To send message Hello, it ended up sending these following:

H x l 4 !
c e - l o
z e 6 l g
H W l v R
q 9 m # o

Similarly, another day we received a message repeatedly like below:

Paws XXXI (Digging up more dirt)

I ending up in my last post with a test that was running but most of the tests where failing.

ok 1 - Call S3->CreateBucket from /home/scolesj/aws-sdk-perl/t/09_requests/s3-create-bucket.request
ok 2 - Got content eq from result
…
ok 11 - Got method eq PUT from result
I had a look at the request object I was getting back

Perl 5 development has moved to Github

I didn't notice much public discussion, but in the last month, Perl 5 development has moved to Github. The logistics of the move were mostly handled by Todd Rinaldo although I'm sure there were other people helping.

The change involved moving the main development repository from perl5.git.perl.org to https://github.com/Perl/perl5, moving the issues from rt.perl.org to Github issues, renaming them in the process, and fixing the code that used the hostnames or URLs for decisions.

Bundling With Platypus

If you've heard of FFI::Platypus you probably know that you can use it to easily write Perl bindings for existing system libraries:

use FFI::Platypus 1.00;
use FFI::CheckLib qw( find_lib_or_die );
my $ffi = FFI::Platypus->new( api => 1 );
# uses the system libarchive
$ffi->lib( find_lib_or_die( lib => 'archive' ) );

You may even know that Platypus integrates nicely with Alien for seamless installation experience, even if the library isn't already installed:

use FFI::Platypus 1.00;
use Alien::Libarchive3;
my $ffi = FFI::Platypus->new( api => 1 );
$ffi->lib( Alien::Libarchive3->dynamic_libs );

Perl Weekly Challenge 45: Square Secret Code and Source Dumper

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

Task # 1: Square Secret Code

The square secret code mechanism first removes any space from the original message. Then it lays down the message in a row of 8 columns. The coded message is then obtained by reading down the columns going left to right.

For example, the message is “The quick brown fox jumps over the lazy dog”.

Then the message would be laid out as below:

thequick
brownfox
jumpsove
rthelazy
dog

The code message would be as below:

tbjrd hruto eomhg qwpe unsl ifoa covz kxey

Paws XXX (Three of a kind)

Goodness Paws 30 and I am at least code compete as far as running through all of the different action found on S3. Now that leads me to a very important part.

I now have to do a little bit of back peddling and come up with a test suite for all the now fixed S3 actions. 90% of the bugs and fixes I have done so far on S3 have been for requests to the server not checking responses form the server.

Following on with this it makes sense that I test how things are sent to the server as well. I had a peek about in the test suite and except for a few of the basic actions there are no tests on request calls.

New Perl project. Interactive Perl coding tasks to run in the browser

Some time ago I have created a small web project about Perl programming language. The site where you can execute Perl code online — PerlBanjo.com. (blog post about the release)

Today I'm happy to announce the new small project about Perl. This is the place with interactive coding tasks. You solve the task, enter the solution, system run it and tell you if it accept your submission. (PerlBanjo.com is used as a backend to run Perl code)

This is the link:

https://SquarePerl.com/en/problems

Now there are only several tasks. The source code for all the all tasks is hosted on GitHub, so anybody can propose a fix for the task or create the new task.

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.