<?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>Tue, 07 Sep 2010 12:52:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>GORM goodies read, discard, refresh</title>
		<link>http://www.intelligrape.com/blog/2010/09/07/gorm-goodies-read-discard-refresh/</link>
		<comments>http://www.intelligrape.com/blog/2010/09/07/gorm-goodies-read-discard-refresh/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 11:24:58 +0000</pubDate>
		<dc:creator>Uday Pratap Singh</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Java tools]]></category>
		<category><![CDATA[automatic update in grails]]></category>
		<category><![CDATA[discard usage]]></category>
		<category><![CDATA[read usage]]></category>
		<category><![CDATA[refresh usage]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1557</guid>
		<description><![CDATA[Grails docs are the best source to understand how to make best use of GORM methods and now the GORM Gotcha&#8217;s series By Peter Ledbrook is also making the docs easy to understand.
So many time it happens when the domain instance values gets updated without calling save method.It  happens because the object is attached [...]]]></description>
			<content:encoded><![CDATA[<p>Grails docs are the best source to understand how to make best use of GORM methods and now the <a href="http://blog.springsource.com/2010/06/23/gorm-gotchas-part-1/">GORM Gotcha&#8217;s series By Peter Ledbrook</a> is also making the docs easy to understand.<br />
So many time it happens when the domain instance values gets updated without calling save method.It  happens because the object is attached to hibernate session, to change this behavior we can use the method like read instead of get/load.<br />
What read actually do is</p>

<div class="wp_syntax"><div class="code"><pre class="groovy">Person person <span style="color: #66cc66;">=</span> Person.<span style="color: #006600;">read</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Output -: ${person?.firstname}&quot;</span>  <span style="color: #808080; font-style: italic;">// Output -: Uday</span>
person.<span style="color: #006600;">firstname</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Uday1&quot;</span>
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Output -: ${person?.firstname}&quot;</span> <span style="color: #808080; font-style: italic;">// Output -: Uday1</span></pre></div></div>

<p>The value is changed but it is not stored in the database. But the changes can be saved into the database if you explicitly call save().  </p>
<p>The other approach could be removing the object from hibernate session, so that the changes made to the database do not get persisted to the database</p>

<div class="wp_syntax"><div class="code"><pre class="groovy">Person person <span style="color: #66cc66;">=</span> Person.<span style="color: #663399;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Output -: ${person?.firstname}&quot;</span>  <span style="color: #808080; font-style: italic;">// Output -: Uday</span>
person.<span style="color: #006600;">firstname</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;Uday1&quot;</span>
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Output -: ${person?.firstname}&quot;</span> <span style="color: #808080; font-style: italic;">// Output -: Uday1</span>
person.<span style="color: #006600;">discard</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Output -: ${person?.firstname}&quot;</span>  <span style="color: #808080; font-style: italic;">// Output -: Uday1</span></pre></div></div>

<p>In above example, none of the change made to the object do not get persisted to the database . Again it will save the changes if you explicitly call save(). </p>
<p>One more good method is refresh() which is used to load the object again from the database, so all the changes made to object will be reverted. Though it is not advisable but sometimes if you want to get the object to its original stage you can do it by refresh.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy">Person person <span style="color: #66cc66;">=</span> Person.<span style="color: #663399;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Output -: ${person?.firstname}&quot;</span> <span style="color: #808080; font-style: italic;">// Output -: Uday</span>
person.<span style="color: #006600;">firstname</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;Uday1&quot;</span>
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Output -: ${person?.firstname}&quot;</span> <span style="color: #808080; font-style: italic;">// Output -: Uday1</span>
person.<span style="color: #006600;">refresh</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993399;">println</span> <span style="color: #ff0000;">&quot;Output -: ${person?.firstname}&quot;</span> <span style="color: #808080; font-style: italic;">// Output -: Uday</span></pre></div></div>

<p>These are the few goodies which are available with the GORM and we can use according to our use case <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Hope it helps</p>
<p>## Uday Pratap Singh ##<br />
uday@intelligrape.com</p>
<p><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/2010/09/07/gorm-goodies-read-discard-refresh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Map database table without id with grails domain</title>
		<link>http://www.intelligrape.com/blog/2010/09/07/how-to-map-database-table-without-id-with-grails-domain/</link>
		<comments>http://www.intelligrape.com/blog/2010/09/07/how-to-map-database-table-without-id-with-grails-domain/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 10:07:04 +0000</pubDate>
		<dc:creator>Uday Pratap Singh</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[grails domain mapping]]></category>
		<category><![CDATA[map domain in grails]]></category>
		<category><![CDATA[map without id table]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1551</guid>
		<description><![CDATA[Recently I got a query regarding mapping a database table which do not have any id and version. For example the table have two varchar fields username and password nothing more than that.
Although it was something strange for me that table doesn&#8217;t have the id field. The good thing is that the username is a [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I got a query regarding mapping a database table which do not have any id and version. For example the table have two varchar fields username and password nothing more than that.<br />
Although it was something strange for me that table doesn&#8217;t have the id field. The good thing is that the username is a primary key in the table and this is not auto incremented user want to create it by his own method.</p>
<p>The good thing about grails is, in most of the cases you get your answer in the docs <a href="http://grails.org/doc/latest/">http://grails.org/doc/latest/</a> . So in this case we just need to change the id field in grails domain like this</p>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="color: #000000; font-weight: bold;">class</span> Test <span style="color: #66cc66;">&#123;</span>
    <span style="color: #aaaadd; font-weight: bold;">String</span> username
    <span style="color: #aaaadd; font-weight: bold;">String</span> password
&nbsp;
    <span style="color: #000000; font-weight: bold;">static</span> mapping <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
        id name: <span style="color: #ff0000;">'username'</span>
        version <span style="color: #000000; font-weight: bold;">false</span>
        id generator: <span style="color: #ff0000;">'assigned'</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
        username<span style="color: #66cc66;">&#40;</span>nullable: <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>and we are done <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .<br />
Hope it helps<br />
## Uday Pratap Singh ##<br />
uday@intelligrape.com</p>
<p><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/2010/09/07/how-to-map-database-table-without-id-with-grails-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>canvas</title>
		<link>http://www.intelligrape.com/blog/2010/09/07/canvas/</link>
		<comments>http://www.intelligrape.com/blog/2010/09/07/canvas/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 07:53:45 +0000</pubDate>
		<dc:creator>umar</dc:creator>
				<category><![CDATA[HTML-UI-CSS]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1542</guid>
		<description><![CDATA[The HTML &#60;canvas&#62; tag is used for creating graphics on the fly. It can be used for rendering graphs, game graphics, or other visual images.
&#160;
To draw on the canvas, the &#60;canvas&#62; tag is used in conjunction with the getContext(contextId) method.
&#160;
Any content between the &#60;canvas&#62;&#60;/canvas&#62; tags is &#8220;fallback content&#8221;- meaning, it will be displayed only if [...]]]></description>
			<content:encoded><![CDATA[<p>The HTML <code>&lt;canvas&gt;</code> tag is used for creating graphics on the fly. It can be used for rendering graphs, game graphics, or other visual images.</p>
<p>&nbsp;</p>
<p>To draw on the canvas, the <code>&lt;canvas&gt;</code> tag is used in conjunction with the <code>getContext(contextId)</code> method.</p>
<p>&nbsp;</p>
<p>Any content between the <code>&lt;canvas&gt;</code><code>&lt;/canvas&gt;</code> tags is &#8220;fallback content&#8221;- meaning, it will be displayed only if the canvas cannot be displayed.</p>
<p>&nbsp;</p>
<p><strong>As a script:</strong></p>
<blockquote>
<div class="wp_syntax">
<div class="code">
<pre class="groovy">function displayCanvas()
	{
      var canvas = document.getElementById("myCanvas");
      if (canvas.getContext) {
        var ctx = canvas.getContext("2d");

        ctx.fillStyle = "rgb(200,0,0)";
        ctx.fillRect (0, 0, 150, 75);

        ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
        ctx.fillRect (40, 30, 125, 75);

        ctx.fillStyle = "rgb(0,0,150)";
        ctx.strokeRect (20, 20, 50, 100);
      }
    }</pre>
</div>
</div>
</blockquote>
<p>&nbsp;</p>
<p><strong>and this is html</strong></p>
<blockquote>
<div class="wp_syntax">
<div class="code">
<pre class="groovy"><code>&lt;canvas id="myCanvas" width="300" height="200"&gt;</code>Your browser does not support the canvas tag. At the time of writing, Firefox, Opera, and Chrome support this tag.

Here's an <a>image of what it's supposed to look like <img src="http://www.intelligrape.com/blog/wp-content/uploads/2010/09/plus.png" alt="image" /></a>.
<code>&lt;/canvas&gt;</code></pre>
</div>
</div>
</blockquote>
<p><strong>Attributes</strong><br />
<strong>width:</strong> {Specifies the canvas width in pixels. The default value is 300.Possible values:[Non-negative integer] (for example, 300)}<br />
<strong>Height:</strong> {Specifies the canvas height in pixels. The default value is 150.Possible values:[Non-negative integer] (for example, 150)}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/09/07/canvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git Stash : A very useful command</title>
		<link>http://www.intelligrape.com/blog/2010/08/31/git-stash-a-very-useful-command/</link>
		<comments>http://www.intelligrape.com/blog/2010/08/31/git-stash-a-very-useful-command/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 13:41:59 +0000</pubDate>
		<dc:creator>Vivek Krishna</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git hub]]></category>
		<category><![CDATA[git stash]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1537</guid>
		<description><![CDATA[We have been using GitHub for version control in one of our projects and I am absolutely loving it! There are quite many advantages over a concurrent version control system like subversion.
One of the commands I found useful was the stash command. It is of use when we are working on a piece of functionality, [...]]]></description>
			<content:encoded><![CDATA[<p>We have been using GitHub for version control in one of our projects and I am absolutely loving it! There are quite many advantages over a concurrent version control system like subversion.</p>
<p>One of the commands I found useful was the stash command. It is of use when we are working on a piece of functionality, which is not in a state to be committed, but find that there is a bug/issue in a previously committed piece of code and want to fix it before proceeding with any further development.</p>
<p>In that case, what we can do is issue the command</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="groovy">git stash save <span style="color: #ff0000;">&quot;work in progress&quot;</span></pre></div></div>

</blockquote>
<p>Once that is done, it is a save point. Now you can revert the code for that particular branch by using the checkout command.<br />
After fixing the issue and committing it (and pushing it) we can get back the copy on which we were working, with the command,</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="groovy">git stash <span style="color: #663399;">pop</span></pre></div></div>

</blockquote>
<p>A very elegant command in what would&#8217;ve been an otherwise tedious job,</p>
<p>Hope this helps.</p>
<p>Vivek</p>
<p>http://in.linkedin.com/in/svivekkrishna</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/08/31/git-stash-a-very-useful-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add Page number using Page Property of CSS</title>
		<link>http://www.intelligrape.com/blog/2010/08/20/add-page-number-using-page-property-of-css/</link>
		<comments>http://www.intelligrape.com/blog/2010/08/20/add-page-number-using-page-property-of-css/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 07:11:22 +0000</pubDate>
		<dc:creator>Uday Pratap Singh</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[HTML-UI-CSS]]></category>
		<category><![CDATA[css page number]]></category>
		<category><![CDATA[css page property]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Paged Media]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1531</guid>
		<description><![CDATA[In my recent project we need to generate the pdf document from HTML page. We are using iText renderer for doing this. The client had the requirement that each page bottom right need to have number on it. All these things need to be replicated on every page. So for doing this we need to [...]]]></description>
			<content:encoded><![CDATA[<p>In my recent project we need to generate the pdf document from HTML page. We are using iText renderer for doing this. The client had the requirement that each page bottom right need to have number on it. All these things need to be replicated on every page. So for doing this we need to know more about the CSS3 page properties . I found the solution in this documentation <a href="http://www.w3.org/TR/css3-page/ ">http://www.w3.org/TR/css3-page/ </a>and <a href="http://www.w3.org/TR/CSS21/generate.html#counters">http://www.w3.org/TR/CSS21/generate.html#counters</a><br />
For doing this I did something like</p>

<div class="wp_syntax"><div class="code"><pre class="groovy">@page <span style="color: #66cc66;">&#123;</span>
        margin-top: 149px<span style="color: #66cc66;">;</span>
        margin-left: 2px<span style="color: #66cc66;">;</span>
        margin-bottom: 40px<span style="color: #66cc66;">;</span>
        margin-right: 2px<span style="color: #66cc66;">;</span>
        <span style="color: #663399;">size</span>: landscape<span style="color: #66cc66;">;</span>
        counter-increment: page<span style="color: #66cc66;">;</span>
&nbsp;
     @bottom-right <span style="color: #66cc66;">&#123;</span>
padding-right:20px<span style="color: #66cc66;">;</span>
        content: <span style="color: #ff0000;">&quot;Page &quot;</span> counter<span style="color: #66cc66;">&#40;</span>page<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
      <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Its just so simple we added and incremental page counter in the page property which can be reset as well. As my counter was incrementing after each page so I defined counter-interment at page level, although depending on the cases you can increment the counter before or after occurrence of any element like.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy">.<span style="color: #006600;">incrementClass</span>:before <span style="color: #66cc66;">&#123;</span>
   counter-increment: page<span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>in above example counter will be incremented before the incrementClass appears on the page.</p>
<p>Hope it helps</p>
<p>## Uday Pratap Singh ##<br />
uday@intelligrape.com</p>
<p><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/2010/08/20/add-page-number-using-page-property-of-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling Password Protected Pdf  with PdfReader</title>
		<link>http://www.intelligrape.com/blog/2010/08/19/handling-password-protected-pdf-with-pdfreader/</link>
		<comments>http://www.intelligrape.com/blog/2010/08/19/handling-password-protected-pdf-with-pdfreader/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 12:03:49 +0000</pubDate>
		<dc:creator>Hitesh Bhatia</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[bouncycastle]]></category>
		<category><![CDATA[iText]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[password protected pdf]]></category>
		<category><![CDATA[password Protection]]></category>
		<category><![CDATA[pdf]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1525</guid>
		<description><![CDATA[In one of our grails project , we had to attach cover to Pdf file . But since some of pdf&#8217;s uploaded were password protected.
To handle this scenario we added bouncyCastle.jar , so our version of   iText was able to handle password protected pdf .
And Then to check whether pdf is password protected [...]]]></description>
			<content:encoded><![CDATA[<p>In one of our grails project , we had to attach cover to Pdf file . But since some of pdf&#8217;s uploaded were password protected.</p>
<p>To handle this scenario we added bouncyCastle.jar , so our version of   iText was able to handle password protected pdf .<br />
And Then to check whether pdf is password protected or not  , we used &#8220;Boolean isOpenedWithFullPermission()&#8221; method.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy">PdfReader pdf <span style="color: #66cc66;">=</span> PdfReader<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;filePath&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #aaaadd; font-weight: bold;">Boolean</span> editable <span style="color: #66cc66;">=</span> pdf.<span style="color: #006600;">isOpenedWithFullPermissions</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>editable<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">//attach Cover</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">//skip  cover</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>As &#8220;isOpenedWithFullPermissions()&#8221; returns a Boolean variable ,<br />
it was easy for us to recognize whether we would be able to edit (i.e attach cover in our case) depending on its output. (i,e true or false)<br />
 </p>
<p>_________________________________<br />
Hitesh Bhatia<br />
<a href="mailto:hitesh@intelligrape.com?subject=Feedback On Blog">Mail</a><br />
<a href="http://in.linkedin.com/in/bhatiahitesh" target="_blank">LinkedIn</a>,<a href="http://www.facebook.com/home.php?#!/profile.php?id=100000114437286" target="_blank">Facebook</a>,<a href="http://twitter.com/d1_ricky" target="_blank">Twitter</a><br />
_________________________________</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/08/19/handling-password-protected-pdf-with-pdfreader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySql : Publish results of a query to a text file</title>
		<link>http://www.intelligrape.com/blog/2010/08/16/mysql-publish-results-of-a-query-to-a-text-file/</link>
		<comments>http://www.intelligrape.com/blog/2010/08/16/mysql-publish-results-of-a-query-to-a-text-file/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 03:59:10 +0000</pubDate>
		<dc:creator>Himanshu Seth</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/2010/08/16/mysql-publish-results-of-a-query-to-a-text-file/</guid>
		<description><![CDATA[A while back I was trying to debug an error in our application logic. For that I had to analyze the results of a query
This analysis was getting pretty tough to do on the command line. So, I tried to find a way to transfer the results of a query to a text file so [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I was trying to debug an error in our application logic. For that I had to analyze the results of a query</p>
<p>This analysis was getting pretty tough to do on the command line. So, I tried to find a way to transfer the results of a query to a text file so that they can be analysed easily.</p>
<p>With help from google, I got my answer at <a href="http://www.wellho.net/forum/The-MySQL-Relational-Database/MySQL-query-to-a-text-file.html" target="_blank">http://www.wellho.net/forum/The-MySQL-Relational-Database/MySQL-query-to-a-text-file.html</a></p>
<p><code>echo "&lt;YOUR SELECT QUERY&gt;"| /usr/local/mysql/bin/mysql --user=root --password=password dbName &gt; /path/to/your/textFIle.txt</code>/</p>
<p>Hope this helps</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/08/16/mysql-publish-results-of-a-query-to-a-text-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Profiling through Firebug&#8217;s Console API.</title>
		<link>http://www.intelligrape.com/blog/2010/08/16/javascript-profiling-through-firebugs-console-api/</link>
		<comments>http://www.intelligrape.com/blog/2010/08/16/javascript-profiling-through-firebugs-console-api/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 03:31:17 +0000</pubDate>
		<dc:creator>Chandan Luthra</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1509</guid>
		<description><![CDATA[Sometimes we want to know which line of codes or methods in the JavaScript is taking time which slows up the page load. Many times our browser gets hanged due to execution of JavaScript.
Firebug allows us to profile the JavaScript. Following are the two methods that are used for profiling JavaScript:
console.profile()
console.profileEnd()
After the execution of the [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes we want to know which line of codes or methods in the JavaScript is taking time which slows up the page load. Many times our browser gets hanged due to execution of JavaScript.</p>
<p>Firebug allows us to profile the JavaScript. Following are the two methods that are used for profiling JavaScript:<br />
<strong>console.profile()<br />
console.profileEnd()</strong></p>
<p>After the execution of the JS, Firebug generates a nice stats through which one can figure out the problematic line of code(if any).</p>
<p>Type this following code in an HTML file, save it and open it up with Firebug enabled Firefox(if Firebug is not enabled then press F12 key to activate it) :</p>

<div class="wp_syntax"><div class="code"><pre>&lt;html&gt;
&lt;head&gt;&lt;title&gt;Firebug&lt;/title&gt;
&lt;script&gt;
function bar(){
	console.profile('Measuring time')<SEMI>
	foo()<SEMI>
	console.profileEnd()<SEMI>
}
function foo(){
	loop(1000)<SEMI>loop(100000)<SEMI>loop(10000)<SEMI>
}
function loop(count){
	for(var i=0<SEMI>i&lt;count<SEMI>i++){}
}
&lt;/script&gt;&lt;/head&gt;&lt;body&gt;
Click this button to profile JavaScript
&lt;input type=&quot;button&quot; value=&quot;Start&quot; onclick=&quot;bar()<SEMI>&quot;/&gt;
&lt;/body&gt;&lt;/html&gt;</pre></div></div>

<p>Click on the button to start the JavaScript profiler. You would see table is generated in the Firebug’s Console panel.<br />
<img src="http://www.intelligrape.com/blog/wp-content/uploads/2010/08/Screenshot.png" alt="JS profiling" title="Firebug&#039;s Console API" width="700" height="78" class="aligncenter size-full wp-image-1514" /><br />
Description and purpose of the columns:<br />
<strong>Function: </strong>This column shows the name of each function.<br />
<strong>Call:</strong> It shows the count of how many a particular function has been invoked. (3 times for loop() function in our case.)<br />
<strong>Percent: </strong>It shows the time consuming of each function in percentage.<br />
<strong>Own Time:</strong> It shows the duration of own script in a particular function. For example foo() function has none of its own code. Instead, it is just calling other functions. So, its own execution time will be approx ~0ms. If you want to see some values for that column, add some looping in this function.<br />
<strong>Time: </strong>It shows the duration of execution from start point of a function to the end point of a function. For example foo() has no code. So, its own execution time is approx ~0ms, but we call other functions in that function. So, the total execution time of other functions is 4.491ms. So, it shows 4.54ms in that column which is equal to own time taken by 3 loop() function + own time of foo().<br />
<strong>Avg:</strong> It shows the average execution time of a particular function. If you are calling a function one time only, you won’t see the differences. If you are calling more than one time, you will see the differences. The formula for calculating the average is:<br />
Avg = Own time / Call<br />
<strong>Min and Max columns: </strong>It shows the minimum execution time of a particular function. In our example, we call loop() for 3 times. When we passed 1000 as a parameter, it probably took only a few millisecond (let’s say 0.045ms.) and when, we passed 100000 to that function, it took much longer than first time (let’s say 4.036ms). So, in that case, 0.045ms will be shown in Min column and 4.036ms will be shown in Max column.<br />
<strong>File: </strong>It shows the file name of file with line number where the function is located</p>
<p>Any comments and suggestions are welcome <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
~~Chandan Luthra~~<br />
References:<br />
Book <a href="https://www.packtpub.com/firebug-1-5-editing-debugging-and-monitoring-web-pages/book">https://www.packtpub.com/firebug-1-5-editing-debugging-and-monitoring-web-pages/book</a><br />
Refcard <a href="http://refcardz.dzone.com/refcardz/getting-started-firebug-15">http://refcardz.dzone.com/refcardz/getting-started-firebug-15</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/08/16/javascript-profiling-through-firebugs-console-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Image comparison</title>
		<link>http://www.intelligrape.com/blog/2010/08/14/image-comparison/</link>
		<comments>http://www.intelligrape.com/blog/2010/08/14/image-comparison/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 13:32:38 +0000</pubDate>
		<dc:creator>anshul</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java tools]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1499</guid>
		<description><![CDATA[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&#40;String firstPhotoUrl, String secondPhotoUrl&#41; &#123;
        boolean result = true;
        BufferedImage bi1 [...]]]></description>
			<content:encoded><![CDATA[<p>In one of our projects, we need to compare images which comes from various sources and remove the duplicate one.</p>
<p>The below algo helps us to remove the duplicate images.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="groovy"> <span style="color: #993333;">boolean</span> compareImage<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> firstPhotoUrl, <span style="color: #aaaadd; font-weight: bold;">String</span> secondPhotoUrl<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #993333;">boolean</span> result <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">;</span>
        <span style="color: #aaaadd; font-weight: bold;">BufferedImage</span> bi1 <span style="color: #66cc66;">=</span> ImageIO.<span style="color: #006600;">read</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">URL</span><span style="color: #66cc66;">&#40;</span>firstPhotoUrl<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #aaaadd; font-weight: bold;">BufferedImage</span> bi2 <span style="color: #66cc66;">=</span> ImageIO.<span style="color: #006600;">read</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">URL</span><span style="color: #66cc66;">&#40;</span>secondPhotoUrl<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #993333;">int</span> size1 <span style="color: #66cc66;">=</span> bi1.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDataBuffer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">size</span><span style="color: #66cc66;">;</span>
        <span style="color: #993333;">int</span> size2 <span style="color: #66cc66;">=</span> bi2.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDataBuffer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">size</span><span style="color: #66cc66;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>size1 <span style="color: #66cc66;">==</span> size2<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">&#40;</span>bi1.<span style="color: #006600;">width</span> <span style="color: #66cc66;">==</span> bi2.<span style="color: #006600;">width</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">&#40;</span>bi1.<span style="color: #006600;">height</span> <span style="color: #66cc66;">==</span> bi2.<span style="color: #006600;">height</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #aaaadd; font-weight: bold;">Raster</span> r1 <span style="color: #66cc66;">=</span> bi1.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #aaaadd; font-weight: bold;">Raster</span> r2 <span style="color: #66cc66;">=</span> bi2.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #aaaadd; font-weight: bold;">DataBuffer</span> db1 <span style="color: #66cc66;">=</span> r1.<span style="color: #006600;">getDataBuffer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #aaaadd; font-weight: bold;">DataBuffer</span> db2 <span style="color: #66cc66;">=</span> r2.<span style="color: #006600;">getDataBuffer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #993333;">int</span> <span style="color: #663399;">size</span> <span style="color: #66cc66;">=</span> db1.<span style="color: #006600;">getSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">;</span> i <span style="color: #66cc66;">&lt;</span> <span style="color: #663399;">size</span><span style="color: #66cc66;">;</span> i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #993333;">int</span> px1 <span style="color: #66cc66;">=</span> db1.<span style="color: #006600;">getElem</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                <span style="color: #993333;">int</span> px2 <span style="color: #66cc66;">=</span> db2.<span style="color: #006600;">getElem</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>px1 <span style="color: #66cc66;">!=</span> px2<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    result <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">;</span>
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #66cc66;">;</span>
                <span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
            result <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</blockquote>
<p>Hope this helped!</p>
<p>Cheers!<br />
Anshul Sharma</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/08/14/image-comparison/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Images rotation and div rotation by CSS Transforms</title>
		<link>http://www.intelligrape.com/blog/2010/08/13/images-rotation-and-div-rotation-by-css-transforms/</link>
		<comments>http://www.intelligrape.com/blog/2010/08/13/images-rotation-and-div-rotation-by-css-transforms/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 05:19:34 +0000</pubDate>
		<dc:creator>umar</dc:creator>
				<category><![CDATA[Grails]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1492</guid>
		<description><![CDATA[The CSS transform property  allows developers to rotate, scale, and skew blocks of HTML via CSS. Although you can do the same thing with images in Photoshop or The GIMP, using CSS transforms allows developers to do the same thing with any HTML markup and allows users to select the text within the transformed [...]]]></description>
			<content:encoded><![CDATA[<p>The CSS transform property  allows developers to rotate, scale, and skew blocks of HTML via CSS. Although you can do the same thing with images in Photoshop or The GIMP, using CSS transforms allows developers to do the same thing with any HTML markup and allows users to select the text within the transformed object.</p>
<p>I saw the design potential of using CSS transforms and was frustrated at Explorer’s lack of support. I originally tried a non-JavaScript solution which involved creating CSS rules that combine transform with an IE technology that does something similar:</p>
<p>the syntax of transform is very obvious:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="">#myObject {</span>
   transform: rotate<span style="color: #66cc66;">&#40;</span>40deg<span style="color: #66cc66;">&#41;</span> scale<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2.0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</blockquote>
<p>but the IE filter code is quite intimidating:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="">#myObject {</span>
   filter: progid:DXImageTransform.<span style="color: #006600;">Microsoft</span>.<span style="color: #006600;">Matrix</span><span style="color: #66cc66;">&#40;</span>sizingMethod<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'auto expand'</span>,
        M11<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1.5320888862379554</span>, M12<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">-1.2855752193730787</span>,
        M21<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1.2855752193730796</span>, M22<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1.5320888862379558</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</blockquote>
<p>The scary numbers that the DXImageTransform.Microsoft.Matrix filter uses requires knowledge of matrix and vector mathematics. Even the mathematically gifted wouldn’t want to do the calculations to do a simple rotate in CSS .</p>
<p>although it is possible to have a list of transformations using transform, the DXImageTransform.Microsoft.Matrix filter only allows one transform matrix. In order to implement multiple transforms using one filter, a designer would have to convert all the transforms into matrices and multiply them together.</p>
<p>when rotating, skewing, or doing any other transformations on objects using the transform property.<br />
##Umar Pahat##<br />
umar@intelligrape.com<br />
www.intelligrape.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/08/13/images-rotation-and-div-rotation-by-css-transforms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
