Search This Blog

Loading...

March 26, 2015

Blocks not Parameters for logging debug information in Ruby

Okay, it really matters if you've got to log your debug information that is more than a plain dumb string without any concatenation.

Let's take our typical habit of writing a debug like below:
logger.debug("This is a " + potentially + " expensive operation")

The above snippet could be better written as below:
logger.debug { "This is a " + potentially + " expensive operation" }

The block form is recommended because the code in the block is evaluated only if the debug log is to be written/logged. 

Reference:
[Ruby Doc] How to log a message?

March 9, 2015

The Bad Developer

"Discipline.. do I look I care?"
It takes one rotten apple to spoil the entire cart of A-grade apples. And it takes one, just one #BadDeveloper to spoil the spirit and works of the entire team and hurt the project beyond anybody's imagination - no pun intended here. It thus becomes imperative to quickly identify the behavioural traits of the #BadDeveloper to save the team, project and the business from sinking.

Here is a quick list of How-To(s) to find out the #BadDeveloper (or the rotten apple in your development team). How to deal with him is for the other post. How to identify him in your team is the focus of this post.

By the way, the list in not comprehensive and I'd appreciate your participation in growing the list by commenting your experience in the comment section of this post. It helps and indeed matters!

February 14, 2015

How to check whether a string contains a substring in Ruby?

Typically, one would expect (at least I end-up trying this first, almost everytime) a method by name contains? to be available for use. Unfortunately, it isn't present.

February 1, 2015

Repair Homebrew Permissions after installing as root

If you have run brew as root or with sudo prefix, later updates to brew fail to change the git versioning. Additionally, the directory permissions to /usr/local and /Library/Caches/Homebrew gets restricted to root only.

To correct this all you need is execute the below command in your terminal:

# Reset the permissions of /usr/local and Homebrew's caches to the current user:
          $ sudo chown -R $USER:admin /usr/local /Library/Caches/Homebrew          

You now should have got your freedom back ;)

September 15, 2014

Prune Run Configuration Meta-data in Eclipse

Sometimes Eclipse IDE fails to clear or prune stale meta-data. One such instance that you'd come across is the stale run configuration for an (Android) application.