hg commit count in a directory

Today I needed to find the number of commits per file in a directory. Doing that by going into each files’ mercurial log and counting manually is a incredibly boring chore. But, the following PowerShell script came to save my life:

If gist embed is not working above, click here.


Irony of language fondness

There is an irony about fondness of language in a programmer’s life. I am not very particular about any programming language, I can read and understand and code in quite a few of those. But, my affection is not same for every language I know, and there is the irony.
My favorite language is C++. It is one of the most powerful languages that we have in the industry. It is multi-paradigm and can be used to solve many, if not all, programming problems. Most importantly, to me, C++ sounds very sweet.
On the other hand, there is C#. It has a very strong affiliation with Microsoft and Windows platform and people are prejudiced about it. Nevertheless, it requires proprietary .Net framework to run on top of. Despite these, C# is an amazing language. Its creator had the opportunity to look back into a long history of many languages and decide very carefully from the experiences we had in last half century. So, C# ended up accommodating a plethora of language features, both in terms of capabilities and syntax. I am very fond of C#.
My current job requires me to program in Java. When, I was first introduced to Java when I was a sophomore I became very fond to it. But, then I learned about C# and C++’s wonders kept on unraveling to me. So, I distanced myself from Java, for more than four or five years, until my MS coursework required me into using it. Now, here is the irony! I started my new job here, in Long Island, and my day to day primary language is now Java. I kept rediscovering a lot of facts about Java, and I started to like it again. Specially, Java 8 brings a lot of things I’d like a high level programming language to have. I am learning new things everyday, and would keep learning about them.
So, the irony is, C++ is my favorite language, I admire C# and my primary language is turning out to be Java. Behold, that is not the end of it. I also have to know JavaScript and Python and PHP and happen to like all of them, more or less. And off course, all these languages have their own utilities.
In the end of the day, it occurs to me that, fondness of languages do not matter after all. Every languages have a lot of things to know about and I’d like to be fluent in at least one of them. I just don’t know which one it is going to be!

Originally posted as a Facebook Note. Continue reading

Setting up NODE_PATH for using global packages via require(…)

Node.js intends global install for applications only. If you want to use some package in your project via require('...') the recommended way is to put them in projects root. However, you may want some packages to install globally via npm install -g package and use them on your node projects. Then, you have to make sure you have the %NODE_PATH% system variable set up to point global node_modules directory, e.g.: %USERPROFILE%\AppData\Roaming\npm\node_modules for Windows 8.

Oh Facebook! plz serve me with better ad

There is an ongoing wave of discussion about Facebook privacy policy update. Apparently, people are more concerned about Facebook policies than Google’s policies while they should be more worried about Google’s.
Now, a lot of so called privacy advocates tell that corporations are selling “you” to make money. Now what is the premise here? Facebook, Google, Twitter etc tech companies are giving you services, quality services and you are not paying a penny. So how do you think they would pay for the cost to run those services?Advertisement is a good source of money for services like Facebook. They provide you with quality service without a charge but in a condition that you’d let them serve you ad. Now, do you want to see your Facebook home covered with tremendous amount of ads? I prefer to see much less but useful sweet ads.

How would they know which ad will be useful to you? They somehow have to infer what you like and what you might be interested in. That is why, they want to analyze your data and usage pattern. They are not going to a different company and giving up your private information to them. Rather, they curate from millions of ads to serve a few that might be of your interest.

Still, they are not super awesome at serving personalized ads. If you searched for a product ten days ago and already bought one, they still serve ads about same type of products. That is totally bad. I am not interested about those; and yet they are charging the seller for those ad impressions. I would rather, see a different product. If I bought a Nikon camera, don’t serve me with ad about a Sony; rather tell me about a tablet may be. Or about lenses at best.
So Facebook, if you can infer what I am buying next, please serve me with best deals out there.

Just another comment on Tablets

Today one of my friends was asking on Facebook, what are the utilities of Tablets? I commented what I thought about it, and here it follow:

Until Surface came, tablet was immature. Now, it is getting a shape and user base too. Here, at US, I see a lot of people using tablets. They have a certain, limited, but handy use case. First of all, tablet is light, weighs light and performance is low too. It is designed to be single app threaded (user will focus on one app at a time). You can use tablets while you are on the move, say attending a seminar, waiting somewhere or just not on our desk. Laptops are portable, but those ones which you can carry around with offer too small a view port (13″). They are relatively useless compared to their price range and weight.
If for only reading ebooks kindle (ink based) are best. But, tablets let you browse too.

With all these limited use cases, you can always be happy by having one tablet as your tertiary device, after your computer and phone. For tablets, I prefer Surface, probably Pro. Android tablets are still crappy (you need a great touch screen on tablets if you don’t get a real keyboard). Apple’s tablets are on per and could be best for most users.

I am currently settled with a mid weight, high performance laptop – which gives me most of the computation power I need, yet allowing me to carry it around if I have too.

Next, when I am going to change my setup, I’d like to have a full fledged desktop as primary device and a Surface Pro as on the fly device and probably a Nexus or something light as phone and no laptop.