This Week I Learned 2019 - Week 03

Last week post or something else instead.

What else I learned this week in separate posts? The third week of ornamental fish culture MOOC on quality characteristics determination on GoldfishKoi and DiscusAngelfish and schooling fish. Continue with literature review on paper of feeding frequency effects on Betta fish growth and fecundity. The week was concluded with a review of MP3::Daemon Perl's module.

What is the best written comment I've read this year? Motivation and willpower is not sustainable compare to just chop wood and carry water. Just do things (as quoted below), one step (or 5 minutes) at a time. However, do check for any health issues. Be kind to yourself. Move, sleep, and eat well.
One day, you will be dead. Each year that passes after your death, fewer and fewer people will remember who you were, what you did or what your face looked like. Eventually, you'll be completely forgotten. Who cares if that side project you put out sucked or not. Might as well put it out there and see what people think. There's a good chance too that the project won't even be remembered even by the time you die.
The best way to get experience is to do things, so given that no one is going to remember, might as well try to do it. Your successes won't be remembered along with your failures.
Should you dump unwanted pet fish into the river? Definitely no. The Amazon sailfin catfish (also known locally as DBKL fish), which is not an indigenous species, have invade our local rivers, ponds, or lakes. The bigger issue is that most people don't know or don't want to euthanize (humanely dispose) of unwanted pet fishes but revert to aquarium dumping instead. Perhaps, sell back these fishes to fish stores or donate to other hobbyist. If all these fail, just use Clove oil.

How does fish farm in SG looks like? Let Ah Hua tells you.

How to breed shrimp? The most important lesson from the video is not about breeding shrimp, but understanding water parameters and maintaining good water quality. Rare we stumbled upon good video in YouTube on breeding fish.

Is luck real? Not really, is only one of many external factors in life as in what they say, "lucks favour the prepared mind". Choose personal empowerment (focus on who you are, choose your own race, and love what you do). Accept those ideas that growth you and reject those which drag you down.

How do you organize everything you want to do? Regardless what system you've implemented, the system should be simple and easy for constant repeated review. Complex system discourage usage and reviewing. Without reviewing, there will be no awareness on the progress on your to-do list, hence stagnance of what you've planned to do.

If not SICP, then what? Maybe HTDP? (via HN) The endless argument on why SICP is not the right entry material for those who want to venture into computer science or software engineering and HTDP is probably a better choice instead.

Perl Module(s) Of The Week - 2019 Week 03 - MP3::Daemon

They said, old habits dies hard, especially if you're coming from console background. The tendency of trying to do everything at the console is hard to break. Console programs in *nix worlds tends to follow the Unix philosophy of do one thing and do it well, work well with other programs, and exchange data using text stream. The Perl module of this week, MP3::Daemon, a text front end to mpg123, was designed to follow such philosophy. For example, play part of a MP3 file repeatedly.
while true ; do mp3 j 1300 ; sleep 386 ; done

Installation and quick run of the program.
$ cpanm MP3::Daemon
$ mp3

Trying to run one of the command and we encountered these error messages. Note that this program was first written in 2001, 18 years ago, maybe there was some bugs or maybe it was due to my local installation. Furthermore, following recent naming convention, the module should have been named `App::MP3`. However, looking and reading old code will give you some insights on writing Perl code without resorting to external modules but focus on just basic Perl code. Nevertheless, we try to resolve these two issues.
 $ mp3 ls
Subroutine main::pod2usage redefined at (eval 16) line 1.
 main::BEGIN() called at (eval 16) line 1
 eval {...} called at (eval 16) line 1
 eval 'use Pod::Usage' called at /home/foobar/perl5/bin/mp3 line 8
No such file or directory at /home/foobar/perl5/lib/perl5/MP3/ line 84.

We first look into the `No such file or directory` error. Looking through the source code at line 84, educated guess that `mpg123` program (the program was name after the MPEG layer 1/2/3 format) have not been installed. Installed the console app will remove the error message.
$ sudo apt install mpg321

If you cannot access the source code, you can jump to the particular line using `less`. The `+84` option will jump to line 84 and `-N` will show line numbers.
$ less +84 -N /home/foobar/perl5/lib/perl5/MP3/

For second issue on subroutine redefined error. Looking through the source code as shown below. In Perl, without using external modules, we use `eval` for exception handling. The code checks for `Pod::Usage` availability, if not found, set the error message to `[email protected]`, the eval error variable.
eval "use Pod::Usage";
if ([email protected]) {
    sub pod2usage { system("perldoc mp3"); exit 1 }

To resolve this issue, first we need to enable `diagnostics` module to give us hints on what and how to resolve this warning. Add this line to the `mp3` executable script.
use diagnostics -verbose;

Run this program again. We will obtain full verbose details on the warning and how to resolve it.
    These messages are classified as follows (listed in increasing order of
        (W) A warning (optional).
        (D) A deprecation (enabled by default).
        (S) A severe warning (enabled by default).
        (F) A fatal error (trappable).
        (P) An internal error you should never see (trappable).
        (X) A very fatal error (nontrappable).
        (A) An alien error message (not generated by Perl).
    The majority of messages from the first three classifications above
    (W, D & S) can be controlled using the warnings pragma.
    If a message can be controlled by the warnings pragma, its warning
    category is included with the classification letter in the description
    below.  E.g. (W closed) means a warning in the closed category.
    Severe warnings are always enabled, unless they are explicitly disabled
    with the warnings pragma or the -X switch.
    Trappable errors may be trapped using the eval operator.  See
    "eval" in perlfunc.  In almost all cases, warnings may be selectively
    disabled or promoted to fatal errors using the warnings pragma.
    See warnings.

Subroutine main::pod2usage redefined at (eval 17) line 1.
 main::BEGIN() called at (eval 17) line 1
 eval {...} called at (eval 17) line 1
 eval 'use Pod::Usage' called at /home/foobar/perl5/bin/mp3 line 9 (#1)
    (W redefine) You redefined a subroutine.  To suppress this warning, say
            no warnings 'redefine';
            eval "sub name { ... }";

Made changes to the program as follow and the warning should be disabled.
  8 eval "use Pod::Usage";
  9 if ([email protected]) {
 10     {
 11         no warnings 'redefine';
 12         eval qq/sub pod2usage { system("perldoc mp3"); exit 1 };/                                          
 13     }
 14 }