Saturday, December 31, 2011

My first domain

Finally, I got my domain: russoue.com. At the time of this writing a web server is running there with a pretty bland welcome page: http://www.russoue.com. I am using a AWS EC2 Micro Instance, which is free for one year, as the server. I am thinking to have my own mail server there. I can't do anything heavy with the micro instance I guess. I am still thinking how I can use the server with its limited resources.

Thursday, November 10, 2011

C/C++ going stronger than what people think

TIOBE published their programming language index for November, 2011 today and as per the usual trend Java, C and C++ are the top three programming languages. I am surprised to see that even after becoming old compared to many of the widely used programming languages, C and C++ are still holding their spots. I am particularly happy to see those three languages at the top because those are also my top three favorite languages. I would be happy to see Python and Ruby doing better. Here is the graph on long term trends on top ten programming languages from that site:


Link: http://www.tiobe.com/content/paperinfo/tpci/images/tpci_trends.png

Wednesday, November 09, 2011

Development model using Git branching

I just read the awesome post on a Git branching model for software development. Thanks Naseem bhai for sharing the link with me. Git is my most favorite SCM tool. I think I am going to use the model for all personal projects. The author of the blog made his points by providing very clear examples. It is surely worthwhile to read it.

Thursday, October 20, 2011

Quick and easy way to split lots of strings in Java

Recently, I had to split strings in a method which would be called potentially couple of billion times. The strings were delimited by only one character e.g. '#'. To be as efficient as possible, I just used String.indexOf(delimiter) and then String.substring(i, j) to get the splits. For this case, I think this certainly is the most efficient solution because the String.substring() method does not allocate new memory, it just returns a new String object which has some meta information to get the string from the original string's buffer (this is a nice optimization but it has its own pitfall). I was happy with it but the code looked messy with all those String.indexOf() calls and lots of index maintenance. Upon getting a review from a colleague I looked for ways to make it look better and easier to maintain. I found couple of alternatives to do the this:

1. StringTokenizer
2. Scanner
3. String.split

StringTokenizer had to be discarded immediately as it is getting old and is only there for backward compatibility. The Javadoc itself says, "StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code." The Scanner is a great utility but seems to be bit heavy for that method. I had to keep in mind that the method would be called potentially billions of times in a row and it has to be as quick as possible. This left me with only the last option. String.split works in a simple way. It returns an array of strings. So, I could just use something like this:

String splits [] = str.split("#");
for (String split : splits) {
    // Do something ...
}

However, as noted here, there is a performance issue with this. Each String.split() call compiles a regular expression pattern and then uses the pattern to split the string. The pattern compilation is indeed very expensive and can slow the method down significantly. So, essentially what the String.split() method does is this:

public String[] split(String regex) {
     return Pattern.compile(regex).split(this);
}

By looking at the implementation, it becomes immediately obvious what one can do if lots of strings need to be split by the same regular expression. One can just have a pre-compiled pattern and call its split method repeatedly:

Patter pattern = Pattern.compile(regex);
...
for (String str : strings) {
    String splits [] = pattern.split(str);
    // Do something with the splits ...
}


The only thing unknown to me is whether the returned strings allocate new memory or the Pattern.split() method just behaves as String.substring(). But from running the code with more than 2.5 billion strings, I did not see any performance difference between the old and the new approach. It might mean that copies of strings are actually not made.

Tuesday, October 11, 2011

Netflix does not support Linux!

After getting annoyed by Netflix because of its recent dramas, I got pissed off today to see it does not support Linux. Its a shame for a new tech company like Netflix to not support a popular Linux distro like Ubuntu. May be the number of users is small compared to other OS users, but in this world of open source and open standards supporting Ubuntu is just a gesture of goodwill. I would say that the disliking that started to grow in me after the price hike just got bigger after discovering this.

Friday, August 12, 2011

A tortured choice in famine: Which child lives?

I read the story here. I think this is the most horrific story I have ever read. I can't imagine that a parent is forced to make a choice to abandon his/her child to die but this is what is happening in this world right now. Can't we do something about it? Surely we can. There are many organizations working in that area trying to help the famine affected people. We can donate some money to them, no matter how small the amount is. This page contains a list of charity organizations working on the problem. One can also donate to UNICEF. Islamic Relief is also taking donations. I am sure there are more organizations trying to help those people. All we need to do is to make up our mind to donate at least a small amount. I think the problem can be easily fixed if only a fraction of us donate some money. This is our chance to have a big impact on someone's life by making a very little effort.


Wednesday, August 03, 2011

My Review of Roku 2 XS Streaming Player

Originally submitted at Roku

Adds an enhanced remote for playing games, plus extra connectivity options.


Roku rocks!

By Rusho from Bellevue, WA on 8/2/2011

 

5out of 5

Pros: Easy to use, High quality picture, Great value, Reliability, Compact, Built in Wi-Fi

Cons: Want more video choices, Set up bugs

Best Uses: Living room

Describe Yourself: Power User, Netflix fan, Technophile

I bought Roku one week ago and I am absolutely enjoying it. The picture quality is superb. However, I faced few minor problems though, most of them during installation. While I was setting up my Wi-Fi connection, it hanged in the third step (connecing to Internet) and I needed to restart it. After I restarted it, it failed to connect to my Wi-Fi at first and said that the password is wrong. I found the password to be correct and tried once more without changing any thing and it worked fine. Since then I am facing no problem with connectivity. The only problem I am having persistently is with the Picasa application. It cannot show any photo though it can show the albums with their covers showing correctly.

Overall, I am very satisfied with my purchase.

(legalese)

Tuesday, July 26, 2011

Eclipse Color Themes Plugin

I was annoyed when I installed a color theme which I did not like. But there was no way to go back to the default theme because the theme made itself the default one! However, I came across the Eclipse Color Themes site. It has a good collection of decent themes. However, to try one you need to download the theme and then import and apply it. This is a painful process unless you install their cool color theme plugin. It is very easy to use and come pre-populated with the themes found in the site. You can import more and switch between the themes very easily. It is really worth giving a try.

Wednesday, July 20, 2011

Finance minister justifies his purchase decision with a sound logic!

The finance minister of Bangladesh announced that he is going to buy some buses with the aid money got from India last year. It should sound like a good news to me. However, I am not sure if it is anything to be happy about. Here is why:

He wants to buy the buses from India and what he says about the decision is, "We could have bought them from other places, but since we're getting the credit from India, we should bring them from India". Is this a logic we want to hear from a finance minister? In today's world, purchase decisions are made not to express gratitude. We should get the best buses the money can buy. If those buses happen to be produced by India then it is fine. There can be one more reason to buy it from India even if they are not the best ones, that is if it is a condition specified in the loan agreement. For no other reason we can choose India as a source for the buses, let alone gratitude. I wonder how this guy qualifies to be our finance minister. The other day I was reading a news about him blabbering that we are going to compete with world economic powers like India and China soon. The commentators on the Prothom Alo page did not like that. I did not take it seriously then. But now I think this guy truly is an incompetent finance minister. Had Bangladesh been a developed democratic country, this guy would have lost his position for these reason. But all we can do is to pray to Allah to save us from incompetent ministers like him.

Thursday, June 30, 2011

Navigation between Vim tabs

I like working with tabs in Vim. It is a quite handy feature. But the navigation between tabs is not easy. It requires to be in command mode and type commands. It is certainly not a quick way and specially if you are jumping between tabs frequently you will soon get tired typing the commands. So I mapped the F7 and F8 keys to go to previous and next tabs respectively. Basically one can map any two keys of his choice to do that. Here is what I added in my vimrc file:

map <F7> :tabp<Enter>
map <F8> :tabn<Enter>
imap <F7> <Esc>:tabp<Enter>
imap <F8> <Esc>:tabn<Enter>

I used both map and imap commands because one works in Ubuntu Linux but not when I use iTerm in Mac OS X and vice versa.

Friday, June 24, 2011

Type 2 diabetes can be reversed at early stage!

I am very excited to know that type 2 diabetes can be reversed at early stage and that too with an inexpensive method: controlled diet! A recent research revealed that. Great works researchers! I hope they will find a cure for old patients too. I hate diabetes because, as the article say, it is a life sentence. I would very much like to see this change. If controlled diet is the cure then it is the best solution that can ever be found. Not only will it cure millions of diabetic people but also it will reduce our habit of overeating and wasting food. The poor and starved people will be directly or indirectly benefited by that. The world would be a better place.

Monday, April 11, 2011

Problem with বাংলা font in Firefox 4

I was excited when Firefox 4 was released. I have used three of their released candidates and found lots of bugs. However, they did a great job of fixing all the bugs before the release. But one thing disappointed me a lot: improper display of বাংলা script. I frequently visit sites like প্রথম আলো, সচলায়তন etc. and write বাংলা in Gmail and Facebook. বাংলা script appeared in distorted form everywhere. The problem was partially solved when I downloaded the SolaimanLipi font from here. বাংলা in প্রথম আলো immediately began to be displayed correctly. However, problems with the rest of the sites were unresolved. Then I solved the problem by changing the default font to SolaimanLipi by going to Options -> Content -> Fonts & Colors -> Advanced. I selected "Bengali" in the "Fonts for" drop-down box. I selected SolaimanLipi for both Serif and Sans-serif. I hope this might solve problems faced by others too.

Sunday, February 13, 2011

A quiz

Quiz: which processor overheats and shuts down the whole machine when a processor intensive program runs?
Ans: AMD (what else can it be?)

Previously, I could not play videos long enough because my AMD laptop would shut itself down because of overheating. Yesterday, I found that I cannot even do format conversion of videos. Both the task has one thing in common: intensive computation by CPU and that is what a process is supposed to do and be good at. But I learnt now that an AMD processor is no good at these tasks. It generates so much heat that I felt an egg can be boiled easily. I bought a lapinator one month ago but it is not helping at all. I guess I have to buy a portable A/C to be permanently attached to the processor and then only I can do something other than word processing with this machine. I am waiting for the day when I would be able to replace this laptop.