Via HN. Explainshell, a simple website to explain the parameters of the console program What a absolute fantastic helpful tool. One of those how come I never thought of that idea. Very useful when you're following a step-by-step tutorial and too lazy to search the meaning of each parameters through man page. Very useful if you need to learn console program with arcane command line arguments like iptables, GNU/Linux kernel firewall.

Sample example (shown below) of using iptables to set up Network Address Translation (NAT) . I used to cut and paste each description into one whole page to print out the full documentation to read it. Now is just too convenient with this tool.
iptables -t nat -A POSTROUTING -s -o eth0 -j SNAT --to-source

How many calories do you need to burn daily to lose weight ?

Short answer for me : 1554.16

Step 1. Calculate your Basal Metabolic Rate (BMR), which is the calories you would burn just by lying on the bed all day. For my case, my BMR is 1711.8.

Step 2. Based on your BMR, determine the total daily energy need using Harris Benedict Equation based on your lifestyle. Unfortunately my current lifestyle is quite sedentary even with a Pedometer. Hence, the calculation as follows:

Calorie = BMR x 1.375
              = 1711.8 x 1.2
              = 2054.16

Step 3. To lose weight, for a start, just reduce your daily calorie by 500. Hence, total daily calories intake should be around 1554.16.

Off course, counting calories is cumbersome and demotivating as well. But is nice to have a baseline figure and you will slowly pay attention to the calorie count of any packages food.

Maybe I should just start with Keto (low carbs, moderate protein, and enough right fat) diet instead as I current weight is not moving anywhere.

Write like a Motherf*cker

No. Is not another provocative post by Zed Shaw. Instead is a post by Jonathan Chen of his on-going project to write everyday for a year starting from Aug 1 2013 till Aug 1 2014.

Is nice to found someone who is doing a similar goal as yours. However, he is way more discipline and a better writer than me. Nevertheless, truly inspiring.

If you've noticed, I have been uttering horseshit (something I learned from Jonathan post) since 8PM yesterday. Why? Just clearing all the pending bookmarks on my Chrome toolbar. I am starting to realize writing has become a medium for me to jot down my discovery, monitor my progress, clarify my thought, and off course, vent my fsckstration. Surely a good daily habit to have and continue to do so as well.


"A few points to note though: Tech people there are smart, educated, and very, very hard working. However the number one thing they all value is "efficiency", or rather: "the efficiency of getting things done". I've talked to people from Tencent, and one guy laughed at American companies approach of writing good, scalable, maintainable but very often over-engineered code. Over at Tencent they very often do whatever it takes to be first to market, and if needed to be, refactor everything 6 months down the road, and rinse wash repeat. It's the only approach that works for them in a hugely competitive market (also the largest one in the world). Company management wouldn't tolerate coding practices that very often serves no purpose other than to stroke the ego of senior software architects."
-- Cookingboy, emphasis added
When you're in a fast-growing competitive market with lots of talents and cheap labour, getting done fast is always preferable over get it done right. Given the options of fast, good, and cheap, and you can pick only two, everyone will go for fast and cheap.  Profitability always triumph over quality.

On a side note, Tencent, the mentioned company, is famously known  for the popular instant messenger QQ in mainland China.

Which Python Framework?

As I was revisiting Python again, I was wondering which Python web framework should I look into ? Denis Krienb├╝hl shared his experiences on using all four popular Python frameworks and which one to use. To expand a bit of his tl;dr; summary.

a) Flask.
Simple and one-page app like dashboard status.

b) Django.
Quick CRUD app with built-in authentication and administration. Opinionated.

c) Pyramid.
Similar to Django but less opinionated and has the flexibility of mixing different libraries.

d) Plone.
For Content Management System (CMS) only.

Maybe I should look into Flask instead of Bottle and Pyramid instead of Django. My friend, Kamal, recommended that I stick with PeeWee and Bootle.
"You will find your own ethical dilemmas in all parts of your lives, both personal and professional. We all have different desires and needs, but if we don't discover what we want from ourselves and what we stand for, we will live passively and unfulfilled. Sooner or later, we are all asked to compromise ourselves and the things we care about. We define ourselves by our actions. With each decision, we tell ourselves and the world who we are. Think about what you want out of this life, and recognize that there are many kinds of success."
"Creating a life that reflects your values and satisfies your soul is a rare achievement. In a culture that relentlessly promotes avarice and excess as the good life, a person happy doing his own work is usually considered an eccentric, if not a subversive. Ambition is only understood if it's to rise to the top of some imaginary ladder of success. Someone who takes an undemanding job because it affords him the time to pursue other interests and activities is considered a flake. A person who abandons a career in order to stay home and raise children is considered not to be living up to his potential-as if a job title and salary are the sole measure of human worth."
-- Bill Watterson, emphasis added
Found via Zen Pencils. Commencement speech given by the Bill Watterson of Calvin and Hobbes comic fame. Truthful, idealistic, and sad as well. One of the best I read so far. Still thinking about getting The Complete Calvin and Hobbes comic strip collection.

Midlife crisis or just midlife stressors?

Borrowing Money While Saving is Absurd

"First in any investment strategy it is far better to pay off any debt first. Borrowing money while saving is absurd because the interest you incur on your debt is always higher than the interest you receive on savings. And borrowing while playing the stock market is even worse. Given the recent new of most people's debt, I suspect reducing debt should be most peoples concern. This includes things like checking if your mortgage agreement allows you to pay off more than the minimum to finish the mortgage early."_
-- polymatter, emphasis added
His comment echo my sentiments exactly. Unless you have extra spare money, is pointless to put your money in any investment that yield lower return than your debt, especially your mortgage debt.

The only doable approach is to change your lifestyle and live like a student regardless how much you earn. Still working towards a minimalist lifestyle and get rid of any unnecessary stuff. Is time to continue back taking my home inventory of my possessions. Not fun realize that you've became a hoarder.

Hopefully I can complete all this in coming September.

Greatest N per Group SQL Problem

Few days back, I encountered a problem where I need to find the last update date for a pricing and I seemed to stuck at the SQL query. Initially I was thinking about using subquery, an old habit of using PostgreSQL for many years. But as you know, this going to be tricky as MySQL is always kind of dog slow at subquery.

Some googling lead me to this simple answer that I realized I had over-analyzed the problem. The question was so common that the Stack Overflow community created a special greatest-n-per-group tag for it.

Let's illustrate this with an example. Imagine you have a employee table with a schema as follows:
- emp_id
- dept
- salary

How do you find the highest paid employee in each department ? The answer was so simple, just use MAX and GROUP BY. The answer in SQL as shown which is so generic and should works with any database system without any optimization.
SELECT emp_id, MAX(salary)
FROM employee

Yes, that all. No complex subquery or joins. Duh ! What was I thinking ?

Cost of Living, Money, and Budgeting

Via HN. Interesting data on cost of living in Kuala Lumpur, Malaysia. While the data still cannot accurately reflect the the exact cost (example is renting a room instead of an apartment), the figure are good enough to serve as a baseline for budgeting.

On a related note, due to a bizarre incident at workplace, I had a long discussion with Mrs Hippo regarding our current financial situation and goals, both short-term and long-term. Different financial personalities, if not handled carefully, can be a relationship wrecker. Especially when one partner is an investor/spender and another a debtor.

The funny thing I noticed, when comes to money, the more you earn, the more you spend. Is like alternative version of Parkinson's Law, "Money spent so as to use the cash available for its fulfillment." Why so ? Lack of awareness. If you don't keep a budget, keep track, and monitor your spending, surely by the end of the month, you must be wondering where have all your money gone to?

How should we solve this? First, create awareness. How ? Develop a daily habit of tracking your spending. As the old saying, "You can't optimize what you can't measure". Start tracking your daily spending in any possible forms (electronic or pen and paper). The moment you spend on something, just jot it down. No blame and no judgement.

While you're doing that, unless necessary, start paying with cash instead of credit card. Having a plastic card change my spending habit. We started to eat out more and buy more unnecessary stuff impulsively (books, books, and books). For me, credit card should be used solely for one reason. Emergency. Example is making initial payment before admitting to hospital.

Once you develop that habit, you will start to spend less. While spending less money is the opposite of earning more money, both achieve the same result, your financial well-being. Having aware of your spending, you can start budgeting and if possible, automate your money allocation. After that, when you feel to be in control of your financial situation, start spending your extra money the right way to seek happiness.

My past experience has shown that is easy to create awareness but damn hard to sustain the habit. Change is always painful and is our tendency to avoid pain. Better suffer now rather than later. I foresee our economic is going downhill and the cost of living is rising in this coming years. Life is going to be tough, especially at my gaining age.

Learning Plan

Via HN. Overwhelmed rather irrelevant. So many new programming languages to catch up and learn. Between Scala, Clojure, Node.js, Go, and Rust, is either node.js or Go for me.

Why these two ? Node.js because I was never into Javascript (too gimmicky and non-essential) and Node Packaged Modules (NPM). Image the fun exploring new unknown packages every day? For Go. Simple. Every programmer should at least master one system level static type language in their programming career.

Or maybe something different? Instead of #learning another programming language, why not focus on the fundamental like algorithm? Enrolled in few online courses but never quite find the time to finish. The lack of self-control, depleting willpower, and diminished motivation issue. I will talk about this in future post.

Going to make a hard decision in coming week, better start planning my learning plan for the remaining of 2013.

Total Steps Walked From 11-08-2013 Till 20-08-2013

The worst possible week since I started walking deliberately a few months back. Getting lazy and can't bother with it anymore. Showing sign of decreasing motivation. Need to get myself a small portable MP3 player so it can encourage me to move my lazy arse and start walking more again.

1. Forget the jot down my daily walking steps. My pedometer only can record the last 7 days. Hence, no record what so ever. Not a good sign.

2. Weekend. Lazy and don't feels like moving. Also is Hungry Ghost month, elders at home kept nagging me not to go out walking alone at night. Also was distracted by certain health issue and busy watching and reading Attack on Titan.

Clarify Thoughts Through Writing

"Once you begin to find a mode of writing that strikes you as interesting, you can begin to almost go out looking for things to write ABOUT, and that leads to very very very interesting discoveries about people, yourself, your friends, human characteristics/ behaviors, and the world in general.
Writing can be a gateway to understanding the world better, and if done correctly, the world may understand you better."
-- naregian, fellow redditor, emphasis added
Also, a way to clarify your thoughts and express your self. Especially on conveying your thoughts or feelings in #writing . Still struggling with word choices due to my limited vocabulary. But the gap is gradually shorten (slowly but surely) since I started writing few months back.

Current approach is trying to develop a daily habit of writing of 100 words (which I still fail to do so). I am going for consistency in quantity and not quality. For writing style, use simple English with short sentences and a mentality of of writing to inform rather than to impress.

I am wondering, by next year, what will happen to me if I manage to make writing my daily habit?

Startup Lessons

Via HN. While I am not working in a startup, totally agree with the development lessons 45 - 53. Firm believer in weekly development sprint. The advantages of adhering to a weekly development and release cycle are shorter feedback time and breaking down of bigger tasks into smaller and manageable chunk.

How I wish I can introduce this into my personal life and projects. Tried a few times but failed miserably. Time is running up and age is catching up on me.

Interesting Command Line Option

Via HN. Show Bibtex entry from GNU Parallel. One of the weirdest command line option I ever encounter.
$ parallel --bibtex
 title = {GNU Parallel - The Command-Line Power Tool},
 author = {O. Tange},
 address = {Frederiksberg, Denmark},
 journal = {;login: The USENIX Magazine},
 month = {Feb},
 number = {1},
 volume = {36},
 url = {http://www.gnu.org/s/parallel},
 year = {2011},
 pages = {42-47}

Total Steps Walked Between 01/08/13 and 10/08/13

Start to increase my daily walking steps in August as I don't feels any pains on my right heel. Anytime I feels any discomfort or pain, I will immediately stop walking.

1. 13110 steps. Highest until now. It has been a while since I last hit 13k. Most are from window shopping with family trying to find a XXXL-size jacket. Something I learned the whole day, when comes to jacket, no differences in pricing between a branded and non-branded.

2. 1349 steps. Was down with recurrence of old sickness (not related to walking), barely can move at all. I've learned my lesson last month. Rest to the fullest if you ever over strain yourself in previous day.

3. 10353 steps. Another day that hit the 10k threshold. Felt good but I think I need to replace my beloved New Balance Minimus Zero with something similar but with more cushion.

Interesting month indeed. Hope to slowly build up my strength before I really start to run. 

Breach SSL Attack

A way better write-up of BREACH SSL attack with details explanation and example. Can I safely assumed that as long as you're randomizing your Cross-site Request Forgery (CSRF) token, your web application should be safe?

Quickest Mitigation to BREACH Attack

Before that, the best explanation I read so far on BREACH attack. To quote from Wikipedia,
"A BREACH attack can extract login tokens, email addresses or other sensitive information from TLS encrypted web traffic in as little as 30 seconds (depending on the number of bytes to be extracted), provided the attacker tricks the victim into visiting a malicious web link."
Maybe is just me but way better explained that the official disclosure. Reluctantly (since performance will be affected), I've opted the most effective mitigation method by disabling HTTP-compression at server side. Example given here is running on #Apache 2.2.22 in Ubuntu 13.04.

1. Check our Apache web server version.
$ apache2 -v
Server version: Apache/2.2.22 (Ubuntu)
Server built:   Jul 12 2013 13:18:14

2. Check if the dynamic module deflate is enabled.
$ sudo apachectl -t -D DUMP_MODULES | grep deflate
 deflate_module (shared)
Syntax OK

3. Double-confirm that the web server is sending compressed content to the client. We're using curl HTTP client. Look for Content-Encoding header field in the HTTP response returned from the web server.
$ curl -I -k --compress https://localhost
HTTP/1.1 200 OK
Date: Wed, 07 Aug 2013 16:36:35 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.9-4ubuntu2.2
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 20
Content-Type: text/html

4. Disable mod_deflate and restart the web server again.
$ sudo a2dismod deflate
Module deflate disabled.
To activate the new configuration, you need to run:
  service apache2 restart

$ service apache2 restart

5. Recheck the HTTP response Content-Encoding header. It should be missing from the result returned.
$ curl -I -k --compress https://localhost
HTTP/1.1 200 OK
Date: Wed, 07 Aug 2013 16:42:53 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.9-4ubuntu2.2
Content-Type: text/html

George Saunders On Editing.

George Saunders on editing process. Interesting exaggerated example given.

1. Bob came happily to the room and sat down on the blue couch.
2. Bob came happily to the room and sat on the blue couch.
3. Bob sat on the blue couch.
4. Bob sat on the couch.
5. Bob.

Will try to buy his latest book, Tenth of December : Stories tomorrow at the KLCC book fair. Even though the review I read were quite mixed but I really love his short, simple, and minimalist writing style. Hopefully I can gain something from reading this book.

Total Steps Walked on Week 31 2013

For this coming August, I need to increase my total daily walking steps compare to July. Instead of hitting 10k steps in one session, break it down into more smaller sessions and do it in different interval. Once I hit a 10k daily goal, take a break the next following. You do not need to walk 10k everyday. You body still need time to recover from all the wears and tears. Let's see how it goes. Looking forwards to August.

1. Lowest steps walked in the whole month, about 1535 steps. Was not feeling well and can't get a good sleep either. Due to injury, I've become less motivated and persistent (become more lazy) in walking more steps. This is worsen by starting to include more fast food to my daily diet as well.

2. Need to attend several events, hence a lot of walking here and there. My right feet didn't feel that weird anymore which was a good sign that I was slowly recovered from Plantar Fasciitis.