Rubocop + vim

Rubocop + vim

Code linters such as Rubocop ensure consistent, clean code throughout your application. If all developers are using the same linter configuration, then you can be sure that any code that you encounter is organized in the same way regardless of the author.

One challenge in using linters is that it should have immediate feedback, or else it may disrupt the coding flow of the user. For example, you can run the linter manually after you make your changes, but as this is a manual process it can be easily forgotten.

Commit Hooks

To solve this, we can use pre-commit hooks (such as in git) to automatically run the linter script whenever we try to commit our changes. In this manner, it is an automated process and so will not be skipped in development.

For example, here is a git pre-commit hook for Rubocop (from
https://gist.github.com/mpeteuil/6147292 and
https://github.com/grosser/dotfiles/pull/7 )

#!/usr/bin/env ruby
#
# put this file into your path and use `<file> install` to add a new hook
# or use it as a binary to check changed files

require 'shellwords'

if ARGV == ["install"]
exec "ln", "-sf", __FILE__, ".git/hooks/pre-commit"
else
raise unless ARGV == []
end

changed = `git status --porcelain`.
split("\n").
map { |l| l.split(" ", 2) }.
select { |status, _| ["A", "AM", "M"].include?(status) }.
map { |_, file| file.delete('"') }

exit if changed.empty?

result = `bundle exec rubocop --force-exclusion #{changed.shelljoin}`
puts result unless $?.success?
exit $?.exitstatus read more

Why Boxing?

Why Boxing?

I admit, I am not a very active person. I would rather read a book or play a game than take a walk outside. But I have a “hobby” that I was doing for years now: boxing. Even though I don’t have other physical activities, boxing helps me to keep a reasonably healthy body.

So what do I like about boxing?

You are on the same ground as the greatest

What I mean is: you have the same basic equipment as the all-time greats. All boxers started with the same equipment and the same routine that you are doing in the gym.

Wherever you go, every boxing gym has these three tools: the speed ball, the double end, and the punching bag. read more

Smelting Yourself

Smelting Yourself

While driving towards home with my family, my younger sister asked me (to make sure I don’t fall asleep), “What is your New Year’s Resolution?“. I paused to think, then replied “I don’t have one and don’t believe in it“.

Explaining further, I told her that changing ourselves should not be tied to a specific date or time. We can start changing ourselves the moment we determine that it is the best course of action.

I do understand the logic behind New Year’s Resolutions: the new number on your calendar is a daily reminder of the things you promised yourself at the start of the year. However, if you find yourself procrastinating on those changes and saying, “I’ll just wait until the new year comes around”, then that is not a good habit. read more

The Way to Wealth

The Way to Wealth

Benjamin Franklin is not only an American patriot, but his writings are also influential in the personal finance space. His annual journal called the Poor Richard’s Almanack contains gems on how to manage money and how to build your wealth. He summarized it in his essay in 1758 called The Way to Wealth. Here, I will highlight some of the items in his essay that resonated with me and helped me in my financial journey.

“Friends,” said he, “the taxes are indeed very heavy, and, if those laid on by the government were the only ones we had to pay, we might more easily discharge them; but we have many others, and much more grievous to some of us. read more

“Nini Ke”

“Nini Ke”

“Mommy, Daddy has a new car“, my daughter said as the new car went in our garage. Our old green car, a 2000 model Ford sedan, was left outside the gate as we only have the space for one car.

When my daughter was only learning to speak, her word for green was “nini” and her word for car is “ke“. So she calls our green car “nini ke“.

First car

We bought green car a few months before my wife and I were married. The owner was living in the same condominium building that we were renting at that time. Originally I planned to buy a second-hand Honda or a Toyota, and I was not really impressed when I first saw the Ford sedan. My wife liked it though and so we decided to buy it.

It has been our primary mode of transport through the years. My sister borrowed it after our wedding to go to the province. When my wife got pregnant, green car was there for every doctor’s appointment. When it was time to deliver my daughter, green car was also there.

My daughter grew up knowing that green car was our car.

I didn’t expect my 4-year old daughter, or my wife, to be very emotional once the reality loomed that our old car is going away. Our garage only has space for one car and we will not have the time or the money to maintain another one. We decided that we will only sell it to a relative or a close friend so we know that green car will be taken care of.

Memories

We have been with green car for 6 years, and has made some memorable events with us.

I have only learned how to drive a few months before we bought green car, and I have used it to fetch my wife to and from work. Combined with having to park daily on a multi-level single lane parking space, it forced me to increase my driving skills.

First (and only) parking mishap

One evening while parking (backing), the rear side of the car scratched the parking column resulting in large scratches. Since then, no other parking mishaps happened thankfully.

First traffic violation

One day while going to the hospital for a doctor’s appointment, I made an illegal turn on a left turn lane and got apprehended by a traffic enforcer. Since my wife is expecting, I said that my wife is about to give birth (which she did one week later). The enforcers let us go without any fuss.

First provincial trip

On our way back home from the province, there was a funeral march in the provincial road which caused very slow traffic. It forced me to level up my clutch and gear skills as not to stall on the hilly road. I had trouble learning those skills while on driving school.

Beach accident

En route to a beach resort, I made a wrong turn on the wrong resort, resulting in my front wheels being stuck in the sand. I tried everything but the car won’t move and it dug the wheels deeper in the sand. Thankfully some kind locals helped me by digging the sand around the wheel and putting water on it so it becomes compact.

Flood

Going home, I saw that the road was gutter-deep in flood. I made a risky decision to go through it. Thankfully the car didn’t stall but the next day I was not able to start the engine. It did start after a few tries though and didn’t have any long-term damage.

Screw in tire

While driving in the province I heard a loud noise from one of the rear wheels. I continued driving for a few kilometers before I was stopped by a motorcycle driver informing me that I was driving flat. Later we found that a screw has embedded itself in the tire. Thankfully no one was hurt and no damage was done on the wheel assembly.

Moving On

They say that a car is like a family member, which is true from my experience. I spend at least an hour washing the car which also serves as my meditation for the day. We made sure the car is maintained at least once a year, replacing any old or worn out parts.

When green car moved away from our home for the last time, it felt like losing a beloved pet. It was hard, but knowing that the new owners appreciated it made it better. Thank you for your service, nini ke!