Grails

Using Ftp with Grails

In one of my Grails project I need to drop files over ftp server. Using JSch one can easily transfer files over sftp. Just follow the below steps. 1. Add the below dependency to Grails project “grails-app/conf/BuildConfig.groovy” file [sourcecode language=”groovy”] dependencies { compile ‘com.jcraft:jsch:0.1.49’ } [/sourcecode] 2. Create a class for adding ftp credentials information. e.g. “FtpCredentail” […]

Grails

Groovy: Ways to represent String

Compared to Java we have a lot of  ways to represent strings : GString, single quote, double quotes, slashy and dollar slashy.   1.GString: A GString is just like a normal String, except that it evaluates expression that are embedded with in string in the form ${..}. [java] String demo="Brother" String doubleQuotes= "Hello ${demo}" println […]

Grails

Groovy : tokenize() vs split()

In the Wild West of text manipulation, Groovy offers two gunslingers for splitting strings: tokenize() and split(). They might seem like two sides of the same coin, but choosing the right one can make your code smoother than a well-oiled six-shooter. Below are some of the significant differences between both tokenize() and split() Feature  tokenize()  […]

Vivek Garg
Vivek Garg
Read

Grails

Script to display Git commits for creating time sheet.

We use “git log” many times a day while using Git in our projects. Sometimes we need to list Git commits between specific dates. Although, Git provides command to do this but the syntax is too long to type. So I created a script named timesheet, which facilitates us to display Git commits between two specific […]

Puneet Behl
Puneet Behl
Read

Grails

Using Category in groovy

In one of my projects, I needed to save file from a particular url. I found a groovier way of doing this using category. [java] class FileBinaryCategory { def static leftShift(File file, URL url) { url.withInputStream {is -> file.withOutputStream {os -> def bs = new BufferedOutputStream(os) bs << is } } } } [/java] Here, […]

raj
raj
Read

Grails

4 Principles of well-designed web UI

Web Designing is nowadays not only just the way to promote our product & services, but is designed and coded to make the website user friendly. It guides user to learn and enjoy what they are doing which makes user to visit your website regularly and explore what you have to share. Here are few […]

Rajan Shergill
Rajan Shergill
Read

Grails

Create game Leaderboard using sqlProjection

Recently I was working on a Facebook game application using Grails 2.0 and Postgres database. The use case was to show the game leaderboard with ranks of the players. Players with same score should be given same rank and next player rank should be incremented rank of last player. Here is the sample data for […]

Bhagwat Kumar
Bhagwat Kumar
Read

Grails

Grails GSP tag: grep

The other day I was reading the Grails docs and I came across a useful GSP tag: grep. I have been using Grails for over 3 years now but just recently got to see this new tag which has eased my life a bit in situations where the list of objects have to be filtered […]

Grails

GSP Debugging tip – showSource

There are times when we have an !!Exception!! which looks like [code] grails_app_views_non_crashable_page_gsp:29 [/code] seems like our non crashable page just crashed, and looking at line 29 in our gsp is of no avail, and we just end up thinking maybe x or maybe y messed up. The trick is simple, simply in your URL […]

avinash
avinash
Read
Services