This Week I Learned - 2017 Week 21

Previous week post or the whole series.

If you cannot keep your habit in a consistent manner, you will need readjust the minimum goal of the habit until there is no more excuses for you not to do it. Is as simple as that.

Second week of eating your dinner before 7pm indeed have significant changes. Additionally with consistent meditation and healthier food choices, surprised to know that I've lost some weight. However, all these lost weight may due to water weight.

#1 Well said. Well said.
"Don’t confuse privacy with secrecy. I know what you do in the bathroom, but you still close the door. That’s because you want privacy, not secrecy."
#2 Interesting that it's not just me who have been doing my own TILs or keeping a developer journals. While some store their TILs in Github repositories, mine just as a weekly collective of blog post. Either way, keeping a journal is always a good habit for anyone practicing their craft.

#3 There are quite a few complimentary Docker utilities that help to improve your Docker usage experiences.

#4 Tracing in GNU/Linux. Always an interesting topic to explore, especially coming from Brendan Gregg.

#5 Managing Git merge conflict? git-mediate seems like a good tool to ease the pain of resolving merge conflicts. I now finally grok how three ways merge works.
  • HEAD - Your changes.
  • BASE - Code before your changes and other branches.
  • OTHERS - Code with other changes that going to be merged to your branch.
#6 Merge with squash. Good to know if you want to do lots of branching.
  • Put the to-be-squashed commits on a working branch (if they aren't already) -- use gitk for this
  • Check out the target branch (e.g. 'master')
  • git merge --squash (working branch name)
  • git commit

This Week I Learned - 2017 Week 20

Last week stuff or the previous posts.

The battlestation have been acting up this week again. Repeated restarts is getting old and rather annoying. Maybe it's a good time to sell it and build a new one instead, probably based on Ryzen. However, the next question to ask is do you want it or need it?

It was so simple that I was shaking my head wondering why it was never occurred to me before. Eating dinner at consistent times of the day will have significant impact on you, both physiological and psychological. Having your dinner before 7 p.m. seemed to have noticeable effects on my body weight and quality of sleep. This is one habit that I need to follow through.

#1 The Starfish Story. Everyone can make a difference in the world, no matter how small the change is. You just have to work fscking hard and stop being lazy. Or maybe taking the opposite approach instead? By adapting a minimalist lifestyle?

#2 While we have web proxy server, it seems that database system also have their own proxy server. For MySQL there are two popular DB proxy servers, ProxySQL and MaxScale. Sadly, I've never implement either one of them in actual production environment. Not everyone works with web scale system.

#3 nftables, iptables replacement. Installation procedure as follow.
$ sudo apt-get install nftables
$ nft --version
nftables v0.6 (Support Edward Snowden)

#4 Google I/O 2017. However, one of less obvious announcement that caught my attention is that the programming language Kotlin have been officially supported on Android. Steve Yegge's long post (HN and Reddit discussion) on the language, as usual, was an interesting read. Maybe it's a good time to start looking into long postponed Android development.

#5 How to start Web Development in 2017. The same old things repeated again and again but getting more and more complicated. Numerous technologies have been superseded by the core essential always remains the same.

#6 Michael W Lucas, interesting author who published both nonfiction and fictions books.

This Week I Learned - 2017 Week 19

Last week post or the whole series.

Slow week but nevertheless, it was an interesting turn of event. Can't wait for more excitements to unfold in coming week. Importantly, never lose focus on your goals over petty things.

#1 One of the best experience shared I've read when comes to employment agreement. Always read the agreement carefully and lawyer up when necessary. Emphasis added by me.
I got sucked into a dispute with a former employer once over intellectual property rights in an employment agreement. They kept trying to sneak in a clause into the agreement in every other paragraph that gave them ownership of, full rights/responsibilities for, and access to, anything I did remotely related to programming or computers outside of work while not on the clock. It was so broad, even my non-lawyer ass knew it was an awful thing. It became a deadlock argument back and forth until I asked if they were accepting liability for any illegal activities I could perform outside of work. Suffice to say those clauses disappeared by CoB the next day in the agreement.
#2 Perl's answers to the Fizz-Buzz question.
#! /usr/bin/env perl
use strict;
use warnings;
use 5.024;

my $t = <>;
chomp $t;

for my $ins ( 0..$t-1) {
    my $limit = <>;
    my $sum = 0;
    map {
        $sum += $_ if ($_ % 5 == 0 or $_ % 3 == 0) 
        } 0..$limit-1;
    print "$sum\n";
}

What interested me is not the solution but the input from the diamond operator (<>) used within this context, which itself is also another interesting story. The diamond operator is useful when writing GNU/Linux console utilities as the operator will work either on standard input or files.

#3 Probably the best sequence diagram to illustrate an HTTP request through CGI. Source from Web Development with Perl.

#4 Why does Google prepend while(1); to their JSON responses? (via HN)

#5 Why you should just use PostgreSQL if you're using Open-sourced database systems? See the number of features (those in green) available. Sigh. Yet we still stuck with MySQL.

This Week I Learned - 2017 Week 18

Last week post or you want to read through the whole series.

Since the prevalent of Internet these days, we're more connected that ever. And yet, we're even more isolated. More and more shopping malls and residential areas are being built especially around the transit stations. Basically all looks the same and people are discourage to travel to another town anymore because everything is available either online or at your nearest malls.

Sick. Down with fever. It has been a while since last time. No one but myself to blame. For people around my age, good rest and food is a way to healthy life. We're not seeking prolonged life but prolonged health.

#1 So, what's your Plan B? Good discussion from the comments. While there is some sort of discrimination against older programmers, but the reality is older programmers may just burn out or bore doing the same mind-numbling stuff over and over again. Yes, the same sh*t but different day. Not everyone have the opportunity to work meaningful projects (yes, subjective view), but most of us just work on some glorified spreadsheet or database skin. You see the same mistakes repeated over and over again from different systems and it's just pointless or bother to raise it up again.

#2 On becoming a low-level programmer. There is a curated list of information especially on the hardware part.. There is also another list of learning the fundamental of computer science. So many things to learn and explore and yet, so little time. Sometimes the reality of life commitments limit our choice on the thing we want to pursuit. I need to finish everything by July before I can start to clear the list from my bucket list. One step at a time. Follow the system.

#3 First, make it work, then make it right, and finally, make it fast. Get the thing to work first before you're thinking about making it right (giving the right name) and optimize it. Fulfill the requirements of the stakeholders first (prototyping) before you're looking into doing it right and fast. Something I need to remind myself constantly as we're often obsess with perfection. What's the point if your build it the right way and fast but does not meet the stakeholder needs?

#4 How to write a REST client in Perl. Most Perl modules have limited documentation, for example, little example on how to use the APIs. This is where PHP (it has been so long since I mentioned something about PHP) really shines. As the language is slowing dying, there are little or no good example on how to start something up fast.

Meanwhile, something rather interesting about Perl. I've seen quite a few Perl codes with subroutines that prepended with ampersand (&) operator. Basically, the ampersand is needed if you're calling a subroutine before its declaration. Off course, there are many other reasons and usages to use the ampersand, but commonly as reference to a subroutine.
&hello;

sub hello {
    print "hello";
}

When using OO with Perl, you will need to instantiate the constructor or method invocation through the arrow (->) operator (a reference). Good examples given below.

Using the arrow notation or virtual method.
my $apple = Fruit->new("apple");
$apple->get_price('usd');

Using the double colons notation or static method.
my $apple = Fruit::new("apple");
Fruit::get_price($apple, "usd");

However, to invoke the method either statically or virtually, you'll need to write the constructor as follow.
sub new {
    my $self  = shift;
    my $class = ref($self) || $self;
    return bless {}, $class;
}

#5 "error: src refspec master does not match any." Silly me. You need to commit something locally before pushing to remote Git server.

#6 Tiny Python Notebook. Definitely not tiny but quite comprehensive guide to Python 3.6.

#7 How to unstage all staged files in Git? It's so easy that the best answer is not upvoted enough.
$ git reset

#8 Postgres Weekly. When come to FOSS database choices for web application for Intranet application, I'm strong opinion that PostgreSQL should be the default choice. Feature like Range Types and others solves quite a lot of issues and save lots of developer-hours. Yes, MySQL has its own usage, but for any business application which involves monetary and strong ACID compliance, it's not a right choice.

Software Process Improvement

The lecture I was attending last week was probably the best so far. The first session was eye-opening for me personally. There are so many things I've learned from the instructor who shared his wisdom and experiences regarding the necessity and relevance of standards like ISO/IEC or CMMI in ensuring quality and process management. Below are some interesting notes taken.

What is quality? Is the degree how we meet the expectation of users. This is to ensure that materials, products, processes, and services are fit for their purposes. Repeatable and scalable are two characteristics of a good pieces of software. (There should be more, for example, like good usability)

What is standard? Collection of best practices. Consultants or auditors always refer to the ISO/IEEE standards to polish up and summarize these before they apply it to the field. Following a standard depends on the degree of compliance. However, there are two questions you will need to ask yourself before apply any standards.
  1. Is BEST, good enough?
  2. Is GOOD ENOUGH, the best?
The answer to these two questions is "the best is the enemy of the good" or also known as "perfect is the enemy of good". In other words, close enough or good enough is sufficient as exact is far too costly. On a similar note, there is this concept of Nirvana fallacy, where we can't or won't (procrastinate) a task due to unrealistic or idealistic expectation.

Sudoku Server

Interesting snippet of Perl code I've found. More complete version is found in Sudoku Garden.

Installing the required packages.
$ sudo apt-get install cpanminus
$ sudo cpanm ojo
$ sudo cpanm Spreadsheet::HTML
$ sudo cpanm Games::Sudoku::Component

Starting the application instance.
$ perl -Mojo -MSpreadsheet::HTML=sudoku -e "a('/' =>; {text =>; sudoku})->;start" daemon
Server available at http://127.0.0.1:3000