This Week I Learned - 2017 Week 12

Last week post or you can read the whole series.

9 hours of writing and only 3 pages done.

#1 The important of morning rituals in developing a system (install a habit) to achieve your life goals. Is good to be morning person as you can achieve quite a lot when your mind is fresh. There are these 7 morning rituals which I will slowly introduce to my daily life. These are:
  1. Plan a day before. I've been slowly adopting this habit by going through the list of items in my bag and write down what I need to do tomorrow. Not consistent though as for some day I failed to plan for anything.
  2. Wake up early. Either from 4:30 AM till 6:30 AM. This is doable provided that you sleep quite early on the previous day. According to this sleep calculator, these are the corresponding time you should sleep if you want to wake up at a particular hours.
    1. 04:30 AM - 7:30 PM or 9:00 PM or 10:30 PM or 12:00 AM
    2. 05:30 AM - 8:30 PM or 10:00 PM or 11:30 PM or 1:00 AM
    3. 06:30 AM - 9:30 PM or 11:00 PM or 12:30 AM or 2:00 AM
  3. Start the day with exercise.
  4. Do your highest priority projects. Study in the morning and reviewing again in the evening before bedtime. This is good for learning as you can recall and rethink what you've learned in the morning. Also? Before even you start your journey to work, you've already accomplished so much for the day.
  5. Work on your side projects. Definitely need to try this. Do not work on your side projects late at night. Do it in the morning.
  6. Have a uninterrupted conversation with your partner. Do we actually having any serious and uninterrupted conversation with our partner, even for just two minutes? Doubt so.
  7. Meditate. I've been doing this since the moment I woke up in the morning. Although for just a mere 10 seconds, slowly but surely I can really concentrate on it.
#2 Beautiful SICP. There is another Python version as well. The discussion is always revolves whether it's good or not. I haven't yet finish the damn book since I bought it 20 years ago. Is this year the year for me to finish it? Doubt so. Even though I placed the book next to my work place and look at it on daily basis. Also, SICP is also the recommended book (debatable) on the subject on programming in Teach Yourself CS. (via HN) While we on that, someone should start another list on Teach Yourself SE. My personal experiences is that Software Engineering knowledge far outweight the Computer Science knowledge.

Since we can all access good quality CS education through the Internet, does local CS degree still relevant today? Or does this means that universities or colleges have been rendered to just another platform for face-to-face socializing instead of gaining knowledge?

#3 Almost 15 years of Design by Contract. I can relate to the author experience and still is a firm believer of Design by Contract (DbC). Bertrand Meyer still have a huge influence on me. Like most things in life, moderation is the key. Use DbC only when necessary.

#4 Real-time LED strip visualization (see Gif animation below) using ESP8266 or Raspberry Pi. Not only the project was interesting, the detail documentation by the developer was impressive. Definitely one of the most solid Github project I've encountered.


#5 Alone in the Wilderness. (via Reddit) A documentary (search YouTube for the video) about Richard Proenneke, who upon his retirement at age of 51 years, build an ultimate man cave to live a life of solitude in Aslaka. Carpentry is such a underestimate skill a man could have.

#6 Interesting Git graph generated by Bit-Booster, the offline commit graph drawing tool from one of my personal Git repository. I'm not sure how to interpret the relationship of my commits, seems somehow broken?


This Week I Learned - 2017 Week 11

Last week post or you can read through the whole series.

Readjust and swapping some my morning and night rituals. I've managed to clear of daily to-do items in a more manageable and less stressful manner. It's amazing that a small change can have a significant impact on your daily life.

#1 What is the best time to have breakfast, lunch, and dinner? McLaren's F1 driver diet plan provides some good reference plan. Breakfast starts at 7 am, follow by lunch at 12:30 pm, and lastly dinner at 6:30pm. Interestingly bedtime is around 10pm, seems way too early. However the total calories is quite high, roughly 2800kcal. Best if you check your daily needed calories.

While we're on calories counting. Someone managed to lose 45kg in 6 months (via HN). Be warned, his approach is quite drastic and not suitable for everyone. Similar posts (here and here) in HN.

#2 Dynamic Dispatch and Jump Table. I've been stuck with a problem of implementing console application in C++. Countless hours of searching and reading and it finally occurred to me that I was googling for the wrong keywords. Unfortunately, my limited knowledge with C++ hamper the progress of the project. Some discussions with two young chaps did open up possible solutions on how to implement Jump Table in C++. Will explore further once everything have been settled down.

#2 Learned optimism as presented by Reginald “raganwald” Braithwaite. Good to read slide and watch the presentation together. The audio quality is kind of lacking. To be more optimistic, use Cognitive Behavioural Therapy to change the way how you explain things to yourself.


#3 Cultural fit for a candidate in a company. The ironic, bitterness, and sarcasm. The comment by sokoloff is spot on. It should be a mutual process, both the candidate and the company. And it should be the responsibility and challenge for the management rather than those reluctant employees. Interestingly, there is only three interview questions to assess whether a candidate is suitable for the job.

This Week I Learned - 2017 Week 10

Last week post or just follow the whole series.

Got my result today. It seems I've officially "crossed" the borderlines stage. I'm still contemplating on the next step but drastic life style changes is inevitable (more in item #5). If left untreated, it can grow into bigger problems, not only for yourself, but for your loved one as well.

#1 You May Want to Marry My Husband (via HN). Beautifully written. We need to be constantly reminded of the fragility of life especially contemplating one's mortality. The lack of awareness will bite you and your loved ones somehow in the future. Over 30-something and still bogged down by random trivialities in life? Nothing but continual reflection on your life priorities (often misplaced) and gratefulness helps to make peace with current and past self. Regrets? Yeah, plenty. Who doesn't? But not to a point where you will lament later in life that you should, would, or could. Wish you've taken a different path? Nah. I'm good. Yes, there is still room for improvement. Looking forward to that.

Further reading. The 10 Best Modern Love Columns Ever.

#2 On Perl. Interesting thing learned. How do you clone a hash and at the same time, reassign new values to some of the existing keys? Simple and yet so effective. To explain this,  `%$foo` expands expands the hash into a key-value pair and the curly braces (anonymous hash constructor) will create a new hash reference. Output is from Devel::REPL module, the modern Perl interactive shell.
$ my $foo = {a => 1, b => 2, c => 3};
\ {
    a   1,
    b   2,
    c   3
}
$ my $bar = {%$foo, a => 4, b => 5}
\ {
    a   4,
    b   5,
    c   3
}

Instead of just doing this.
$ my $foo = {a => 1, b => 2, c => 3};
\ {
    a   1,
    b   2,
    c   3
}
$ my $bar = {%$foo};               
\ {
    a   1,
    b   2,
    c   3
}
$ $bar->{a} = 4;
$ $bar->{b} = 5;
$ $bar
\ {
    a   4,
    b   5,
    c   3
}

#3 Carton. Bundler for Perl. In other words, module dependency manager for Perl. Is Perl a lost cause that only a few diehard users still using and maintaining it? Seems likely to me.

#4 Ship daily. That probably the way to get your side project moving and don't feels like you're not completing anything. Can't do it? Maybe you're setting the bar too high and setting yourself up to failure. Of course, some are created to be thrown away. While I don't totally agree on the needs to to finish all your side projects, but when comes to actual paid work, we need rethink our role. Instead of a programmer, think yourself as a problem solver instead. A tiny shift of that mentality will get you closer to the deliverable.

#5 Getting older? Getting weaker? Maybe you should check your weight and measure your Body mass index (BMI)? If so, you should to readjust your diet. Stop eating like you're in college days. More (not just) portions of fruits and vegetables? Furthermore, be informed and mindful of what you put inside your body. Of course, exercise is needed as well. However, exercise alone does not lose weight. Joao Venture have experienced weight lost by reducing most of his sugar intake and maintaining 3 km daily walks per day. Using this calculator, 3 km is 3937 steps, rounded to 4000 steps. Those who works as software developer with sedentary life style, it's a struggle to reach 4000 on daily basis.

Looking through my steps count below, both my mean and median are roughly around 3000 to 4000 range. This fulfill at least one of the criteria. The next step is to adjust my diet by reducing my sugar intake. Interestingly, since the beginning of 2017, I only manage to hit 10000 steps only four times!


On a related note, sleep is also a crucial factor as well. What Kind of Sleeper Are You?

#6 The Unofficial MySQL 8.0 Optimizer Guide. The section on profiling is interesting and I really don't have time to go through each item on databases I'm working one. Definitely going to improve any legacy and messy databases.

#7 When comes to programming, some of us still missing the point that we're a problem solver first and a programmer second. Follow a process and the convention. Prioritize. Keep the solution simple (yes it maybe boring) and don't try to do things the fancy way unless really, really necessary.

Samsung M2070W WiFi Printing with TP-Link Archer C7

It took me a while to finally set this up and to my amazement, this is actually quite damn simple. While there is another way to do it, through Samsung's Printer Settings Utility, unfortunately the `libnetsnmp.so.10` does not exists anymore in Ubuntu 16.10. Therefore, to get this to works, we have to resolve to WPS method.

There are three devices you will need to setup properly. These devices are your laptop, the router, and lastly the printer itself.

1. Install the Samsung printer driver in your Ubuntu system. You should be able to print through USB cable.

2. Next is to get the network configuration details of the printer, specifically the MAC address. From the printer buttons, Menu -> 4. Network -> Network Conf. -> Print? -> Yes. Jot down the MAC address.

3. Go to the router. DHCP -> Address Reservation -> Add New. Assign the MAC address in Step 2 to a fixed IP address so we always connect to the printer using a consistent IP address. Reboot the router. If you enable MAC filtering, do remember to white list the MAC address of the printer.



4. Again, in the router, we will need to enable WPS. Go to Wirelss 2.4GHz -> WPS -> Enable WPS. You may need to reboot the router again if WPS is not enabled.


5. Continue by clicking the Add device button. There are two options to add new device. Pick the second option and click Connect.



6. Go to your printer and press the WPS button for more than 2 seconds. Wait until the printer connected to the router. Once the printer is connected, you can disable the WPS in the router. You printer now will be part of your home network and assigned an IP address.

7. In your Ubuntu installation, open the browser the connection to CUPS management site at http://127.0.0.1:631. Go to `CUPS for Administrators` -> `Adding Printers and Classes` -> `Manage Printers` -> Select the printer you've install in Step 1 -> `Administration` -> `Manage Printer`. You will be prompted for login credential. Use the same credential when you login to Ubuntu desktop environment.

We're going to use the Internet Printing Protocol (IPP). While there are many printing protocols but for convenient sake, we will pick IPP. You can obtain the IPP full address from Step 2. It looks something like `ipp://192.168.0.123/ipp/print`. The IP address is set in Step 3.


8. Unplug your USB cable and print any sample test page from your laptop. If everything have been setup properly, you should be able to print wireless.

9. Additionally to enable Samsung Cloud Print, you can manage the printer remotely through SyncThru™ Web Service. Open up your browser and connect using these details. You will see this page if everything have been set up correctly.

Login : admin
Password: sec00000


This Week I Learned - 2017 Week 09

Last week post or the whole series.

Medical checkup. Enough said.

#1 Geek Career Paths. Or should I just rephrase it as where does old grumpy programmer goes? Tim Bray shares his experiences and explores different different career paths for a technical person. There is one thing missing from the list, being a teacher, especially when come to tech-related stuff. Something which I found surprisingly fulfilling and engaging, putting aside some idiocy office politics.

#2 Why we use 32768 KHz crystals? The MSP430G2 LaunchPad came with a 32k-Hz crystals. Unfortunately, you will need to solder it manually yourself. What is a crystal (think salt) or cyrstal oscillator? Basically a electronic component used generate consistent time.


While we're at electronic, there exists a type of clock which is powered by electric and the accuracy is determined by utility frequency of 50 or 60 Hz.

#6 Design Patterns revisit. The main purpose of any pattern book is to have a common vocabulary of how things are organized. After so many years, some patterns are still not built into the programming languages. Good examples are:
// Unit of work, commits changes before the reference gets removed from stack
public unit CustomerForm { } 

// There can be only one.
public singleton DatabaseConnectionHighlander {}

// Any method called updates values in some way
public builder QueryString {}

#7 What Happens to Your Body on a Thru-Hike (via HN). Most important blogpost I've read so far when come to health. Walk as much as possible, especially after meals may increase your metabolic efficiency. Cut down those refined carbs as well. Before you start any plan to keep yourself healthy, you must measure before you can improve. Knowing what to measure and where you stands is half the effort for healthy lifestyle. List of items to measure are:

Body Mass Index (BMI). To determine your body fat which directly indicates whether you are obese or not. Measure yourself.

Resting Heart Rate (RHR). Measurement is quite easy and you do not need special equipment, just two fingers and a timer. First, locate your pulse. You can sense this at your wrist, side of the neck, inside of elbow, or top of the foot. Then, place index and middle fingers on these areas. Count the number of beats over 30 seconds and double that figure. Similarly, count the beats by 15 seconds and multiple by 4 to get the heart rate per minutes. Do this while resting (after you've wake up in the morning) and log the counts for several times per week.

What does this RHR indicates? It shows physical fitness. RHR is the number of times within a minute for your heart to pump all the blood to your whole body. Figure within the range of 40 till 100 is considered as normal but if your RHR falls within the range of 80 till 100, chances of you getting cardiovascular disease is extremely high. Athlete will have lower RHR of 40. To lower your RHR, there is no other way than exercise.

Blood sugar. Hemoglobin A1c. For screening and diagnosis of diabetes or pre-diabetes.

Cortisol and Testosterone. Especially for a man, both hormones are highly influences to your health. We should striving for low Cortisol and high Testosterone level. Stress is linked to Cortisol level, the higher, the more stressful you are. Meanwhile, Testosterone defines, physically, what makes a man, man. For example, muscle development and your sex drive. I can't seems to find local

Metabolic efficiency. How efficient your body in burning carbs and fat? While it's more relevant for athlete involved with endurance sports, it's good to know how you can fully optimize your body energy usage. Check out Andrew Skurka's detail post on this.