Archive for the 'tips' Category

Having memory problem with Firefox? Use Flock!

Several months ago when I first tried Flock, I was pretty disappointed. The browser is buggy and even has bigger memory problem as Firefox. Not long after the installation, I uninstall it. And I never intended to try it one more time. Not even when it escaped the beta. A social browser just doesn’t get my attention.

This is somehow changed when I see the post in Techcrunch. According to the post:

Then came Flock 1.0. I’d never been a Flock fan before, always believing it to be nothing more than Firefox with plugins (Flock is based on the Firefox engine). Having watched the demo at TechCrunch 40 I downloaded the beta of Flock 1.0 and surfed away without incident. Some how the folks at Flock had tweaked the underlying Firefox engine to stop the memory issues.

So I give Flock another try. And yes, it seems to me that it is working better than Firefox. The previous post shows an image how much memory taken by Flock compared to Firefox.

Memory comparison of Flock and Firefox

Great work Flock team. Sadly I won’t still use your social features. I certainly will use Firefox more often if the solution can be implemented in Firefox, but I guess it will just be a dream since Firefox’s memory leak is a feature.

Java Tips: Generic Method

Generic is a pretty powerful addition to Java 5. But often people only use generic in the class and forget that generic can also be useful in method. This post will discuss a pretty neat use of generic to avoid casting and reduce duplication.

First, let start with the problem. Say that you have a lot of methods that catch exception and wrapped it with other exception.

public void methodName1() throws AnotherException1 {
   try {
      ...
   } catch (SpecificException1 e) {
       throw new AnotherException1(e);
   }
}
 
public void methodName2() throws AnotherException2 {
   try {
      ...
   } catch (SpecificException2 e) {
       throw new AnotherException2(e);
   }
}

Then, customer comes with another requirement that all exceptions should be logged before thrown. Here… the obvious solution is like this:

public void methodName1() throws AnotherException1 {
   try {
      ...
   } catch (SpecificException1 e) {
       AnotherException1 ex = new AnotherException1(e);
       log(ex);
       throw ex;
   }
}
 
public void methodName2() throws AnotherException2 {
   try {
      ...
   } catch (SpecificException2 e) {
       AnotherException2 ex = new AnotherException2(e);
       log(ex);
       throw ex;
   }
}

But that solution is not that elegant because we have to add two lines in every try catch. We can come up with a new method to simplify the change.

public Exception logAndReturnException(Exception e) {
   log(e);
   return e;
}
 
public void methodName1() throws AnotherException1 {
   try {
      ...
   } catch (SpecificException1 e) {
       throw (AnotherException1) logAndReturnException(new AnotherException1(e));
   }
}
 
public void methodName2() throws AnotherException2 {
   try {
      ...
   } catch (SpecificException2 e) {
       throw (AnotherException2) logAndReturnException(new AnotherException2(e));
   }
}

That’s remove duplication but not that pretty since we have to add casting in every place. Here, generic can be used to simplify and make our code prettier.

public <E extends Throwable> E logAndReturnException(E e) {
   log(e);
   return e;
}
 
public void methodName1() throws AnotherException1 {
   try {
      ...
   } catch (SpecificException1 e) {
       throw logAndReturnException(new AnotherException1(e));
   }
}
 
public void methodName2() throws AnotherException2 {
   try {
      ...
   } catch (SpecificException2 e) {
       throw logAndReturnException(new AnotherException2(e));
   }
}

Pretty neat, right? With the same technique we can simulate lambda calculus or function calling in Java. Try it!

Fixing Samba symbolic links’ problem from Leopard

Oh no… all symbolic links are not accessible from Leopard. It shows error message that the target links can’t be found. They are OK with Tiger, so I’m thinking that there is a bug in Leopard. For a while, I can live with copying the file from Linux to Mac and worked with the copy in Mac. But when the first update of Leopard is out, it’s still not fixed so I somehow curious what really happen here.

So today I spent some time to examine the problem and found a suggestion from here to restart the samba server everytime mac connects to it. It’s not that convenient.

Reading more to the links given by it, I found out that simpler solution is available. Just by adding this line to smb.conf (in Ubuntu the location is /etc/samba/smb.conf), the problem can be resolved.


unix extensions = no

Nice way to explain a thing

Introducing a new thing is not as easy as it seems. Even when the concept is actually easy, the ‘oooh…’ effect is hard to obtain. We need a good strategy to get this. For example, the For Dummies series tries to get it by positioning their readers as… well… dummies.

A production company named Common Craft knows exactly how to do this. See the following example on how they explain blog.


Continue reading ‘Nice way to explain a thing’

Using Gmail as mail application

I never thought before that I will be enjoying using Gmail as a mail application. That’s why I always download my gmail emails to my local computer. I do enjoy the possibility to read all my emails even if I were on the road, but it never as convenience as read one in Thunderbird.

But lately, with several enhancements to Gmail, I’m rethinking my decision. I’m traveling quite a lot these days and reading Gmail is becoming more pleasant experience than before. So let me summarize what I did lately.

Before, it’s not very easy to create a filter in Gmail, but this is dramatically changed. Now, creating a filter (especially for mailing list) is a snap! Nothing to type, just four clicks. I never found any mail desktop application that can do this better than Gmail. Not only that, they don’t use sender or message title for doing this, instead they use a hidden information about a mailing list that usually available in most mailing lists. The result is the filtering is better and more precise than before.

Since now I filter my message in Gmail, POP is just too complicated. I don’t want to create two filters in Gmail and another in my Thunderbird. So I change my Thunderbird setting to use IMAP. Now all folders are just mirror of the labels in Gmail. How convenience, huh?

And I never thought to forward my email to one single email before. Now since Gmail has increased its capacity and the filtering is so easy… and the spamming control is much better that GMX or Yahoo… well… it’s no brain for me to start forwarding all my POPs email to Gmail. There is still one enhancement that is not there probably. I really like to see Gmail automatically retrieves my Yahoo email.

Last enhancement by Gmail make it possible for me to give colors to labels. I can give a background to the label if the label is pretty important or just change the text if the label is not that important. My Gmail is now colorful and I like it!

Overall I’m very satisfied with what Gmail team done lately. Life won’t be so easy without it. Now please GIVE US BETTER AND FASTER BROWSER. Until that happens, my thunderbird will still busy downloading the messages every five minutes.

TV Streaming (SopCast) on Linux

I’ve already spent some time to find a way to watch TV streaming on my Ubuntu box but were too lazy to follow the unclear explanation. Instead of trying, I just open the VMware and run the application under Windows. Unfortunately, the video quality of this solution is too poor (still better than nothing). This night, in the spirit of watching Indonesia - Saudi Arabia tomorrow afternoon (CET time zone), I tried this one more time.

Continue reading ‘TV Streaming (SopCast) on Linux’

Installing VMWare on Ubuntu 7.04

The default VMWare Player and Workstation distribution can’t be installed in Ubuntu 7.04 due to some kernel errors. This is the error message:

Extracting the sources of the vmmon module.Building the vmmon module.
Building for VMware Player 1.0.2 or 1.0.3 or VMware Workstation 5.5.2 or 5.5.3.
Using 2.6.x kernel build system.
make: Entering directory `/tmp/vmware-config1/vmmon-only'
make -C /lib/modules/2.6.20-gentoo-r6/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. modules
make[1]: Entering directory `/usr/src/linux-2.6.20-gentoo-r6'
CC [M]  /tmp/vmware-config1/vmmon-only/linux/driver.o
In file included from /tmp/vmware-config1/vmmon-only/linux/driver.c:85:
/tmp/vmware-config1/vmmon-only/./include/compat_kernel.h:21: error: expected declaration specifiers or ‘...’ before ‘compat_exit’
/tmp/vmware-config1/vmmon-only/./include/compat_kernel.h:21: error: expected declaration specifiers or ‘...’ before ‘exit_code’
/tmp/vmware-config1/vmmon-only/./include/compat_kernel.h:21: warning: type defaults to ‘int’ in declaration of ‘_syscall1’
make[2]: *** [/tmp/vmware-config1/vmmon-only/linux/driver.o] Error 1
make[1]: *** [_module_/tmp/vmware-config1/vmmon-only] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.20-gentoo-r6'
make: *** [vmmon.ko] Error 2
make: Leaving directory `/tmp/vmware-config1/vmmon-only'
Unable to build the vmmon module.

What you have to do is:

  1. change dir to the installer directory, and enter /lib/modules/source
  2. untar vmmon.tar
    tar xvf vmmon.tar
  3. edit the file vmmon-only/include/compat_kernel.h, add the following preprocessor statements
    /*
     * compat_exit() provides an access to the exit() function. It must
     * be named compat_exit(), as exit() (with different signature) is
     * provided by x86-64, arm and other (but not by i386).
     */
    #define __NR_compat_exit __NR_exit
    #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
    static inline _syscall1(int, compat_exit, int, exit_code);
    #endif
  4. tar back the file
    mv vmmon.tar vmmon.orig.tar
    tar cvf vmmon.tar vmmon-only
  5. run vmware-config.pl again
    # sudo ./vmware-config.pl
    ...
    
    You can now run VMware Player by invoking the following command:
    "/opt/vmware/player/bin/vmplayer".
    
    Enjoy,
    
    --the VMware team

“Force link that open new window to open in new tab” for Firefox 2

Firefox 2 removes option to “Force link that open new window to open in new tab”. I found this to be very disappointing, since I always activate this option. Working with tabs is one of the reason I use Firefox, if some sites force me to open new window, it is just as annoying as using MSIE 6 again!!

So here is how you can set this in Firefox 2:

Open about:config and set:
browser.link.open_external -> 3
browser.link.open_newwindow -> 3
browser.link.open_newwindow.restriction -> 2

And you’re done!

freepops

Are you using mail.yahoo.com as your email? Do you want to download your email to your favorite email client? Several years ago, this was possible, but then yahoo close pop3 access to yahoo.com and only provided it to they who pay for their service. As alternative, you may consider using other yahoo domain such as yahoo.co.uk to be able to use pop3.

FreePOPs

Continue reading ‘freepops’

latex-beamer is cool

What tools do you use to create your presentation? I bet most of you will say that you use Microsoft Powerpoint, or maybe OpenOffice Impress. Well, they are the easiest tools to create your presentation, but they are not the best. I guess that is my impression after I see what kind of presentation latex can create. Latex is become one of my first choice since I move to Ubuntu Linux.

beamer.png

beamer2.png

Latex? Yes… latex. Latex is not only useful for creating document. Its architecture provides possibility for users to extends its functionality. One of them is to create presentation.

Continue reading ‘latex-beamer is cool’