Tuesday, July 25, 2006

5 PHP Design Patterns

Five common PHP design patterns
http://www-128.ibm.com/developerworks/library/os-php-designptrns/?ca=dnw-725

Tuesday, July 18, 2006

Writing your own newsreader

From:www.indicthreads.com
XML feeds are the way today to keep a tab on what's happening in the blogosphere as well as to know about site updates and new additions. I had heard about two popular open source feature-rich Java APIs to deal with the feeds, ROME and Informa but could never really savor them.

For one of my own sites where I, sort of hand-built the aggregator as Myjavaserevr does not allow deploying external JARs or Taglibs I did not get any chance to play with these APIs. So when I got some opportunity it was imperative that I tried them.

The following is a very elementary example of using the two news aggregation libraries that imitates a newsreader. The examples, as I said, are pretty basic and they would make a hit to the specified Feed URL every time you call the JSPs. The code snippets are not meant to demonstrate good coding practice.

Both the libraries support almost all versions of RSS, RDF and Atom and features such as dynamic discovery of feed format. Feature wise probably Informa has an upper hand (it supports OPML, recognizes the Enclosure element making it suitable to comprehend Podcast feeds and can be configured to use a persistence mechanism built over Hibernate) but what it lacks is availability of documents. There are no primers at the site and the code is very poorly commented making the Javadocs difficult to come to pace quickly. The two Java.net articles that I could, Google have been outdated, as I used the 0.6.5 version of the library.

ROME, on the other hand, has very nice documentation available at its site, complete with code examples. Many desirable features are unfortunately still on the TODO list. For comprehending the "Enclosure" element ROME needs a separate plugin module (that also supports iTunes extensions). While I have not investigated them, there are a number of sub-projects based on both ROME and Informa, for example: there is a JSP Tag library based on Informa. There is a short review of various libraries here but I guess much stuff on Informa is not relevant now since its latest release.

I am not mincing my words when I say that each API has its own strengths, Informa library is pretty bulky but supports OPML while Rome has a wider support for all kind of XML feeds and has a pluggable architecture. The good thing about these APIs is that they pretty much offer you everything that you may want to do with feeds, reading, generating your own, and creating a digest from multiple feeds and so on.

To run these JSPs, needless to say, you would need to download Informa and ROME libraries. I ran these on jakarta-tomcat-5.0.28 / j2sdk1.4.2_06 and the only dependency I was missing was the JDOM jar that ROME needs.

Concurrent Prograaming Good Reference

Concept and Notations in Concurrent Programming By Andrews and Schneider

Monday, July 17, 2006

Saturday, July 15, 2006

Sunday, July 09, 2006

Concept Drift

http://www.bloglines.com/blog/Tilmann?id=6

Concept Drift

http://www.bloglines.com/blog/Tilmann?id=6

On the Business Delegate Pattern

http://www-128.ibm.com/developerworks/java/library/j-ejb1022.html

J2EE pattern langugae


from java.sun.com

Tuesday, July 04, 2006

What is business logic?

The part of an application program that performs the required data processing of the business. It refers to the routines that perform the data entry, update, query and report processing, and more specifically to the processing that takes place behind the scenes rather than the presentation logic required to display the data on the screen (GUI processing). Client applications are made up of a user interface and business logic. Server applications are mostly business logic.

Both client and server applications also require communications links, but the network infrastructure, like the user interface, is not part of the business logic

Design Patterns: Visual

Monday, June 26, 2006

Berkeley DB: Part Three

Message Handler

package db.GettingStarted;
import com.sleepycat.db.Environment;
import com.sleepycat.db.MessageHandler;

public class MyMessageHandler implements MessageHandler
{
// Our constructor does nothing
public MyMessageHandler() {}
public void message(Environment dbenv, String message)
{
// Put your special message handling code here
}
}

Set the databaseconfig to use this messagehandler
package db.GettingStarted;
import com.sleepycat.db.DatabaseConfig;
...
DatabaseConfig myDbConfig = new DatabaseConfig();
MyMessageHandler mmh = new MyMessageHandler();
myDbConfig.setMessageHandler(mmh);

Chimney Bluff State Park

http://www.fotosearch.com/CRT369/15420-01ns/

Visited this on 06/25/06

Friday, June 23, 2006

Berkeley DB:Part Two

1. Code for exception handing

try
{

}
catch (DatabaseException e)
{
}


2. Errno values, if the errno values are greater than zero then a system error occurred. Special error values like the key and the data being searched is not found results in a error withe negative value.

3. Key and Data of records managed by DatabaseEntry class.

DatabaseConfig class allows setting the properties of the database,
package db.GettingStarted;
import com.sleepycat.db.Database;
import com.sleepycat.db.DatabaseConfig;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.DatabaseType;
import java.io.FileNotFoundException;
...
Database myDatabase = null;
try {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
dbConfig.setType(DatabaseType.BTREE);
myDatabase = new Database("sampleDatabase.db",
null,
dbConfig);

if (myDatabase != null)
myDatabase.close();

} catch (DatabaseException dbe) {
// Exception handling goes here.
} catch (FileNotFoundException fnfe) {
// Exception handling goes here
}

Berkeley DB: Part one

Berkely DB concepts
----------------------

1.DB databases contains records
2. A record contains a key and value.
3. key/data of a record , the data cen be complex.
4. DB database similar like a table in a relation
5. DB applications could use more than one DB databases ( more than 1 tables)
6. The DB database containing records have an assoicated access methods to them
a) Btree
b) Hash
c) Queue
7. Typical DB applications will using many DB databases.
8. Retrieving the records = get()
Putting the records = put()
9. If the databases does not support duplicate records , the next time you insert the data records with existing key, this key replaces the old key.

10. In addition to handles, cursors could be used to insert/retrieve data. Cursors could be used to seek to the data
11. DB provides secondary database which serves as an index to the primary database. Cursors are iterators over the records on the database.
12. Btree access method the most popular method to retrieve data.
13. RecNo , logical records numbers as keys.

Arbitrary Data (strings) Btree or Hash
logical records number (integer) Queue or Recno.

14. Small working datasets no difference between RecNo.

Thursday, June 22, 2006

My laptop crash

So what I did not want has finally happened. My laptop crashed yesterday and even though I think I managed to backup some data before that, but now I am in a precarious position.

First I have suse 9.2 and windows on my laptop. And i had a spyware problem with my PC and I tried to remove it with tools in the market. And since I have rebooted nothing shows up on my screen, not even the BIOS screen. I tried to boot from my recovery drive disk in the CD-ROM drive but nothing seems to happen on my computer screen.

I am trying to boot through the SUSE bootable CD and see what happens.

Wednesday, June 21, 2006

Talk with Werner Vogels and Jim Gray in ACM queue

http://www.acmqueue.com/modules.php?name=Content&pa=showpage&pid=388

Saturday, May 13, 2006

Java Caching System

http://java-source.net/open-source/cache-solutions

Friday, May 12, 2006

AWK one liners

Taken from http://www.softpanor....org/Tools/awk.shtml

# Print the length of the longest input line:
awk '{ if (length($0) > max) max = length($0) } END { print max }' data

# Print every line that is longer than 80 characters:
awk 'length($0) > 80' data

# Print the length of the longest line in data:
expand data | awk '{ if (x < length()) x = length() }
END { print "maximum line length is " x }'

# Print seven random numbers from 0 to 100, inclusive:
awk 'BEGIN { for (i = 1; i <= 7; i++) print int(101 * rand()) }

# Print the total number of bytes used by files:
ls -l files | awk '{ x += $5 }
END { print "total bytes: " x }'

# Print the even-numbered lines in the data file:
awk 'NR % 2 == 0' data

# Print first two fields in opposite order:
awk '{ print $2, $1 }' file

# Print lines longer than 72 characters:
awk 'length > 72' file

# Print length of string in 2nd column
awk '{print length($2)}' file

# Add up first column, print sum and average:
{ s += $1 }
END { print "sum is", s, " average is", s/NR }
# Print fields in reverse order:
awk '{ for (i = NF; i > 0; --i) print $i }' file

# Print the last line
awk '{line = $0} END {print line}' file

# Print the total number of lines that contain the word Pat
awk '/Pat/ {nlines = nlines + 1}
END {print nlines}' file

# Print all lines between start/stop pairs:
awk '/start/, /stop/' file

# Print all lines whose first field is different from previous one:
awk '$1 != prev { print; prev = $1 }' file

# Print column 3 if column 1 > column 2:
awk '$1 > $2 {print $3}' file

# Print line if column 3 > column 2:
awk '$3 > $2' file

# Count number of lines where col 3 > col 1
awk '$3 > $1 {print i + "1"; i++}' file

# Print sequence number and then column 1 of file:
awk '{print NR, $1}' file

# Print every line after erasing the 2nd field
awk '{$2 = ""; print}' file

# Print hi 28 times
yes | head -28 | awk '{ print "hi" }'

# Print hi.0010 to hi.0099 (NOTE IRAF USERS!)
yes | head -90 | awk '{printf("hi00%2.0 f \n", NR+9)}'

# Find maximum and minimum values present in column 1
NR == 1 {m=$1 ; p=$1}
$1 >= m {m = $1}
$1 <= p {p = $1}
END { print "Max = " m, " Min = " p }

# Example of using substrings
# substr($2,9,7) picks out characters 9 thru 15 of column 2
{print "imarith", substr($2,1,7) " - " $3, "out."substr($2,5, 3)}
{print "imarith", substr($2,9,7) " - " $3, "out."substr($2,13 ,3)}
{print "imarith", substr($2,17,7) " - " $3, "out."substr($2,21 ,3)}
{print "imarith", substr($2,25,7) " - " $3, "out."substr($2,29 ,3)}

# Single space to Double space
awk '{print ; print ""}' infile > outfile

Data Normalization in Weka

weka.filters.unsupervised.attribute.Normalize

Normalizes all numeric values in the given dataset. The resulting
* values are in [0,1] for the data used to compute the normalization
* intervals.