This Week I Learned 2018 - Week 17

Last week post or something from the past instead.

Humour aside, I've known two persons (a tech guy and a lecturer) who don't even have a mobile phone, let alone social media accounts. Yes, they are on the rather extreme cases but that was due to their own personal stands and life philosophy. While there have been quite a lot of minimalist life style movement these days but little emphasis on digital world. As usual, moderation is the key here. Too much of everything will cause unwanted disturbance and distraction to your personal and working life.


The Playoff Rondo is part stats and part myth although the stats don't tell the full story. But it's quite entertaining to watch him play, especially the playoff and with big centers.

Plan B before you turn 40. (via HN) Relevantly, experiences on those over 50 who have been laid-off from the tech-force seemed quite positive, life still goes on although on different path. Well there are differences different between Western and Asia countries, this is just part of your work life, especially for those working in tech. Practice minimalist life style, live below your means, exercise and keep healthy, and do what you love. You have to agree with, web development is so accessible these days. Anyone good basic knowledge of English and keen persistence, they can build up the system fairly quite fast. Furthermore, as you aged, priority in life changed as well as your health. Moreover, older tech guy tends to question more and call out BS.

Where SCRUM is not the right choice. (via Reddit) The discussion in the Reddit tells a lot of the horror or abuse stories where SCRUM was implemented literally. It does not work for software team with different project and don't share the SAME backlog. If you have different products, you can't implement SCRUM within the same backlog! Period.

Friendship’s Dark Side: ‘We Need a Common Enemy’. It's a common knowledge but right now it have been proven that "Xenophobia and in-group bias go hand-in-hand". Average fall-outs withing the social group is around 7-plus months. Interesting read.

One item checked off the bucket list. More items to go.
$ cpanm Webservice::Swapi
--> Working on Webservice::Swapi
Fetching http://www.cpan.org/authors/id/K/KI/KIANMENG/Webservice-Swapi-0.1.1.tar.gz ... OK
Configuring Webservice-Swapi-0.1.1 ... OK
Building and testing Webservice-Swapi-0.1.1 ... OK
Successfully installed Webservice-Swapi-0.1.1 (upgraded from 0.1.0)
1 distribution installed

Select all parent and child records. This is when having a Venn diagram really help in visualizing the details.
SELECT ...
FROM comments AS parent
LEFT JOIN comments AS child 
ON child.parent_id = parent.id
WHERE parent.parent_id IS NULL
ORDER BY parent.id, child.id;

Upgrade to Ubuntu 18.04 Bionic Beaver

Yes, the regular updates on my Ubuntu distro in my lappy. While reading back my old posts, I just realized that I've written personal for almost each Ubuntu release like 17.10, 17.04, 15.10, and 13.04. Not sure why, but I didn't jot down any upgrade notes on 16.10, 16.04, 14.10, 14.04, 13.10, and earlier.

Upgrade was done as usual but with a few hiccups. Full upgrade was possible with a few manual intervention of the package management.

First, not enough free disk space in '/boot' folder.

The upgrade has aborted. The upgrade needs a total of 127 M free
space on disk '/boot'. Please free at least an additional 82.7 M of
disk space on '/boot'. You can remove old kernels using 'sudo apt
autoremove' and you could also set COMPRESS=xz in
/etc/initramfs-tools/initramfs.conf to reduce the size of your
initramfs.

Resolved this by removing all the previous Linux kernels and so surprised to know that my machine have so many different versions lying around. No wonder there was limited spaces available.

Second, upgrading was halted due to packaging dependency. Not sure why. Googling around for answers and trying a few usual solutions did not help at all and kept getting the same old error message.

E: Sub-process /usr/bin/dpkg returned an error code (1)

dpkg: error processing archive 
   /var/cache/apt/archives/libmariadb3_3.0.3-1build1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/mariadb/plugin/dialog.so', 
   which is also in package libmariadb2:amd64 2.3.3-1
 Errors were encountered while processing:
 /var/cache/apt/archives/libmariadb3_3.0.3-1build1_amd64.deb
 E: Sub-process /usr/bin/dpkg returned an error code (1)

At the end of the days, the Synaptic tool save the day and resolving all the conflicts.


It's just me or something else, `apt` doesn't seems to have a right default options to resolve conflicts compare to Synaptic.

Now for the changes, reading through the release notes, I've learned a few things and realized that I was quite lost touch with the server part of Ubuntu distro.

1/ Netplan, the network configuration abstraction renderer. Basically it's just a tool to manage networking through YAML file. Surprisingly, the console tool was written in C instead of the regularly used Python. Not sure why but surely it must have a good reason.

2/ New features only available for new installation but not upgrade. For example, swap file instead of swap partition, Python 3 over Python 2, full disk encryption (LUKS) instead of folder encryption.

3/ Subiquity, the server installer was available for server user. Definitely a DIY solution to differentiate themselves from default Debian installer.

4/ LXD 3.0. A better alternative or solution to Vagrant or Docker. I've been lost tracked of this project. Maybe it's the right time to look and get my homelab machine to run this again.

5/ chrony replaced ntpd (there are comparison as well). One good thing is chrony was licensed in GPLv2.

6/ On the desktop front, from the GNOME 3.28 release notes, Boxes was getting much needed love. Previous version was so buggy that made you wonder why it was ever released in the first place.


Cpanm with local library installation

One of the issue I kept facing when developing local Perl modules installation and dependency management.

$ cpanm -nq --installdeps --with-develop --with-recommends .
!
! Can't write to /usr/local/share/perl/5.26.0 and /usr/local/bin: Installing modules
! to /home/foobar/perl5
! To turn off this warning, you have to do one of the following:
!  - run me as a root or with --sudo option (to install to 
!    /usr/local/share/perl/5.26.0 and /usr/local/bin)
!  - Configure local::lib in your existing shell to set PERL_MM_OPT etc.
!  - Install local::lib by running the following commands
!
!    cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
!

Either we do this manually everytime.
$ cpanm --local-lib=~/perl5 local::lib 
$ eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
local::lib is up to date. (2.000024)

Or setup your local environment for once through local::lib.
$ PATH="$PATH:~/perl5/bin"

Additional directories for Perl library.
$ export PERL5LIB=~/perl5/lib/perl5

Options for Module::Build.
$ export PERL_MB_OPT="--install_base '$HOME/perl5'"

Options for Module::MakeMaker.
$ export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"

$ curl -L http://cpanmin.us | perl - -l ~/perl5 App::cpanminus local::lib

Add this to your `.profile` as well.
$ eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)
$ source ~/.profile # reload

Or just use Perl's Docker container image.

Or just use Carton and set everything to local folder.

This Week I Learned 2018 - Week 16

Last week post or something from the archive.

看了一套墨西哥的戏,《行走距离》。电影讲述一个三百公斤的胖子,寄托于摄影以解生活的苦闷。间接中,也结交了几位好友,让他生命有所改善。没有惯性的情节,简单不过及现实的故事。健康是宝,平淡是福。

Another week of learning new English vocabulary. One issue with making sentences using these words was that the sentences was either too forceful or too literally (直译的) translated.
Sandy alleviates (缓解) the excruciating pain on her lower body part by elevating both legs into a bucket with warm water. By doing so, they hope it can obliterate (忘却) the pain she was going through. Both legs were swelling due to her falling into liquescent (易液化的) soil and stabbed by tree trunk while trekking in the wood. The swelling have worsen and everyone worry that the muscle may liquefy (使液化) from within. 

Stuck with an interesting MySQL problem, which was quite easy but I can't seem to get it right after several tries. Basically we want to update certain column in t1 to the maximum value from a group of similar records. The SQL query was quite straightforward, just join with the second table, t2 with maximum record with the first table, t1.
UPDATE t_transaction tu
JOIN (
    SELECT code, MAX(flag) AS flag
    FROM t_transaction
    GROUP BY code
) t
ON tu.code = t.code
SET tu.flag = t.flag

Modern backend developer in 2018? (via HN) A checklist and decision making tree are always a good choice to make good decision making when picking up new technology stack.

Perl constant array. Sometimes the simplest and easiest way is the only way instead of going through and abusing quirky Perl syntax.
use constant FRUITS => ['apple', 'orange', 'banana'];

my $fruit = 'apple';
if (!grep $fruit eq $_, @{+FRUITS}) {
    print "Is not a fruit";
} else {
    print "Is a fruit";
}

use constant FRUITS => qw(apple orange banana); 
use constant FRUITS => (apple orange banana);  
my $fruit = 'apple';
if (!grep $fruit eq $_, FRUITS) {
    print "Is not a fruit";
} else {
    print "Is a fruit";
}

Modern PHP without a framework. (via HN) Nah, still hate it after all these years. Maybe I'm just prefer a more prettier programming language.

回顾自己的工作生涯,真的必须自我检讨未来的工作方向,看看那些是自己重视的
所以,你得先釐清有哪些條件是你重視的,像薪水、公司品牌、職位、工作內容等,一一把它寫出來。列出條件後,再排定先後順序,之後,和你手邊的 offer(拿到手的工作)比較,做成表格。縱軸是你重視的條件,並依照先後順序,由上而下排列;橫軸則是你拿到的 offer。當你完成表格後,該選擇的工作就會自動「跳出來」。
當我們在思考應該向哪家公司投遞履歷時,其實已經在篩選公司了,但如果是以「錢多事少離家近」為標準,長遠而言卻未必是最適合自己的公司。所謂「知己知彼,百戰百勝」,此時應該要先釐清自己的需求,包括期望的上下班時間、喜歡的工作環境、想做內勤或外務、理想的管理方式、工作如何分配、會議如何進行、同事如何相處、以及有哪些學習機會等。再依這些喜好排出先後順序,然後評估要應徵哪些公司。
工作上要留下那个”人才“? 当然是人品态度优先,能力可以慢慢去培养。

What are some tech companies that do not use open floor plan? Interesting question for those who are looking to justify cubicles. The office at Fog Creek was in between, open space for collaboration and private office for working.

Data class in Python 3.7. (via HN) What took them so long? Syntactic sugar or not, this should have been in any fundamental data type for any programming that supports OOP.

Vipassana for Hackers. (via HN) A book on how a tech guy perceived and practiced Vipassana meditation without involving religion, just the practice. Contrary to typical meditation book, lots of pictures explaining the core concepts.

Moving for good. (via HN) Good write-up when you're moving to a new place. Key quote here (emphasis added),
Ask lots of questions. Ask them to explain things, and show you how it’s done. When they state a fact, ask how they know. When they state an opinion, ask for examples.
How to be a systems thinker. (via HN) I still can't get my head to understand this and the list of reading materials is quite long. Worth spend time on this? We shall see then.

This Week I Learned 2018 - Week 15

Last week post or grab something from the archive.

Travelling. Short and late write-up for this week.

一年一度的大自然环境“欣赏”周。水上活动总是有它的危险性。任何这类的活动都必须去注意团队的每个人的安全。如果一旦出现什么差错,到时要怪罪何人?关于个人安全,东方人及西方人的文化都明显都所差异。这是我们必须认真去检讨的。发展中国家的旅游胜地,虽然是经济的消费,但是也显出人民之间的贫富差距。罪该祸首还是不完善的教育体制,过于注重宗教而不注重论理學等知識。简单的算数,对某些孩子却是何苦艰难。

Travis CI and Perl. Some minor hiccup but I managed to get the Continuous Integration (CI) to work correctly. Unfortunately, I can't seem to find a way to test the CI within the local development environment.

The history of React.js. Didn't realize that React have came a long way, since 8 years ago. Yes, you got it right, 8 long years ago! The competition of the front-end Javascript libraries have settled down to either React, Angular, and Vue. Due to some "compelling" circumstances, this is a good time for "reacting" (pardon the pun), and nothing better to start with the fundamental basis (via HN).

"Manage your energy, not your time." How you manage your day (especially the morning) determine the productivity for the whole day, week, month, and year.

This Week I Learned 2018 - Week 14

Something from the archive or last week post.

We have been doing blood pressure measurement wrongly for all this while. You must measure blood pressure from both arms. Yes, both arms and find the differences. According to Harvard Health,
"A blood pressure difference of 10 to 15 points or more between arms also boosted the chances of having a stroke or dying from cardiovascular disease. "
Personal data and GDPR: practical guide for developers. Shaking my head while reading through the whole post. I was wondering how a software team going to ensure data anonymization in development environment when handling production data? When come to this, the US/Canada software houses are doing a better job than the EU/Asia counterpart.

What if we apply this to our life instead? Rearrange your line of thoughts in your writing. Intriguing discussion when come to writing.


"The Surgical Team" (chapter 3 in the infamous book, The Mythical Man-Month), a different software development team structure which it's similar to the surgery team where,
"The idea was to construct development teams in a way similar to the surgery teams - one lead developer, one assistant developer (these two "adult" and very good), and a 3-4 other people who 's job is to make the life easier for the main devs - someone to manage documentation, someone else to do detailed testing, one average dev to do the simple and boring stuff, and so on."
Maybe an alternative approach where the Agile methodology like Kanban or Scrum cannot be applied successfully or productively. Why so? Cargo cult software engineering, as coined by Steve McConnell where software development houses try to imitate successful processes or approaches without understanding why such methodologies works for them. What works well (may due to luck and timing) for an organization or team may not be suitable for another organization or team. Don't uses Scrum for the sake of using Scrum. Another good example, the reinventing of office space, open office, pool table, ping pong table, gaming corners, and the like. Yes, the startups starter pack.

Fork and Pull Request Workflow. While version control system have been available since the 70s, till today, amazingly, some companies still refuse or slow to adopt it. Everyone have their own workflow and branching models.

Quite a number of MySQL Gotchas this week. Fair enough, it will happen to any of the DBMS out there. My tolerance towards MySQL have increased along these years. Must be something to do with getting old.

How do you order a list of items where the NULL data is at the bottom of the list? It's actually quite easy, just use ORDER BY ISNULL. See the example below.
SELECT * FROM table ORDER BY ISNULL(field), field ASC;

NULL, NULL, NULL, 1, 2, 3, 4
1, 2, 3, 4, NULL, NULL, NULL

Creating a function in MySQL. That was rare but somehow we may need it to reduce or shorten the SQL query. Yet, we kept encounter this idiotic error of "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER |' at line 1". Just add a BLOODY space! Yes, a BLOODY space before the semicolon!
DELIMITER //
Create function or procedure
Write your function or procedure here...
End (without semicolon)
//
DELIMITER ; (semicolon with space)

Write UPDATE SQL query with multiple joins and SUB-SELECT but the query won't work in SUB-SELECT? Wrap the SUB-SELECT condition with one more join!
DELETE FROM story_category
WHERE category_id NOT IN (
    SELECT cid FROM (
        SELECT DISTINCT category.id AS cid FROM category
        INNER JOIN story_category ON category_id=category.id
    ) AS c 
)

How many ways to insert a not found record in MySQL? Plenty of ways. Not sure these works cross database systems.

Career do-over? Either moving to management and if you don't like it, restart your development career again.


This Week I Learned 2018 - Week 13

Last week post or something from the past. This going to be a very long weekly post. So many things written down this week and might as well put everything together.

又是那个季节。每当这个时候,都会想起唐代杜牧的著名诗句。以前倒是没什么去注意了解,但是没想到,根据百科解说,每一句都是诗者高明的写法。随着年龄增长,是时候重读起唐诗宋词,陶冶性情。
“清明时节雨纷纷”。第一句,交代情景、环境、气氛。
“路上行人欲断魂”。第二句,写出了人物,显示了人物的凄迷纷乱的心境。
“借问酒家何处有”。第三句,提出了如何摆脱这种心境的办法。
“牧童遥指杏花村”。第四句,写答话带行动,是整篇的精彩所在。
The Nightmare Letter: A Subject Access Request under GDPR (via HN). GDPR (General Data Protection Regulation), the new data protection law coming into force on 25th May, 2018. Ironically, an article posted in a site that making profit from our shared data. There always this saying I read online many moons ago regarding privacy, "If you have done nothing wrong, then why you need to worry about people tracking your Internet usage?". And the counter argument to this question is "Everyone knows what we did in the toilet, then why we still need to close our door?". Corporations have long monitored and tracked our daily movements and behaviours and people needs to be educated and aware of such activities and their right to erasure, also known as "the right to be forgotten".

Off course, all these discussions was due to the recent social media data breaching. And usual things was, some noises were made, another call for deletion of your social media account, and things will cool down, and live goes on. Nothing drastic will happen, people still will keep their social media account and no one will delete it. Social media site will be replaced by another social media site, somehow or another.

Surprising to find out about this on feeding Betta fish (emphasis added). And we were feeding the Betta fishes with more than 2 to 3 pellets! Pellets will expand in their stomach. No wonder some of the Bettas were having constipation issue.
Adult bettas can be fed once a day and babies (young) can be fed twice a day. It may not seem enough, but many pellets expand to more than 2x their size when they get wet. To put this in a further perspective, the stomach of a betta fish is about the size of their eye! Additional power supplies may be necessary depending on the level of activity and personality of your betta.
Read the story about the origin of Giant Betta. Most of the new Betta type was due to anomaly of breeding and continuous selective breeding.

Reality when comes to management as described below:
In this case, it's management giving the impression that they are "doing something." We see the same thing with, "can we add more developers to speed this up?" The answer is almost universally "no" and, presumably, any manager in the modern era should have read (or at least be familiar with) the over 40 year-old book, "The Mythical Man Month." But, from a senior management position, there aren't many levers to pull--and when the heat is on, they have to be seen to "do something."
Write or build your own software projects. Yes, is a time waster to re-implement something from scratch, but you will gain valuable insights by doing so. Build your own React is probably something relevant that everyone should look into if they wish to understand what the hype about front-end development using React and the like.

Thought provoking post on how Lisp, the programming language ruined a person development career (via HN). Are you a software plumber or software developer? The comment did raise an interesting question on how once see his or her software development career. If you're doing mostly business software or glorified spreadsheet, then you're a plumber, not the later. If remember correctly, long ago, there was this discussion about software developers who are producer and those who are consumers.

Is the ability to focus the key skill that separate successful and unsuccessful people. This HN user think so. The next question is how to increase your focus?
Pretty awesome! If I ever had to say the one thing that differentiates successful people from unsuccessful people it wouldn't be intelligence, or even perseverance, or passion. It'd be focus. With focus, you can be amazingly successful in so many types of occupations.
(That being said, passion / perseverance / intelligence can often lead to focus)
How to tell great story? Feeling stuck or suck? Just follows the Pixar’S 22 rules of storytelling. Rule number 4 or the The Story Spine way is the most common and popular.
Once upon a time there was ___. Every day, ___. One day ___. Because of that, ___. Because of that, ___. Until finally ___.
Meanwhile, while reading about writing, saw this post about whether we can start a sentence with a conjunction? Definitely yes. Good examples shown below:
It’s a pretty smart and progressive budget. But do you think those changes go far enough?
Some people are calling this film the worst movie ever. And who are we to argue?
Dworkin’s answer is no. But why not?
Who would have thought it? And is it really true?
While we at it, this week vocabulary list. Lots of similar words and it was quite hard to link these words up into a cohesive paragraph.
When sedition (煽动叛乱) law have been applied selectively, societies will slowly disintegrated (瓦解) from within rather by external influences. Inconsistency and partially interpretation this law will result in serious crisis in the legislation and judicature (司法) of our country or worse, the ridicule (奚落) of our judicial (法庭的) system. Therefore, there should be a judicial review of the law should be an integral (整体) part of the to the rule of law. That was David, an adjunct professor (副教) of law, judicious (有见识的) closing statement before the class adjourned (休庭) for lunch break. While he was discussing remaining details with his fellow students, Mary, his personal assistant, interjected (插话) their discussion to remind Davis about his itinerary (行程) for today. He should be in the transit (中转) lounge at the airport in two hours and additional amendment of this law was not be the ambit (范围) of their discussion right now.