Sachin

Grails Enthusiast, Technology lover and a self confessed foody... ;-)

Grails

Defining a bean by calling function on another bean

In Grails, We can define custom beans in resources.groovy. A simple bean definition looks like [java] myClass(MyClass) [/java] Read more about them here. Recently, I wanted to define a bean, where the bean's constructor required me to call a method on another bean to be instantiated. To make it more clear, Let us consider a...

by Sachin
10-Dec-2014

Technology

Logging to remote MySQL Server using SSH tunneling

Very often, we all need to access a remote database for debugging or any other related stuff. The simplest thing that comes to mind is to take the dump of remote database and bring it to the local and run the application using that data. We can avoid that, if we can connect our local mysql client to a remote machine over a SSH...

by Sachin
17-Sep-2012

Grails

Using Initialization bean to set properties

Using Grails, we often set some application wide constants or config properties or execute certain tasks in bootstrap.groovy when the application starts . A better approach is to create a new class in src/groovy and have it implement Initialization bean interface [java] import org.springframework.beans.factory.InitializingBean ...

by Sachin
14-Aug-2012

Grails

Rendering JSON with formatting

In Grails, We often use [java] render list as JSON. [/java] It renders json output without any formatting (spaces and new lines), often we need to provide users an option to receive formatted json (pretty printed) as response, so that it could easily be read and understood by users. We can easily do that using [java] def...

by Sachin
16-Jul-2012

Technology

Normalization Forms for Accented Characters in Java

Text Normalization is the process of "standardizing" text to a certain form, so as to enable, searching, indexing and other types of analytical processing on it. Often working with large quantities of text we encounter character with accents like é , â etc. Unicode provides multiple ways to create such characters . For example we can...

by Sachin
29-Jun-2012

Technology

Normalizing Accented Words

We all often need to work on data aggregated together from different sources, and before we analyse it, we often need to normalize it to a certain standard, A normalization process typically includes removing special characters, converting all text to lower case , We can also have certain rules that words like "saint" will always be...

by Sachin
14-Jun-2012

Technology

Using Git Rebase

Working on a cool project, doing cool and unusual stuff has its own charms and challenges. For doing cool things, you need cool tools to play with and Git surely is one of the coolest ones around. One of the many powerful features of git is rebase. While working on a large project, you almost always develop your feature on a new...

by Sachin
22-Jan-2012

Grails

Dbconsole in Grails.

So, Grails 2.0 was released a few days back and I upgraded my application to it as soon as I came to know of its final release and it rocks.!! Among the many things which are making a lot of noise on grails 2.0, there seems to be a lack of noise over the GUI Database console which grails has provided. Developers can connect to the...

by Sachin
25-Dec-2011

Technology

Sorting in javascript

Recently in my project I needed to sort an object list on the basis of object name. For the same purpose I created the following function [java] function sortList(objList) { objList.sort(sortByName); } function sortByName(a, b) { var x = a.name; var y = b.name; return ((x < y) ? -1 : ((x > y) ? 1 : 0)); } ...

by Sachin
13-Mar-2011

Technology

Getting up and Running With Cassandra

Luckily, I got some time outside my usual obligations in the project, to learn something new and I devoted the time to getting up and running with cassandra . Getting starting up with it was a bit bumpy, as the case almost always is when you start with something entirely new. Lets get Started.. 1) First step of course is to get the...

by Sachin
17-Jan-2011

Grails

MalformedByteSequenceException with Grails jasper plugin 1.1.6

Hi All, I was facing a lot of problems with creating pdf reports using jasper plugin 1.1.6 in grails, Though I had earlier worked with 0.9.5 and 0.9.7 versions of the plugin with a lot of ease but some how 1.1.6 version of plugin was not generating reports  it always ended up throwing MalformedByteSequenceException: Invalid byte 1 of...

by Sachin
03-Dec-2010

Grails

Only Read and Insert In Domain Class

In my recent Project, I wanted to create a domain class in which records could only be added and read and no update was to be allowed on any of the records and I found a very nice way of doing it. Adding [java] static mapping = { cache usage: 'read-only' version false } [/java] in the domain class did the trick for me...

by Sachin
14-Nov-2010