Tuesday, December 07, 2010

Setting up usb modem for ubuntu 10.10

If you want to setup the drivers for your usb modem, firstly check out this link. It shows the list of 3G hardware and the test result along with the necessary information.
In my case, I have Option Wireless iCON 225 (HSDPA) and I'm quite lucky to have mine listed as working and there's enough information for preparing the drivers.

Here's the summary of how I prepare the drivers:
1. Download and compile ozerocdoff --> udev.tar.gz (http://www.pharscape.org/ozerocdoff.html)
2. Skip installing hso driver kernel module since my kernel version is 2.6.35 (which is above or equal 2.6.31) --> http://www.pharscape.org/hso.html
3. Install HSOConnect (http://www.pharscape.org/hsoconnect.html) which requires hsolinkcontrol (http://www.peck.org.uk/hsolinkcontrol.html). And it turns out it just didn't work for me and I opt to use the default Network Manager.
4. Check if all works fine:
- Make sure hso module is already installed
find /lib/modules/`uname -r` -name 'hso.ko'
- Plug in the usb modem device and execute command below
lsmod | grep hso
If you see that hso is listed that's a good sign for you
- Check if the ports have been created
ls /dev/ttyHS*
My output is: /dev/ttyHS0 /dev/ttyHS1 /dev/ttyHS2
If you can see the output that also means ozerocdoff is already working
5. Go to my Network Manager, edit connections and add a new Mobile broadband connection.

6. Go online with my new broadband connection :)


References:
  1. Network Manager - Hardware 3G (https://wiki.ubuntu.com/NetworkManager/Hardware/3G)
  2. PHARscape iCon 255 (http://www.pharscape.org/icon225.html)
  3. ozerocdoff (http://www.pharscape.org/forum/index.php?topic=545.0)
  4. HSOConnect (http://www.pharscape.org/forum/index.php/topic,743.0.html)
  5. Using Network Manager (http://www.pharscape.org/networkmanager-0.7.0-and-3g-wwan-modems.html)

Saturday, December 04, 2010

Aspire 4741z battery is not charging

If a battery is not charging then the cause is either the battery is broken or the charging module needs replacement or could be BIOS problem. In my case the cause is neither above, apparently after taking out my battery I just realized that somehow I left the lock switch to unlock position. And indeed that's the cause of the battery is not charging.

Friday, December 03, 2010

Configuring mic in aspire 4741z - ubuntu 10.10

Luckily for me, my installed alsa is already the latest one. All that is needed is just to add 2 lines below to /etc/modprobe.d/alsa-base.conf

alias snd-card-0 snd-hda-intel
options snd-hda-intel model=acer


My mic works now but it seems a bit quiet. Hopefully I can find the way to boost the mic.

A nice tool that might help is alsamixer, run it from a terminal.

Tuesday, November 30, 2010

Ubuntu 10.10 brightness problem in Acer Aspire 4741

To those who have problem with brightness configuration after installing Ubuntu 10.10 and you are using Acer Aspire 4741, here's a solution for you:
  1. sudo gedit /etc/default/grub
  2. Change the line GRUB_CMDLINE_LINUX="" into
    GRUB_CMDLINE_LINUX="acpi_osi=Linux"
  3. sudo update-grub
  4. Restart your linux

Hopefully it helps.

Tuesday, October 19, 2010

Spring security core build path problem

First time trying Grails 1.3.5, creating a new test project. Installing spring-security-core plugin (following the tutorial) and then importing the project to STS 2.5M1 and letting STS know that it's a Grail project (Configure->Convert to a Grails project... something like this). I was hoping for an easy ride here, expecting no errors since I haven't add anything, all are auto generated.

But as usual, with programming world, there ain't no such things as a bug/error free codes. I got compile errors like this in my LoginController.groovy.



I know that I'm missing org.springframework.security.core-3.0.3.RELEASE.jar release in this case and the shortcut to solve this is just to add the jar to the project build path. But, is this going to happen for each plugin jar that I'm going to use? and anyway I don't like the solution to put the jar manually on the build path, it does look an ugly solution.

Fortunately I find a menu to refresh Grails' dependencies and the good news is it works for me, no more compile errors. Here's the context menu that pops up when I right click on my project:



I think this is caused by me adding the plugin from command prompt and then importing the project in STS. Imho, if the plugin is added thru STS' grails command prompt it should works without refreshing.

Hmm... just remember that this is similar to when I add a new file to my project using my file manager. Eclipse can't see the file, until I refresh the project.

Tuesday, September 14, 2010

Using hibernate generated collection in h:dataTable

It's a bit difficult to pick the correct title for the thing that I'm going to write :) It's about having your POJO generated by hibernate and then feed it to h:dataTable.

When your object has a collection properties and the elements contained are unique within the collection, hibernate will create a Set to contains it. The thing with a Set is h:dataTable just can't accept it. The simplest solution is to change Set to Collection object and h:dataTable can accept it and Hibernate won't complain about it :)

Rolling back transaction (Seam managed transaction)

JSF+Seam is what I'm learning at the moment. And the case is I need to rollback the transaction due to business exception but I don't want to not catch the transaction (when a runtime exception is uncaught the transaction will be rollback automatically). The business exception here is a new exception class extending RuntimeException.

At first try, I add ApplicationException annotation with rollback = true in my BusinessException class. The controller class which invokes the business service class and under certain condition an exception of BusinessException type is thrown. In my scenario my transaction should be rolled back, the thing is... it was not rolled back.

This forced me to dive into seam's code (that's why I love open source) and find out how to handle the transaction. And I came into Transaction class, which I can use to do what I want.
Here's how to use it to mark the transaction as rollback:

Transaction.instance().rollback();

Actually all I wish is when the exception is thrown by the service class (already registered to seam) the transaction will be rolled back automatically, unfortunately for me it doesn't work :(

Entity inheritance-single table per class hierarchy strategy with JPA + Hibernate

I happened to have the chance to implement entity inheritance using single table per class hierarchy strategy. At first I though I would sail smooth and arrive at the promised land easily :) but as usual with programming, it is a rare thing a code would sail smooth at the first time.
Persisting entity works like charm, retrieving it makes me speechless. Here's an example:

The base class (ItemReference)


Subclass#1 (ItemReferenceAge)


Subclass#2 (ItemReferenceSex)


DDL


One class that I don't include here is the class which has a collection of ItemReferenceSex and a collection of ItemReferenceAge, let's call this class Wrapper.

The scenario is I add 2 instances of ItemReferenceAge to wrapper collection and persisted it. What happened when I try to load the same wrapper instance is both collections are having elements in them. Remember, I only add ItemReferenceAge instance which means the collection of ItemReferenceSex should be empty.
Looking at the query generated shows that the discriminator column is not used in the where clause of the select query. What I can think of the design reasoning is that it is assumed that there will not be two or more type of instances loaded in the same parent object which in my case it is.
Luckily for me, there's a solution for this and unfortunately it's hibernate specific annotation (is it maybe because of JPA doesn't state how to handle my case or is it hibernate implementation?). All I need to do is to add ForceDiscriminator annotation in my base class and the problem is solved!

Thursday, August 19, 2010

Eclipse fails to start?

Your eclipse fails to start? actually we could say your workspace fails to start. I've gone through it several times and my solution was to create a new workspace and import the existing projects into the new workspace.
However, this time I'm trying to solve it once for all (as though it's possible :). Googled around and I found, imho, a rough solution that works for me. It's as simple as deleting org.eclipse.core.resources folder inside {workspace}/.metadata/.plugins and then run eclipse -clean.
The result is eclipse is working but I still have to import the existing projects back. The good thing is I don't lost all the preferences and server setting (though I could just import the preferences file I once exported).

Check the link on the title and also this one, tools from eclipse team that maybe could help with the broken workspace (I never tried it yet... my workspace already fixed :)

Tuesday, August 17, 2010

A bit on classloader

At first glance, I thought java could face the same problem as dll was (dll hell). But then classloader scoping comes to the rescue. And by the way, I won't explain the theory of classloading here. By having classloader scope set to the application, it will allow each application to bring their own libraries without worrying of library conflict.

For example, I built a library of common utilities and there are already 2 versions of it. And 2 of my web applications are using the library, however each with a different versions from the other. If the flat classloading is used, only one of the 2 versions of the library will be used and the impact is the web application which used the version not loaded will have strange errors such as ClassCastException, IllegalAccessErrors and possibly many others. Having classloader scoping will allow each of my web application to use its respective library.

One thing cross my mind, how could I have a smaller deployment size for a web application and still having the classloader scoping. Smaller deployment size here refers to my classes only without the whole bunch of libraries. Usually when people delivers a patch for the web application, all is packed in war file which size is quite large. On my case, the library size are around 80% of the war file size. Up to now, all I can do is to deploy the application as exploded. Thus allowing me to deploy patches by replacing the content/libraries. Not an elegant solution but still a viable one, until I can find a nicer solution.....

Sunday, August 15, 2010

Initialize static List and Map

If you intend to create a List or Map for your constants, here's how you do it.

List

public static String CONSTANT_1 = "1";
public static String CONSTANT_2 = "2";

public static List CONSTANTS = new ArrayList() { {
add(CONSTANT_1);
add(CONSTANT_2);
}};


Map


public static Map CONSTANTS = new HashMap() { {
put("key1", "value1");
put("key2", "value2");
}};


Even better is to wrap the ArrayList/HashMap by passing them to Collections.unmodifiableList or Collections.unmodifiableMap. Thus making sure that it is truly a constant list/map.

Wednesday, July 28, 2010

How to search for column reference in oracle

Imagine that you need to find out which code update a column in a table. Some developer tools could point out who refers to the table but so far I couldn't find the one that could answer my need.

All_source comes to the rescue, I'd say that it is a special view that holds all the database objects accessible by the user.

Here is the description on the view's columns:
OWNER VARCHAR2(30) NOT NULL Owner of the object
NAME VARCHAR2(30) NOT NULL Name of the object
TYPE VARCHAR2(12)
Type of object: FUNCTION, JAVA SOURCE, PACKAGE, PACKAGE BODY, PROCEDURE, TRIGGER, TYPE, TYPE BODY
LINE NUMBER NOT NULL Line number of this line of source
TEXT VARCHAR2(4000)
Text source of the stored object

Example:
I need to find out who refers to column FK_USER.

select * from all_source where text like '%FK_USER%'

And I will get all the places which have reference to FK_USER.

If you would take it further, you could utilize it for searching almost anything (e.g. comments in the code, TODO tag, exception).

... wondering if there're more "magical" view like this.

Saturday, July 24, 2010

Retrieving generic's Class type

Quite few times I've been using generic and I needed the Class type. I found out that I've to pass the class type instead of extracting the class type from the type parameter. This story comes to an end when I found out a way to extract the type, thanks to Type interface :)

Here's the recipe:
- First extract the genericSuperclass
- Retrieve the actual type arguments

.. and the code is:
ParameterizedType type = (ParameterizedType) getClass().getGenericSuperclass();
Class classType = (Class) type.getActualTypeArguments()[0];

ParameterizedType represents an invocation of a generic class or interface, better explanation could be read in the javadoc.

That's all... :)

Saturday, June 12, 2010

Knowing the exact location of error in your jsp

Actually it's been several times I have to deal with error happening during jsp rendering. To be more exact, the error doesn't lie in the jsp page but in the content prepared before rendering the jsp. Usually what I do is just removing part by part of the jsp page until I can locate the part that caused the rendering error. I keep on doing it until I remember that during page rendering a buffer is used and the buffer size itself is configurable.

Here's in short of how to do it:
- Insert the following page direction to the top of the jsp page
<%@ page buffer="none" %>
- Try to open the page again in the browser and view the source
- The last position of the source page will show exactly the position of the error, i.e. the position before the source of the error
- After you've managed to fix the error, don't forget to remove the page directive. It will certainly degrade the performance if you leave it there

Tuesday, April 27, 2010

Configuring static IP in Fedora

If all you have is a CLI, then you might find this to be of benefit. Otherwise you could just use the Network Device Control GUI.

Here are the steps:
  1. Execute ifconfig and find out your ethernet configuration name (e.g. eth0)
  2. Go to /etc/sysconfig/network-script
  3. edit ifcfg-eth0 (depends on your ethernet)
  4. Update the file as follow (set the IPADDR, BROADCAST according to your desired configuration)

  5. Restart the network service
    service network restart

Here's a brief explanation on the configuration:
  • BOOTPROTO : telling the network that we're configuring it as static ip
  • ONBOOT : the configuration will be set at boot time
  • BROADCAST : your gateway
  • NETMASK : your netmask


.

Saturday, December 12, 2009

Opera Turbo

Someone asks me if is it safe browsing with Opera mini (which defaulted to use Turbo)? The safe here mentioned refer to the data sent being stored by Opera Turbo (remember, all data traffic goes thru Opera Turbo so that it could compressed the content and sent the result to the browser). This question is answered on the following link:
http://labs.opera.com/news/2009/03/13/

If you are using ssl, Opera Turbo is bypassed and we're communicating with the SSL site directly. Which implies that turbo is turned "off" and you're back to the old way of browsing. Opera Turbo also declares that it doesn't store any user's information.

The conclusion is if we're looking for a cheaper way to browse, which is the case where the price mostly depends on the data being transferred (usually per KB), Opera Mini will be a great choice. Bear in mind, the statement declares that no user's data is stored. If you don't trust it then it simply mean don't use Opera.

Before I finished, I read one of the comments on this blog. It mentioned that Opera is a Norwegian company, which means that it follow the Personal Data Act (http://www.datatilsynet.no/templates/Page____194.aspx). And it is extremely strict.

Wednesday, December 09, 2009

Agile Manifesto

The thought of using agile methodology started about 3 years ago. Never been involved in a project using agile, I was looking for one to be involved in or have "my" project using it.
It seems to be challenging enough to use it, to know the advantage and of course the weaknesses. To find out the know how-when to use agile or waterfall. I'm not all for agile, but I have to admit agile excites me more. Adopting one of agile practice in one of the projects I'm involved in, which is daily meeting (face to face communication), opened my eyes to realize that the team starts to become more alive. Everyone starts to involve themselves more, discussion on the requirements become more often. As opposed to developer works only as they're told to.

Reading on agile manifesto, quoted below

We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value:

  • Individuals and interactions over processes and tools
  • Working software over comprehensive documentation
  • Customer collaboration over contract negotiation
  • Responding to change over following a plan
That is, while there is value in the items on the right, we value the items on the left more.


quite confirms that agile might be the one we should use for the development. But still I'm not all for agile, there're still some factors that drives me to choose the old methodology. Such as large complex projects, the number of developers involved. Maybe it's me not knowing in depth on how agile methodology really works.

After all, it fall back to one step at a time. Welcome agile, I'm looking forward to really understand you more :)

Tuesday, July 07, 2009

Connect to wireless network using netsh

If you kinda tired of constantly changing your wireless network when you're at home or office, batch file could be a great help for you. A single click is enough to setup your wireless connection. I was using Net Profiles and I'm a satisfied user, but this single click idea beats Net Profiles.
Of course you've to create a batch file for each connection you want to setup, but that's not too much to do (imho).

FYI, I'm using Vista. For XP, the command could be a bit different but the idea is still the same (c'mon improvise).

Now, here's the simple command line to connect to a wireless lan:
netsh wlan connect name="network name" interface="Connection name under Manage Network Connection" ssid="the ssid"

example:
netsh wlan connect name="hpsetup" interface="Wireless Network Connection" ssid="hpsetup"

in case you use static ip in your office or home, the command goes like this:
netsh interface ipv4 set address "Connection name under Manage Network Connection" static the_static_ip mask the_gateway

example:
netsh interface ipv4 set address "Wireless Network Connection" static 192.168.1.102 255.255.255.0 192.168.1.103


One more thing, running under Vista you need to run the batch file as administrator.

After all, it's only one click away.....

Tuesday, June 16, 2009

Virtual Serial Port

How did I start to play around with it? It all began when a friend of mine was asking me for a favour to help him develop a simple software to communicate to another software thru serial port. My laptop doesn't have a serial port (of course, unless it was a very very old laptop) and I only have one usb to serial converter.

My first idea is to buy another usb to serial converter and a null modem cable to connect 2 laptops, thereby I can test the serial communication. Another idea is to use my old desktop (I have one and lent it to someone and actually forgot about it until I need it) but I don't think it is easy to do.
Then today at the office, asking my friend and he gave me one brilliant solution called VIRTUAL SERIAL PORT. I never heard it until today and my oh my... it is the solution to my problem (Thanks Adhi).

Googling around and I found one free driver (http://com0com.sourceforge.net/). Easy to install and I think I don't need to setup anything more, unless I need to configure another serial port pair. One thing lacking is the GUI to configure the ports. Anyway, it's free and open source, I couldn't be happier.

Friday, June 05, 2009

Turning Toshiba Satellite illumination led off

The first time I got my Toshiba M300 (actually it's not mine, it's my office's), I love to see all the LEDs light up the laptop.



Not until a week that it already bored me to see my laptop lights up as if it was a festival. Then to my dismay, I found out that turning off the LEDs wasn't easy (I did manage to turn it off though).
My colleague buying the same laptop as mine, also find it difficult and he did ask me how.

Today, someone asked me (she's using toshiba also) how to turn the LED off and gladly I told her and write in this post on the how to.

1. Press fn button and click on the rightmost button


2. Click on the HWSetup button


3. Go to Illumination tab and select Off and click OK. You're done.