Had I been in Voyager 1!!!
I am Mohammad Farhan Husain, a Bangladeshi American. This is all about my day-to-day life and opinions.
Monday, July 12, 2021
Are blogs still popular?
Saturday, August 02, 2014
A simple Rust `pow` function for the built-in numeric types
While playing with Rust I wrote a simple pow
function:
fn pow<T: Num + FromPrimitive + Copy>(a: T, mut b: uint) -> T {
if b == 0 {
return FromPrimitive::from_int(1)
.expect("1 must be convertible to type of a");
}
let mut m: T = a;
b -= 1;
while b != 0 {
m = m * a;
b -= 1;
}
return m;
}
Here is a link to the playpen where you can test it out: http://is.gd/JBWtVf
Sunday, July 29, 2012
Installed Jelly Bean on my Nexus S
The Jelly Bean (Android 4.1.1) factory image was released by Google very recently. I did not want to wait any long this time. AT&T still did not push the ICS update, so nothing to expect from them. I went ahead and followed the same procedure I went through last time to install ICS. So far it seems like Jelly Bean is indeed faster than ICS. Right after the phone rebooted itself Google Play Store was downloading some 30+ apps I had before and I was browsing, setting up my exchange email account and synching it at the same time. I did not experience any significant lag even though such a large job was going on in the background, something unthinkable with Android before. I am certainly happy with the update but it still has to go a long way to match the instant reaction feel iOS gives to the user for any UI event. It is good to see that they finally started to address the issue.
Sunday, July 22, 2012
Blog composed by Ecto
Today I was trying to find a good desktop blog editor for Mac. I used Windows Live Editor few years back and found it to be very good at editing blogs. Not only that I don't use Windows any more but also Microsoft discontinued it. I found a long list of such editors by Hongkiat Lim. I tried QTM but it failed to connect to my blogger account. I tried Qumana, it failed to authenticate too. Then I tried ScribeFire for Firefox but to no avail. At this point I was wondering if my account is blocked or I forgot my credentials. However, I gave a chance to Ecto and voila it could connect. I will continue to use it for some time to see if it is worth to buy it.
Friday, June 22, 2012
Tree command in Mac
find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
I just created an alias in my bashrc file and enjoying it :)
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
Tuesday, May 22, 2012
How to install Android 4.0.4 on Google Nexus S
Thursday, February 23, 2012
Temporary fix for SSH broken pipe error with Mac OS X Lion
There is a lot of discussion going on in the web on how to fix this problem. I tried a few but none of them worked. Eventually I added an alias to my ".bash_profile" file:
This seems to be working for now.
Thursday, January 19, 2012
A hadith we should take to heart but we won't
Rasul Allah (sal Allahu alaihi wa sallam) once sent somebody to collect zakat from a certain region. When the man returned he handed some of the zakat over and kept some for himself saying that he had received it as a gift from the people. Allah’s Apostle then ascended his pulpit and addressed everybody. In it he said: “I employ some men from among you for some job which Allah has placed in my charge, and then one of you comes to me and says, ‘This (amount) is for you and this is a gift given to me.’ Why doesn't he stay at the house of his father or the house of his mother and see whether he is given gifts. By Allah whoever takes anything unlawfully will bring it on the Day of Resurrection by carrying it over his neck.” [Bukhari]
Giving or taking bribes is at the root of corruption. Islam clearly states that both the giver and the receiver of a bribe end up in Jahannum (Hell). But how is one to recognize that he or she is involved in this practice? In this hadith, Rasul Allah (sal Allahu alaihi wa sallam) describes a simple test that each person can perform to check themselves, when receiving favours while serving in a particular position. They should ask themselves whether what they receive is something they would be ‘gifted’ had they been sitting at home, i.e. not serving in that position. If the “gift” you receive is because of your office, so that you can use your position to do the gift-giver a favour, then this is a misuse of authority.
(Source: http://wayoflife-islam.com, 18 January 2012 CE | 23 Safar 1433 AH)
If at least 10% of our government officials learn anything from the hadith and practice in real life, our country will start to see dramatic changes. But the question is, would anyone do it?
Saturday, December 31, 2011
My first domain
Saturday, November 19, 2011
My Kindle Fire review
Thursday, November 10, 2011
C/C++ going stronger than what people think
Link: http://www.tiobe.com/content/paperinfo/tpci/images/tpci_trends.png
Wednesday, November 09, 2011
Development model using Git branching
Thursday, October 20, 2011
Quick and easy way to split lots of strings in Java
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:
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!
Friday, August 12, 2011
A tortured choice in famine: Which child lives?
Wednesday, August 03, 2011
My Review of Roku 2 XS Streaming Player
Adds an enhanced remote for playing games, plus extra connectivity options.
Roku rocks!
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
Wednesday, July 20, 2011
Finance minister justifies his purchase decision with a sound logic!
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
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!
Thursday, June 23, 2011
Monday, April 11, 2011
Problem with বাংলা font in Firefox 4
Sunday, February 13, 2011
A quiz
Thursday, December 23, 2010
Dissatisfied with AMD laptop
Thursday, November 18, 2010
A potential game changer medicine
Thursday, October 21, 2010
Friday, September 17, 2010
How two horses plotted history
Tuesday, August 24, 2010
Equinox GTK theme with Faenza icons
Saturday, August 14, 2010
Halal status of lamb steak at Outback Steakhouse in the U.S.
Tuesday, July 20, 2010
Is Wind Power Green?
I did not know wind power is so abundant and that it can solve the renewable energy issue so easily. Though densely populated countries like Bangladesh might not be able to utilize it, countries having enough land to have them installed should go ahead and start exporting if they have redundant power. It would be a nice way to get rid of dependency on fossil fuel and will eventually bring more peace to the world :-).