Tuesday, December 04, 2007

Word Wrap in Eclipse
Eclipse without wordwrap function sometimes is a nuisance. Find a plugin to solve it.
http://ahtik.com/blog/2006/06/18/first-alpha-of-eclipse-word-wrap-released/

In Eclipse, Help -> Software Updates -> Find and Install -> Search for new features to install -> New Remote Site -> Name: Wordwrap; URL: http://ahtik.com/eclipse-update/, then click OK -> click Finish.

In the right-click manu, choose Virtual Word Wrap. Done!

Thursday, August 23, 2007

A JAXB Problem
JAXBContext jc = JAXBContext.newInstance("edu.iu.cgl.gpir");
Unmarshaller u = jc.createUnmarshaller();
ResourceStatic rs = (ResourceStatic)u.unmarshal(new StreamSource(new StringReader(rslt)));

The above method works fine for GPIR while got an error for QBETS:
Exception in thread "main" java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to edu.ucsb.cs.nws.MachinesType

I debugged and found that the returned value of unmarshal() is JAXBElement, but don't know why it can't be cast to the type I expect.

Found the solution at http://www.velocityreviews.com/forums/t298335-javalangclasscastexception-javaxxmlbindjaxbelement.html

Use
MachinesType machines = (MachinesType)((JAXBElement)u.unmarshal(new StreamSource(new StringReader(rslt)))).getValue();

It works.

Friday, July 20, 2007

JAXB 2.1 and JDK 6
I'm trying to use JAXB to generate corresponding Java class file from the xsd file.
When I ran xjc.sh, an error popped:
"Exception in thread "main" java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/globalhome/yiligong/software/jaxb-ri-20070125/lib/jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/)"

The solutions might be:
1. Use Java endorsed mechanism to override whats in Java platform. See http://java.sun.com/j2se/1.5.0/docs/guide/standards/ for more details on Endorsed Standards Override Mechanism.
2.
Simply copy jaxb-api.jar to /lib/endorsed.
3. Since I have no root privilege, I added "-Djava.endorsed.dirs=/globalhome/yiligong/software/jaxb-ri-20070125/lib" into the last line of xjc.sh, i.e. exec "$JAVA" $XJC_OPTS -Djava.endorsed.dirs=/globalhome/yiligong/software/jaxb-ri-20070125/lib -jar "$JAXB_HOME/lib/jaxb-xjc.jar" "$@".

A JAXB 2.1 tutorial:
http://www.javaworld.com/javaworld/jw-06-2006/jw-0626-jaxb.html?page=1

Wednesday, July 04, 2007

Total Copy
I was trying to copy a .iso file (6.22G) from one one computer to another.

Found Total Copy online and it worked perfect.
http://ranvik.net/totalcopy/

Thursday, June 21, 2007

Thinkpad T60 Memory Installation

http://www-307.ibm.com/pc/support/site.wss/MIGR-62825.html
Easy!

Wednesday, June 20, 2007

TeraGrid Related Stuff
Java-based GSI-SSH Term:
http://grid.ncsa.uiuc.edu/gsi-sshterm/

Single Sign-On on TeraGrid:
http://www.teragrid.org/userinfo/access/index.php

Friday, June 15, 2007

Zebra sent me a video on Youtube. Following it I found this website: http://www.ted.com/. A lot of new and funny stuff inside.

Lili sent me this for my laptop update use: http://www.cpuid.com/cpuz.php.

Thursday, June 14, 2007

gnuplot
Haven't used gnuplot for a long time and reheat it now.
gnuplot 4.2: http://www.gnuplot.info/
a good start tutorial: http://www-128.ibm.com/developerworks/library/l-gnuplot/
Some complicated plots here: http://mos.stanford.edu/papers/Plotting.pdf

Tuesday, June 05, 2007

How to construct a histogram in Excel (without Data Analysis Toolpak)




This example uses the following simple data set (quiz scores for twenty students): 5, 7, 8, 3, 7, 7, 1, 9, 6, 8, 5, 6, 7, 8, 7, 9, 6, 8, 6, 6. To construct a histogram with five bars:
Type numbers in column A, starting at A1. Press ENTER after each number.
In column B, starting at B1 type 2, 4, 6, 8. Note that it is not necessary to write 0 or 10.
Because the histogram will have 5 separate bins, select 5 contiguous cells, for example c3:c7.
Click in the formula bar (the long white bar with the equals sign) and type =frequency(a1:a20, b1:b4). The first array contains the data; the second array contains the bin separators.
Press Control-Shift-Enter simultaneously. You will see an array of 5 numbers.
To draw the graph, you can use the chart wizard: Highlight the number in column C. Click on the chart icon at the top of the page. Choose columns. Click on "next". A bar graph will appear in the window. To make the graph comprehensible to others, add some titles by clicking on "next". For titles, type "histogram of quiz scores". For category, type "quiz score". For value on the y axis, type "quiz score frequency". Click "finish".
The graph that you see now is technically a bar graph, NOT a histogram, because there are spaces between all the bars. Histograms should not have spaces between the bars unless there are categories that have no observations. To rectify this, double click on one of the bars. Another window will appear. Click on "options" and change the gap width to 0. Then click "OK". Now it’s a legitimate histogram.

Tuesday, April 10, 2007

Usage of RDTSC
rdtsc is a VC call and implemented in
assembly. It gets the current ticks of CPU.
1) header files
#include
#pragma intrinsic(__rdtsc)
#include
2) body
LARGE_INTEGER m_largeint;
QueryPerformanceFrequency(&m_largeint); //get the clock frequency of CPU in HZ
unsigned __int64 i = __rdtsc(); // get the current CPU ticks
int c = my_write_packet_to_queuepSendQueue,tLibnet); // the code you want to measure
unsigned __int64 j = __rdtsc(); //
get the current CPU ticks
int m = (j - i)/m_largeint.QuadPart; // the running time in seconds

Sunday, January 28, 2007

What Is Web 2.0
Design Patterns and Business Models for the Next Generation of Software
by Tim O'Reilly
http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html?page=1

Quote:
Core Competencies of Web 2.0 Companies
In exploring the seven principles above, we've highlighted some of the principal features of Web 2.0. Each of the examples we've explored demonstrates one or more of those key principles, but may miss others. Let's close, therefore, by summarizing what we believe to be the core competencies of Web 2.0 companies:
* Services, not packaged software, with cost-effective scalability
* Control over unique, hard-to-recreate data sources that get richer as more people use them
* Trusting users as co-developers
* Harnessing collective intelligence
* Leveraging the long tail through customer self-service
* Software above the level of a single device
* Lightweight user interfaces, development models, AND business models

End of quote