2011年11月30日 星期三

[E-Mail] Introduce oneself

Dear Mr. Green,

I learned from the newspaper that your company wants to hire an English interpreter. I'm very interested in this job and I would like the opportunity to be interviewed.
To begin, I would like to introduce myself to you. My name is WaHaHa Liu, and I'm twenty-five years old. I graduated from Foreign Languages Department of National Taiwan University in 2008. I have three years' English teaching experience in a middle school. I am good at English, especially spoken English. In addition, I can speak a little Japanese and can talk with foreigners in Japanese. Generally speaking, I believe I am qualified for this job posting.
Enclosed herewith are a copy of my diploma and my resume for your reference.
Your prompt reply would be greatly appreciated.

Sincerely yours,
WaHaHa Liu

2011年11月27日 星期日

[E-Mail] Seeking a Job

Dear Sir,

I'm very excited and delighted over the good news that you are recruiting an administrative assistant. From the enclosed resume, you can see that I once worked in a famous multinational corporation for three years. I am very skilled at dealing with routine office work, and my major in college was office automation systems. So it should be clear that I am qualified for the job.
With respect to salary, my requirement is four thousand dollars one month. I assure you that if appointed, I will do my best to meet or exceed your expectations.
I hope I may be granted an interview, so I can fully explain my qualifications.
Looking forward to hearing from you soon.

Sincerely yours,
Lulala Yea

2011年11月25日 星期五

[E-Mail] Hotel Reservations

Dear Sir or Madam,

Please reserve a single room with a shower and air conditioning from Jan 1st to Jan 5th, under the name of Jack Hsu.
I'd like you to provide a room on the seventh floor, overlooking the whole city, if possible. I am arriving on the afternoon of Jan 1st and leaving on the morning of the Jan 5th.
An early confirmation for this reservation would be much appreciated.

Sincerely yours,
Jack Hsu

2011年11月24日 星期四

[E-Mail] Train Ticket Reservations

Dear Sir or Madam,

I'd like to book a hard seat for the T123 train from A to B on January 21st.
I hope the tickets for T123 haven't been all booked up on that day, but if the tickets have been sold out, please inform me as soon as possible.

I appreciate your early confirmation.
Sincerely yours,
Jack

[E-Mail] Airline Ticket Reservations

Dear Sir or Madam,

I am going to fly from A to B on the earliest flight. Could I book one economy class seat on a flight leaving A on May 12th?
The Agricultural Bank of China has been instructed to pay the fare and booking fee, and I would ask you to submit your invoice directly to them?

I will appreciate your early confirmation.
Sincerely yours,
Brain

2011年11月15日 星期二

[Unix Programming] Zombie

Zombie: Child process terminates without parent's waiting.
As a result, all you have to do is to wait the child process while terminating.


void waitchild() {
  signal( SIGCHLD, waitchild); // re-enable the signal to fit all systems
  while( wait(NULL) <= 0 )
    /*NOTHING*/;
}


int
main (int argc, char **argv)
{
  signal( SIGCHLD, waitchild);
  if (fork() == 0) {
    // child process
  } else {
    // parent
  }
}

Refer:
http://home.educities.edu.tw/shirock/comp/Anti_zombie_process.htm
http://starryalley.twbbs.org/blog/index.php?/archives/683-linux-zombie-process.html

2011年11月13日 星期日

[Google MAP] Address to Google Map

Address -> longitude and latitude -> KML -> Google Map

Address to longitude and latitude:
http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html

KML:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>

<name>Vincent Cheng</name>
<description><![CDATA[test]]></description>
<Style id="style">
<IconStyle>
<Icon>
<href>http://maps.gstatic.com/mapfiles/ms2/micons/blue-dot.png</href>
</Icon>
</IconStyle>
</Style>

<Placemark>
<name>Test1</name>
<description><![CDATA[]]></description>
<styleUrl>#style</styleUrl>
<Point>
<coordinates>120.913872,24.639008,0.000000</coordinates>
</Point>
</Placemark>

<Placemark>
<name>Test2</name>
<description><![CDATA[]]></description>
<styleUrl>#style</styleUrl>
<Point>
<coordinates>120.916405,24.642361,0.000000</coordinates>
</Point>
</Placemark>

</Document>
</kml>

2011年11月8日 星期二

[C] call by value/reference/address

Call by Value, Call by Address(Pointer), C++ includes Call by Reference
http://csie-tw.blogspot.com/2010/03/call-by-valuecall-by-pointercall-by.html

Call by Value:
int main()
{
  int x=1;
  printf("x=%d\n", x);
  foo(x);
  printf("x=%d\n", x);
}
void foo(int x)
{
  x++;
}

result:
1
1


Call by Address/Pointer:
int main()
{
  int x=1;
  printf("x=%d\n", x);
  foo(&x);
  printf("x=%d\n", x);
}
void foo(int *x)
{
  (*x)++;
}

result:
1
2


Call by Reference:(C++)
int main()
{
  int x=1;
  printf("x=%d\n", x);
  foo(x);
  printf("x=%d\n", x);
}
void foo(int &x)
{
  x++;
}

result:
1
2

[C] pointer to function

#include <stdio.h>
#include <stdlib.h>

void func(int);

main(){
      void (*fp)(int);

      fp = func;

      (*fp)(1);
      fp(2);

      exit(EXIT_SUCCESS);
}

void
func(int arg){
      printf("%d\n", arg);
}