Showing posts with label Technology. Show all posts
Showing posts with label Technology. Show all posts

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.



Thursday, February 23, 2012

Temporary fix for SSH broken pipe error with Mac OS X Lion

I recently upgraded from Snow Leopard to Lion. Since then my ssh sessions are timing out pretty quickly with the following error:

Write failed: Broken pipe

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:

alias ssh='ssh -o TCPKeepAlive=no -o ServerAliveInterval=15'

This seems to be working for now.

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.

Sunday, May 02, 2010

My Ubuntu 10.04 Desktop

Canonical has done a great job on Ubuntu 10.04. I love the theme and the start up time is really as short as they have touted. Here is my Ubuntu desktop with the default wallpaper:

Friday, April 02, 2010

Vrapper

Back in 2003 I had to write code in Linux for the first time in my life. For some reason I could not get the GUI running so I had to find an editor which works in text user interface. Immediately, I found the two most famous editors for Unix: Emacs and Vi. Vi seemed to be hard to grasp at that time. I did not get the idea of having two modes: the command mode and the insert mode. So I quickly decided to use Emacs which was much easier to learn. However, last summer I decided to give Vim a try. After using it for couple of days I started to like it and eventually it became my most favorite editor for coding. I was so habituated to using Vim that while working in Eclipse I subconsciously tried to use the Vim commands. Recently, I thought that given the huge number of Vim fans in the software developer community, there must be one or two projects on combining the power of Eclipse and Vim together and yes, I was right. I found several projects working on the idea:
  1. VimPlugin
  2. Eclim
  3. Vrapper
I tried VimPlugin. You need to have gVim installed in your system to make it work. It provides a fully working Vim editor in Eclipse. However, it misses the powerful auto-completion feature and other features on the context menu of Eclipse's default editor and so I was not satisfied with it. I did not try Eclim because the main focus of that project is to run Eclipse inside Vim instead of the other way around. Then I installed Vrapper plugin and found it to be the one I was looking for. As the name suggests, it wraps the default editor to provide Vim-like functionality. The feature list it provides is still a subset of that of Vim and they are working on providing more features. However, the plugin has the basic features for which people love Vim and I think I like it too. Features like search with regular expression and search and replace are marked for future versions. But I can live without them for the time being. Those who like both Eclipse and Vim can certainly give it a try.

Tuesday, March 02, 2010

Getting openRDF Sesame 2.3.1 installation with Tomcat 6 to work

After deploying the war files: openrdf-sesame.war and openrdf-workbench.war by Tomcat's web-admin interface, I encountered the following problem while trying to access http://localhost:8080/openrdf-sesame/:

java.security.AccessControlException: access denied (java.util.PropertyPermission info.aduna.platform.appdata.basedir read)

I found a discussion about it here. Eventually I solved the problem in the following way:

1. Create and assign the home directory "/home/tomcat6" to tomcat6 user.
2. Create the directory "/home/tomcat6/.aduna".
3. Add the property "-Dinfo.aduna.platform.appdata.basedir=/home/tomcat6/.aduna/" in JAVA_OPTS in the /etc/default/tomcat6 file.
4. Restart Tomcat.

But this did not solve the problem. Then I had to turn off the security entirely which I am sure is not the recommended way. Here is what I did:

1. Set TOMCAT6_SECURITY=no in /etc/default/tomcat6 file.
2. Restart Tomcat.

Problem solved! But in an inelegant way. Does anyone have a better solution?

N.B.: lucene-2.9.2 must be in the classpath in order to get BigOWLIM-3.2.6 working properly.

Monday, November 30, 2009

Problem with libssl-dev while installing Virtuoso Universal Server open source edition in Ubuntu 8.04

While installing Virtuoso Universal Server's open source edition in Ubuntu 8.04 I faced the following problem when I ran the configure utility:

checking validity of the OpenSSL headers in /usr... configure: error: bad. Check config.log for details

The solution is to install libssl-dev which can be done as root as the following:

apt-get install libssl-dev

Then I ran make and make install without any problem.


Thursday, November 26, 2009

Web Calendar and Desktop Notifier?

I am looking for a good web calendar and a desktop notifier for it. I know there are couple of excellent web calendars out there like Google Calendar, Windows Live Calendar etc. But none of them has a good desktop notifier. In fact, I could not find any notifier for them. The motivation for not having a desktop notifier for Google Calendar is obvious. Google wants to move everything to the cloud and a desktop notifier for its calendar will be counter-intuitive to that. But I was expecting something from Microsoft as it proposes such a paradigm in its Software + Services strategy site. Though Outlook and Windows Live Mail both can access the calendar, there is not standalone notifier which will run at start up and show and notify upcoming events. Probably there are one or more desktop gadgets out there which I could not find. Can anyone help me in this regard?

Monday, May 04, 2009

Programmer Cartoons

A friend of mine sent me this link. It has some really hilarious cartoons. Enjoy!

Thursday, March 26, 2009

Change default shell in Linux

There is a simple command to do it: chsh [options] [login]. As an option you have to provide -s /path/to/new/shell. The /etc/shells file contains the list of currently available shells in the system.

Monday, February 16, 2009

Setup passphraseless ssh for Hadoop in Fedora 10

To run Hadoop it is necessary (at least that is what I know) to be able to ssh to the localhost without a passphrase. The Hadoop quick start guide has simple instructions on how to do that. The first time I installed and ran Hadoop was for a class project and I worked in a pc having Ubuntu 8.04. I could follow all the instructions of that guide without any problem. But this time when I wanted to run it on my laptop having Fedora 10, the passphraseless ssh was not working. I searched the internet for a solution and I found an excellent one here, thanks to Daniel Owen for the article. The trick is in the permissions. The authorized_keys file must have the permission 644. Anything other than that does not work. The known_host file created by ssh client also has the same permission.

Tuesday, February 10, 2009

Installing TrueType fonts in Fedora 10

I wanted to install four Bangla fonts to read some Bangladeshi newspapers. I searched the net for instructions on how to do it and found quite a few relevant results. But all of them used some commands which I could not find in my system even with full pathnames. They simply do not exist in my Fedora box. Then I just tried the following:

1. Opened a shell and changed to super user:
# su
Password: myrootpassword
2.. Created a new directory "banglafonts" in /usr/share/fonts:
# mkdir /usr/share/fonts/banglafonts
3. Changed directory to that one:
# cd /usr/share/fonts/banglafonts
4. Copied the ttf fonts to that directory
# cp /path/to/directory/having/downloaded/fonts/*.ttf .
5. Created fonts.dir:
# mkfontdir
6. Rebuilt the fonts cache
# fc-cache
7. Exited the shell
# exit
8. Restarted Firefox.

There may be some GUI tools to ease the process but my system do not have them and I also do not want to install something which will be rarely used. The simple steps described above are easy enough, even for a newbie, to install ttf fonts in a Fedora box.

Wednesday, February 04, 2009

Adding mp3 Support to Fedora 10

As mp3 support is not built-in in any Linux distributions, I was looking for some way to add it to my newly installed Fedora 10. I found some working instructions here: http://www.ghacks.net/2008/12/25/add-mp3-support-in-fedora-10. There is one typo in the second command, it should be "rpmfusion-nonfree" instead of "rmpfusion-nonfree".

Thursday, January 29, 2009

How to Determine Main Memory Size in Solaris

I was looking for a way to check the memory size of a Solaris machine I am working on. I found a blog post having three commands here: http://sysdigg.blogspot.com/2007/12/how-to-check-memory-size-in-solaris.html. I tried all three but only the following one worked for me:

# /usr/platform/sun4u/sbin/prtdiag | grep Memory
Memory size: 4096 Megabytes

Here is the machine information:

# uname -a
SunOS *** 5.10 Generic_127111-11 sun4u sparc SUNW,Sun-Fire-880

Friday, June 27, 2008

Windows Live Writer

Zippy Zed introduced this nice tool here and I decided to try it immediately. I was looking for something like this for a long time. I have blogs in Blogger and Wordpress and I wanted to have a tool by which I can post to both of them simultaneously. I tried at least one such tool before but was disappointed. I could not even connect to my Wordpress blog. But Windows Live Writer makes it so easy! Using the tool is very easy. It needs only one click to publish. To publish to more than one blog, you have to switch current blog but the text in the editing area does not get lost. Then you have to click the publish button again. The only downside I found so far is the installation process. It took longer than I expected. But considering installation a one time process, I would certainly recommend it to anyone who want to edit blog posts offline and/or want to post to multiple blogs. This is a good job done by Microsoft.

Thursday, June 12, 2008

Pledge a Firefox 3 download

Pledge a Firefox 3 download here. It is going to be released on June 17, 2008. Mozilla Foundation is trying to set a Guinness record of maximum download in a day. I surely will do two downloads: one for Windows Vista and the other for Fedora 9.

Wednesday, June 04, 2008

Bangladeshi Inventor Has Demonstrated Fuel Free Magnetic Power!

The story can be found here. Giasuddin Kachi invented a generator which needs external energy to start but then on produces energy indefinitely without any need of further external energy. This is too good a story to be true. Some expressed doubts that this machine violates fundamental principles of electricity and energy preservation. Nonetheless, if the generator works who cares! In that case, it will be one of the greatest invention of mankind. All the Bangladeshis will be very very proud of Giasuddin Kachi.