Friday, December 5, 2008

Spring method interceptors

An excellent feature of spring AOP
http://www.javalobby.org/java/forums/t44746.html

Excellent podcast spanning from spring framework, AJAX to cloud and grid computing. Must see
http://skillsmatter.com/podcast/java-jee

Saturday, October 25, 2008

Fedora 9 on lenovo 3000 N200

My lenovo 3000 N200 was sick last week.
I have a dual boot win xp and fedora 9 setup. It worked for a few months..Then the agony...
The laptop would shutdown suddenly, or while booting and sometimes it even would wake up by itself although it was shutdown (like a zombie). Scary !!.

After some initial struggle and making dozens of calls to Lenovo support centre, a techie told me that N200 has a problem with BIOS and I had to reset it to defaults.

Well I did it. Guess what - my windows xp BSOD started showing up on startup.
Fedora 9 also was crashing now.

Luckily I had fedora 9 setup cd and after a re-install things were normal with fedora. However the windows BSOD persists.
Tried to get hold of a windows XP cd, but unfortunately though I am able to but up with win xp, it simply says setup is now checking.... and simply hangs with Black screen...Seems like it's not able to detect HDD

Anyway I got fedora 9 with internet working fine.
However I had a problem with sound. As per a forum i setup sound and it worked like a charm. The fix was:
In /etc/modprobe.d/alsa-base add a line
options snd-hda-intel model=lenovo.
Restart, voila sound's good.

Next with fedora, i was not able to play mp3,
After some searching around, I got a cool tool for fedora 9, it is named easylife - an opensource project. This installs all the required software on fedora at one go. Like skype, adobe, flash, etc. Everything is taken care under the hood.
next flash on fedora was not working..
Had to checkout if it was 64 bit installation using $uname -a
Yes it was for me and hence followed below instructions:

Installation on Fedora 64-bit

The following steps are required for Fedora 64-bit users.

First install the Adobe YUM repository, as stated above:

[mirandam@charon Download]$ sudo mkdir -p /usr/lib/mozilla/plugins
[mirandam@charon Download]$ sudo yum install nspluginwrapper.{i386,x86_64} pulseaudio-libs.i386 libflashsupport.i386
[mirandam@charon Download]$ sudo yum install flash-plugin

[mirandam@charon Download]$ sudo mozilla-plugin-config -i -g -v

This was adapted from the Fedora 9 Release Notes.

NOTE - PulseAudio - I was able to hear sound properly in both Gnome and KDE in Firefox when PulseAudio was enabled.

I'm yet to try this link to revive win xp.. http://forums.lenovo.com/lnv/board/message?board.id=N_Series_Lenovo_3000&thread.id=269

Friday, October 10, 2008

Jquery

It is :
* simple (include a javascript into ur existing page and you start playing with Jquery),
* light weight(core is just 20KB), pluggable/ extensible(thousands of plugins) and
* easy to use (implicit event handling, expression evaluation and function chaining to name a few).

Client-side
Also a jquery-form plugin( http://malsup.com/jquery/form/ ) makes HTTP form post much more easier.
This takes care of marshalling the HTML input fields automatically , make a form post and deal with the HTTP response.

Server-side
There is some work done already on (spring MVC + jquery) http://www.infoq.com/articles/First-Cup-Web-2.0-Joel-Confino
Tried a prototype using this and jquery-form. Actually it works well with Xstream and Jettison mapped driver .
Also converting the existing spring MVC controller to have AJAX capability is just a matter of setting a custom Json View instead of existing Velocity
view.

Data can be transferred from browser to server in either of the format:
JSON(Java script object notation) or XML.
JSON is simple as it gives you a java like object graph and is more popular in open source community.
However it lacks XML flexibility (like having attributes,etc)

Obviously, having an IDE for jQuery would make development easier. Searched around for an IDE with JS code completion and debugging capabilities.
There are few of them to evaluate - Aptana and Spket IDE.

JQuery... Ahh kids play, is it really? find out yourself http://www.youtube.com/watch?v=8mwKq7_JlS8
How it works : http://docs.jquery.com/How_jQuery_Works
Best practises
http://www.smashingmagazine.com/2008/09/16/jquery-examples-and-best-practices/
Examples http://www.noupe.com/jquery/50-amazing-jquery-examples-part1.html

Thursday, September 25, 2008

Apache commons usage

There are many good ready to use commons libraries from apache. These should have been in JDK. Often we fail to use their feature and spend time and effort to reinvent the wheel. I make an effort to brief the practical usage of these libraries here: 1. commons-lang public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof Institution)) return false; Institution rhs = (Institution) obj; return new EqualsBuilder() .appendSuper(super.equals(obj)) .append(this.getSubscriberId(), rhs.getSubscriberId()) .isEquals(); } public int hashCode() { // Don't be tempted to use reflection here - Hibernate throws a major wobbly :( return new HashCodeBuilder() .appendSuper(super.hashCode()) .append(getSubscriberId()) .toHashCode(); } public String toString() { // Don't be tempted to use reflection here - Hibernate throws a major wobbly :( return new ToStringBuilder(this) .appendSuper(super.toString()) .append(getSubscriberId()) .toString(); } 2. commons-digester -This provides a wrapper to parse XML. Usage: Digester articleDigester = new Digester(); articleDigester.addObjectCreate("art", ArticleXMLTO.class); articleDigester.addCallMethod("art/fm/bibl/source", "setSource", 0); //setSource is a setter in ArticleXMLTO articleDigester.addCallMethod("art/fm/cpyrt/year", "setCopyrightYear", 0); //for publication date. articleDigester.addCallMethod("art/fm/history/pub/date/day", "setTempPublicationDay", 0); //For passing params to methods.. trialDigester.addCallMethod("MRCT_RECORD/CONTENTS/TITLE/DATA", "addField",2 ); trialDigester.addObjectParam("MRCT_RECORD/CONTENTS/TITLE/DATA", 0, "FIELD-NAME"); trialDigester.addCallParam("MRCT_RECORD/CONTENTS/TITLE/DATA", 1); //For encapsulated objects articleDigester.addObjectCreate("art/fm/bibl/aug/au", AuthXMLTO.class); articleDigester.addCallMethod("art/fm/bibl/aug/au/fnm", "setFName", 0); articleDigester.addCallMethod("art/fm/bibl/aug/au/mi", "setMName", 0); //for a set of objects articleDigester.addSetNext("art/fm/bibl/aug/au", "addAuth"); //addAuth method adds the object to the list. articleXMLTO = (ArticleXMLTO) articleDigester.parse(xml); Simpler than dealing with DOM or SAXing isn't it. 3.commons-configurator Please refer here

JDBC essentials

Good to know on how to build jdbc URL here

More to come .....

Friday, August 29, 2008

Java Classpath issues

The most difficult problem to solve from a distance... But if we look closely its a piece of cake.
Many developers spend so much time in fixing this issue. Lot of frustration and anger. What they dont spend time on is finding how the classpath and class loading is done in java. Once you know it, you are done.

I herewith try to log a list of java classpath issues:

1. Junit cannot load classpath resource:
The ideal solution as I know is to put the resource along with the junit class(unless it is not reused across). Then load the resource using MyClassTest.class.getResourceAsStream("articles.xml");

This is a simple and elegant solution rather than hardcoding or putting a relative path , which are bound to fail in different environments.

Sunday, August 10, 2008

AJAX - What javascript can do..

AJAX is asynchronous javascript and XML. AJAX in it raw form is difficult to build rich applications. Many frameworks are developed hence. As javascript is object oriented, building a framework on it is easy. Something like a JDK with packages can be built and maintained easily.. Though AJAX was for XML, HTTP responses and JSON(kind of protocol) are supported. The following are in the market:
  1. GWT -by google. Java to javascript compiler makes it easy for java developer.
  2. Zk -very powerful and simple.
  3. DWR -simple
  4. Dojo - Excellent.
  5. Yahoo kit - dont know
  6. Ext JS
  7. Jquery
  8. More.....
Setting up the environment for these AJAX development is always a pain. Will write more in future on this. Links: Excellent gwt components here : http://www.gwt-ext.com/demo Jquery slider for select boxes : http://www.filamentgroup.com/lab/progressive_enhancement_convert_select_box_to_accessible_jquery_ui_slider/
This guy is 12 yr old.. and he knows so much of  jquery :
http://uk.youtube.com/watch?v=8mwKq7_JlS8

jquery with jsp
http://www.infoq.com/articles/First-Cup-Web-2.0-Joel-Confino

Automatic form post jquery plugin:

http://malsup.com/jquery/form/

Yes it is infact simple (include a javascript into ur existing page and
you start playing with Jquery), light weight(core is just 20KB),
pluggable/ extensible(thousands of plugins) and easy to use (implicit
event handling, expression evaluation and function chaining).





Also its jquery-form plugin( http://malsup.com/jquery/form/ )  makes
things much more easier. This takes care of marshalling the HTML input
fields automatically at the browser end.



There is some work done already on (spring MVC  + jquery) http://www.infoq.com/articles/First-Cup-Web-2.0-Joel-Confino

Tried a prototype using this and actually it works well with Xstream and Jettison mapped driver .

Also converting the existing spring MVC controller to have AJAX
capability is just a matter of setting a custom Json View instead of
Velocity view.



Data can be transferred from browser to server in either of the format:

JSON(Java script object notation) or XML.

   JSON is simple as it gives you a java like object graph and is more popular in open source community.      

   However it lacks XML flexibility (like having attributes,etc)



Obviously, having an IDE for jQuery would make development easier
especially with code completion  and debugging capabilities. There are
few of them to evaluate - Aptana and Spket IDE.

Jquery Editor:
http://spket.com/jquery.html

Tuesday, August 5, 2008

Oracle tips

A sneeky tool in oracle SQL developer to help u visually generate sql query is here


Printing a tree hierarchy using SQL connect by:

select
lpad('-', (level)*2,' ' ) || HIERARCHY_cat_short_name as padded_name, HIERARCHY_cat_id, HIERARCHY_cat_parent_id, level
from HIERARCHY_category
connect by prior HIERARCHY_cat_id =HIERARCHY_cat_parent_id
start with
HIERARCHY_cat_id in (select HIERARCHY_cat_id from HIERARCHY_category where
HIERARCHY_cat_parent_id is null)

quick reference here :http://philip.greenspun.com/sql/trees.html

Oracle CONTAINS function for XML based search
select count(*) from ATABLE where contains(xml_COLUMN, 'HASPATH(//filed="12568") ') >0

Extractvalue from xml column
SELECT distinct EXTRACTVALUE( xmltype(column_meta_xml), '//field',    'xmlns:ora="http://xmlns.oracle.com/xdb"') from atable





Friday, August 1, 2008

Textpad tricks

Textpad tricks

Find and replace 

Input : 66 Urology & Nephrology 737 Spermatogenesis
Replace : the bold text in the above input

Find Pattern : ^\([0-9]+\)\(.*[a-z \t]+\)\([0-9]+\)
Replace pattern: \1 \3

output: 66 737 Spermatogenesis


Gotcha's

Always escape group by characters ( or ) with \ [backslash] like this \( \)

^ is the beginning of the line

$ is the end of the line

\n is new line.

Thursday, July 24, 2008

Struts Magic

Had a recurring problem in struts app - passing attributes from one action to another by forward is getting lost, here is a solution : redirect="true" should solve the issue. http://strutscollections.blogspot.com/2008/02/action-chaining.html

Tuesday, July 22, 2008

Speed typing tips.

Here are a some basic tips, summarized from various typing tutorials and lessons. These tips are useful for taking tests as well as everyday keyboarding:
  • Tap on each key crisply but lightly. If you use minimum force (don't bang on the keys), your fingers will move faster.
  • Type as quickly as you are able, but don't "try" too hard or force your speed or you'll make many mistakes.
  • Relax!
  • Use proper posture, sit upright.
  • Keyboard/monitor positioning: your wrist, elbows and keyboard should be on the same horizontal plane, and at a 90 degree angle to your upper arms.
  • The top of your screen should be near eye level.
  • Stretch your wrists and fingers before starting a typing test (don't laugh, it does help!).
Ref: http://www.calculatorcat.com/typing_test/

Friday, July 18, 2008

I love log4j

Logging is a very useful thing. Without this most of our java softwares are like black boxes.
The major problems we face is setting up the log4j. Also trying to decipher the cryptic clues is annoying, like say log4j WARNING No appenders could be found. Who has time to fix these issues..
Well it pays of well if you fix it as I said u cant fix a software problem without seeing what is happening inside. It will be like the movie HAPPENING(Should have been what is happening) ...


A few tricks to get the log4j setup:
Passing VM arguments
-Dlog4j.configuration=file:C:/development/projects/webapp/target/classes/log4j.properties

-Dlog4j.debug=true .....Excellent option to know what is happening inside log4j.


commonly used log4j.properties is below:
---------------------------------------------------------------------------------------------
log4j.rootLogger=debug, stdout, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log

log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
-----------------------------------------------------------------------------------------

More log  to come here...

Ref: http://logging.apache.org/log4j/1.2/manual.html

Tuesday, July 15, 2008

Print request object using JSTL


        
<p>Headers</p>   
<c:forEach var="hdr" items="${header}">                           
<table bgcolor="lightgreen">
    <tbody>
        <tr>
            <td>
                <c:out value="${hdr.key}">
                </c:out>
            </td>
            <td> 
            <c:out value="${hdr.value}">
            </c:out>
            </td>
        </tr>
    </tbody>
</table>
</c:forEach>
        
        
<p>Attributes:</p>

        
        
<c:forEach var="attr" items="${pageContext.request.attributeNames}">                         
<table bgcolor="lightgreen">
    <tbody>
        <tr>
            <td>
                <c:out value="${attr}"> </c:out>
            </td>
        </tr>
    </tbody>
</table>
</c:forEach>
        
        
<p>Parameters</p>

        
        
<c:forEach var="pmtr" items="${pageContext.request.parameterMap}">                          
<table bgcolor="lightgreen">
    <tbody>
        <tr>
            <td>
                <c:out value="${pmtr.key}"> </c:out>
            </td>
            <td> 
            <c:out value="${pmtr.value}">
            </c:out>
            </td>
        </tr>
    </tbody>
</table>
</c:forEach>

Monday, July 14, 2008

Working with microsoft DLL,ODBC connection and IIS for a java developer

DLL's are dynamic link library. They are like .jar files in java.
Normally the error we get in dll's are due to dependency on other dll's. Tools like dependency walker and dll explorer come for the rescue.

To register a dll use(like loading jars to JVM)
regsvr32 [DLL path]

also
rundll32 [dll path]

IIS
  • IIS is web server provided by microsoft.
  • For the IIS we need to configure the components.
  • For this, go to control panel-- admin tools --computer mgmt --component services -- computer--my computer -- COM+ applications -- new application --Add users and imports ...Thats it the IIS will pick it up...

To unit test a package in the dll create a x.vb file with the below code:

set testobj = nothing
set testobj = createobject("IMPORT.Job")

msgbox "PR: " & testobj.PathRemoved("C:\development\miscellaneous\COM\testmdb")

if(testobj.DeleteFile ("C:\development\miscellaneous\COM\test.mdb"))Then
msgbox "Deleted your file!"
End if



--------------------------------------------------------------------------------------------------------------
Oracle connection through microsoft:

update \oracle\product\10.2.0\client_1\NETWORK\ADMIN\tnsnames.ora
Go to control panel-- datasourc(ODBC) connections --add new connection in first tab.Select database name and auth details.Do a test connection. Thats it

-----------------------------------------------------------------------------------------------------------------

I need to set a number of environment variables via a bat file currently I m executing as below.
The user environment variables are updated but I want to set the system ones, what do I have to do.
Also when I try to add paths to the path variable I get an error
@echo on
setx IT_CONFIG_DOMAINS_DIR=C:\Program Files\IONA\etc\domains
setx IT_DOMAIN_NAME=BankWorld
setx IT_LICENSE_FILE=C:\Program
Files\IONA\etc\Orbix_licenses.txt
setx IT_PRODUCT_DIR=C:\Program Files\IONA
setx PATH=%PATH%;C:\Program Files\IONA\bin;C:\Program Files\IONA\asp\6.3\bin
pause
:end
pause

How about using the -m switch?
setx IT_CONFIG_DOMAINS_DIR=C:\P
rogram Files\IONA\etc\domains -m
setx path "%path%;c:\new directory"



Using Cygwin
Where is my windows drive? Ans: inside cygdrive<br />bash$ cd C:/Windows<br />bash$ pwd<br />/cygdrive/c/Windows</pre><br /><b>IIS<br />Changing the default port:<br /></b><table class="list ol"><tbody><tr><td class="number"><small><small></small></small></td></tr><tr><td class="number"><small><small></small></small></td></tr></tbody></table><small><small>Microsoft Internet Information Services versions 4.0 to 6.0</small></small><script type="text/javascript">loadTOCNode(2, 'moreinformation');</script><table class="list ol"><tbody><tr><td class="number"><small><small>1.</small></small></td><td class="text"><small><small>Open Internet Service Manager or Internet Information Services (IIS) Manager.</small></small></td></tr><tr><td class="number"><small><small>2.</small></small></td><td class="text"><small><small>If necessary, expand the Web server that you want, and then expand <b>Web Sites</b>.</small></small></td></tr><tr><td class="number"><small><small>3.</small></small></td><td class="text"><small><small>Right-click the Web site that you want to change.</small></small></td></tr><tr><td class="number"><small><small>4.</small></small></td><td class="text"><small><small>Click <b>Properties</b>.</small></small></td></tr><tr><td class="number"><small><small>5.</small></small></td><td class="text"><small><small>Click the <b>Web Site</b> tab.</small></small></td></tr><tr><td class="number"><small><small>6.</small></small></td><td class="text"><small><small>Change the TCP Port Number in the <b>TCP Port</b> edit box (or click <b>Advanced</b> for multiple Port settings).</small></small></td></tr><tr><td class="number"><small><small>7.</small></small></td><td class="text"><small><small>Click <b>OK</b> to save the changes.</small></small></td></tr></tbody></table><br />Ref:<br /></div><small>Environment variable excellent reference : http://www.wilsonmar.com/1envvars.htm<br />IIS port change ref: http://support.microsoft.com/kb/149605<br /><br />IE browser issues<br />Having made a web application live, the user logoff action doesn't actually log off in IE. It works fine on firefox.. So the problem is obviously with the browser. Crap the microsoft IE doesn't handle caching well inspite of setting the pragma in the head tag. You need to put it in the bottom of the page as well.<br />Put the following in top and bottom under html tag<br /><pre><br /><head><br />   <meta http-equiv="cache-control" content="max-age=0, must-revalidate, no-cache, no-store, private"><br />   <meta http-equiv="expires" content="-1"><br />   <meta http-equiv="pragma" content="no-cache"><br /></head><br />

Here is the fix.
http://support.microsoft.com/kb/222064/

http://www.vbaccelerator.com/insprob.htm







Saturday, July 12, 2008

linux mysql setup quick start

To summarize ,

3306 default port of mysql

Login as root.

Start the database: /etc/rc.d/init.d/mysqld start

Databases located in: /var/lib/mysql/
Default config file installed by RPM: /etc/my.cnf

The first task is to assign a password:

[prompt]$ mysqladmin -u root password 'new-password'

Create a database: (Creates directory /var/lib/mysql/bedrock)

[prompt]$
mysqladmin -h localhost -u root -ppassword create bedrock
(or use SQL command: CREATE DATABASE bedrock;)

Add tables, data, etc: Connect to database and issue the following SQL commands:

[prompt]$
mysql -h localhost -u root -ppassword
...
mysql>
use bedrock; - Define database to connect to. Refers to directory path: /var/lib/mysql/bedrock
mysql>
create table employee (Name char(20),Dept char(20),jobTitle char(20));
mysql>
DESCRIBE employee; Shutting down the database:

[prompt]$
mysqladmin -u root -ppassword shutdown - PREFERRED
OR
[prompt]$
/etc/rc.d/init.d/mysqld stop
OR
[prompt]$
service mysqld stoplt;/b> mysqladmin -h localhost -u root -ppassword create bedrock

Ref:
http://www.yolinux.com/TUTORIALS/LinuxTutorialMySQL.html

Wednesday, July 9, 2008

Maven - an expert .

Basics set MAVEN_HOME mvn install mvn clean install mvn package -Dmaven.test.skip=true mvn surefire-report:report mvnrepository.com It downloads the repository to c:\Documents and Settings\[USER]\.m2\repository Intermediate Setting up maven based projects into eclipse Eclipse needs to find the Maven-downloaded jars for compilation. Under Preferences > Java > Build Path > Classpath Variable M2_REPO should be set to ..\.m2\repository Run mvn eclipse:clean --- dletes .class and .project files mvn eclipse:eclipse --- creates .class and .project files using pom.xml (recursively) Thats it. Advanced Steps to create an archetype project: Use below to create a sample archetype meta project. />mvn archetype:create -DgroupId=[com.biomedcentral] -DartifactId=[archetype-spring-jar] -DarchetypeArtifactId=maven-archetype-archetype Update the archetype [archetype-spring-jar]\src\main\resources\META-INF\maven\archetype.xml Keep all the relevant resource in the [archetype-spring-jar]\src\main\resources\archetype-resources\... and update the archetype with its reference. Install the archetype project itself: />mvn install Now time to use this project generator: mvn archetype:create -DarchetypeGroupId= -DarchetypeArtifactId= -DarchetypeVersion= -DgroupId= -DartifactId= This is amazing...From an existing architecture u can clone yours ... A sample command using above for spring hibernate is below: #mvn archetype:generate -DarchetypeGroupId=com.webtide -DarchetypeArtifactId=maven-archetype-SpringJpa -DarchetypeVersion=1.0 -DgroupId=c om.my.package -DartifactId=ImageLibraryCategoryManager mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create -DgroupId=com.my -DartifactId=springmvc-hibernate-app -DarchetypeArtifactId=appfuse-basic-spring -DarchetypeGroupId=org.appfuse.archetypes A bit on Maven Plugins: 1. maven-dependency-plugin : http://maven.apache.org/plugins/maven-dependency-plugin/ Very useful for copying dependency jars for a standalone app,etc. Reference: http://mevenide.codehaus.org/ -- plugin for eclipse http://maven.apache.org/guides/mini/guide-attached-tests.html http://www.webtide.com/resources.jsp --samples For springmvc-hibernate archetypes use http://docs.codehaus.org/display/MAVENUSER/Archetypes+List http://maven.apache.org/guides/mini/guide-creating-archetypes.html Debug maven : http://tech.puredanger.com/2009/02/25/maven-tips/

Monday, June 30, 2008

Useful developer tools , Fire fox plugins and tweaks

Useful developer tools: Smart Draw 7 -- for drawing good quality diagrams. Loads of templates to quickly do the task(free). Jude -- Very easy UML developer tool(free). JProfiler -- To profile java application(10 day licence free). Profiler4j -- Opensource profiler for java wink - A good screen capture/presentation tool . Can convert to compressed swf, etc. http://www.debugmode.com/wink/ freemind - a opensource mind mapping tool. currports - for getting the port information on windows. BareTail - A linux tail for windows Archiva - Surround SCM Test Track ProBug tracker. Better use free JIRA bug tracker instead. Mingle - highly recommended for agile process management. But pricy! Sonar - Code report and monitoring app. PuTTY Connection Manager - My favourite. Manage multiple putty consoles in this tab based connection manager. Also the windows can be arranged and split up..excellent!! DownThemAll - Good when you want to download large sized files on firefox
Capistrano - automating remote tasks. Works only for linux Crucible - Code review tool remotely. Confluence- collaboration software. (news, etc) Perfect Macro Recorder (http://www.perfectiontools.com/) for automation Best firefox plugins for developers:
  1. LightShot-- Nice screenshot add-on.
  2. Firebug -- Best of the breed, javascript debugging, DOM explorer
  3. LiveHttpHeaders -- shows request header
  4. UrlParams -- shows get and post params
  5. iMacros -- macro to automate work.
  6. tamperData - to check post/get request in browsers..my fav!
  7. Secure Login - To auto fill login submission.

  8. web developer - html, css, xhtml compliance, table border...good tool for html development
  9. bugmenot- to auto login site with dummy password
  10. autopager - reduce clicks while searching
Others:
  1. ImgLikeOpera -- save bandwidth
  2. ScribeFire -- Quickest way to blog from firefox. Type about:config in browser url Then search and update the property display.history.numbertoshow (default is 10) Restart browser. This should list more blogs
  3. GSpace --virtual file system
  4. del.ico.us -- online tagging (book marks)
  5. Autocomplete Manager 2.0

Firefox AutoFill address bar As you type a web site address into Firefox's location bar, by default a dropdown with suggestions based on your history expands, and you can use the down arrow key to select one. For more aggressive URL auto-completion, head on into Firefox's about:config area and set the browser.urlbar.autoFill For more check http://lifehacker.com/software/firefox-tip/enable-firefox-address-bar-autocompletion-313533.php value to true.

Firefox Memory Optimization (Ref http://nicusor.com/internet/firefox-memory-optimization/ )

  • Open Firefox browser, go to address bar, type about:config and hit enter
  • You’ll see a page full with text under 4 columns: Preference Name, Status, Type, Value
  • Right-click anywhere on that page and select New -> Boolean
  • You’ll get prompted to enter a Preference Name - enter this: config.trim_on_minimize and hit enter
  • You’ll be prompted for a value - select True and hit enter
  • That’s it - close Firefox and open it again!
  • Now, whenever you minimize your Firefox, the amount of memory used will be reduced to approximately 20%. Minimize Firefox and see what happens
  • Enable network.http.proxy.pipelining to true
  • Enable network.http.piplelining to true
  • Enable network.http.pipelining.max... to 30 from 4
  • create integer nglayout.initialpaint.delay and set value to 0
Ref: http://c4lpt.co.uk/Top100Tools/ Firefox plugin development : http://www.gmacker.com/web/content/tutorial/firefox/firefoxtutorial.htm http://www.captain.at/howto-firefox-toolbar-tutorial.php http://www.slideshare.net/skeevs/mozilla-firefox-extension-development/ Tools for firefox plugin development extension developer extension https://addons.mozilla.org/en-US/firefox/addon/7434/ spket ide XUL booster Windows XP performance tuning:
  1. Right click my computer-- properties -- advanced -- performance -- Select adjust for best performance.Appy.
  2. click start -- run -- msconfig -- startup -- disable all ( note do selective disable if u want to have some programs in task bar).
  3. Go to start -- all programs -- accessories -- system tools -- disk clean up. This will clean up all crap.

Powered by ScribeFire.

Tuesday, April 8, 2008

Software tools

The list of software plugins/tools useful throughout a projects SDLC.

More links
http://weierophinney.net/matthew/archives/101-Using-Windows-XP.html
<br /><br />

Friday, April 4, 2008

Movies To watch

This is the list of movies from Shubhajit to watch out for-
  • The art of negative thinking
  • the pursuit of happiness
  • Once you are born
  • We shall overcome
  • For more sun
  • Blind flyers
  • The best of youth
  • The edge of heaven
  • Little miss sunshine
  • An inconvenient truth
  • Happy Feet
Thanks :)

Monday, March 24, 2008

Code Generator

Tiny drops of water makes a mighty ocean. So here is my first few drops ;) I just started off with a project in source forge. Though its life cycle is going at a snail's pace, i hope to get it done sometime. The project link is http://sourceforge.net/projects/lifegen/ Here is the plan for this simple code generator for web application development(used freemind software for planning this).

More to come soon....

Thursday, March 20, 2008

Cobertura- junit coverage tool

First, you need to add a task definition to the build.xml file. This top-level taskdef element specifies that the cobertura.jar file is in the current working directory:

&lt;taskdef classpath="cobertura.jar" resource="tasks.properties" /&gt;

For eclipse IDE, you need to add the cobertura.jar, junit.jar in the
global path of Ant through Eclipse--} preferences--} Ant --} Global entry.

Next, you need a cobertura-instrument task that adds the logging code to the already compiled class files. The todir attribute instructs where to put the instrumented classes. The fileset child element specifies which .class files to instrument:

&lt;target name="instrument"&gt;

 &lt;cobertura-instrument todir="target/instrumented-classes"&gt;
   &lt;fileset dir="target/classes"&gt;
     &lt;include name="**/*.class"/&gt;
   &lt;/fileset&gt;
 &lt;/cobertura-instrument&gt;
&lt;/target&gt;

You run the tests with the same type of Ant task that normally runs the test suite. The only differences are that the instrumented classes need to appear in the classpath before the original classes, and you need to add the Cobertura JAR file to the classpath:

&lt;target name="cover-test" depends="instrument"&gt;
 &lt;mkdir dir="${testreportdir}" /&gt;
 &lt;junit dir="./" failureproperty="test.failure" printSummary="yes"
        fork="true" haltonerror="true"&gt;
   &lt;formatter type="plain" usefile="false"/&gt;
   &lt;!-- Normally you can create this task by copying your existing JUnit
        target, changing its name, and adding these next two lines.
        You may need to change the locations to point to wherever
        you've put the cobertura.jar file and the instrumented classes. --&gt;
   &lt;classpath location="cobertura.jar"/&gt;

   &lt;classpath location="target/instrumented-classes"/&gt;
   &lt;classpath&gt;
     &lt;fileset dir="${libdir}"&gt;
       &lt;include name="*.jar" /&gt;
     &lt;/fileset&gt;
     &lt;pathelement path="${testclassesdir}" /&gt;

     &lt;pathelement path="${classesdir}" /&gt;
   &lt;/classpath&gt;
   &lt;batchtest todir="${testreportdir}"&gt;
     &lt;fileset dir="src/java/test"&gt;
       &lt;include name="**/*Test.java" /&gt;
       &lt;include name="org/jaxen/javabean/*Test.java" /&gt;

     &lt;/fileset&gt;
   &lt;/batchtest&gt;
 &lt;/junit&gt;
&lt;/target&gt;&gt;

The Jaxen project uses JUnit as its test framework, but Cobertura is framework agnostic. It works equally well with TestNG, Artima SuiteRunner, HTTPUnit, or the home-brewed system you cooked up in your basement.

Finally, the cobertura-report task generates the HTML files you saw at the beginning of the article:

&lt;target name="coverage-report" depends="cover-test"&gt;
&lt;cobertura-report srcdir="src/java/main" destdir="cobertura"/&gt;
&lt;/target&gt;

The srcdir attribute specifies where the original .java source code files reside. The destdir attribute names the directory where Cobertura should place the output HTML.

Once you've added similar tasks to your own Ant build file, you generate a coverage report by typing:

% ant instrument
% ant cover-test
% ant coverage-report

Thursday, February 7, 2008

Internationalization utility

This uses jericho HTML parses.
This utility is just to extract static text out of a HTML/JSP and put in the property file. The static text is replaced with [spring:message key="xyz /].

Just provide input and output folders and all the i18n message are extracted to srcFolder\messages_en_US.properties file and JSP/HTML are updated.

Code is below:
/**
*
*/
package parser.htmlParser;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang.StringUtils;

import au.id.jericho.lib.html.Element;
import au.id.jericho.lib.html.OutputDocument;
import au.id.jericho.lib.html.Segment;
import au.id.jericho.lib.html.Source;
import au.id.jericho.lib.html.TextExtractor;

/**
* @author Sandeep.Maloth
*
*/
public class JerichoInternationalizer {
final static String SRC_DIR_NAME = "D:\\ProjectRelated\\evaluation\\liferay4.3.2\\webapps\\cmpWeb2\\WEB-INF\\jsp";

final static String DSTN_DIR_NAME = "D:\\ProjectRelated\\evaluation\\liferay4.3.2\\webapps\\cmpWeb2\\WEB-INF\\jsp\\TEMP";

final static String FILE_NAME = "articledisplay_view.jsp";

static Map messageKeyValueHolder = new LinkedHashMap();

static Map messageValueKeyHolder = new LinkedHashMap();

static Map elementsToReplace = new LinkedHashMap();

static int counter = 1;

/**
* @param args
* @throws IOException
* @throws Exception
*/
public static void main(String[] args) throws Exception, IOException {
doProcess(SRC_DIR_NAME, DSTN_DIR_NAME );
storeMessages(SRC_DIR_NAME);
System.out.println(messageKeyValueHolder);
System.out.println(messageValueKeyHolder);

}

private static void doProcess(String srcDirName, String dstnDirName) throws IOException, FileNotFoundException, Exception {
File dir = new File(srcDirName);
String files[] = dir.list();

for (int i = 0; i &lt; files.length; i++) {
String fileName = files[i];
final File fileObject = new File(srcDirName, fileName);
if (fileObject.isDirectory()) {
String tempSrcDir = srcDirName + "\\" + fileName;
final String tempDstnDirName = dstnDirName + "\\"+fileName;
doProcess(tempSrcDir, tempDstnDirName);
} else {
if (!(fileName.toUpperCase().endsWith("JSP") || fileName.toUpperCase().endsWith("HTML"))) {
System.out.println("Skipping " + fileName);
continue;
}

System.out.println("Parsing .... " + fileName);

Source source = new Source(new FileInputStream(fileObject));

source.fullSequentialParse();
final List childElements = source.getChildElements();
extractMessages(childElements, source, fileName);

// The extracted messages will be in elementsToReplace and need
// to be replaced in the source
Set entrySet = elementsToReplace.entrySet();
OutputDocument outputDocument = new OutputDocument(source);
for (Iterator iter = entrySet.iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
Segment content = (Segment) entry.getKey();
String value = (String) entry.getValue();

outputDocument.replace(content, value);

}

final File dstnDir = new File(dstnDirName);
if (!dstnDir.exists()) {
dstnDir.mkdirs();
}
final File tempFile = new File(dstnDirName, fileName);
FileWriter fileWriter = new FileWriter(tempFile);
outputDocument.writeTo(fileWriter);
fileWriter.close();

elementsToReplace.clear();
System.out.println();
}
}
}

private static void storeMessages(String dstnDirName) throws FileNotFoundException, IOException {
Set msgsEntrySet = messageKeyValueHolder.entrySet();
FileWriter fileWriter = null;
StringBuffer sbuf = new StringBuffer();
for (Iterator iter = msgsEntrySet.iterator(); iter.hasNext();) {
final Object object = iter.next();
System.out.println(object);
Map.Entry entry = (Map.Entry) object;
String key = (String) entry.getKey();
String value = (String) entry.getValue();
sbuf.append(key).append("=").append(value).append("\r\n");
}
try {
fileWriter = new FileWriter(new File(dstnDirName + "\\messages_en_US.properties"));
fileWriter.write(sbuf.toString());
} finally {
if (fileWriter != null)
fileWriter.close();
}
}

private static void extractMessages(List childElements, Source source, String fileName) throws Exception {

for (Iterator iter = childElements.iterator(); iter.hasNext();) {
Element element = (Element) iter.next();

final List childElements2 = element.getChildElements();

if (childElements2 != null && childElements2.size() &gt; 0) {
extractMessages(childElements2, source, fileName);
} else {
final TextExtractor textExtractor = element.getTextExtractor();

String txt = textExtractor.toString();
String key = "";
if (txt != null) {
txt = txt.trim();

if (txt.length() &gt; 0 && !StringUtils.isNumeric(txt)) {
System.out.println(txt);
String ctrString = "";
if (counter &lt; 10) {
ctrString = "0000" + counter;
} else if (counter &lt; 100) {
ctrString = "000" + counter;
} else if (counter &lt; 1000) {
ctrString = "00" + counter;
}else if(counter&lt;10000){
ctrString = "0" + counter;
}

if (!messageValueKeyHolder.containsKey(txt)) {
key = "MESG" + ctrString;
messageKeyValueHolder.put(key, txt);
messageValueKeyHolder.put(txt, key);
elementsToReplace.put(element.getContent(), "&lt;spring:message code=\"" + key + "\"&gt;&lt;/spring:message&gt;");

counter++;
} else {
key = (String) messageValueKeyHolder.get(txt);
elementsToReplace.put(element.getContent(), "&lt;spring:message code=\"" + key + "\"&gt;&lt;/spring:message&gt;");

}
}
}
}
}
}

}

Wednesday, February 6, 2008

internationalization support in spring -usage

Spring Internationalization web MVC

1. Add two properties files in /WEB-INF/classes: 1) messages_zh_CN.properties Chinese message file. 2) messages_en_US.properties English message file.

2. Add bean in action-servlet.xml: [bean id="localeResolver" class="org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver"/]

Spring will set UI language locale and message according to the client-side browser locale configuration.

3. JSP files

1. [fmt:message key="key1"/]

2. Error message [spring:bind path="account.password"] [input type="password" name="${status.expression}" value="${status.value}"/] [span class="fieldError"]${status.errorMessage}[/span] [/spring:bind]

3. button [input type="submit" class="button" name="prev" value="[fmt:message key="prev"/]" /]

Spring Internationalization for portlet MVC

1. Add two properties files in /WEB-INF/classes:

1) messages_zh_CN.properties -Chinese message file.

The Java properties files are created using a native encoding or in UTF-8. This must be converted to an ascii format for Java. This is done as part of the extraction process on the translation website but if you have a manually created file in UTF-8 that needs to be encoded, then use the native2ascii command that comes with with Java JDK.

Call native2ascii to ascii encoding, specifying the original file has UTF-8 encoding:

Eg: native2ascii.exe -encoding UTF-8 chinese_zh.txt ApplicationResource_zh_CN.properties

2) messages_en_US.properties -English message file.

2. Update applicationContext.xml file as below:

/WEB-INF/classes/messages " style="position: absolute; margin-left: 0pt; margin-top: 0pt; width: 451.5pt; height: 96pt; z-index: 1;" o:allowoverlap="f"> Spring will set UI language locale and message according to the client-side browser locale configuration.For guest user liferay creates a cookie called GUEST_LANGUAGE_ID with the language based on the browser configured locale.

  1. Replace the static text in JSP files with

[spring:message code=”key1”/] where key1 is the key available in message_xx.properties file

Note :The Java properties files are created using a native encoding or in UTF-8. This must be converted to an ascii format for Java. This is done as part of the extraction process on the translation website but if you have a manually created file in UTF-8 that needs to be encoded, then use the native2ascii command that comes with with Java JDK. Call native2ascii to ascii encoding, specifying the original file has UTF-8 encoding:

native2ascii.exe -encoding UTF-8 chinese_zh.txt ApplicationResource_zh_CN.properties Ref: http://wiki.lamsfoundation.org/display/lams/LAMS+i18n

The below JSP is Useful to troubleshoot locale related issues:

[%

//java.util.Locale locale = (java.util.Locale)request.getSession().getAttribute

("org.apache.struts.action.LOCALE");

Locale locale = renderRequest.getLocale();

String language = locale.getLanguage();

String country = locale.getCountry();

out.println(language +" "+country);

// Remember, messagesis the fully qualified name of a bundle in the classpath

// e.g. WEB-INF/classes/messages_*.properties

ResourceBundle res = ResourceBundle.getBundle("messages", new java.util.Locale(language, country));

java.util.Enumeration en=res.getKeys();

while(en.hasMoreElements())

{

out.println(en.nextElement());

}

out.print(res.getString("key1"));

%]

Thursday, January 31, 2008

Linux ssh autologin with putty

html">

ssh autologin with putty

This article shows how to do it when

connecting from a windows machine using putty to a linux box.


1. download PuTTYgen and start it.

2. at the bottom of the window, select SSH2 RSA

3. click generate and start moving your mouse over the blank part of
the window until the bar is filled and it shows some more options.

4. change the key comment to something meaningful like the name of your computer or you

5. save the private key (and if you want for later use, save the public
key too, but we don’t need this one for our auto login)

6. copy the public key from the textarea at the top of the window and
paste it into the ~/.ssh/authorized_keys file on your server you want
to logon in the home directory of the user you want to logon as. if
this file doesn’t exist yet, create it. (you may again want to
save the copy/pasted key to a text file on your computer in case you
have some more servers you want to auto-logon, so you can always open
it and copy/paste it from that file)

7. start putty and load your server settings

8. go to Connection–>Data and enter the username you want to
login as in the up most field “Auto-Login username”

9. go to Connection–>SSH–>Auth and choose the newly
reated private key file you saved before in the last field
“Private key file for authentication” by hitting the browse
button.

10. go back to Session and save all these settings.


now your’re done. from now on you will automatically be logged in when you open a session to that server


somem more tutorials for this and other os’s can be found here: http://wellsi.com/sme/ssh/ssh.html

More here for linux as well http://wiki.dreamhost.com/index.php/SSH#Passwordless_Login


Wednesday, January 30, 2008

Spyware trojan and virus removal tools

Hijackthis is one of the best. More here : http://www.spywareinfo.com/~merijn/programs.php

Wednesday, January 23, 2008

PHP and Related

http://www.dbforums.com/t1044828.html

I just installed Apache/PHP5/MySQL on my Windows PC with XP Home OS. I followed the Tut Installing PHP under Windows  by Matthew Phillips Referred to in the Post: Easy to understand Apache/PHP/MySQL install on XP box

This worked OK aside from a couple obvious differences. I had the most troube getting MySQL configured with PHP and had to do some searching to find the answer. Here is what I had to do to get it working.

In the Apache httpd.conf File at 'C:\Program Files\Apache Group\Apache2\conf\httpd.conf' You have to add these lines for PHP5

LoadModule php5_module php5apache2.dll
AddType application/x-httpd-php .php

In addition to installing MySQL etc. I had to do this to get MySQL to work:

1. Make sure that you have a valid php.ini in your windows directory.
OR (Per the tut the 'php.ini' can be installed in the 'C:\Program Files\Apache Group\Apache2' folder. This works fine.)
2. copy libmysql.dll to the system32 directory (php_mysql.dll would not load without doing this)
3. set the extension_dir in php.ini to the ext directory of your PHP installation directory (like e.g. extension_dir=C:\php5\ext)
4. enable the MySQL extension in php.ini by uncommenting the line extension=php_mysql.dll
5. Restart Apache Server

Check this link for latest php host

http://www.0php.com/free_PHP_hosting.php Useful open source apps: Online exam - TCExam (sourceforge project) perfect for online exam .(http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcexam) Fixes: Remember to add the user right (with groups , date format is yyyy-mm-dd) Install the application through the application. project management http://itprojectguide.org/ Drupal - an excellent content mgmt system. Joomla - similar to Drupal Imageflow - image gallery showcase.

Tuesday, January 8, 2008

Tomcat enabling security using Catalina.policy

Add the -security option in the startup script of catalina

For debugging security information have below setting in catalina
CATALINA_OPTS=" -Djava.security.debug=acess,failure"

The catalina.policy file should be present under $tomcat/conf/

Change the catalina.policy as required by checking the debug information

To check acess failures use the below:
grep -v "access allow" /usr/local/sso/logs/catalina.out |more

Note: -v is used to invert the search pattern.

or use
grep -v "access allow" /usr/local/sso/logs/catalina.out |egrep "domain|denied" |more


Saturday, January 5, 2008

Pega PRPC

Pega is a collection of rules linked to a business process

Pega = Rules Engine + Business Process

It is smart as it is built for changes and has all the capabalities required in a SDLC(s/w development life cycle). Here is a few:

- An inbuilt Versioning system.Excellent feature to manage releases. Never seen such good feature in my career in other products.
- An inbuilt clipboard and tracing tool for debugging. Rule inspector for debugging HTML on the fly. What else do you want with zero developer configuration.
- Inbuilt security system. Imagine building security in J2ee world , it is really a pain.
- A interface to view/design/manage the work flow from any corner of the world. Just have a browser and you are done. You setup the server environment once. No need to setup any other environment  for individual developer. 
- Object oriented.
- Java Based and inbuilt internationalization support
- Can include new java libraries easily (Rule-utility)...
- Smart product for smart people.
-  Excellent external service integration
- It solves most of the repeatedly occuring problems in a J2ee webapp development and hence a sure winner. Most problems are captured as rules which can be changed easily.
- Rule testing capability like Junit in java.

What it lacks in V4.2(correct if i am wrong)
- Sucks lot of Memory. Maybe deu to the rules stored in memory.
- Customizing the user interface layout takes a hell lot of time and effort. Also depends on the skillset of the developer.
- Didn't find a worthy information of handling back button in a work flow. Going back from one flow to another is not possible.
- How do we support AJAX? Portlets , etc? Is it there in V5 ?
- Hard Core *Coder* will not like it as it is not as flexible and tunable. :)
-Bigger learning curve of rules. But with it's feature its worth.
- Not open sourced :-).  If it get's opensourced no other product can beat it.

[update]
Useful links 
Forum for pega
Question and answer

Developer notes 1 


More to come here
TODO:
-How to develop pega app from scratch quickly
-Best Practices
-Essential rules what a pega developer should know.
 
[updates]
Another developer blog on its experiences:
 
http://claforet.wordpress.com/2010/06/26/getting-started-with-pega-development/