Monday, November 28, 2011

Encoding problems in Grails

If there are problems with charsets while submitting forms in Tomcat, and headers for responses/requests looks correct, you can try to fix it by adding URIEncoding="UTF-8" into your server.xml. This fixed things nicely to me. Read more about it at

Thursday, November 24, 2011

MySQL dump without locking tables

If you just do MySQL dump without any parameters, it locks tables and consumes a lot of memory. If you want to avoid it and you have InnoDB, best way to do it is to add single-transaction (run in single transaction) and q (dump one row at once) properties, for example like:

mysqldump -q --single-transaction -u login -ppassword db > dump.sql

Monday, November 14, 2011

Time difference with DST

If you need to calculate time difference that include Daylight Saving Time in Groovy, it is super simple with groovy.time.TimeCategory:

TimeDuration hours = TimeCategory.minus(end.time, start.time)