Anshul Sharma

Grails

File Compression

Creating a zip file using AntBuilder. def ant = new AntBuilder() ant.zip( destfile: destPath, basedir: basePath, includes: includeFiles, // Comma seperated file names excludes: excludeFiles, // Comma seperated file names level: 9 ...

14-Feb-2011

Grails

Posting messages on facebook wall using graph api

Firstly ,you need to connect with facebook. Once you have facebook access token you can post messages on the facebook wall using the below code. void postMessage(String facebookAccessToken, String message, String facebookId) { StringBuilder stringBuilder = new StringBuilder("access_token="); ...

14-Dec-2010

Technology

Integrate java application with Facebook using graph api.

These are few basic steps which will help you to integrate your java application with facebook using facebook graph api. Steps : 1) Register your application at http://www.facebook.com/developers/ 2) Facebook will return Consumer Key and Consumer Secret for your application. 3) Create a login action: String...

14-Nov-2010

Grails

Grails: execute sql script in Bootstrap

This blog might help you to speed up your bootstrap process, especially when you need to populate records in tables. Earlier we used populate our database table by reading line by line from a CSV file and creating Domain Class object ad Save. But this was taking a huge time. And in our case, this data (more like a static information) was...

14-Sep-2010

Grails

Image comparison

In one of our projects, we need to compare images which comes from various sources and remove the duplicate one. The below algo helps us to remove the duplicate images. boolean compareImage(String firstPhotoUrl, String secondPhotoUrl) { boolean result = true; BufferedImage bi1 = ImageIO.read(new...

14-Aug-2010

Grails

Integrating Java Application with Twitter

These are few basic steps which will help you to integrate your java application with twitter using twitter4j. Twitter4J is a Java library for the Twitter API. With Twitter4J, you can easily integrate your Java application with the Twitter. Steps : 1) Register your application at http://twitter.com/apps 2) Twitter will return...

13-Jul-2010

Grails

Serializing objects to XML

XStream is a simple Java library to serialize objects to XML and back again. Suppose we have a Person class as follows: public class Person { private String name private int age private Address address } public class Address { private String street private String city private String state private String...

14-May-2010