Wednesday, December 19, 2007

An update & my progress in Kiva

Today I received an e-mail from kiva with happy Holidays message. Felt I like I need update my blog about my progress as a small kiva lender. I discovered Kiva in April 2007 via a PBS, tpt, Frontline program. I updated this same blog about this one. I was amazed by the Kiva founder’s sprit, website and the ease of loaning $25 to entrepreneurs around the world. I felt this is the best way to help “poorest of the poor” or "unlucky souls". I felt this is the right thing to do, So I was contributing to kiva whatever left in my savings account. (At the end, I am an immigrant here and working hard for my living.) I used to donate some good $ to few charities but for some reasons I felt this is the best way to make people responsible. { Donation is creating more dependency.} The fact is that I received no interest on my $ loan was immaterial. The important thing was being repaid in most cases. To date, my Kiva loan portfolio contains over 59 loans, including 5 loans that have been repaid completely and then re-loaned & I reached my little goal of loaning 50 entrepreneurs always. Now I am targetting 100 entrepreneurs in the next two years.
Following is my kiva lender page http://www.kiva.org/lender/dhasa

Friday, November 16, 2007

Java DefaultListModel performance issues

Recently I received a big customer escalation on search domain.
Basically end user was searching for enterprise information based on end user input criteria.
In our java rich client, we are showing a simple dialog to select the list of users in the enterprise. This action was consuming 10+ minutes.
Real culprit was UI works fine for simple 100 to 1000 users.
However customer is testing with 10K plus users.
After analyzing the all the code at server side & finally I looked in the client layer.
At client, server data is getting added to DefaultListModel with addElement() in a for loop.
Real culprit is addElement() method.
After seeing the implementation of the above method & its sequence of event calls &
Little bit of browsing the java forums, I found out that we should use the above class for large lists. Yes never use DefaultListModel directly. Still this problem exists in JDK 1.5 version. There are multiple solutions to this problem. Just Google it. You will find many.
I made a quick fix based on some suns forum advice. (Basically it is fast & I am seeing 90% improvement)

Steps:

1) Extend your DefaultListModel as shown below

class FastListModel extends DefaultListModel { private boolean listenersEnabled = true;
public boolean getListenersEnabled() { return listenersEnabled; }
public void setListenersEnabled(boolean enabled) { listenersEnabled = enabled; } public void fireIntervalAdded(Object source, int index0, int index1) { if (getListenersEnabled()) { super.fireIntervalAdded(source, index0, index1); } }
}

2) Add list listener to your list model

ListDataListener listener = new ListDataListener() { public void intervalAdded(ListDataEvent e) { list.ensureIndexIsVisible(e.getIndex1()); } public void intervalRemoved(ListDataEvent e) { } public void contentsChanged(ListDataEvent e) { } }; model.addListDataListener(listener);

3) Turn on & off listener explicitly

model.setListenersEnabled(false);

//add content for(int i = 0; i <>

// now enable the listers

model.setListenersEnabled(true);

Wednesday, October 03, 2007

New Java Runtime methods

If you building complex Java client & eclipse RCP based clients, always use
Java Runtime methods like maxMemory(), freeMemory() totalmemory() etc. to know your application or your module memory usage. It always helps.
Also use availableProcessors () elegantly if you application is spanning too many threads.

Thursday, September 06, 2007

hooray XSLT now part of JDK 1.5

XSLT now part of JDK 1.5 itself.
(Thanks god, we don’t have to download xalan, xerces etc.
& setting big class paths to author style sheets.)

Minus points are Java implementation of xalan sucks badly.
It is working fine for simple transformation use cases &
but failing for the complex cases.

(I will write those test cases in the next post)

Following is the sample Test.java to transform the input xml in to HTML ( or another other output) using java Xalan libs.

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Document;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class Test
{
public static void main(String[] args) throws Exception
{

Source source = new StreamSource(new FileInputStream("C://AE_html.xsl"));

Transformer t = TransformerFactory.newInstance().newTransformer(source);

Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new FileInputStream("c://users.xml"));

System.out.println("Transforming...");
t.transform(new DOMSource(doc),new StreamResult ( new FileOutputStream("C://users.html")) ); }
}


//System.out.println( "doc as text content"+ doc.getTextContent() );
//t.transform(new DOMSource(doc), new StreamResult(System.out));

Thursday, August 30, 2007

MN State Fair pictures continued





We spend lot of time at pet animal section. Both Dhanvi & Saketh enjoyed a lot.
I observed big change in Poultry section. ( i.e. lots of new Rabbits. This change is good.)

Tuesday, August 28, 2007

MN State Fair pictures




Few pictures from flower stand. Compared to last year display, this year flower stand is less attractive. But a good one. I simply love this one. A must watch for me.

Monday, August 27, 2007

State Fair pictures






We went to State Fair over weekend. It became a ritual to visit State Fair every year.
Few picture from the fair. I will post more later.



Monday, June 04, 2007

More online references

Few more alternatives to wikipedia (www.wikipedia.org) I am finding more useful
Scholarpedia
www.scholarpedia.org

Conservapedia
www.conservapedia.org

Citizendium
www.citizendium.org

Wednesday, April 11, 2007

Became a member in kiva

As usual, yesterday, I was watching PBS documentaries.
But following program was really inspiring. (It is a small part in Frontline)

(A Little Goes a Long Way)
Watch it online first.
http://www.pbs.org/frontlineworld/stories/uganda601/

Immediately decided to be a member in kiva.
I believe in the concept (microfinance & direct lending & to the needy.)
I watched many programs on microfinance.
But I never know how to be part of it or Can an individual can join.
www.kava.org helped me to contribute.
At present I am thinking of contributing to the same for another one year.
Started with 6 & my goal is help 50 all the time.
Please read the FAQ etc in the www.kiva.org before jumping.

“It's a new, direct and sustainable way to fight global poverty, and the way I see it, I get a higher return on $25 helping someone build a future than the interest my checking account pays. “


Following is my lender page in kiva.
http://www.kiva.org/lender/dhasa