BLOG: The Weekly Challenge #068

https://perlweeklychallenge.org/blog/weekly-challenge-068

I plan to release SPVM 1.0 at the end of July.

I plan to release SPVM 1.0 at the end of July.

SPVM

If you have any feedback on the bugs or features, please contact Github Issue or kimoto.yuki@gmail.com

Perl Weekly Challenge 105: Nth Root and The Name Game

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (March 28, 2021). 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: Nth Root

You are given positive numbers $N and $k.

Write a script to find out the $Nth root of $k. For more information, please take a look at the wiki page.

Example:

Input: $N = 5, $k = 248832
Output: 12

Input: $N = 5, $k = 34
Output: 2.02

Contacting author of Net::Azure::StorageClient

I am trying to contact Junnama Noda author of Net::Azure::StorageClient

I have sent two emails now to the public email address listed in his public github profile and have received no bounce or response.

If anyone is in contact with him, please have him contact me

Dean

BLOG: The Weekly Challenge #067

https://perlweeklychallenge.org/blog/weekly-challenge-067

Handling Perl character codes is very easy even for beginners.

I feel that Perl users are losing confidence because of negative feedback from other communities.

The opinions of people who intend to harm Perl are 99% useless in my experience.

Handling character codes is actually simple.

Because all you have to do is remember the following three things.

1. use utf8 and save file as UTF-8

2. if you print text, encode text to platform charset(Linux is UTF-8, Windows is cp932)

3. if you get text from outside, decode text from platform charset(Linux is UTF-8, Windows is cp932)

If "use v7;" enabled "use utf8", it would be less memorable and less mistake.

Beginners will first remember that Perl source code is stored in UTF-8.

Next, the introductory person will notice that using a print statement results in a "Malformed ..." warning.

And, to get rid of the warning, he will have to encode with the platform character code.

Once he have learned that, he will naturally learn that he need to decode when he bring in text from the platform.

CY's Post on PWC#064 - my shortcomings

This is a part of Perl Weekly Challenge(PWC) #064 and the followings are related to my solutions. If you want to challenge yourself on Perl, go to https://perlweeklychallenge.org, code the latest challenges, submit codes on-time (by GitHub or email)(before Monday GMT+0 00:00) if possible.

Task 1:

A runner has to run from the upper-left corner to the lower-right corner in a race. The stadium of this race is rectangular, and each square meter area has different level of difficulty (caused by sand, cement, grass, slope...). Our runner has to choose a path with the least difficulty to complete the race.

My description makes it look like something from a competitive programming problem. Maybe someone will discover sometimes I made sentimental names in the codes. (I was a long-distance runner in high school and university, by the way.)

The heart of my solution for this task is:

Perl Weekly Challenge 64: Minimum Sum Path and Word Break

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

Spoiler Alert: This weekly challenge deadline is due in a few 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: Minimum Sum Path

Given an m × n matrix with non-negative integers, write a script to find a path from top left to bottom right which minimizes the sum of all numbers along its path. You can only move either down or right at any point in time.

Example

Input:

[ 1 2 3 ]
[ 4 5 6 ]
[ 7 8 9 ]

The minimum sum path looks like this:

graphql-perl - plugin to make GraphQL "just work" with Mojo publish/subscribe functionality

GraphQL is the new, shiny way to do APIs. It minimises number of round-trips for clients to query what need. But what about real-time updates? How can we cut down the time needed for clients to get new information? Are we forcing them to constantly poll? That seems expensive and also slow.

GraphQL's official standard now includes "subscriptions". The obvious transport for that is WebSockets, and the de facto standard for that is Apollo GraphQL's subscriptions-transport-ws.

As of 0.16, Mojolicious::Plugin::GraphQL supports WebSockets, and GraphQL subscriptions, conforming to the Apollo protocol.

A well-known model for distributing information in an event-driven way is "publish/subscribe" (or "pub/sub"). To both demonstrate the subscription capability, and to provide useful functionality, there is now a new "convert plugin" for GraphQL with the two Mojo modules that implement pub/sub (with Redis and PostgreSQL): GraphQL::Plugin::Convert::MojoPubSub.

+1 "use v7;" in Perl 7

As one of Perl user, +1 "use v7;" in newer version of Perl.

The use v syntax is worth it.

use v5.14

This syntax is the history of Perl and is also a mechanism for maintaining backward compatibility with newer versions of Perl.

The reason this was not used is simply the small granularity.

I don't remember much about Perl, so I can't tell the difference between use v5.20 and use v5.30.

And because the warnings and utf8 aren't turn on, I couldn't find a meaning to actively use it.

use v7; is very easy to understand.

use v7;

Imagine an application user actively uses it instead of writing use strict, use warnings, use utf8;, use feature'say', ....

I also think that I use it aggressively in application code.

BLOG: The Weekly Challenge #064

https://perlweeklychallenge.org/blog/weekly-challenge-064

Perl Weekly Challenge 104: Fusc Sequence and NIM Game

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (March 21, 2021). 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: Fusc Sequence

Write a script to generate first 50 members of FUSC Sequence. Please refer to OEIS for more information.

The sequence is defined as below:

fusc(0) = 0
fusc(1) = 1
for n > 1:
    when n is even: fusc(n) = fusc(n / 2),
    when n is odd: fusc(n) = fusc((n-1)/2) + fusc((n+1)/2)

Fusc Sequence in Raku

CY's Recent Submission for PWC(061-063)

This is a part of Perl Weekly Challenge(PWC) and the followings are related to my solution. If you want to challenge yourself on Perl, go to https://perlweeklychallenge.org, code the latest challenges, submit codes on-time (by GitHub or email)(before Monday GMT+0 00:00) if possible, before reading my blog post.

Miss out blogging for a while. Here just write some lines on the recent PWC coding experience.

Challenge 061

ch-1 :

Enumeration

ch-2 :

Before coding, I had thought it was a complicated task for regular expression. It turned out smoother.

I use a subroutine possible_octet to check whether a number can be a part of IPv4 octet.

Its content:

sub possible_octet {
    my $item = $_[0];
    if ($item =~ /^[0-9]$/ or $item =~ /^[1-9][0-9]$/ ) {
        return 1; }
    elsif ($item =~ /^[1-9][0-9][0-9]$/) {
        return  ( $item <= 255) ;
    }
    else {
        return 0;
    }
}

Stack Overflow Developer Survey 2020

There's a lot in it and we could question some of the methodology, but here's some thoughts.

EZFPPD-WoAAv2Dq.jpeg

Perl developers are older (and there aren't that many of them) but salaries are excellent.

I would note that TIOBE didn't match up too closely with common usage but there's no silver lining.

Ruby is now in consistent decline, I have read people linking this to Twitter moving away from Ruby on Rails but can't cite that claim. My observation is that RoR seems to have gone out of fashion in favor of lightweight server frameworks and I would suggest that Kubernetes has sidelined Puppet, so organizations aren't bringing in Ruby via apps/frameworks they want to use.

BLOG: The Weekly Challenge #062

https://perlweeklychallenge.org/blog/weekly-challenge-062

Perl Weekly Challenge 100: Fun Time and Triangle Sum

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

Task 1: Fun Time

You are given a time (12 hour / 24 hour).

Write a script to convert the given time from 12 hour format to 24 hour format and vice versa.

Ideally we expect a one-liner.

Example 1:

Input: 05:15 pm or 05:15pm
Output: 17:15

Example 2:

Input: 19:15
Output: 07:15 pm or 07:15pm

New Arel like SQL Manager

Some months ago I started working in a system similar to ActiveRecord. But then it became pretty big so then I centered my attention in a SQL AST manager instead.

So I made a library that is basically an Arel port. You can see the README with most of the basic info. After looking at implementations in CPAN I realized there are many of them already but all of them based on hash structures.

This impl can instead represent a full SQL AST mainly using builder chainable methods.

I need some feedback on wether you think it will be something that is useful.

Thanks in advance.

Repo link: https://bitbucket.org/juankpro/perl-sql/src/master/

PD: Here is another question. If you try to download and use the lib right now it will not work because it depends on another library made by me as well: https://bitbucket.org/juankpro/model-support/admin

This library is a group of packages with somewhat unrelated utility functions that allows me to support my own perl OOP engine implementation shared through other libraries I'm working on. I don't know what's the best approach to handle this. Is it ok to upload this library separately? if I need to reuse this code again, how do I prevent collisions if my other libs will use it as well?

Prima: release v1.59 adds major text rendering functionality

  1. Previously it was only possible to output text with strings using text_out() method. Now, a more versatile and modern way is added with text_shape() method that converts text string in a series of glyphs, that allows the following:

    • Full unicode bidi processing
    • Support for font ligatures
    • Native support for right-to-left text
    • Transparent font substituion where a single font does not contain necessary glyphs

    In addition to that, infrastructure was added to support RTL and shaping in all standard Prima widgets. Run podview Prima::Drawable::Glyphs and check out the examples in the end of the document.

  2. PostScript backend rewritten to generate embedded Type1 fonts. This allows to generate unicode text in PostScript documents.

  3. In X11 backend, standard key combination (Ctrl+Shift+U) accepts unicode hex number as a character input. Try typing "a" then Ctrl+Shift+U 300 ENTER.

  4. Prima::*Dialog packages are moved to Prima::Dialog::* namespace

glyphs.png

Dancer2 0.300004 Released

The Dancer Core Team would like to announce the availability of Dancer2 0.300004. This release brings several important fixes and enhancements:

  • Session cookies can be restricted to a first-party or same-site context

  • There were a number of spots where Dancer2 would return a 500 error upon receiving an invalid request, rather than (correctly) returning 400 - Bad Request. Many, if not all, of these have been fixed.

For more information about same-site context, please refer to [RFC-6265bis]( https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site).

To use this, add the cookie_same_site key to your session engine configuration in the appropriate YAML file. Valid settings include Strict, Lax, and None.

The complete changelog is as follows: 0.300004 2020-05-26 20:52:34-04:00 America/New_York

Perl Weekly Challenge 99: Pattern Match and Unique Subsequence

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

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

You are given a string $S and a pattern $P.

Write a script to check if given pattern validate the entire string. Print 1 if pass otherwise 0.

The patterns can also have the following characters: - ? - Match any single character. - * - Match any sequence of characters.

Example 1:

Input: $S = "abcde" $P = "a*e"
Output: 1

Example 2:

Input: $S = "abcde" $P = "a*d"
Output: 0

Example 3:

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.