<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Intelligrape  Groovy &#38; Grails Blogs</title>
	<atom:link href="http://www.intelligrape.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.intelligrape.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 20 Feb 2012 16:37:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
			<title>Intelligrape  Groovy &amp; Grails Blogs</title>
			<url>http://www.intelligrape.com/blog/wp-content/uploads/2011/05/favicon2.ico</url>
			<link>http://www.intelligrape.com/blog</link>
			<width></width>
			<height></height>
			<description></description>
		</image>		<item>
		<title>Grails 2.0 action arguments data binding</title>
		<link>http://www.intelligrape.com/blog/2012/02/20/grails-2-0-action-arguments-data-binding/</link>
		<comments>http://www.intelligrape.com/blog/2012/02/20/grails-2-0-action-arguments-data-binding/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 16:37:13 +0000</pubDate>
		<dc:creator>Uday Pratap Singh</dc:creator>
				<category><![CDATA[Design Pattern]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[action databinding]]></category>
		<category><![CDATA[custom url]]></category>
		<category><![CDATA[data binding]]></category>
		<category><![CDATA[parameter binding]]></category>
		<category><![CDATA[url binding]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5106</guid>
		<description><![CDATA[One feature that I really like in Grails 2.0 is action arguments databinding. While reading more about it I also found a nice grails.web.RequestParameter annotation. When you know something you always find its use case. In my recent project I need to take radius and height as params for creating a cylinder so my action [...]]]></description>
			<content:encoded><![CDATA[<p>One feature that I really like in Grails 2.0 is action arguments <a href="http://grails.org/doc/latest/guide/theWebLayer.html#dataBinding">databinding</a>. While reading more about it I also found a nice grails.web.RequestParameter annotation. When you know something you always find its use case. In my recent project I need to take radius and height as params for creating a cylinder so my action looks like</p>
<pre class="brush: java;">
def save(float radius, float cylinder){
....
}
</pre>
<p>but now I have changed my action as</p>
<pre class="brush: java;">
def save(@RequestParameter('r')float radius, @RequestParameter('h')float height){
....
}
</pre>
<p>Now radius will initialize with params.r and height will initialize with params.h. It made my urls short and my code more readable.<br />
I believe that the real benefit of this annotation would be in a scenario where an external API returns some result whose fields are not that intuitive.<br />
However I have a wish here, that if we could use this annotation on command object fields as well then it will be more useful.</p>
<p>Hope it helps<br />
<br/><br />
## Uday Pratap Singh ##<br />
uday@intelligrape.com<br />
<a href="http://www.IntelliGrape.com/">http://www.IntelliGrape.com/</a><br />
<a href="http://in.linkedin.com/in/meudaypratap">http://in.linkedin.com/in/meudaypratap</a>  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/02/20/grails-2-0-action-arguments-data-binding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using aliases in aggregate functions of criteria queries</title>
		<link>http://www.intelligrape.com/blog/2012/02/13/using-aliases-in-aggregate-functions-of-criteria-queries/</link>
		<comments>http://www.intelligrape.com/blog/2012/02/13/using-aliases-in-aggregate-functions-of-criteria-queries/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 09:30:56 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[aliases]]></category>
		<category><![CDATA[createCriteria]]></category>
		<category><![CDATA[criteria query]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5083</guid>
		<description><![CDATA[When using criteria queries, many times we encounter a use case where we need to order our result not on any field of domain class but on  our result set, in these cases aliases can be used. 


In my project,  use case was to find most liked products from the domain:

ProductStat{
Date dateCreated
Product product
}

To [...]]]></description>
			<content:encoded><![CDATA[<p>When using criteria queries, many times we encounter a use case where we need to order our result not on any field of domain class but on  our result set, in these cases aliases can be used. </p>
<pre>
</pre>
<p>In my project,  use case was to find most liked products from the domain:</p>
<pre class="brush: java;">
ProductStat{
Date dateCreated
Product product
}
</pre>
<p>To find the result, the query I used was :</p>
<pre class="brush: java;">
ProductStat.createCriteria().list() {
            projections {
                groupProperty(&quot;product&quot;)
                count(&quot;product&quot;, &quot;totalProducts&quot;)  // alias totalProducts
            }
            order(&quot;totalProducts&quot;, &quot;desc&quot;)
}
</pre>
<pre>
</pre>
<p>In this way using alias &#8220;totalProducts&#8221; I was able to order the result according to the count of products.</p>
<pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/02/13/using-aliases-in-aggregate-functions-of-criteria-queries/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Alphanumeric Sorting using Criteria Query (with MySQL database)</title>
		<link>http://www.intelligrape.com/blog/2012/02/02/alphanum_sort/</link>
		<comments>http://www.intelligrape.com/blog/2012/02/02/alphanum_sort/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 07:48:06 +0000</pubDate>
		<dc:creator>Gaurav Sharma</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[GORM]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Alphanumeric Sort]]></category>
		<category><![CDATA[criteria query]]></category>
		<category><![CDATA[formula]]></category>
		<category><![CDATA[Human Sort]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[Natural Sort]]></category>
		<category><![CDATA[sorting]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5051</guid>
		<description><![CDATA[I am working on a Grails application with MySQL database. I had a use case in which I had to implement alphanumeric sorting using Criteria Query on Grails. By alphanumeric sorting I mean if there is a class Employee with field empId then on doing :

Employee e1 = new Employee(empId:'emp10').save()
Employee e2 = new Employee(empId:'emp2').save()
Employee e3 = [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on a Grails application with MySQL database. I had a use case in which I had to implement alphanumeric sorting using Criteria Query on Grails. By alphanumeric sorting I mean if there is a class Employee with field empId then on doing :</p>
<pre class="brush: plain;">
Employee e1 = new Employee(empId:'emp10').save()
Employee e2 = new Employee(empId:'emp2').save()
Employee e3 = new Employee(empId:'emp1').save()
Employee e4 = new Employee(empId:'1emp').save()
Employee e5 = new Employee(empId:'10emp').save()
Employee e6 = new Employee(empId:'2emp').save()

Employee.createCriteria().list([sort:'empId'])
            /* OR */
Employee.createCriteria().list{
    order('empId')
}
</pre>
<p><strong>should give result like [e4,e6,e5,e3,e2,e1]</strong>. But according to sql sorting the <strong>result would be [e5,e4,e6,e3,e1,e2]</strong><br />
<br />
One thing to note was that criteria query implemented sorting at the database end.<br />
After googling around, I came <a href="http://drupal.org/project/natsort">across a script</a> that had a SQL function which converted the field value to string that can alphanumerically sorted easily at database end.</p>
<p>To migrate the functions in script to database you have to unzip the script and write following command on terminal:</p>
<pre class="brush: bash;">mysql -u username -p database_name &lt; /path/to/unzipped/directory/natsort.install.mysql</pre>
<p>Now only thing I had to do was to get a derived field from the Grails property that had to be sorted alphanumerically which was easily possible as the Grails had ability to create transient field using formula (thanks to wonderful <a href="http://www.intelligrape.com/blog/2010/12/31/create-transients-using-formula-in-grails/">Blog by Uday</a>). Thus I had to create a new transient field using SQL function in formula. So I did something like this :</p>
<pre class="brush: groovy;">
class Employee {
    String empId
    String empIdSortField           //transient field
    static mapping = {
        empIdSortField formula: 'natsort_canon(empId, &quot;natural&quot;)'
    }
}
</pre>
<p>Now if I had to get Employee objects are sorted by empId alphanumerically, what I would do is :  </p>
<pre class="brush: groovy;">
Employee.createCriteria().list {
    order('empIdSortField')
}
</pre>
<p>Hope this was helpful to you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/02/02/alphanum_sort/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Groovy annotations for ToString and EqualsAndHashCode</title>
		<link>http://www.intelligrape.com/blog/2012/01/29/groovy-annotations-for-tostring-and-equalsandhashcode/</link>
		<comments>http://www.intelligrape.com/blog/2012/01/29/groovy-annotations-for-tostring-and-equalsandhashcode/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 12:10:29 +0000</pubDate>
		<dc:creator>Uday Pratap Singh</dc:creator>
				<category><![CDATA[Design Pattern]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[equals grails domain class]]></category>
		<category><![CDATA[grails domain class template]]></category>
		<category><![CDATA[groovy annotations]]></category>
		<category><![CDATA[groovy equals]]></category>
		<category><![CDATA[groovy hasCode]]></category>
		<category><![CDATA[groovy toString]]></category>
		<category><![CDATA[hashcode grails domain class]]></category>
		<category><![CDATA[tostring grails domain class]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5037</guid>
		<description><![CDATA[As I am a lazy programmer most of the time I dont implement toString and equals methods on my grails domain classes. I would like to say thanks to Groovy for helping me out and giving me a ready made recipe for this. Now I just need to annotate my class with ToString and EqualAndHashCode [...]]]></description>
			<content:encoded><![CDATA[<p>As I am a lazy programmer most of the time I dont implement toString and equals methods on my grails domain classes. I would like to say thanks to Groovy for helping me out and giving me a ready made recipe for this. Now I just need to annotate my class with <a href="http://groovy.codehaus.org/gapi/groovy/transform/ToString.html">ToString</a> and <a href="http://groovy.codehaus.org/gapi/groovy/transform/EqualsAndHashCode.html">EqualAndHashCode</a> annotation it adds appropriate implementation of these methods for me. Now My domain class looks something like this.</p>
<pre class="brush: java;">
@ToString(includeNames = true, includeFields = true, excludes = 'dateCreated,lastUpdated,metaClass')
@EqualsAndHashCode
class Item {
    String name
    Float price
    boolean active = true
    Date dateCreated
    Date lastUpdated
}
</pre>
<p>Before adding this annotation my domain class toString looks like this</p>
<pre class="brush: java;">
Item item = new Item(name: &quot;Chips&quot;, active: false, price: 15)
println &quot;To String output -: &quot; + item //To String output -: com.intelligrape.myapp.Item : null
</pre>
<p>Now I get the following output for Item object toString</p>
<pre class="brush: java;">
Item item = new Item(name: &quot;Chips&quot;, active: false, price: 15)
println &quot;To String output -: &quot; + item //To String output -: com.intelligrape.myapp.Item(name:Chips, price:15.0, active:false)
</pre>
<p>To get this annotation on all my domain classed I updated the template of grails domain classes so that whenever I do create-domain-class it give me the annotated domain classes</p>
<pre class="brush: java;">
@artifact.package@
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString

@ToString(includeNames = true, includeFields = true, excludes = 'dateCreated,lastUpdated,metaClass')
@EqualsAndHashCode
class @artifact.name@ {

    Date dateCreated
    Date lastUpdated
}
</pre>
<p>Hope it helps</p>
<p><br/><br />
## Uday Pratap Singh ##<br />
uday@intelligrape.com<br />
<a href="http://www.IntelliGrape.com/">http://www.IntelliGrape.com/</a><br />
<a href="http://in.linkedin.com/in/meudaypratap">http://in.linkedin.com/in/meudaypratap</a>  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/01/29/groovy-annotations-for-tostring-and-equalsandhashcode/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Extending Audit Logging Plugin to track changes to Persistent Collections</title>
		<link>http://www.intelligrape.com/blog/2012/01/23/extending-audit-logging-plugin-to-track-changes-to-persistent-collections/</link>
		<comments>http://www.intelligrape.com/blog/2012/01/23/extending-audit-logging-plugin-to-track-changes-to-persistent-collections/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 07:52:38 +0000</pubDate>
		<dc:creator>Ankur Tripathi</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Audit Logging]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5016</guid>
		<description><![CDATA[In one of our project we needed to maintain history of domain objects when they are updated. We saw Grails Audit Logging Plugin  as a good candidate. But later, found that it doesn&#8217;t take care of persistent collections. So with help of my colleague Vivek and this Stack Overflow thread, we extended this plugin [...]]]></description>
			<content:encoded><![CDATA[<p style="padding-bottom: 10px">In one of our project we needed to maintain history of domain objects when they are updated. We saw <a href="http://grails.org/plugin/audit-logging" target="_blank">Grails Audit Logging Plugin </a> as a good candidate. But later, found that it doesn&#8217;t take care of persistent collections. So with help of my colleague <a href="http://www.intelligrape.com/blog/author/vivek/" target="_blank">Vivek</a> and this <a href="http://stackoverflow.com/questions/812364/how-to-determine-collection-changes-in-a-hibernate-postupdateeventlistener" target="_blank">Stack Overflow thread</a>, we extended this plugin without making it inline, to handle this limitation.</p>
<p style="padding-bottom: 10px">Audit Logging plugin provides a bean named auditLogListener to handle Hibernate events and provide handlers in Grails Domain classes with old values map and new values map. So what we have to do is create a class named CustomAuditLogListener which extends AuditLogListener from the plugin and overrides the onPostUpdate() method. Implemetation for this class is:</p>
<pre class="brush: plain;">
import org.codehaus.groovy.grails.plugins.orm.auditable.AuditLogListener
import org.hibernate.collection.PersistentCollection
import org.hibernate.engine.CollectionEntry
import org.hibernate.engine.PersistenceContext
import org.hibernate.event.PostUpdateEvent

class CustomAuditLogListener extends AuditLogListener {

    @Override
    void onPostUpdate(final PostUpdateEvent event) {
        if (isAuditableEntity(event)) {
            log.trace &quot;${event.getClass()} onChange handler has been called&quot;
            onChange(event)
        }
    }

    private void onChange(final PostUpdateEvent event) {
        def entity = event.getEntity()
        String entityName = entity.getClass().getName()
        def entityId = event.getId()

        // object arrays representing the old and new state
        def oldState = event.getOldState()
        def newState = event.getState()

        List&lt;String&gt; propertyNames = event.getPersister().getPropertyNames()
        Map oldMap = [:]
        Map newMap = [:]

        if (propertyNames) {
            for (int index = 0; index &lt; newState.length; index++) {
                if (propertyNames[index]) {
                    if (oldState) {
                        populateOldStateMap(oldState, oldMap, propertyNames[index], index)
                    }
                    if (newState) {
                        newMap[propertyNames[index]] = newState[index]
                    }
                }
            }
        }

        if (!significantChange(entity, oldMap, newMap)) {
            return
        }

        // allow user's to over-ride whether you do auditing for them.
        if (!callHandlersOnly(event.getEntity())) {
            logChanges(newMap, oldMap, event, entityId, 'UPDATE', entityName)
        }
         executeHandler(event, 'onChange', oldMap, newMap)
        return
    }

    private populateOldStateMap(def oldState, Map oldMap, String keyName, index) {
        def oldPropertyState = oldState[index]
        if (oldPropertyState instanceof PersistentCollection) {
            PersistentCollection pc = (PersistentCollection) oldPropertyState;
            PersistenceContext context = sessionFactory.getCurrentSession().getPersistenceContext();
            CollectionEntry entry = context.getCollectionEntry(pc);
            Object snapshot = entry.getSnapshot();
            if (pc instanceof List) {
                oldMap[keyName] = Collections.unmodifiableList((List) snapshot);
            }
            else if (pc instanceof Map) {
                oldMap[keyName] = Collections.unmodifiableMap((Map) snapshot);
            }
            else if (pc instanceof Set) {
                //Set snapshot is actually stored as a Map
                Map snapshotMap = (Map) snapshot;
                oldMap[keyName] = Collections.unmodifiableSet(new HashSet(snapshotMap.values()));
            }
            else {
                oldMap[keyName] = pc;
            }
        } else {
            oldMap[keyName] = oldPropertyState
        }
    }
}
</pre>
<p style="padding-bottom: 10px">Now we need to register CustomAuditLogListener class as implementation for auditLogListener which will be done in resources.groovy. The bean has to be defined in resources.groovy as:</p>
<pre class="brush: plain;">
 auditLogListener(CustomAuditLogListener) {
        sessionFactory   = ref('sessionFactory')
        verbose          = application.config?.auditLog?.verbose?:false
        transactional    = application.config?.auditLog?.transactional?:false
        sessionAttribute = application.config?.auditLog?.sessionAttribute?:&quot;&quot;
        actorKey         = application.config?.auditLog?.actorKey?:&quot;&quot;
    }
</pre>
<p style="padding-bottom: 10px">Now we will be able to fetch older values for persistent collections in onChange handler as <a href="http://grails.org/plugin/audit-logging" target="_blank">documented in plugin documentation.</a></p>
<p style="padding-bottom: 10px">Hope you find this helpful.</p>
<p>Ankur Tripathi<br />
ankur@intelligrape.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/01/23/extending-audit-logging-plugin-to-track-changes-to-persistent-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Git Rebase</title>
		<link>http://www.intelligrape.com/blog/2012/01/22/using-git-rebase/</link>
		<comments>http://www.intelligrape.com/blog/2012/01/22/using-git-rebase/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 13:20:43 +0000</pubDate>
		<dc:creator>Sachin</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[advanced git]]></category>
		<category><![CDATA[git branching]]></category>
		<category><![CDATA[git rebase]]></category>
		<category><![CDATA[rebase]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=4973</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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 <a href="http://git-scm.com/" target="_blank">Git</a> surely is one of the coolest ones around. One of the many powerful features of git is <strong>rebase</strong>.</p>
<p>While working on a large project, you almost always develop your feature on a new branch, and for a large enough feature/requirement, It could take up to month or more to deliver it.</p>
<p>Lets consider a scenario where you need to begin on a new feature and you create a separate branch,(coolNewStuff) , off your main integration branch, (master).</p>
<p style="text-align: center;"><a href="http://www.intelligrape.com/blog/wp-content/uploads/2012/01/Graphic1.jpg"><img class="size-full wp-image-4990 aligncenter" title="Branch" src="http://www.intelligrape.com/blog/wp-content/uploads/2012/01/Graphic1.jpg" alt="New Branch from master" width="216" height="165" /></a></p>
<p>While you were working on the stuff, other guys in your team were pushing and integrating their stuff into the master branch. As a result master branch moved ahead and there were loads of commits and other stuff added to it.</p>
<p style="text-align: center;"><a href="http://www.intelligrape.com/blog/wp-content/uploads/2012/01/Graphic11.jpg"><img class="aligncenter size-full wp-image-4995" style="margin-top: 10px; margin-bottom: 10px;" title="Master branch moves ahead" src="http://www.intelligrape.com/blog/wp-content/uploads/2012/01/Graphic11.jpg" alt="" width="350" height="100" /></a></p>
<p>Now before pushing your cool stuff into master, you would need to pull in the changes in the master to your current(coolNewStuff) branch. You could easily do that using</p>
<pre class="brush: plain;">
git pull origin master
</pre>
<p>Resolve conflicts. commit changes and merge this branch with master.</p>
<p>Nothing wrong with that actually, except that it creates a lot of intermingled commits in the branch, and it won&#8217;t give a clear roll back point.</p>
<p>What you actually want to do is put your work on top of the existing master branch as a separate commit so that you get a clear roll back point in case something goes wrong.</p>
<p><strong> You want your changes of coolNewStuff branch on top of current master head, you don&#8217;t want master on top your coolNewStuffBranch.</strong></p>
<p style="text-align: center;"><strong><br />
</strong></p>
<p><strong>Enter Rebase.</strong></p>
<p>What rebase allows you to do is rewrite the history of your branch. You can actually pull in the changes from master branch place them above the master branch, you branched out off  (some 30-45 days back) and then place all the stuff you developed (all commits you made since the day you branched off) on top of this new pulled in changes from master. So, this looks like&#8230;</p>
<p style="text-align: center;"><a href="http://www.intelligrape.com/blog/wp-content/uploads/2012/01/Graphic12.jpg"><img class="aligncenter size-full wp-image-5001" title="Result after Rebase" src="http://www.intelligrape.com/blog/wp-content/uploads/2012/01/Graphic12.jpg" alt="" width="350" height="100" /></a></p>
<p>All you need to do is on the coolNewStuff branch call</p>
<pre class="brush: plain;">
git rebase master
</pre>
<p>This will start your rebasing process. It will basically collect the changes you made since you branched out of master to another temporary location, merge the old coolNewStuff (which was same as the master at the time you branched off) with the new changes on the master and then places your changes on top of it.</p>
<p>This process rewrites the history of the branch.</p>
<p>If you get conflicts. resolve the conflicts and <strong>add </strong>the files back</p>
<pre class="brush: plain;">
git add fileName
</pre>
<p>Continue with rebase</p>
<pre class="brush: plain;">
git rebase --continue
</pre>
<p>Do a git log and see that your changes are on top of the latest changes of master branch.</p>
<p>Now You won&#8217;t be able to push the changes to coolNewStuff branch as the history of branch has been rewritten.</p>
<p>On doing git status you would get a message saying</p>
<p><strong>Your branch and &#8216;origin/coolNewStuff&#8217; have diverged</strong></p>
<p>You will need to remove your remote branch</p>
<pre class="brush: plain;">
git push origin :coolNewStuff
</pre>
<p>and push again. Do remember to notify other guys who are working on the coolNewStuff branch to delete their local coolNewStuff branch and fetch the new coolNewStuff branch.</p>
<p>Now when you merge this branch with master you will see that your changes are on top of the recent stuff on master and you can easily roll back the stuff in case something goes wrong.</p>
<p>Hope this helps.</p>
<p>Sachin Anand</p>
<p>email : sachin[at]intelligrape[dot]com</p>
<p>twitter : @sachin__anand</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/01/22/using-git-rebase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Top 9 Features from Grails 2.0</title>
		<link>http://www.intelligrape.com/blog/2012/01/18/my-top-9-features-from-grails-2-0/</link>
		<comments>http://www.intelligrape.com/blog/2012/01/18/my-top-9-features-from-grails-2-0/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 13:22:07 +0000</pubDate>
		<dc:creator>Vivek Krishna</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[GORM]]></category>
		<category><![CDATA[grails 2.0]]></category>
		<category><![CDATA[grails testing]]></category>
		<category><![CDATA[new features of grails]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=4960</guid>
		<description><![CDATA[The  groovy world is abuzz about the latest release from the Grails Stable, Grails 2.0, which packs a lot more punch than its predecessors, which by  themselves were productivity enhancers and wonderful to develop our web  applications with. The new version brings with itself a lot of changes  compared to the [...]]]></description>
			<content:encoded><![CDATA[<p>The  groovy world is abuzz about the latest release from the Grails Stable, Grails 2.0, which packs a lot more punch than its predecessors, which by  themselves were productivity enhancers and wonderful to develop our web  applications with. The new version brings with itself a lot of changes  compared to the previous releases and deserves to be truly called 2.0 instead of 1.4 or 1.5.</p>
<p>I  would like to walk you through some of the coolest features from grails 2.0 that I have discovered in the limited time I have spent with the  new version and fell in love with.</p>
<ol>
<li> <strong>The Improved Interactive Mode</strong>:  I love working on the command line and the new interactive mode is a  joy to work with. The auto-completions, combined with the quick response  times(as a result of not having to load JVM for each command) is a sure  shot productivity booster. That I can run normal commands from the  grails shell by just prefixing them with a “!” is an added advantage.</li>
<li><strong>Dynamic Domain Class Reloading</strong>:  One activity that consumed a lot of time with earlier versions of  Grails was waiting for the servlet container to restart, once we made  even a line’s change in the domain class or src/groovy file. Now, the  reloading is dynamic which means that the changes take effect very  quickly, this letting us focus on the development without the flow being  interrupted by the restart process.</li>
<li><strong>HTML5 scaffolded screens</strong>:  One of the complaints I had with earlier versions of grails was the  not-so-good looking screens that were generated by scaffolding. For most  of the admin screens, the scaffolded screens are sufficient and the new  HTML5 compatible scaffolded screens are very easy on the eye and  provide an excellent user experience. With the new screens however, I  can simply change the logo and they make for sufficiently pleasing CRUD  screens.</li>
<li><strong>Business Class Citizenship for Testing</strong>:  Testing has been a first class citizen of the framework right from day  1, but the new testing framework has made life easy for people like me,  for whom testing doesn’t come naturally. With scaffolded tests being  generated, newbies will find it easier to learn aspects of testing the  application. In addition to that, the capability to unit-test criteria  queries adds an element which was missing from earlier versions.</li>
<li><strong>Link Generation/Page Renderer APIs</strong>:  Earlier, generating html from gsp files from non-request bound threads  was a pain, especially with mocking the web request. Now, with the  PageRenderer API, generating a view in a job or a service is as simple  as injecting a groovyPageRenderer bean and calling  groovyPageRenderer.render() method just like from within a controller.</li>
<li><strong>GORM Finders with Groovy Collection find/findAll like syntax</strong>:  If there was one feature I could keep from all the enhancements in 2.0,  it would be this. This is also the feature which, I think would go a  long way in making GORM queries easier. There couldn’t be a more  expressive syntax!</li>
<li><strong>Public methods in controllers as actions which can take arguments</strong>:  Earlier, it used to be a pain to type-cast the parameters into their  respective types(when one felt that command objects are an overhead  while working with at most 2-3 params). The new method like syntax lets  us define actions as public methods in controllers, which automatically  bind data to the method arguments, based on the params. If I have a  command object as argument, it works just the way it worked earlier. We  talk about thin controllers a lot. This also means that we’ll be more  diligent while creating methods in controllers and even if we really  must, they have to be private. This just made the controllers thinner!</li>
<li><strong>The New Improved Test Reports</strong>:  The new test reports are very easy on the eye and even more easier  while finding test failures. Though we don’t recommend having println statements in our test cases, the fact that I can see the system outputs  on the same page as my test case is a winner.</li>
<li><strong>DB Console</strong>: Viewing the contents of the in-memory DB was a pain in the earlier versions. The new dbconsole, which can be accessed only in development mode is a clear winner.</li>
</ol>
<p>Grails 2.0 comes with its set of wonderful features which makes development with it, a much better experience.</p>
<p><script src="https://www.surveymonkey.com/jsEmbed.aspx?sm=G7LJIMEJCZsd6zwvkl7fJA_3d_3d"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/01/18/my-top-9-features-from-grails-2-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Custom &#8216;Share&#8217; button on Facebook wall post</title>
		<link>http://www.intelligrape.com/blog/2012/01/16/custom-share-button-on-facebook-wall-post/</link>
		<comments>http://www.intelligrape.com/blog/2012/01/16/custom-share-button-on-facebook-wall-post/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 13:05:34 +0000</pubDate>
		<dc:creator>Vishal Sahu</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Facebook App]]></category>
		<category><![CDATA[facebook post]]></category>
		<category><![CDATA[facebook wall post]]></category>
		<category><![CDATA[Social Media]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=4938</guid>
		<description><![CDATA[Hi,
In one of my Grails project, i needed to have Share feature on the messages/post published by our application on facebook wall.
In Facebook, if the message/text published is simple text, then Share link appears on it, but if it contains any link/URL attached to it, then Facebook do not provides Share button on it.


To implement [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
In one of my Grails project, i needed to have <strong>Share</strong> feature on the messages/post published by our application on facebook wall.<br />
In Facebook, if the message/text published is simple text, then <strong>Share</strong> link appears on it, but if it contains any link/URL attached to it, then Facebook do not provides Share button on it.</p>
<pre>
</pre>
<p>To implement it, i created my own <strong>Share</strong> button and thought it worth sharing.</p>
<pre>
</pre>
<p>Publishing to facebook wall post requires facebook access_token and we have to do a post call to publish it on facebook wall.<br />
I am assuming that you already have the access_token, if not you can find how to get access_token from <a href="http://www.intelligrape.com/blog/2010/11/14/integrate-java-application-with-facebook-using-graph-api/">here</a></p>
<pre>
</pre>
<p>Basic URL to share somthing on facebook wall is as below</p>
<pre class="brush: java;">

    private static final String SHARE_BUTTON_BASIC_URL = &quot;http://www.facebook.com/sharer.php?u=&quot;
    private static final String BUTTON_NAME = &quot;Share This&quot; // name to appear on the Share button
</pre>
<p>To create our own &#8216;Share&#8217; button, we have to oass the custom button parameters in &#8216;actions&#8217; attribute of the post call.</p>
<p>Code to publish message/post which contains any link attachment is as :-</p>
<pre class="brush: java;">
      String message=  //Message to be published on facebook wall
      String access_token= // facebook access token
      String attachmentImageUrl= // Url of the image to be published in the wall post
      String attachmentLink= // Link attached with the message

       StringBuilder sb = new StringBuilder(&quot;access_token=&quot;);
        sb.append(URLEncoder.encode(access_token, &quot;UTF-8&quot;));
        sb.append(&quot;&amp;message=&quot;);
        sb.append(URLEncoder.encode(message, &quot;UTF-8&quot;));
        sb.append(&quot;&amp;picture=&quot;);
        sb.append(URLEncoder.encode(attachmentImageUrl, &quot;UTF-8&quot;));
        sb.append(&quot;&amp;link=&quot;);
        sb.append(URLEncoder.encode(attachmentLink, &quot;UTF-8&quot;));
        sb.append(&quot;&amp;actions=&quot;)
        sb.append(URLEncoder.encode(&quot;[{name: '${BUTTON_NAME}', link: '${SHARE_BUTTON_BASIC_URL}${attachmentLink}' }]&quot;, &quot;UTF-8&quot;));

            URL url = new URL('https://graph.facebook.com/feed');
            HttpURLConnection connection
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod(&quot;POST&quot;);
            connection.setRequestProperty(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;);
            connection.setRequestProperty(&quot;Content-Length&quot;, &quot;&quot; + sb.toString().length());
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(connection.getOutputStream());
            outputStreamWriter.write(sb.toString());
            outputStreamWriter.flush();
            connection?.disconnect()
</pre>
<p>So, whatever we provide in the &#8216;actions&#8217; property of post call, will appear in the wall post with the defined action. Here we are using it as link to Share a facebook wall post.</p>
<pre>
</pre>
<p><strong>Sample post with custom &#8216;Share This&#8217; link on facebook Wall</strong></p>
<div style="float:left;width:100%">
<a href="http://www.intelligrape.com/blog/wp-content/uploads/2012/01/rsz_screenshot_at_2012-01-16_18002611.png"><img src="http://www.intelligrape.com/blog/wp-content/uploads/2012/01/rsz_screenshot_at_2012-01-16_18002611.png" alt="" width="519" height="215" class="alignleft size-full wp-image-4943" /></a>
</div>
<pre>
</pre>
<pre>
</pre>
<p>This worked in my case.<br />
Hope it helps.</p>
<p>Cheers!!!</p>
<p>Vishal Sahu<br />
vishal@intelligrape.com<br />
<a href="http://www.intelligrape.com">www.intelligrape.com</a><br />
<a href="http://www.linkedin.com/in/vishalsahu">http://www.linkedin.com/in/vishalsahu</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/01/16/custom-share-button-on-facebook-wall-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating GIT Alias</title>
		<link>http://www.intelligrape.com/blog/2011/12/30/creating-git-alias/</link>
		<comments>http://www.intelligrape.com/blog/2011/12/30/creating-git-alias/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 19:47:54 +0000</pubDate>
		<dc:creator>Hitesh Bhatia</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[fsck]]></category>
		<category><![CDATA[gc]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[global config]]></category>
		<category><![CDATA[prune]]></category>
		<category><![CDATA[reset hard]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=4917</guid>
		<description><![CDATA[Since Git is awesome. It also provides functionality of making aliases.
Example
git config --global alias.co checkout 
Here we created co as an alias for checkout (All the aliases that are created goes into .gitconfig file under home folder). Now to checkout a branch named testBranch, We can also write
git co testBranch
Switched to branch 'testBranch'
Here are couple [...]]]></description>
			<content:encoded><![CDATA[<p>Since Git is awesome. It also provides functionality of making aliases.<br />
Example</p>
<pre class="brush: bash;">git config --global alias.co checkout </pre>
<p>Here we created co as an alias for checkout (All the aliases that are created goes into .gitconfig file under home folder). Now to checkout a branch named testBranch, We can also write</p>
<pre class="brush: bash;">git co testBranch
Switched to branch 'testBranch'</pre>
<p>Here are couple of interesting git aliases that we can make</p>
<p>1.git config &#8211;global alias.undo &#8216;reset –hard&#8217;</p>
<p style="padding-left: 30px">Now if we write  “git undo” then any of changes after my last commit will be removed.</p>
<blockquote>
<p style="padding-left: 30px">
</blockquote>
<p>2.git config &#8211;global alias.cleanup = ! git fsck &amp;&amp; git  prune &amp;&amp; git gc</p>
<p style="padding-left: 30px">In this Command we have used exclamation mark (!), this indicates that these commands would be running on terminal.<br />
And in git if I want multiple command to be running one after another we use double ampersand (&amp;&amp;) (We cannot use semicolon as we would usually do in terminal).<br />
This command will run git fsck (file check), git  prune (to clean dangling commits/blobs)  and git garage collection</p>
<p>Number of git alias that can be made are endless all it needs is little creativity.</p>
<div>_________________________________</div>
<div>Hitesh Bhatia<br />
<a href="http://in.linkedin.com/in/bhatiahitesh" target="_blank">Mail,LinkedIn</a>,<a href="http://www.facebook.com/home.php?#%21/profile.php?id=100000114437286" target="_blank">Facebook</a>,<a href="http://twitter.com/d1_ricky" target="_blank">Twitter</a><br />
_________________________________</div>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/12/30/creating-git-alias/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GIT Maintenance</title>
		<link>http://www.intelligrape.com/blog/2011/12/30/git-maintenance/</link>
		<comments>http://www.intelligrape.com/blog/2011/12/30/git-maintenance/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 19:25:37 +0000</pubDate>
		<dc:creator>Hitesh Bhatia</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[fsck]]></category>
		<category><![CDATA[garbage collection]]></category>
		<category><![CDATA[gc]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[maintenance]]></category>
		<category><![CDATA[prune]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=4908</guid>
		<description><![CDATA[Since we use git numerous times a day over and over, hence needs maintenance. There are few commands that will help you to keep our git healthy. If you feel that you git has somewhat slowed down, these would do the trick for you.
Since ours is a pretty big project . I run it once [...]]]></description>
			<content:encoded><![CDATA[<p>Since we use git numerous times a day over and over, hence needs maintenance. There are few commands that will help you to keep our git healthy. If you feel that you git has somewhat slowed down, these would do the trick for you.</p>
<p>Since ours is a pretty big project . I run it once a week to make sure my git is healthy.</p>
<p>1.git fsck</p>
<p>This commands helps to identify any corrupted, unreachable (dangling blobs) objects in your database.<br />
Example</p>
<pre class="brush: bash;">
git fsck
dangling commit 652424f02c17b5d881158a625f1a34f6039dc231
dangling commit 7e6510c2663530d949ea9fb67900496dcf5cbc4c
dangling commit 177864469ea87564ade9101106d5aa85cceb0d29
dangling commit 848665007bc412910b68dc3e528e74c23ce1f165
dangling blob dfa6756511b525996946de84fa7f67b6f9a0d32f
dangling blob e7f8f1145c7e739a6ffd8806a6d26d60f0443897
dangling blob f1f905a5eb35724622249f25f6d9ef7c646e4283
dangling blob 221417781e017cf02f90b872aea80f30ed41787c
dangling blob c1356b24fb2a4ea453dba87ed4058e7a48e97dce
dangling blob cb6fe3d5321b7b152a8781541bbc6132c59b9c94
dangling blob 3ce2e76cd54f0c8265ec6167f78d5dfe71c2242d
dangling blob daf073729960c40a44c5291c745092445bb2c3b0
</pre>
<p>2.git prune<br />
With git fsck, we identified some of dangling commits and blobs,  now to remove them we use git prune.<br />
Now After running git prune, If I run git fsck again, my git would be cleaner than before and healthy.</p>
<pre class="brush: bash;">
git fsck
dangling commit 177864469ea87564ade9101106d5aa85cceb0d29
dangling commit 848665007bc412910b68dc3e528e74c23ce1f165
</pre>
<p>But it still has some dangling commits.This is where git&#8217;s garbage collection comes in play.<br />
</br></p>
<p>3.git gc (Garbage Collection)<br />
This command will gathers up all the loose objects and places them in packfiles. And  removes objects that aren’t reachable from any commit. This command will save some space and speed up many of git commands.<br />
Example</p>
<pre class="brush: bash;">
git gc
Counting objects: 121775, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (18239/18239), done.
Writing objects: 100% (121775/121775), done.
Total 121775 (delta 76189), reused 120913 (delta 75659)
Removing duplicate objects: 100% (256/256), done.
</pre>
<p>Output of this commands tells several things  to us , that is compressed 18239 objects for us out of total 121775 objects. And it also removed 256 duplicate objects. This way my git stayed healthy.</p>
<div>_________________________________</div>
<div>Hitesh Bhatia<br />
<a href="http://in.linkedin.com/in/bhatiahitesh" target="_blank">Mail,LinkedIn</a>,<a href="http://www.facebook.com/home.php?#%21/profile.php?id=100000114437286" target="_blank">Facebook</a>,<a href="http://twitter.com/d1_ricky" target="_blank">Twitter</a><br />
_________________________________</div>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/12/30/git-maintenance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

