The Answer to Life, the Universe, and Everything

Saturday, September 30, 2006

Already 2nd half!!


Recently my daughter asks me every morning like "Where do we go?" when she is about to leave the house for the kindergarten. I answer "Kindergarten" and she says "Disssnneeland". Then I think about what she said. Ah-humm "Disneyland!".

After several days, I'm forced to make a plan to take them to Disneyland. Now I'm looking for the nice hotel around there in France.

Wednesday, September 27, 2006

At Command for PDP Context

If there is no hotspot around while you are out, it's good to use your mobile as modem to connect to internet via your note PC.

Define PDP Context +CGDCONT
  1. at+CGDCONT= < cid > , <PDP_type>, <APN>, <PDP_addr> ,<d_comp>,<h_comp>

  2. <precedence> a numeric parameter which specifies the precedence class
    <delay> a numeric parameter which specifies the delay class
    <reliability> a numeric parameter which specifies the reliability class. Only values 3, 4 and 5 are currently supported.
    <peak> a numeric parameter which specifies the peak throughput class
    <mean> a numeric parameter which specifies the mean throughput class

  3. at+CGQREQ?

  4. +CGQREQ: <cid>, <precedence>,<delay>, <reliability>, <peak>, <mean>

  5. +CGQREQ=?

  6. +CGQREQ: <PDP_type>, (list of supported <precedence>s), (list of supported <delay>s), (list of supported <reliability>s) , (list of supported <peak>s), (list of supported <mean>s)

      For more info:

[RFC 2616] Transfer Codings

Trouble maker transfer coding:chunked ! Just for ref, putting RFC.

3.6 Transfer Codings

Transfer-coding values are used to indicate an encoding transformation that has been, can be, or may need to be applied to an entity-body in order to ensure "safe transport" through the network. This differs from a content coding in that the transfer-coding is a property of the message, not of the original entity.

transfer-coding = "chunked" | transfer-extension
transfer-extension = token *( ";" parameter )

Parameters are in the form of attribute/value pairs.

parameter = attribute "=" value
attribute = token
value = token | quoted-string

All transfer-coding values are case-insensitive. HTTP/1.1 uses transfer-coding values in the TE header field (section 14.39) and in the Transfer-Encoding header field (section 14.41).

Whenever a transfer-coding is applied to a message-body, the set of transfer-codings MUST include "chunked", unless the message is terminated by closing the connection. When the "chunked" transfer- coding is used, it MUST be the last transfer-coding applied to the message-body. The "chunked" transfer-coding MUST NOT be applied more than once to a message-body. These rules allow the recipient to determine the transfer-length of the message (section 4.4).

Transfer-codings are analogous to the Content-Transfer-Encoding values of MIME [7], which were designed to enable safe transport of binary data over a 7-bit transport service. However, safe transport has a different focus for an 8bit-clean transfer protocol. In HTTP, the only unsafe characteristic of message-bodies is the difficulty in determining the exact body length (section 7.2.2), or the desire to encrypt data over a shared transport.

The Internet Assigned Numbers Authority (IANA) acts as a registry for transfer-coding value tokens. Initially, the registry contains the following tokens: "chunked" (section 3.6.1), "identity" (section 3.6.2), "gzip" (section 3.5), "compress" (section 3.5), and "deflate" (section 3.5).

New transfer-coding value tokens SHOULD be registered in the same way as new content-coding value tokens (section 3.5).

A server which receives an entity-body with a transfer-coding it does not understand SHOULD return 501 (Unimplemented), and close the connection. A server MUST NOT send transfer-codings to an HTTP/1.0 client.

3.6.1 Chunked Transfer Coding

The chunked encoding modifies the body of a message in order to transfer it as a series of chunks, each with its own size indicator, followed by an OPTIONAL trailer containing entity-header fields. This allows dynamically produced content to be transferred along with the information necessary for the recipient to verify that it has received the full message.

Chunked-Body = *chunk

chunk = chunk-size [ chunk-extension ] CRLF
chunk-data CRLF
chunk-size = 1*HEX
last-chunk = 1*("0") [ chunk-extension ] CRLF

chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
chunk-ext-name = token
chunk-ext-val = token | quoted-string
chunk-data = chunk-size(OCTET)
trailer = *(entity-header CRLF)

The chunk-size field is a string of hex digits indicating the size of the chunk. The chunked encoding is ended by any chunk whose size is zero, followed by the trailer, which is terminated by an empty line.

The trailer allows the sender to include additional HTTP header fields at the end of the message. The Trailer header field can be used to indicate which header fields are included in a trailer (see section 14.40).

A server using chunked transfer-coding in a response MUST NOT use the trailer for any header fields unless at least one of the following is true:

a)the request included a TE header field that indicates "trailers" is acceptable in the transfer-coding of the response, as described in section 14.39; or,

b)the server is the origin server for the response, the trailer fields consist entirely of optional metadata, and the recipient could use the message (in a manner acceptable to the origin server) without receiving this metadata. In other words, the origin server is willing to accept the possibility that the trailer fields might be silently discarded along the path to the client.

This requirement prevents an interoperability failure when the message is being received by an HTTP/1.1 (or later) proxy and forwarded to an HTTP/1.0 recipient. It avoids a situation where compliance with the protocol would have necessitated a possibly infinite buffer on the proxy.

An example process for decoding a Chunked-Body is presented in appendix 19.4.6.

All HTTP/1.1 applications MUST be able to receive and decode the "chunked" transfer-coding, and MUST ignore chunk-extension extensions they do not understand.

Tuesday, September 26, 2006

Quick Sort in Java

I developed small application and used sort algorythm. Here is the good performance quick sort Java sample.

public static DTO[] sort(DTO _dto[],int left,int right){
//Quick Sort
int key;
key = _dto[(left+right)/2].getDateValue();
int i=left -1;
int j=right +1;
while(_dto[++i].getDateValue() while(_dto[--j].getDateValue()>key);
DTO t = _dto[i];
_dto[j] =t;

sort(_dto, left, i-1);
sort(_dto, j+1, right);

/*Bubble Sort
for(int i=0;i<_dto.length-1;i++){
for(int j=_dto.length-1;j>i;j--){
DietDTO t=_dto[j];



return _dto;

Tuesday, September 12, 2006

int <=> byte[]

In some occation such as the low level processing in the Java programming, you might need to convert the "int" data into "byte array" and the opposite case as well.

Here is the sample code ( in my case for CLDC1.0 or 1.1 programming).

Converting the int data type into byte array.

* In order to conver the int data type into byte array
* @param value the int value you want to convert
* @return byte array data
public static byte[] getIntBytes(int value) {
byte[] b = new byte[4];
b[0] = (byte) ((value >>> 24) & 0x000000FF);
b[1] = (byte) ((value >>> 16) & 0x000000FF);
b[2] = (byte) ((value >>> 8) & 0x000000FF);
b[3] = (byte) (value & 0x000000FF);
return b;

Converting the byte array into int data type

* In order to convert the byte array into int data type
* @param value the byte array you want to convert
* @return int data
public static int getInt(byte value[]) {
int ret = 0;
ByteArrayInputStream bais = null;
try {
bais = new ByteArrayInputStream(value);
ret = new DataInputStream(bais).readInt();
bais = null;
} catch (Throwable t) {
} finally {
if (bais != null) {

try {
bais = null;
} catch (Throwable t) {
return ret;


Monday, September 11, 2006

Pareto chart

A Pareto chart is a special type of bar chart where the values being plotted are arranged in descending order. It is named for Vilfredo Pareto, and its use in quality assurance was popularized by Joseph M. Juran and Kaoru Ishikawa.
Simple example of a Pareto chart using hypothetical data showing the relative frequency of reasons for arriving late at work.
Simple example of a Pareto chart using hypothetical data showing the relative frequency of reasons for arriving late at work.

The Pareto chart is one of the seven basic tools of quality control, which include the histogram, Pareto chart, check sheet, control chart, cause-and-effect diagram, flowchart, and scatter diagram. See Quality Management Glossary.

Typically the left vertical axis is frequency of occurrence, but it can alternatively represent cost or other important unit of measure. The right vertical axis is the cumulative percentage of the total number of occurrences, total cost, or total of the particular unit of measure. The purpose is to highlight the most important among a (typically large) set of factors. In quality control, the Pareto chart often represents the most common sources of defects, the highest occurring type of defect, or the most frequent reasons for customer complaints, etc.
(Reference WiKipedia)

Cause & Effect Diagrams

The cause & effect diagram is the brainchild of Kaoru Ishikawa, who pioneered quality management processes in the Kawasaki shipyards, and in the process became one of the founding fathers of modern management. The cause and effect diagram is used to explore all the potential or real causes (or inputs) that result in a single effect (or output). Causes are arranged according to their level of importance or detail, resulting in a depiction of relationships and hierarchy of events. This can help you search for root causes, identify areas where there may be problems, and compare the relative importance of different causes.

If the influence level of the factor is quantitatively Pareto chart.

Small Giant Step

This month is her first Debut for social community. Now she goes to British pre-school. So far she really enjoy the time at the kindergarten.

It's a small step but giant step for her future!!

Friday, September 08, 2006

Java :: Leap Year

Yes. I recovered all the photos of memory from the S/W crashed HD. I install picasa2 from google and look around the ones taken for 5 years.

Time flies. Here is the photo 1 year ago @ Italy where the family of my sister in law lives.

Good memories of pizza , mozzarella and flash back ;-)

These days I'm bussy @ work and not many time for the dev @ home. Also looking for the good server host to rent the space for the Ajax server side appli. Anyway I don't have nether time nor money ;-( Need to wait for the next month...

The formula of calculating the leap year is very simple but easy to forget. Just for a note.

* This is the method to check the leap year
* @param year the year you want to check if the leap year
* @return true:leap year false: not the leap year
public static boolean isLeapYear(int year){
boolean result = false;
if ((year % 4 == 0 && year % 100 != 0) (year % 400 == 0)) {
result = true;
return result;

Tuesday, September 05, 2006

Vacation @ Poland

Just before the vacation to Poland, my GNU/Linux PC @ Home crashed because of the mis-configuration of some xorg etc... I bought Acronis Disk Director Suite to recover some of the data stored in the HD. The application was on promotion (25 euro) and very well that I could recover the data of photos for 6 years. ( My wife would kill me if I couldn't get it back ;-0) I immediately made the buckup to DVD which I bought a month ago. Now I know how important it is to make a backup regularlly.

The vacation was so busy that we couldn't really relax at all. Everyday meeting the relatives and friends of my wife. But kids seems to be very happy that the sister in law and her bf played with them a lot. There we did a lot of shopping as well. We spent the amount of 2 month salary.

This is the snapshot @ hotel in Berlin on our way back home.