Tarun Pareek « Intelligrape Groovy & Grails Blogs
Subscribe via E-Mail:

Tarun Pareek

http://www.intelligrape.com

Grails and Open Source Fanatic, Agile Practitioner, JQuery Devotee, Hands on DOJO. LinkedIn : http://in.linkedin.com/in/tarunpareek, Twitter : http://twitter.com/TarunPareek_

Posts by Tarun Pareek:

  • Increasing the connection timeout between browser and the tomcat server

    21 Dec 2011 in System

    Hi,

    There is a case stuck recently in my project where i need to increase the connection timeout between browser and the server, because of the reason before the response get completed server leave the connection which result in no response. My colleague Himanshu told me to change the setting in server.xml, which help in my purpose.

    To increase the connection timeout on tomcat server follow the following steps :

    1. Open the file server.xml residing in tomcat6/conf/.
    2. You just need to set variable connectionTimeout in it to Value in Milliseconds.(i.e 1000 milliseconds = 1 second)

    For example :

    File : server.xml

    <Connector port="8080" protocol="HTTP/1.1"  connectionTimeout="20000" URIEncoding="UTF-8"            redirectPort="8443" />

    I thought it will be useful to share, hope it helps.
     

    Thanks,
    Tarun Pareek
    tarun@intelligrape.com
    http://in.linkedin.com/in/tarunpareek

    • Share/Bookmark
  • JQGrid Expanding SubGrid on page load

    13 Feb 2011 in Javascript/Ajax/JQuery

    Hi,
     
    Recently guys, i faced problem while expanding the JQGrid SubGrid onLoad of the page.
     
    Initially, i used the following code on gridComplete Event of JQGrid, Using the code given below, i am only able to expand grid but without data populated in subgrid.

    gridComplete: function() {
                    var rowIds = $("#testTable").getDataIDs();
                    $.each(rowIds, function (index, rowId) {
                            $("#testTable").expandSubGridRow(rowId);                   
                    });
                }

    After trying different ways, and many efforts i came up with this solution and it worked for me.
    Solution to above problem given below :

    gridComplete: function() {
                    var timeOut = 50;
                    var rowIds = $("#testTable").getDataIDs();
                    $.each(rowIds, function (index, rowId) {
                        setTimeout(function() {
                            $("#testTable").expandSubGridRow(rowId);
                        }, timeOut);
                        timeOut = timeOut + 200;
                    });
                }

    It worked for me. Hope it help you too.

    Thanks & regards,
    Tarun Pareek
    LinkedIn

    • Share/Bookmark
  • JQGrid Powerful Plugin With Cool Features

    12 Jan 2011 in Javascript/Ajax/JQuery

    Recently i worked on a JQuery plugin named JQGrid, I found it very productive if you know how to code in JQuery and Javascript. As it also provide event handler and user API it make it more flexible and easier to code.
     
    JQgrid provide plenty of features, some of its cool features such as,
     
    - Solve problem regarding fixing table header while inner scroll is applied to the table data(body).
    - Easy to implement Basic Grid, with searching, sorting and filtering with fix header and scalable table structure.
    - Provide both XML and JSON support for data. You can also use local data and generate grid using it.
    - Provide pagination, and virtual scrolling(Auto loading of data while scrolling)
    - Multi language support(i18n)
    - Provide subgrid implementation
    - Provide Grouping
    - Provide Tree grid
    - Event Handling and various methods gives more flexibility
    - Formatting is another cool feature, you can format the content of the cell and create your custom formatters also.
    - Inline Editing in supported(text, textarea, checkbox, select, image, button type).
    - Client side validation of entered data is supported.
    - Form Editing is supported, full control of form, all features of editing including client side validation.
    - Similarly support cell Editing.
    - Searching and filtering,
       - custom search
       - toolbar search
       - complex form search
       - Advanced searching with criteria defined
    - Support loadonce(load all the data at once)
    - hideGrid Feature, work like accordian, collapse/expand of table on click of header.
    - Remote data upload
    - Navigator footer, you can add your own button to provide functionality on footer.
    - Also provide row footer,
    - UI DatePicker support, JQuery UI Themes etc.
     
    Some Tricks :
    - Use ignoreCase:true feature to apply case-insensitive filtering.
    - To display All rows, either simply set the number of rows to rowNums or you can use ‘-1′, set rowNum:-1 it will display all the rows.
    Note : Precaution leave always last row blank, as ‘-1′ deduct one row from all the record in the table.(I face the same problem)
    - Use afterInsertRow Event, But Note: this event does not fire if gridview option is set to true.
     
    A DrawBacks :
    - Doesn’t support row and colspan :( That the one thing i feel is missed in plugin.
     
    Else very powerful plugin. :)
     
    This plugin provide so much feature which really make the table implementation with so much functionality on the tip of your hand.
     
    Following Links that may Help you in implementation of JQgrid 3.8,
     
    Demo : http://trirand.com/blog/jqgrid/jqgrid.html
    Documentation : http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jqgriddocs
    Events : http://www.trirand.com/jqgridwiki/doku.php?id=wiki:events
    Options : http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options
    Methods : http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods
    Treegrid : http://www.trirand.com/jqgridwiki/doku.php?id=wiki:treegrid
     
    Hope this, JQgrid plugin help you to improve your UI and implementation made much easier. (Powerful plugin with cool features.)
     
    Thanks & regards,
    Tarun Pareek
    LinkedIn

    • Share/Bookmark
  • Linux Trick for screen collaboration or shell sharing

    14 Nov 2010 in Linux& System

    In recent week, i got to know about really good way of collaborating the screen in a linux.
     
    Let us take a scenario, Suppose User having name ‘B’ on the 5th floor of the company is having a problem/difficulty related to code execution, unable to figure out what to do?, and then he call the fellow guy who can help him out, but he is on 1st floor his name is ‘Lazy A’.
     
    Lazy A guy is really lazy, so here come handy screen collaboration trick to help him out and save him from walking 4 Floors to reach 5th one (:phew!:)
     
    Lazy A support guy open its terminal and perform the following tricks consisting of 4 steps:
     
    1. ‘Lazy A’ remote login into the User B system through following command:

    lazyA# ssh B

    2. After that Lazy A logged in as super user B, on B machine

    B# su - B

    3. Now Lazy A is on the B machine logged in as super user B, and ‘Lazy A’ runs the following command,

    B# screen -S sos

    4. Then Lazy A guy ask B to run following command on his/her system :

    B# screen -x sos

     
    Note that same alias ’sos’ is being used by both in last 2 commands, and both guy are logged in as same user.
     
    Actually the last two command cause both user session joined together in linux shell and now both users can type on there shell and see what other is typing or doing to fix the issue, and this is how lazy A help out the B without walking to 5th floors.
     
    After providing help, ‘Lazy A’ terminate the session by performing ctrl-C and then ctrl-D command on its terminal. Thats the way they get detach from each other and get back to there respective work.
     
    And code happily ever after :)
     
    Example to Test command on your machine:
     
    To test the ’screen -S’ and ’screen -x’ command you can open two separate terminal or shell on your linux system, then run following command on your 1st terminal or shell
     
    Terminal 1:

    # su - tarun
    tarun# screen -S mytest

    And run another command on Terminal 2:

    tarun# screen -x mytest

    Then type on any screen you will see what you are doing on one is appearing on both the shells. To terminate session use ctrl-C and then ctrl-D. :)
     
    Regards,
    Tarun Pareek
    LinkedIn

    • Share/Bookmark
  • Setting Expires HTTP header on server response through Apache

    13 Sep 2010 in Linux& System

    In recent poc, i have set the expires HTTP header on server response for one of the project, such that it will again set when access by user for the specified period, if header is expired already.

    The module that control it is “mod_expires.c”. This module is not enabled by default.

    You need to enable it by following command (You need to be sudo user):

    a2enmod {module name} //here module name is "expires"

    Then, open your site configuration file available at apache2/sites-available/{your site}

    Append following xml entries in your site configuration file :

    <IfModule mod_expires.c>
          <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
              ExpiresActive On
              ExpiresDefault "access plus 2 days"
          </FilesMatch>
    </IfModule>

    ExpiresDefault Syntax :

    ExpiresDefault "{base} [plus] {num  type}*"

    Note : Here base is : ‘access’ and the type is : ‘years’, ‘months’, ‘weeks’, ‘days’, ‘hours’, ‘minutes’, ’seconds’

    You can also use “ExpiresByType” for setting different expires for different file type instead of “ExpiresDefault”.

    Hope this code will help :)


    Regards,
    Tarun Pareek
    Intelligrape Software

    http://in.linkedin.com/in/tarunpareek

    • Share/Bookmark
  • What is Google Web Optimization, How to use or apply it in your project?

    Recently as part of POC, I need to apply the google web optimizer on various parts of page to determine which content user respond to best and will be most effective in getting conversions. For this you need to keep track of the various conversions, but how? Thats where google web optimizer come handy, providing reports based on experiments specified by you on various parts of page and also suggesting action to optimize your site for better business results.

    Steps to apply google web optimization in your project :

    1. Create an account in google web optimizer and sign in.

    2. Then take some time to determine which aspect or parts of page you want to test and how.(for more valuable and better results).

    3. Create an experiment in google web optimizer :

    • 3.1 Choose algo for experiment: Multivariate test or A/B test.
      • 3.1.1 Multivariate test allow you to apply variations on various part of same page.
      • 3.1.2 A/B test allow you to apply conversion between two pages. (Not on various part of page).
      • **In my case i choose multivariate test.
    • 3.2 Fill in details : Give your experiment unique name, specify the tracking page public URL on which various parts optimization is to be done and also specify the conversion page public URL on which user will be directed after successful conversion.(Very useful in term of form submission).

    4. Tag Pages -> Now the optimizer provide you several tags, How to apply scripts/tags on your page for that particular experiment :

    • 4.1 Control Script : Randomly control the variations on parts of page. (Must Applied in header tag of page)
      	<!-- Google Website Optimizer Control Script -->
      	<script>
      	function utmx_section(){}function utmx(){}
      	(some script......................................................
      	length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
      	d.write('<sc'+'ript src="'+
      	'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'...........
      	................................. some more script text here
      	</script>
      	<!-- End of Google Website Optimizer Control Script -->
    • 4.2 Tracking Script : Track the user behaviour. (Applied at bottom of the page within body tag).
      	<!-- Google Website Optimizer Tracking Script -->
      	<script type="text/javascript">
      	Some script text here...................................
      	........................................................
      	<script type="text/javascript">
      	try {
      	var gwoTracker=_gat._getTracker("....some id for tracker..........");
      	gwoTracker._trackPageview("...tracker page.....");
      	}catch(err){}</script>
      	<!-- End of Google Website Optimizer Tracking Script -->
    • 4.3 How to apply Variation Script : Applied just before the part of code to be tested(headline, image, promotext, button) i.e. on which variation is to be applied and at the end of that code part “noscript” tag need to be applied to specify the region for variation and unique tag names for particular variation section.
      	<script>utmx_section("payment")</script>
      		Test Drive our product in <b>$10</b>
      	</noscript>
    • 4.4 Conversion Script : To be applied in body tag at bottom of converision page you specified.
      	<!-- Google Website Optimizer Conversion Script -->
      	    <script type="text/javascript">
      	    some script.....................................................
      	    '.google-analytics.com/ga.js"></sc'+'ript>')</script>
      	    <script type="text/javascript">
      	    try {
      	    var gwoTracker=_gat._getTracker("....some id for tracker..........");
      	    some script code here.....................................
      	    }catch(err){}</script>
      	<!-- End of Google Website Optimizer Conversion Script -->

    5. Validate Pages -> First apply all the tags on your page as specified above and then validate the page with optimizer validate page link, that all the script are applied correctly.

    • 5.1 If you use validate pages button then it will use the public URL you specified for tracking and conversion page.
    • 5.2 To validate the pages offline, Optimizer provide option to manually provide pages that are to be validated.

    Note : All the test need to be passed to apply optimization on your page.

    6. Create a Variations -> After applying tags, create variations for the various part of page. Variation can include any type of string(it can be a html code, text, script etc).

    Example : Within payment tag :

    Original Variation : Test Drive our product in $10 (specified in your page)
    Variation 1 named “Classic” :

    		Test Drive our product in <b>$50</b>

    Variation 2 named “Executive” :

    		Test Drive our product in <b>$100</b> with additional privileges

    7. Review and Launch the Experiment, in Google web optimizer.

    Example :

    	<html> 
    	<head>   
    	    <!-- Google Website Optimizer Control Script -->
    		<script>
    		function utmx_section(){}function utmx(){}
    		some script.....................................................
    		length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
    		d.write('<sc'+'ript src="'+
    		some code here ...............................................
    		+new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
    		'" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
    		</script>
    		<!-- End of Google Website Optimizer Control Script -->
    	</head>
    	<body>
                 ............body code start here............................................................................
                 ....................................................................................................................
    	    <script>utmx_section("offer")</script>
    			Secure your child future in <b>$10</b>
    	    </noscript>
               ....................................................................................................................
               ....................................................................................................................
     
     
    	    <!-- Google Website Optimizer Tracking Script -->
    		<script type="text/javascript">
    		some script.....................................................
    		'.google-analytics.com/ga.js"></sc'+'ript>')</script>
    		<script type="text/javascript">
    		try {
    		some code...................................................
    		}catch(err){}</script>
    		<!-- End of Google Website Optimizer Tracking Script -->
     
    	</body>
    	</html>

    Hope this will help to improve your site business ;)

    Regards,
    Tarun Pareek
    Intelligrape Software

    • Share/Bookmark
  • Suppress Tracking of various scripts on test and development environment

    In my recent project, every time the page loads, it loads with lots of scripts making calls to and getting content from googleapis, fb, clixpy, cdn etc. to provide the functionality, due to which the page loads very slowly and this led to the wastage of time to test a certain functionality.

    To overcome this problem in test and development environment and at the same time to run those script in the production environment, I added the “suppressTracker” tag that enable or disable the script on the basis of environment on which it is executing or on the basis of session set for tracker.

    Step 1 : Create the suppressTracker tag in your tagLib,

    import grails.util.Environment;
     
    def suppressTracking = {attrs, body ->
            if (Environment.currentEnvironment==Environment.PRODUCTION && !session.suppressTracking){
                out<< body()
            }
    }

    Step 2 : Add suppressTracker tag on the script which you want to suppress for test and development environment,

    <util:suppressTracking>
      <script type="text/javascript">
           Your Script Code ..........
      </script>
    </util:suppressTracking>

    Hope this code will help :)

    ~Regards,
    Tarun
    Intelligrape Software

    http://in.linkedin.com/in/tarunpareek

    • Share/Bookmark
  • Configuring Log4J for logging level specific logs of different packages into file using appenders

    09 Jun 2010 in Grails& Groovy

    Recently i worked upon redirecting all the log related to a specified package in my project to a specific file. It seem very helpful as it provide precise context about run of your application and make it easier to debug as compare to low level debugging method such as println. Here we can also disable certain logs statement as per our need as it follow level Inheritance.

    There are several logging levels like:
    ALL < DEBUG < INFO < WARN < ERROR < FATAL

    The two basic things you need to specify to store log level specifically into the File : (example all logs related to INFO for com.cc package stored into file infoLog)

    1. Add appender to the config.groovy, you can have more than one appender assigned respective to various level.

    log4j = {
        appenders {
             file name:'infoLog',
             file:'logs/infoLog.log',
             layout:pattern(conversionPattern:'%r [%t] %-5p %c - %m%n'
        }
    }

    *Note : Here Layout specify conversionPattern which is a format in which log stored in file. Keywords for conversion pattern

    2. Now specify the level you assigned to appender. So that only that level logs are written to the specified file in appender for particular package.
    syntax : loglevel filename:’package name’
    *note : Here filename as specified in appender.

    log4j = {
        appenders {
             file name:'infoLog',
             file:"logs/${appName}.log",
             layout:pattern(conversionPattern:'%r [%t] %-5p %c - %m%n'
        }
     
        info infoLog:'grails.app.controller.com.cc'
        //similarly for error, debug, warn etc.
    }

    Hope this code will help !:)

    Regards,
    Tarun Pareek
    Intelligrape Software
    http://in.linkedin.com/in/tarunpareek

    • Share/Bookmark
  • Google Form Submission

    19 Apr 2010 in Grails& Groovy

    Recently in my project I used google form submission for the email subscription’s and find it very handy for various purpose.

    Steps to create google form :

    1. go to google docs, click create new -> form
    2. Here you can additem/field like text, paragraphtext, multi-select etc as per your project need.
    3. Save that form by clicking save now, it will generate the spreadsheet where data is being submitted by form.

    After performing above 3 steps your form is ready to use and integrate/embed into your project.

    Steps to submit your form to google into your project :

    1. In form edit window, below you can see a view form link. click on it to view form.
    2. Now from the souce code of the form simply copy url from action attribute of form tag and paste it in your form action attribute.
    3. The url look like this action=”http://spreadsheets.google.com/formResponse?formkey=dHFBbWdtRTRXb0tyMlJyTERteVFwemc6MQ&ifq”
    4. and set the field’s name into your form to the entry.0.single or entry.1.single etc. respective to the form name in google form.
    5. We can also use iframe by setting the target attribute of the form

    Example:

    <script type="text/javascript"><!--mce:0--></script>
    <form id="detailForm" style="display: block; float: left; width: 440px;" action="http://spreadsheets.google.com/formResponse?formkey=dHFBbWdtRTRXb0tyMlJyTERteVFwemc6MQ&amp;ifq" method="post">
    <input name="pageNumber" type="hidden" value="0" />
    <input name="backupCache" type="hidden" />
     
    <label for="firstName">First Name</label>
    <input id="firstName" name="entry.0.single" type="text" />
     
    <label for="lastName">Last Name</label>
    <input id="lastName" name="entry.1.single" type="text" />
     
    <label for="email">E-mail</label>
    <input id="email" name="entry.2.single" type="text" />
     
    <input id="detailsSubmit" name="submit" type="submit" value="Submit" />
    </form>

    ~Tarun Pareek~

    • Share/Bookmark