My Quotes


When U were born , you cried and the world rejoiced
Live U'r life in such a way that when you go
THE WORLD SHOULD CRY






Thursday, October 14, 2010

Integrating SAS

The SAS support team has a very good collection and design for integrating SAS with various clients like JAVA , .NET , web services etc.,

http://support.sas.com/rnd/itech/doc9/dev_guide/dist-obj/winclnt/windotnet.html

The samples code base provides many sample codes which you can download and customize it.

http://support.sas.com/kb/?nh=100&la=en&qm=3&ct=51000&qt=offering:"INTTECH"+contenttype:"sample"+"SAS+Integration+Technologies"+

Enjoy integrating SAS.

Thursday, October 7, 2010

CSS compression and Image Optimization


1.    Introduction

There have been many instances where we have struggled to increase performance of the web site because in practical situation,
·                  applications become very complex with tons of JavaScript’s and huge CSS
files and
·                  downloading that information takes time if the bandwidth is low.

Here we can increase the performance using the ideas below without changing any code.

2.    Installation Procedure


Improving the engineering design of a page or a web application usually yields the biggest savings and that should always be a primary strategy.
With the right design in place, there are many secondary strategies for improving performance such as minification of the code.
The goal of JavaScript and CSS minification is always to preserve the operational qualities of the code while reducing its overall byte footprint (both in raw terms and after gzipping, as most JavaScript and CSS served from production web servers is gzipped as part of the HTTP protocol).
The YUI Compressor is JavaScript minifier designed to be 100% safe and yield a higher compression ratio than most other tools.
The YUI Compressor is written in Java (requires Java >= 1.4) and relies on Rhino to tokenize the source JavaScript file.
It starts by analyzing the source JavaScript file to understand how it is structured. It then prints out the token stream, omitting as many white space characters as possible, and replacing all local symbols by a 1 (or 2, or 3) letter symbol wherever such a substitution is appropriate (in the face of evil features such as with, the YUI Compressor takes a defensive approach by not obfuscating any of the scopes containing the evil statement).
The CSS compression algorithm uses a set of finely tuned regular expressions to compress the source CSS file. The YUI Compressor is open-source, so don't hesitate to look at the code to understand exactly how it works.


3.    ANT build script for compression

1.     Download and Copy the following YUI Compressor jar file into the ANT LIB folder
2.      Change the following properties in the build.properties file
    1. javascript.compress=true
    2. jsp.compress=true
3.      Here is the sample ANT target to do the compression change the directories according to your needs.

            <target name="compressjsandcss" depends="init">
                                <taskdef name="yui-compressor" classname="net.noha.tools.ant.yuicompressor.tasks.YuiCompressorTask"/>
                                                <mkdir dir="${web.build.dir}/war/cssmin" />
                                                <mkdir dir="${web.build.dir}/war/jsmin" />
                                                <!-- invoke compressor -->
                                                <yui-compressor
                                                    warn="false"
                                                    munge="true"                                  
                                                    preserveallsemicolons="false"
                                                    fromdir="${web.build.dir}/war/css"
                                                    todir="${web.build.dir}/war/cssmin">                          
                                                </yui-compressor>
                                                <yui-compressor
                                                    warn="false"
                                                    munge="true"                                  
                                                    preserveallsemicolons="false"
                                                    fromdir="${web.build.dir}/war/js"
                                                    todir="${web.build.dir}/war/jsmin">                            
                                                </yui-compressor>
                                                <copydir dest="${web.build.dir}/war/js" src="${web.build.dir}/war/jsmin" includes="**/*.js" forceoverwrite="true" />
                                                <copydir dest="${web.build.dir}/war/css" src="${web.build.dir}/war/cssmin" includes="**/*.css" forceoverwrite="true" />    
                                <delete>
                                                <fileset dir="${web.build.dir}/war/cssmin" includes="**/*.css"/>
                                </delete>
                                <delete>
                                                <fileset dir="${web.build.dir}/war/jsmin" includes="**/*.js"/>
                                </delete>                              
                </target>

4.    Other techniques of compression

a.    Compressing the JSP pages

JSP pages when compressed are a real boom to the performance of a page

I use regular expression to achieve this.

                <target name="compressjsp" depends="init">             
                                <echo>+------------------------------------------------------------+</echo>
                        <echo>+           Cleaning the JSP files                            +</echo>
                        <echo>+CAT View module name = ${web.build.dir}/war/jsp             +</echo>
                                <echo>+------------------------------------------------------------+</echo>
                                <replaceregexp flags="g" byline="true">
                                  <regexp pattern="&amp;&gt;\n+&amp;&lt;"/>
                                  <substitution expression="&amp;&gt;&amp;&lt;"/>
                                                <fileset dir="${web.build.dir}/war" includes="**/*.jsp"/>
                                 </replaceregexp>
                                <replaceregexp match="\s+" replace=" " flags="g" byline="true">
                                                    <fileset dir="${web.build.dir}/war" includes="**/*.jsp"/>
                </replaceregexp>                                
                </target>

b.    Stripping white spaces in  a Javascript file

             <target name="stripWhiteSpace" depends="init">
                                <echo>+------------------------------------------------------------+</echo>
                        <echo>+           Cleaning the JSP files                            +</echo>
                        <echo>+CAT View module name = ${web.build.dir}/war/jsp             +</echo>
                                <echo>+------------------------------------------------------------+</echo>
                    <replaceregexp match="\s+" replace=" " flags="g" byline="true">
                      <fileset dir="${web.build.dir}/war" includes="**/*.jsp"/>
                    </replaceregexp>                 
                    <replaceregexp match="&amp;&gt;\n+&amp;&lt;" replace="&amp;&gt;&amp;&lt;" flags="g" byline="true">
                      <fileset dir="${web.build.dir}/war" includes="**/*.jsp"/>
                    </replaceregexp>   
                 </target>

c.    Stripping Line Breaks

         <target name="stripLineBreaks" depends="init">
         <copy todir="${web.build.dir}/war" overwrite="true">
           <filterchain>
             <striplinebreaks/>
           </filterchain>
           <fileset dir="${web.build.dir}/war">
             <include name="**/*.jsp"/>
           </fileset>
         </copy>
        </target>

d.   Deleting Blank Lines

        <target name="noblanklines" depends="init">
        <fileset dir="${web.build.dir}/war" includes="**/*.jsp"/>
        <filterchain>
        <tokenfilter><ignoreblank/></tokenfilter>
        </filterchain>
        <replaceregexp flags="g" byline="false"> 
                        <regexp pattern="\r\n[\s]*\r\n[\s]*\r\n"/> 
                        <substitution expression="&#13;&#10;&#13;&#10;"/> 
                        <fileset dir="${web.build.dir}/war" includes="**/*.jsp">                                           
                        </fileset> 
        </replaceregexp> 
                        <replaceregexp flags="g" byline="false"> 
                        <regexp pattern="\r\n[\s]*\r\n[\s]*\r\n"/> 
                        <substitution expression="&#13;&#10;&#13;&#10;"/> 
                        <fileset dir="${web.build.dir}/war" includes="**/*.js">                                             
                        </fileset> 
        </replaceregexp>                                
        </target>

5.    Backup Plan.

1.      If there is an issue in any of the above techniques ensure that the build.properties has the parameters set to “false”.

Monday, September 20, 2010

Agile SCRUM and Pragmatic Agile development

Agile Scrum - An Overview
Many of us have experienced projects that drag on much longer than expected and cost more than planned. Companies looking to improve their software development processes are now exploring how Agile can help their Enterprise more reliably deliver software quickly, iteratively and with a feature set that hits that mark.  While Agile has different "flavors", Scrum is one process for implementing Agile.

So what is Agile?
According to Wikipedia, Agile software development is a conceptual framework for software engineering that promotes development iterations throughout the life-cycle of the project.  
Simply put, Agile allows your team to identify the most critical features of the software that can be completed within a short time frame (normally 1 to 2 months), and it delivers a complete build with this set of limited features as the first iteration.
Once that is done, you can move those features to production or continue on to the next iteration. 
By breaking the releases into shorter stints, it allows you to gain quicker releases and to capture return on investment more quickly by putting the working (but limited) features into production sooner. 
This is in stark contrast to the more traditional "Waterfall" approach, where you design all features upfront, code each one, test each one, then move into production. 
Agile projects are iteratively released to production months where Waterfall projects normally span a year or more before they are released to production.

So what is Scrum?
Scrum is process of implementing Agile, where features are delivered in 30 day sprints
Scrum borrows its name from Rugby,  where a sprint is the process of stopping play, then vigorously playing until the sprint ends and a new one begins. 
The same idea applies here, where you define the requirements for a 30 day sprint and work on them with vigor for 30 days without being sidetracked by other things or having things re-prioritized.  
A specific feature is not recognized as being completed until it is analyzed, designed, coded, tested, re-factored and documented. 
At the end of the 30 day sprint, most features defined in the 30-day sprint should be completed. 
If some did not get finished (because of being underestimated), the uncompleted features can be moved to a later sprint. 
A sprint is considered successful if all the completed features have high quality and can be put into production (or beta) upon ending the sprint.




Do Team Member Responsibilities Change?
Managing Scrum development requires a major change in how teams work together. 
In traditional Waterfall development, teams normally have
·         a project sponsor,
·         a project manager,
·         analysts,
·         designers,
·         programmers,
·         testers, and
·         documentation specialists. 
Each team member has specific duties which normally do not overlap and they have a specific reporting structure (most team members report to the project manager).
With Scrum, you have just 3 team roles and they are normally limited to 7 or less individuals (however, you can have multiple Scrum teams in sets of 7 or less):
  • Product Owner - This is the person that identifies and prioritizes the features that will appear in a 30 day sprint.  This is normally the CEO, CTO, or some other high level stakeholder that ultimately is responsible for shaping the roadmap of their product.
  • ScrumMaster - The ScrumMaster is akin to the Project Manager in Waterfall environments, but does not manage the team deliverables at a micro level.  Instead, this person is responsible for ensuring that the 30 day sprint stays on course, no new features are added to the sprint, code inspection, and ensuring everyone plays by the rules.
  • The Team - With Waterfall, a team consists of analysts, designers, testers and documentation specialists.  With Scrum, each team member is empowered and expected to self-manage themselves and to participate in all duties needed to deliver a feature.  This includes analysis, design, coding, testing and documentation.
So how does Scrum Work on a Day-by-Day Basis?
Scrum begins with an 8 hour Scrum Kickoff Meeting
The Scrum Kickoff meeting is divided into (2) 4 hour segments, where you first determine what features are desired for the 30 day sprint. 
The last 4 hours are used to provide rough estimates for the items identified for the sprint. 
If the estimates exceed the available resources, the features are prioritized and less important features are dropped from the sprint. 
An important component of Scrum is using a time-box approach, where meetings and events have a definite time period (e.g. no more than 8 hours for the kickoff meeting) and this time-box is strictly enforced. 
Once the features are locked in for the 30-day sprint, no changes are allowed (new features can not be introduced until the next sprint). 
When estimating features for a sprint, the estimates must include time for analysis, design, coding, testing, re-factoring, and documentation. 
A feature is not considered complete until all those things are done.
Each day, a Daily Scrum Meeting is held to determine how the features are progressing.  The meeting is no longer than 15 minutes, and each team member is asked 3 questions:
  • What have you accomplished since the last Daily Scrum Meeting?
  • What will you do before the next Daily Scrum Meeting?
  • Is there anything that is impeding your progress (and remedies are discussed)?
From a programmer's perspective, Scrum development is a new paradigm which is very empowering but does require them to follow specific rules:
  • Code is only checked out for the duration needed to complete a feature.  No exceptions.  Most code will be checked in daily, as most features are broken down into small feature sets.
  • Time must be entered daily.   For each feature, you will have estimated hours, actual hours and hours remaining to complete the feature.  This information must be updated at the end of every day so that the ScrumMaster can determine if the release progress is trending as required.
  • Programmers are not allowed to be pulled off on tangent projects, they must stick to the features they have been assigned for the sprint.
  • All team members must attend the Daily Scrum Meeting and must be on time.
  • Code is compiled and deployed to a test server daily. Teams can use automated build tools to speed up this process.  Automated tests should be run against the daily releases to discover any issues introduced by the release.
Once a Scrum 30 day sprint is completed, all features that were completed can then be moved to a beta or production environment.  Following the sprint is a Retrospective (post mortem), where team members discuss and document things that went well and things that can be improved upon in the next sprint.
There are many other things that needs to be defined, formulated and practiced like
·         Team Composition - how teams work together
·         Understanding the SCRUM rules – no.of hours , estimates up in front, enter time daily, daily builds, no new requirements etc.,
·         Product Backlogs - set the goal for the sprint and prioritize product backlog items to determine which ones can fit within the sprint
·         Daily meetings
·         Reporting and Metrics
·         Retrospectives
·         Tailoring SCRUM to your project

More to follow

Friday, August 27, 2010

How to prevent OOM exceptions in WLS admin server with JROCKIT

JAVA_OPTIONS="${JAVA_OPTIONS} -XXlargeObjectLimit=512k -XXtlasize=512k -XXexitOnOutOfMemory -XxdumpFullState -XxcompressedRefs=0"
export JAVA_OPTIONS

The TLA size needs to be adjusted based on the server machine capacity




How to read and write CLOB data

The following example demonstrates the Oracle JDBC 10g enhanced features for inserting and retrieving CLOB data from the database. Using the new features, large  data of more than 32765 bytes can be inserted into the database using the  existing PreparedStatement.setString() and PreparedStatement.getString()  methods.

public static void main(String[] args) throws SQLException {
java.sql.Connection conn = null;
java.sql.ResultSet rSet = null;
java.sql.PreparedStatement pstmt = null;


  // create the driver manager
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
}
private void insertClob() throws SQLException {
String sql = "insert into MYTABLE (FILEVALUES) values(?)";
      // create the connection
            if ((conn == null) || conn.isClosed()) {
                conn = DriverManager.getConnection(url, "kesavanarayanan", "kesavanarayanan");
            }

       pstmt = conn.prepareStatement(sql);
       // Read a big file(larger than 32765 bytes)
      String str = this.readFile();
}

    private void selectClob() throws SQLException {

        // Create a PreparedStatement object
        PreparedStatement pstmt = null;

        // Create a ResultSet to hold the records retrieved.
        ResultSet rset = null;
        try {
            // Create the database connection, if it is closed.
            if ((conn == null) || conn.isClosed()) {
                // Connect to the database.
                conn = DriverManager.getConnection(this.url, this.props);
            }

            // Create SQL query statement to retrieve records having CLOB data
            // from
            // the database.
            // String sqlCall = "SELECT UIN,CLIP_NAME,FORM,
            // WRITEPLACER_PROMPTS_ID,USER_RESPONSE_TEXT,BATCH_ID FROM VUEBATCH
            // WHERE rownum<10";
            //String sqlCall = "SELECT IEC_FILE from CAT_EXPOSURE_CONTROL where test_detail_id=1";
            String sqlCall = "SELECT IEC_FILE from CAT_EXPOSURE_CONTROL where test_detail_id=2";
            pstmt = conn.prepareStatement(sqlCall);

            // Execute the PrepareStatement
            rset = pstmt.executeQuery();

            FileWriter writer = null;
            // Get the CLOB value from the resultset
            while (rset.next()) {
                Clob clobVal = rset.getClob(1);
                Reader clobStream = null;
                if (clobVal != null) {
                    /*
                     * clobStream = clobVal.getCharacterStream(); // Holds the
                     * Clob data when the Clob stream is being read StringBuffer
                     * suggestions = new StringBuffer(); int nchars = 0; //
                     * Number of characters read // Read from the Clob stream
                     * and write to the stringbuffer char[] buffer = new
                     * char[4096]; //Buffer holding characters being transferred
                     * while((nchars = clobStream.read(buffer)) != -1) {// Read
                     * from Clob suggestions.append(buffer, 0, nchars); // Write
                     * to StringBuffer }
                     * System.out.println(suggestions.toString()); writer = new
                     * FileWriter(new File("sample.txt"));
                     * writer.write(suggestions.toString());
                     */
                    int len = (int) clobVal.length();
                    String clobStr = clobVal.getSubString(1, len);
                    System.out.println(clobStr);
                }
                if (clobStream != null)
                    clobStream.close(); // Close the Clob input stream
            }
            if (writer != null) {
                writer.flush();
                writer.close();
            }
        } catch (SQLException sqlex) {
            // Catch Exceptions and display messages accordingly.
            System.out
                    .println("SQLException while connecting and querying the "
                            + "database table: " + sqlex.toString());
            sqlex.printStackTrace();
        } catch (Exception ex) {
            System.out.println("Exception while connecting and querying the "
                    + "database table: " + ex.toString());
            ex.printStackTrace();
        } finally {
            // Close the resultset, statement and the connection objects.
            if (rset != null)
                rset.close();
            if (pstmt != null)
                pstmt.close();
            if (conn != null)
                conn.close();
        }
    }




Monday, August 9, 2010

Local DTD and catalog file

Most of the HTML / XMl file when referencing DTD's from the web especially the XMLNS attribute will have problems due to the high bandwidth for these DTD web sites.

In order to over come this issue, we can go for the alternative of local DTD's.

The advantages are you don't need to wait for the web traffic. The disadvantages are that you need to update the DTD's when the same is updated in the sites.









Friday, July 2, 2010

Integrate PMD with Eclipse

Here are the detailed steps to integrate PMD with eclipse version 3.
  1. Start Eclipse.
  2. Start the installation procedure : select the Help>Software Updates>Find and Install... menu item.
  3. Select "Search for new features to install" option and click Next.
  4. Click New Remote Site...
  5. Give a name (ie PMD Eclipse Site), enter the URL http://pmd.sourceforge.net/eclipse
  6. Select this new site in the Sites to include in search list and click Next.
  7. Select PMD for Eclipse 3 and Apache Xerces in the "Select the features to install" list and click Next.
  8. Accept the terms of the license agreements and click Next.
  9. Verify that the install location is your Eclipse installation directory, otherwise select the correct one, click Finish.
  10. A warning appear telling the feature is not signed. Ignore and click Install to continue.
  11. Accept to restart the workbench to load PMD into the workbench. 
  12. Eclipse is restarted and a PMD welcome page is displayed : the plugin is correctly installed.