This Week I Learned - 2017 Week 49

Last week post or something from the archive.

A few weeks ahead and we will reach the end of the year 2017 and embrace 2018. Slow week, lots of travelling and nothing much done. Interesting conversation with quite a few breeders.

Da Hu Fa is another good animation coming from China this year since the release of Big Fish & Begonia in 2016, preceded by Monkey King Hero Is Back in 2015. The Chinese animation industry comes a long way since the early days of Havoc in Heaven. It's still growing but still heavily influenced by Japanese anime in some ways and lack of the maturity and unique styles.



Interesting discussion on JavaScript itself with other developers. For RESTful API, use Koa.js (the development guide have some documentation), the next generation web framework for Node.js and the successor for Express.js.

Someone introduced me to Flow-based programming (FDP) and if you're using JavaScript, there is NoFlo. If you're from UNIX background, think FDP as pipeline or pipe and filter. Worth exploring and use it in your project? Well it depends, pretty much on the context or the type of system.



Looping and concatenating multiple arrays in Perl

Saw this code while searching through something and it caught my attention. Interesting way to concatenate arrays.
use strict;
use warnings;
use Data::Dumper;

my $a = [1,2];
my $b = [3,4];

my $c = [];
push @$c, @$_ for $a, $b;

print Dumper($c);

$perl main.pl
$VAR1 = [
          1,
          2,
          3,
          4
       ];

Alternatively, you can write it as this way where we concatenate both arrays.
use strict;
use warnings;
use Data::Dumper;

my $a = [1,2];
my $b = [3,4];

my $c = [];
push @$c, $_ for (@$a, @$b);

print Dumper($c);

$perl test1.pl
$VAR1 = [
          1,
          2,
          3,
          4
       ];

However, if we have any duplicated item in both $a or $b, it will be merged as well.
use strict;
use warnings;
use Data::Dumper;

my $a = [1,2];
my $b = [1,2,3,4];

my $c = [];
push @$c, $_ for (@$a, @$b);

print Dumper($c);

$perl test2.pl
$VAR1 = [
          1,
          2,
          1,
          2, 
          3,
          4
       ];

To resolve this, we need to remove the duplicate items in the combined array by using
List::MoreUtils.
use strict;
use warnings;
use Data::Dumper;
use List::MoreUtils qw(uniq);

my $a = [1,2];
my $b = [1,2,3,4];

my $c = [];
push @$c, $_ for uniq(@$a, @$b);

print Dumper($c);

$ perl test3.pl
$VAR1 = [
          1,
          2,
          3,
          4
        ];

This Week I Learned - 2017 Week 48

The usual last week post or something from the archive.

Down with fever and flu. At certain age, you really need to love your body as much as possible. On the bright side, I'm almost off the grid for the past few days.

The Best Monitor for Programming: A Cheap 40″ 4K TV. (via HN) Not really a good choice if you want to reduce eye strain and myopia. Also, you will need to have a good distance in order to get the actual benefits. However, definitely not for me. A large screen size is suitable for people who love to have multiple opened windows at the same time. I always prefer one window at a time.

The Diderot Effect. We all will experience this someway or another. Picking up a new hobby, for example, photography. Well, not only you're just getting the camera body only, you will purchase the whole system (complementary accessories), which includes bags, lens, filters, books, magazine, and etc. The constant upgrades will lead to endless hoarding. James Clear have recommended a few ways to manage Diderot Effect. The main take away are reduce exposures, prevent impulsive purchases, self-imposed constraints, and downgrade. The last strategy seems interesting. We're seldom downgrading on stuff we owned but constant pursuit for latest greatest.

CS007: Personal Finance For Engineers (via HN) Worth every minute of your time to go through the whole thing. We have been taught and educated on different types of mathematics but not really on finance. This should be the compulsory subject for all students. Start them young and early.

Emulate the SRV tones? Forget the about the budget and get his signature guitar, amps, and pedals. Or without bursting the bank, something more affordable. While having similar gears does getting you closer to emulate original tones, do know that how a guitarist play, hold, pick, and grip guitar have a huge influence on the tone. Furthermore, post processing have a big impact on the final sound and tone. However, something related, PixxyLixxx gave a good advice on why you should have a limit on how much you can spend on a guitar (in his case, is USD 300 with certain exception). Unless you're freaking rich, when you past certain age, different priorities in life set in. You should put the extra money in your kids college funds or fixing your house.