Friday, October 30, 2009

How to log Hibernate SQLs and parameters ?

These configs are handy to log Hibernate SQLs and parameters using log4j. (optional)

Sunday, October 18, 2009

Practical Approach to Google's AdWords

These steps can be helpful in deciding best strategy for online Ad campaign using Google's AdWords.
  1. Find out your target customers and do customer segmentation.

  2. Coin proper keywords combination focusing on target segment. Choosing right keywords is most essential part of Ad campaign.

  3. Next step comes of refining chosen keywords and controlling the behavior of display of Ad in search results by using various options to define your keywords.
    • So once you have a number of alternative keyword combinations, go for that which is closest to your products/services.
    • Use quotes, brackets, exclamation mark (to negate words) to control display of Ad in search results.
  1. A realistic budget can be set on monthly basis so that you don't run out of advertising money if there are unexpectedly very high number of hits.

  2. A regular monitoring of ad campaign is necessary. You should do data mining to find out "customer conversion rates", "expense vs returns".

  3. Localization is very useful in targeting perspective customers having higher possibility of conversion. For example if your products/services are physically present only in certain cities or areas you should localize your Ads to these places only. This can save you ton of money by avoiding unnecessary hits from people outside of your focus area.

  4. Create specifically designed landing pages tied up with the Ad. Sending visitors to homepage can leave them lost in piles of information.

  5. Ad campaign can be outsourced to SEO companies for better returns. These companies have experts of this field. They properly launch, design, refresh and monitor Ad campaigns.

  6. There is a risk factor with AdWords. You may loose your money without return if any computer generated program hits your Ad. Money may be returned by Google in such cases if it had been proved but there would be additional pain in claiming your money back.

  7. If your business is very new of its kind and most of the people don't know about it, AdWords may not be the right choice for you. People generally avoid clicking on Ads in such a case. Traditional ways of promoting productions/services may be better choice to go with.

Saturday, August 01, 2009

Embed Code in Blog and Webpages with Syntax Highlighting

Ever wondered how one can embed code in blogs and web pages with language specific highlighting? Let's hit ground directly. It is a cakewalk by using js based open source Syntax Highlighter developed by Alex Gorbatchev.

Here We'll talk about embedding code with language specific syntax highlighting in blogger/blogspot. But it is pretty straight forward to do the same in any web page.

Setup Syntax Highlighter for Blogger
  1. Open template layout for editing in 'Edit Html' mode.
  2. Add following lines of code in head section (just before closing head tag </head>)
  3. <!-- Adding Syntax Highlighter -->

    <link href="" rel="stylesheet" type="text/css">
    <link href="" rel="stylesheet" type="text/css">
    <script src='' type='text/javascript'/>

    <!-- language specific brushes (js files) go here -->
    <script src='' type='text/javascript'/>
    <script src='' type='text/javascript'/>
    <script src='' type='text/javascript'/>
    <script src='' type='text/javascript'/>
    <script src='' type='text/javascript'/>
    <script src='' type='text/javascript'/>
    <script src='' type='text/javascript'/>
    <script src='' type='text/javascript'/>

    <!-- Adding Syntax Highlighter Ends Here -->
    //enabling syntax highlighter for blogger
    <script type='text/javascript'>
    SyntaxHighlighter.config.bloggerMode = true;
  4. Save template and you are done with setting up syntax highlighter for your blogger!
Writing Post with Syntax Highlighting
Open editor in "Edit Html" mode and wrap code in language specific pre tags
  1. SQL Example

    <pre class="brush:sql">
    password VARCHAR(255) NOT NULL,
    user_type VARCHAR(10),
    active CHAR(1) NOT NULL DEFAULT 'Y');

  2. Result:
    password VARCHAR(255) NOT NULL,
    user_type VARCHAR(10),
    active CHAR(1) NOT NULL DEFAULT 'Y');
  3. Javascript Example

    <pre class="brush:js">
    <script type="text/javascript">
    // The Vehicle class
    return this.wheels


** Don't forget doing HTML encoding of text for getting properly formatted HTML.
HTML Encoder 1
HTML Encoder 2

Friday, January 23, 2009

Remote Debugging - SunOne+Eclipse

In server.xml ( for my installation it is at /opt/jsws70/https-<user>/config/server.xml )

1. Set debug option under jvm to true.

2. Set the port on which debugging to be enabled
<debug-jvm-options>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=<desired port></debug-jvm-options>

3. Now for Eclipse configuration, go to debug configuration. Use server name or IP and in the port option, put the same port that you have set in server.xml <desired-port>

4. If you need more detail, please follow steps in Remote Debugging - Tomcat+Eclipse

Friday, January 16, 2009

Remote Debugging - Tomcat + Eclipse

I am assuming that you have setup Tomcat by exploding its zip distribution. Windows installer distribution of Tomcat doesn't contain all config and script files including catalina.bat or . I used
- Tomcat 6.0.18
- Eclipse 3.4

- Windows XP

Tomcat Configuration
  1. Go to CATALINA_HOME\bin and edit catalina.bat in any editor, say Notepad++ . Here CATALINA_HOME is your tomcat installation directory. For me it is C:\Tomcat6.0 .
  2. Find JPDA_TRANSPORT and set it as JPDA_TRANSPORT=dt_socket .
  3. Find JPDA_ADDRESS and set it as JPDA_ADDRESS=8000 (you can use any unused port).
  4. Check if port specified is not being already being used; by executing "netstat" at command prompt. Check list of local ports.
  5. Save your changes.
  6. Start your server in debug mode by hitting "catalina jpda start". You may like to add CATALINA_HOME\bin in you PATH environment variable.
Eclipse Configuration
  1. Click on green beetle -> debug configurations...
  2. At Remote Java Application, click new and configure the settings.
  3. Give a name to this debug configuration (homebase-tomcat for me).
  4. Type localhost at Host or any name you have given to you localhost, mapped to in hosts file ( for me).
  5. Type 8000 as the port. Please note that the port must be the same with the JPDA_ADDRESS in catalina.bat file.
  6. Browse the project that you would like to debug.
  7. Click on debug button.

  1. Go to your code and put breakpoints by double clicking on the left panel, wherever you want to debug.
  2. Hit your server by opening pages, where you want to debug, in browser.
  3. You will see eclipse switches to debug perspective and debug control flow stops at first breakpoint on the way.
  4. Use following eclipse shortcuts to proceed debugging
  • F5 - Step into (you may like to go inside any method on the way)
  • F6 - Step over (line by line)
  • F7 - Step return (coming out back after going down into a call hierarchy)
  • F8 - Resume debugging (breakpoint to breakpoint)
  1. Use terminate and disconnect buttons to stop debugging
You all set to play with debugging!!

Monday, January 12, 2009

Joomla Vs Drupal

Here I'll try to compare two hottest PHP based content management system Joomla and Drupal, based on some prevailing factors, and my experience while working/evaluating Joomla and Drupal.


Excels at:
  1. Eye candy themes and templates
  2. Great at functionalities
  3. Shopping Cart - Virtumart and OSCommerce
  4. Huge library of free/commercial extensions
  5. Events & Calendar - good support
  6. Document Management - Promising DocMan extension
  7. Excelent web admin interface
Under performs at:
  1. Architecture is poor
  2. No Multi-site management support (Separate installation for each site)
  3. Poor in standard's compliance
  4. SEO - You may hit your head against wall to make it working

Excels at:

  1. Multi-Site Management
  2. Standard's Compliance
  3. Architecture - Very good
  4. SEO - Supports well (Search engine friendly pages)
  5. Better Documentation
  6. Internationalization (using i18n module)
  7. SSL Compatible
Under performs at:
  1. Themes and Templates - are very simple not eye candy
  2. Shopping Cart - addon is not as good (seems good option Ubercart )
  3. Event & Calendars - not great
  4. Document Management - nothing like DocMan in Joomla

Joomla as a CMS appears to excel in elements that can be identified as functional, while Drupal succeeds in the architectural elements. Which element is more important in a CMS, architecture or function? According to Deane Barker he believes it is more important for a CMS to have better architecture.

As a developer with the capability to write code, I find myself much more concerned with architectural matters. Functionality can be programmed, but I’m at the mercy of architecture. Put another way, give me the right tools and materials, and I can build anything. But give me nothing but a pile of sand and a toothbrush, and I’m pretty much screwed.

In other words, if you agree with Barker that architecture is more important than function you're likely going to want to choose Drupal. However, if you need to make a quick sell where function, third party integration, and eye candy is important right out the box... Joomla still has the advantage.

Learnig Curve - Joomla has relatively shallow learning curve. It is one of the very easiest CMS systems to learn and customize but you may find some mess at coding level. Drupal has a little steeper than Joomla, but still relatively easy to learn.