Autovivification in Ruby

Recently, I came across a problem where I need to store values inside a nested Hash. The catch is, the keys within that Hash are unknown, and each key can also have a nested Hash within. In addition to that, the final value of this nested Hash is an Integer that needs to be accumulated.

In Ruby, we need to define the Hash keys first before we can get or modify the value. If you try and access a key that does not exist yet, it will return nil. When you try and access another key within that non-existent key, it raises an exception: Continue Reading

Don’t just consume, create!

Don’t just consume, create!

How do you usually spend your day?

You wake up on a weekday, annoyed at the alarm clock for reminding you once again to go to work. Phone in hand, you take a quick glance at social media to get the freshest news. After a quick breakfast, you prepare your things and head to work. To maximize your time commuting, you listen to your favorite podcast while in your car. Continue Reading

Rage against the dying of the light

Rage against the dying of the light

If there is one recognizable aphorism on how we should live our days to the fullest, it would be carpe diem. This is famously known to mean “seize the day”, but it is actually mistranslated. Its true meaning is closer to “gather while the day is ripe”.

This year has been hard for many of us. The pandemic brought widespread disruption in people’s lives by losing loved ones, layoffs, closed businesses, and isolation. Our family was not spared as well. This year I lost my sister to cancer. Several uncles and relatives passed away. This led me to think about the shortness of this life. Was gathering while the day is ripe enough? How can I even know if the day is ripe or not? Continue Reading

Managed investments are alright!

Managed investments are alright!

Why did you get that VUL? They are inefficient! Just buy Term Insurance and invest the difference!“. This was me years ago after I found out that a friend just purchased a Variable Universal Life Insurance from a big insurance company. I then went on a tirade about the insurance fees, agent commission, and managed fund expenses. I continued on about why it is a bad idea to mix insurance and investments.

Was I trying to help? My intentions were good: I wanted my friend to have the best insurance and investment set up. Paying unnecessary fees is a big no-no from my perspective. Continue Reading

Life Concepts

Life Concepts

As I add another digit to my life’s marker this month, sometimes I can’t help but look back and check to see if I have really grown worthy of my age. I found that through several trials and heartaches these past year, what helped me the most are the things I learned exploring and reading about personal philosophy.

These are some concepts that I find worthy of sharing to everyone. As they only touch the general idea behind each concept, I will leave it to the reader to decide whether they are ideas worth looking deeper into. Continue Reading