Open source reader

Friday, April 21, 2006

Great servlet filters, caching, compression, validation, urlrewrite

http://www.opensymphony.com/clickstream/ Track information with each click the user makes

oscache has a caching filter http://www.opensymphony.com/oscache/wiki/CacheFilter.html

http://tuckey.org has great filters !
http://tuckey.org/urlrewrite/ like the url rewrite apache module, but in your container ! Now that is cool!
http://tuckey.org/validation/ a validation filter, you xhtml unvalid code is show like this.

Want your xhtml code to be clean to ease you development ? http://jtidy.sourceforge.net/multiproject/jtidyservlet/filter.html

No need to waste your bandwith ? http://www.servletsuite.com/servlets/gzipflt.htm get a compression filter

There's more, please share yours :)

Converting videos to 3GP

You want to convert your videos for you mobile usages ? 3GP is what you need...

Here is a way I read in doc from Nokia nMMConverter_v2_0_Users_Guide.pdf


The Multimedia Converter 2.0 package also contains a console application (MMConverterCon.exe).
This allows you to convert large numbers of files using batch files. The following paragraph summarises the instructions for using the console version of Multimedia Converter 2.0.


Say hello to "Multimedia Converter 2.0 console version" !

Two computers at home ? You may need synergy.

Two computer at home ? Want to use both with a single keyboard/mouse ? You do not want to buy hardware ? You are rigth, it would be a waste of money, because there is ... http://synergy2.sourceforge.net/ !


Excerpt:

Synergy lets you easily share a single mouse and keyboard between multiple computers with different operating systems, each with its own display, without special hardware.
It's intended for users with multiple computers on their desk since each system uses its own monitor(s).

For your scheduling needs: quartz or jcrontab

For your scheduling jobs, I do recommend quartz http://www.opensymphony.com/quartz/

Quartz is a full-featured, open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application - from the smallest stand-alone application to the largest e-commerce system.
Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components or EJBs.
The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering.


For a simple cron replacement http://jcrontab.sourceforge.net/

Provides a system to run Classes/Threads/main/EJB/Methods/NativePrograms... at a given time.
Provides a parser of crontab-like files that are fully compatible with UNIX-POSIX crontab files

Thursday, April 20, 2006

Bypassing buggin login forms or mail confirmation

Just in case you do not know this free service driven by the community http://www.bugmenot.com

So usefull that you will most probably want to use also http://www.mailinator.com when you really need to create a login/password.

Please check them, it is really worth the click ! ... share sites like this around you :)

Display tag

I just like the displaytag tag library (http://displaytag.sourceforge.net/) it generates tables like
displaytag
If you have specific rendering needs needs, decorators are for you (here).

I was thinking about adding a feature to this tag: an alphabetical navigation ... well alphanavbar have done it, take a look at http://www.aikiinc.com/alphanavbar/ it generates this kind of output:
alphanavbar

Pretty neat.

Wednesday, April 19, 2006

Smallest hibernate starter kit ... ever

I have just found what I find the smallest hibernate starter kit :)
It is very basic, very raw, no structure, no package (!!), no folder, just 8 files, I guess it makes sense for newbies to see with 5 files what it hibernate about, you can get it directly here.
Next step for them Appfuse ... then Spring !

Java web framework sweet spots, Ruby on rails bashed

Read in http://www.virtuas.com/files/JavaWebFrameworkSweetSpots.pdf
excerpt:

This document was compiled by asking a number of different Java web framework authors the following questions:

1. What is your framework’s “sweet spot”, and for what type of projects should it strongly be considered?
2. What type of scenarios does it not fit into? Would you recommend another framework in this scenario? If so, which one?
3. Of the other web frameworks mentioned below, have you tried any of them? If so, which ones, and what did you like about them? What didn’t you like?
4. What is the future of your web framework? What’s coming that’ll make it easier for users to develop with? Do you support Ajax natively? If not, are you planning on adding support?
5. Are there myths about your framework you’d like to challenge? If so, which ones?
6. What do you think of Ruby on Rails?


Something I found very interresting about ruby on rails (http://www.rubyonrails.org/) by patrick lightbody (main developer of http://www.opensymphony.com/webwork/)


I’ve used Rails to build a small app. I threw it away and rewrote it in Java in less time. I would say that Rails does let you get 80% of your app done rather quickly; the last 20% still takes much longer than the first 80% took. This is classic application development.
The scaffolding stuff is very cool, especially how the ActiveRecord changes the classes at runtime. But in the end, you end up having to write custom UIs, custom validation rules, custom security mappings, etc. Just because you can have a CRUD-based app “working” in 30 minutes doesn’t mean that you will continue at that pace.


Ok let's re-read this last sentense:


Just because you can have a CRUD-based app “working” in 30 minutes doesn’t mean that you will continue at that pace.

Sleepy cat at Google

Here is a document from sleepycat use at google for their single sign on http://www.sleepycat.com/customers/pdfs/cs_google_1005D.pdf

Looks like this kind of software is really for specific needs, I do not really see where it fits for regular usage, any ideas ?

Simple html merge renderer

A nice simple html renderer for merge using http://sourceforge.net/projects/jlibdiff ...

package com.blandware.atleap.webapp.util.core;

import jlibdiff.Diff;
import jlibdiff.Hunk;
import jlibdiff.HunkAdd;
import jlibdiff.HunkChange;
import jlibdiff.HunkDel;
import jlibdiff.HunkVisitor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.BufferedReader;
import java.io.StringReader;
import java.util.ArrayList;

/**
*

Merge two strings of HTML or plain text


*


*

View Source


*
* @author Andrey Grebnev <andrey.grebnev@blandware.com>
* @version $Revision: 1.5 $ $Date: 2006/03/16 11:09:43 $
*/
public class MergeUtil {

public static final int OLD_HTML = 0;
public static final int NEW_HTML = 1;

/**
*

Merges the HTML


*

The changes will be emphasized using div with following styles: addHtml, oldHtml, newHtml, delHtml


*

If some error is occured the text will be empty


*

If htmls are identical, the old text will be as result


*
* @param oldString Old HTML string
* @param newString New HTML string
* @return merged HTML
*/
public static String mergeHtml(String oldString, String newString) {
Log log = LogFactory.getLog(MergeUtil.class);

final ArrayList hunks = new ArrayList();
BufferedReader oldReader = new BufferedReader(new StringReader(oldString));
BufferedReader newReader = new BufferedReader(new StringReader(newString));
StringBuffer mergedHtml = new StringBuffer();

try {
Diff diff = new Diff();
diff.diffBuffer(oldReader, newReader);
diff.accept(new HunkVisitor() {
public void visitHunkAdd(HunkAdd hunkAdd) {
hunks.add(hunkAdd);
}

public void visitHunkChange(HunkChange hunkChange) {
hunks.add(hunkChange);
}

public void visitHunkDel(HunkDel hunkDel) {
hunks.add(hunkDel);
}
});

int position = 0;
if ( hunks.size() != 0 ) {
for ( int i = 0; i < hunks.size(); i++ ) {
Hunk hunk = (Hunk) hunks.get(i);

if ( hunk instanceof HunkAdd ) {
mergedHtml.append(oldString.substring(position, getOffsetSOL(hunk.lowLine(OLD_HTML), oldString)))
.append("
")
.append(newString.substring(getOffsetSOL(hunk.lowLine(NEW_HTML) - 1, newString), getOffsetEOL(hunk.highLine(NEW_HTML) - 1, newString)))
.append("
");
position = getOffsetSOL(hunk.highLine(OLD_HTML), oldString);
} else if ( hunk instanceof HunkChange ) {
mergedHtml.append(oldString.substring(position, getOffsetSOL(hunk.lowLine(OLD_HTML) - 1, oldString)))
.append("
")
.append(oldString.substring(getOffsetSOL(hunk.lowLine(OLD_HTML) - 1, oldString), getOffsetEOL(hunk.highLine(OLD_HTML) - 1, oldString)))
.append("
\n")
.append("
")
.append(newString.substring(getOffsetSOL(hunk.lowLine(NEW_HTML) - 1, newString), getOffsetEOL(hunk.highLine(NEW_HTML) - 1, newString)))
.append("
");
position = getOffsetSOL(hunk.highLine(OLD_HTML), oldString);
} else /* HunkDel */ {
mergedHtml.append(oldString.substring(position, getOffsetSOL(hunk.lowLine(OLD_HTML) - 1, oldString)))
.append("
")
.append(oldString.substring(getOffsetSOL(hunk.lowLine(OLD_HTML) - 1, oldString), getOffsetEOL(hunk.highLine(OLD_HTML) - 1, oldString)))
.append("
");
position = getOffsetSOL(hunk.highLine(OLD_HTML), oldString);
}
}
mergedHtml.append(oldString.substring(position));
} else {
//if identical
mergedHtml.append(oldString);
}

} catch ( Exception ex ) {
if ( log.isErrorEnabled() ) {
log.error("Cannot merge html cause" + ex.getLocalizedMessage(), ex);
}
} finally {
try {
oldReader.close();
newReader.close();
} catch ( Exception ex2 ) {
//do nothing
}
}

return mergedHtml.toString();
}




/**
* Returns offset of start of line
*
* @param linenumber
* @param buffer
* @return offset of the start of the line or 0 is the first is the first line
*/
protected static int getOffsetSOL(int linenumber, String buffer) {
if ( linenumber == 0 ) {
return 0;
} else {
int counter = 0;
int offset = -1;
int tmp = -1;
while ( counter < linenumber ) {
offset++;
counter++;
tmp = buffer.indexOf('\n', offset);
if ( tmp == -1 ) {
return buffer.length();
}
offset = tmp;
}
return offset;
}
}

/**
* Return offset of the end of the line
*
* @param linenumber
* @param buffer
* @return offset
*/
protected static int getOffsetEOL(int linenumber, String buffer) {
int offsetSOL = getOffsetSOL(linenumber, buffer);
int offsetEOL = buffer.indexOf('\n', offsetSOL + 1);
if ( offsetEOL == -1 ) {
return buffer.length();
} else {
return offsetEOL;
}
}
...
}

Open source reader

I am an open source java developper, I read open source java code, I'll share what I liked with you.