SUSE Hackweek Day 3 - (Not) Loading Objects in YAML::PP

Here's what I did on Thursday of the SUSE Hackweek.

Previous posts:

Perl Weekly Challenge # 14: Van Eck's Sequence and US States

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

Challenge # 1: Van Eck's Sequence

Write a script to generate Van Eck’s sequence starts with 0. For more information, please check out wikipedia page. This challenge was proposed by team member Andrezgz.

Jan Ritsema van Eck's sequence is an integer sequence defined recursively as follows. Let a(0) = 0. Then, for n ≥ 0, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) = n − m; otherwise a(n+1) = 0. Thus, the first occurrence of an integer in the sequence is followed by a 0, and the second and subsequent occurrences are followed by the size of the gap between the two most recent occurrences.

This time, I'll start with Perl 6 (but complete the challenge in both P5 and P6).

Van Eck's Sequence in Perl 6

RPerl at the Perl Conference in Pittsburgh - Day 1

After the Texas Linux Fest, Team RPerl went all the way across the country to attend the 2019 North American Perl Conference. This time, I was not in charge of manning a booth. Instead, I was one of the official volunteers for the 3 days of the conference.

What does a volunteer do? He or she can work as a moderator, a runner, or a cameraman, depending on the needs of each talk. The moderator makes sure the speaker follows the schedule and has time for Q&A; the cameraman records the slides and films the speaker; while the runner is there in case something is needed, such as water for the speaker, more chairs, etc.

diff-so-fancy v1.2.6

diff-so-fancy strives to make your diffs human readable instead of machine readable. This helps improve code quality and helps you spot defects faster.

Version 1.2.6 of this perl utility has just been released.

Check it out here on github

SUSE Hackweek Day 2 - YAML::PP !include

In this post I'll talk about what I hacked on the second day of the SUSE hackweek. If you missed my other posts:

Perl Weekly Challenge - Perl5 / Perl6


We are into the 14th week of Perl Weekly Challenge. If you look at participation of Perl5 and Perl6, based on data so far, we can clearly say Perl5 is the winner. However, I must clarify the race between the two is not objective of the Perl Weekly Challenge. But I see a pattern between the two. Perl6 solutions is always full of surprises where as Perl5 is just holding the ground. It could be because Perl5 is not new to me but anything and everything about Perl6 is new to me. Having said, some Perl5 solutions are full of surprises. I have become fan of some Perl5 contributors by the quality of code. I don't want to name just few. It would do injustice to others. Similarly there are some dedicated to Perl6 only and they are too good and great ambassador for Perl6. Damian Conway is one such who took the Perl Weekly challenge to another level.

Perl Weekly Challenge 014: Van Eck and the US States

This week, there was more work to be done for some of us: in addition to the standard three challenges, there was one more from Neil Bowers. His suggestion for a challenge had been simplified, so he published the original specification.

Van Eck’s Sequence

Let a0 = 0. Then, for n ≥ 0, if there exists an m < n such that am = an, take the largest such m and set an+1 = n − m; otherwise an+1 = 0.

I didn’t find a non-recursive formula for the sequence. I implemented a solution using an iterator: a subroutine that returns the next element of the sequence on each call.

Let’s start with a test.

Why Perl 5 benefits is never talked in Perl Weekly Challenge?

Why Perl 5 benefits is never talked in Perl Weekly Challenge?


SUSE Hackweek Day 1 - Perl ♥ Bash

This week we had the SUSE Hackweek 18. It was my first Hackweek since I started working for SUSE. It happens about once or twice a year. People can contribute to any open source project they want to in that week.

So, thanks to SUSE for making this happen!

This blog post is about what I hacked on Tuesday, when Hackweek started for me. Expect more posts for the other days ;-)

Simplicity made easy

The second task of last week's Weekly Challenge
was to list the dates of the last Friday in every month of a given year.

Many of the participants went to great lengths to create efficient and accurate solutions:
tracking the last day of each month, detecting leap years correctly,
working out formulas for the day of the month for a particular date,
managing the complex date arithmetic required.

But, given the powerful Date class built into Raku, most of those
admirable exertions were not actually necessary.

The entire task could be accomplished simply by walking through
from 1 January to 31 December of the given year, first checking
if each date is a Friday (i.e. the "day of the week" value is 5), and then
checking if the following Friday (i.e. the date exactly one week later)
happens to fall in a different month.

If both of those criteria are true, then we have a "last Friday of the month",
so we simply print it.

In other words:

Perl Weekly Challenge - Story so far ...

Originally posted on officially website, here I share the journey so far.

Perl Weekly Challenge #013

Challenge 1: Write a script to print the date of the last Friday of every month in a given year

First thought was to use a module to look up the day of the week for the last day of each month in the given year, then work backwards (in each month) to get the last Friday. But — well, once the weekday of any day in the year is known, the rest can be calculated directly without a further module look-up.

Actually, no module look-up is really needed at all once the day-of-the-week of any day in any year is known. And since I know that 17th June, 2019, is a Monday, I should be able to derive the solution from first principles, as it were, by counting backwards or forwards as needed. But working out leap years is tricky! So I compromised: one look-up for each given input year.

Perl 5 solution

Searching Perldocs

Search is a hard problem. It is the task of getting users to what they want to find, even if they don't know exactly what that is. Its requirements vary widely based on the kinds of things people will want to find and the kinds of people that want to find them. It's also an expected feature of almost anywhere on the web that is more complex than a single page. So shortly after putting together a demo for Perldoc Browser which would become the backend for perldoc.pl, I needed to make it searchable.

Perl Weekly Challenge 013: Last Fridays and Hofstadter Female and Male Sequences

Last Fridays

Write a script to print the date of last Friday of every month of a given year.

To handle dates, I used Time::Piece, a core module since 5.10. It has no method to get the last Friday of a month directly, so I tried a simple trick: get the first day of the next month, subtract one day, and continue to subtract days until we get a Friday.

Time::Piece does all the date maths in seconds. I also used Time::Seconds to get the constant ONE_DAY so I didn’t have to count it myself (60 * 60 * 24, right?)

Dancer2 0.208000 released

On behalf of the Dancer Core Team, I would like to announce the release of Dancer2 0.20800 (the TPCiP release). This version introduces a new keyword, prepare_app, and features a small handful of bug and documentation fixes.

We have found a growing number of instances where not having the ability to execute code on application load is a real annoyance. The prepare_app keyword will allow you to run a block of code when your app is loaded, and is inspired from Plack's prepare_app method. Thanks, Sawyer, for making this happen.

The full changelog is as follows:

Perl Weekly Challenge # 13: Fridays and Mutually Recursive Subroutines

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

Spoiler Alert: This weekly challenge deadline is due in several days from now (June 23, 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: Thank God, It's Friday

Write a script to print the date of last Friday of every month of a given year. For example, if the given year is 2019 then it should print the following:

Coding with an even fuller toolset

Sigh. It's always the way, isn't it?

You no sooner get done writing about how having the right tools can make a particular coding task trivially easy...when you realize that, right next door, there was a much better example you could have used to make exactly the same point.

The "longest initial subpath" example I talked about in my previous post was challenge #2 of last week's Weekly Challenge. But challenge #1 that week makes it even clearer how much the right tool can simplify a task.

Challenge #1 was to find the smallest Euclid number that isn't a prime. The Nth Euclid number is given by the product of the first N primes, plus one. So the sequence of Euclid numbers is:

(2)+1, (2*3)+1, (2*3*5)+1, (2*3*5*7)+1, (2*3*5*7*11)+1, ...

Better Shell Completion for Your Tools

In November 2015 I started my App::Spec commandline framework and wrote this blogpost.

It's not only a framework for perl. It can also generate shell tab completion for other tools.

Since then I have been busy with other things, but recently continued working on it for several reasons, and fixed several bugs, mostly for bash.

Last year I started a collection of generated completion scripts for bash and zsh:

https://github.com/perlpunk/shell-completions

Today it contains completions for 20 tools, mostly for perl commands. If you miss a tool there, let me know, or try to write your own YAML specification and generate the completion.

Below you will see some examples.

How to display NA in CPAN Testers

How to display NA in CPAN Testers?

I asked qustion "I want to display NA instead of UNKKONW in CPAN Testers"

I get some answers.

Thank you for everone!

I write a example to to display NA in CPAN Testers.

Perl Weekly Challenge 012: Non-Prime Euclid Numbers and the Common Path

The Smallest Non-Prime Euclid Number

An Euclid number is a number that equals 1 + product of a sequence of primes.

To speed things up, I used an object that caches the sequence of primes discovered so far. The method size returns the length of the sequence of primes; extend_to extends the sequence up to the specified number.

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.