Tuesday, May 4, 2010

PNG fix for IE6

This is a good PNG fix for the IE6 browser.

References:
http://www.dillerdesign.com/experiment/DD_belatedPNG/

Thursday, April 8, 2010

Easiest way to sort a Map in JAVA


Comparator<Integer> comparer = new Comparator<Integer>() {

public int compare(Integer o1, Integer o2) {
return o1.compareTo(o2);
}
};

// hours
Map<Integer, String> hoursUnsorted = new HashMap<Integer, String>();
for (int i = 1; i <= 12; i++) {
if (i <= 9) {
hoursUnsorted.put(i, "0" + i);
} else {
hoursUnsorted.put(i, "" + i);
}
}
Map<Integer, String> hours = new TreeMap<Integer, String>(comparer);
hours.putAll(hoursUnsorted);

NTFS mount error in ubuntu

ERROR

$LogFile indicates unclean shutdown (0, 0)
Failed to mount '/dev/sda1': Operation not supported
Mount is denied because NTFS is marked to be in use. Choose one action:

Choice 1: If you have Windows then disconnect the external devices by
clicking on the 'Safely Remove Hardware' icon in the Windows
taskbar then shutdown Windows cleanly.

Choice 2: If you don't have Windows then you can use the 'force' option for
your own responsibility. For example type on the command line:

mount -t ntfs-3g /dev/sda1 media/win -o force

Or add the option to the relevant row in the /etc/fstab file:

/dev/sda1 media/win ntfs-3g force 0 0

SOLUTION

1) Run Disk identifire
sudo fdisk -l

2) Create a new mount point in your system
sudo mkdir /media/chaami

3) Mount your NTFS drive to your mount point by using ntfs-3g
sudo mount -t ntfs-3g /dev/hda1 /media/chaami -o force

Friday, April 2, 2010

Create bootable flash drive by using UNetbootin

UNetbootin allows you to create bootable Live USB drives for a variety of Linux distributions from Windows or Linux, without requiring you to burn a CD.

References:
http://unetbootin.sourceforge.net/

Friday, March 19, 2010

Could not execute JDBC batch update; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

Error:
Could not execute JDBC batch update; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

WARN [btpool0-1] JDBCExceptionReporter.logExceptions(77) | SQL Error: 1064, SQLState: 42000

ERROR [btpool0-1] JDBCExceptionReporter.logExceptions(78) | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition=2, created_on='2010-02-15 00:00:00', description='
ERROR [btpool0-1] AbstractFlushingEventListener.performExecutions(301) | Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.springframework.orm.hibernate3.HibernateTemplate$28.doInHibernate(HibernateTemplate.java:888)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:886)


Solution:
If you are using hibernate annotation in POJO's with MySQL,
in this example, we can eliminate this error by modifying the POJO.

Before the change

@Column(name = "condition", nullable = false)
private int condition;

After the change

@Column(name = "`condition`", nullable = false)
private int condition;

Friday, January 8, 2010

Eclipse vs IntelliJ IDEA

Eclipse advantages:
- It is free.
- You cannot close useless tool windows in IDEA as you can close views
in Eclipse. Eclipse can roughly emulate IDEA's layout with fast-view
but this does not apply vice versa.
- Eclipse has faster analysis of code.
- Eclipse can auto position semicolons.
- Eclipse can guess method call parameters.
- IDEA has nonstandard hot key for 'redo'.
- Eclipse supports multiple projects in one system window.
- IDEA loads project longer time and freezes while doing it.
- Drag & drop doesn't work when I want to add files to e.g. lib
folder. I'm accustomed to standard copy & paste of libraries in
Eclipse.
- IDEA cannot restart itself after changes in installed plugins.
- Eclipse can generate test class from to-be-tested class.

IDEA's advantages:
- Better refactorings (e.g. 'Replace method call duplicates...').
- Somewhat better code analysis.
- Nice pop-up that source file has changed in source control.
- Better navigation through code, e.g. you can navigate through
interface to implementation of any method. Eclipse can't do this for
interfaces. The only choice I found is F4 and then click on method
name in hierarchy.
- Eclipse hangs a little during update process.
- In IDEA you can 'extract local variable' anywhere in the line, but
in Eclipse you have to select the desired part of code.
- Weak support of Spring configuration file in Eclipse without
plugins.
- If you add a new method to an interface in IDEA, you have the option
to generate the method implementation in all implementations.
- IDEA doesn't ask if I want to reload the file from the file system,
just reloads it.
- IDEA has kind of support for Eclipse projects but not vice versa.

References:
http://coding.derkeiler.com/Archive/Java/comp.lang.java.softwaretools/2008-12/msg00017.html