Tuesday, January 31, 2006

Get Java Software Logo

For some reason, ur client might have no or old version of Java Virtual Machine installed.
To ensure they have correct JVM installed. Sun now introduced the "Get Java Logo"
After u signed up the http://logos.sun.com/spreadtheword. You will be able to enbed this logo on ur applet pages.
My registion provided me the follow code snippest:

Small Button

GetJava Download Button

88 x 31


<a href="http://java.com/java/download/index.jsp?cid=jdp74840" target="_blank">

<img width="88" height="31" border="0"
style="margin: 8px;" alt="GetJava Download Button" title="GetJava"
src="http://java.com/en/img/everywhere/getjava_sm.gif?cid=jdp74840">

</a>
Medium Button

GetJava Download Button
100 x 43


<a href="http://java.com/java/download/index.jsp?cid=jdp74840" target="_blank">

<img width="100" height="43" border="0" style="margin: 8px;" alt="GetJava Download Button" title="GetJava" src="http://java.com/en/img/everywhere/getjava_med.gif?cid=jdp74840">
</a>

Large Button

GetJava Download Button
170 x 100


<a href="http://java.com/java/download/index.jsp?cid=jdp74840" target="_blank" >

<img width="170" height="100" border="0" style="margin: 8px;" alt="GetJava Download Button" title="GetJava" src="http://java.com/en/img/everywhere/getjava_lg.gif?cid=jdp74840">
</a>

For Your Users Who Don't Have Java Runtime Environment Yet

Content owners can dramatically improve their users' experience by embedding the GetJava button within their applet. Doing so means that, if users do not have the Java Runtime Environment (JRE) installed, they will see the GetJava button, rather than a grey box. Here's the sample applet code with the HTML snippet placed within the <applet> tags.


<applet code=applet.class width=425 height=400>

You have visited a page that contains an applet written with Java
technology. Please install the Java Runtime Environment before
refreshing this page. <br>
<a href="http://java.com/java/download/index.jsp?cid=jdp74840"><img width="88" height="31" border="0" style="margin: 8px;" alt="GetJava Download Button"
title="GetJava" src="http://java.com/en/img/everywhere/getjava_sm.gif?cid=jdp74840"></a>
<br>
</applet>

Tuesday, January 24, 2006

Mustang's HTTP Server

Alan Bateman has kindly provided me with a link to the HTTP server API documentation. This will soon be hooked up in the Mustang docs.

Several times, I've seen Mustang's inclusion of an HTTP server mentioned. A technical article points to bug 6270015, which asks for support of a lightweight HTTP server API. This bug is marked "closed, fixed". Yet, you won't find anything in the Mustang JavaDoc on it. What's the deal? Well, if we read carefully, Mustang will include an HTTP server API, not JSE 6. If we follow David Herrons recommendation, we should therefore forget about this quickly.

However, that API looks like it had some thinking put into it, is documented and itself distinguishes thoroughly between com.sun.* (sort-of presentable?) and sun.* (don't go there?) packages. Here's how you run a simple server:

HttpServer httpServer = HttpServer.create(new InetSocketAddress(8000), 5);
httpServer.createContext("/", new HttpHandler() {
public void handle(final HttpExchange exchange) throws IOException {
Headers requestHeaders = exchange.getRequestHeaders();
exchange.getResponseHeaders().set("Content-Type", "text/plain;charset=utf-8");
exchange.sendResponseHeaders(200, 0);
OutputStream responseBody = exchange.getResponseBody();
PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(responseBody, "UTF-8"));
for (Map.Entry> entry : requestHeaders.entrySet())
printWriter.println(entry.getKey() + ": " + entry.getValue());

printWriter.close();
}
});

// the server will be single-threaded unless you uncomment this line
// httpServer.setExecutor(Executors.newCachedThreadPool());
httpServer.start();

Simple enough. If this thing sur

Friday, January 20, 2006

Samsung Notebook Drivers Downaload

Download Here

Model is NQ20

Bios Pwd:
332334

VMware ser-ial num-ber

详细内容:
4.x
For Windows 6CHHE-F0N4G-88N6Q-4HHLM URWKX-TAXAK-H2N63-4HJJ5 1H8FX-C494F-K04D3-4H5T1 48TM5-M014X-N81F7-4HNTJ 6TH4H-K20DZ-R0HFP-4K4J

For Linux DJX29-QWA2Y-C2062-4K4V5 JUEK5-46K6E-C8N6Q-4HNV0 UU9WM-9YCD7-GA1D2-4HHT0 818Y1-GU8FX-W05D

5.0:
CC06T-E8ZAD-A2H4Z-4PXQ2

Thursday, January 19, 2006

My Applet Shows

Today, I also created a site to store the exercises I prepared for Ka-ho(very professional thru?)
All the source codes and demos can be download on the site ^__^, and the password for the source codes is the first letter of the filename ~_~;;;

http://urwelcome.servehttp.com/


or

http://www.myjavaserver.com/~torotime/

Tuesday, January 17, 2006

Vieta's Formula

Vieta's Formula for Pi
We continue the discussion on approximating Pi by calculating the areas of a circle using inscribed and circumscribed regular polygons. We illustrate Vieta's formula, developed in 1593, the oldest exact result derived for Pi.
The Formula
Vieta's formula expresses as an infinite product of nested square roots.
Here is the implementation:public class Vieta {
public static double rhs(int n) {
double result = 0;
double rhs_1 = 0;
double rhs_2 = 0;
for (int i = 1; i <= n; ++i) {
if (i == 1) {
result = Math.sqrt(0.5 + 0.5 * Math.sqrt(0.5));
rhs_1 = result;
rhs_2 = result;
} else if (i == 2) {
result = rhs_1 * Math.sqrt(0.5 + 0.5 * rhs_1);
rhs_1 = result;
} else {
result = rhs_1 * Math.sqrt(0.5 + 0.5 * rhs_1 / rhs_2);
rhs_2 = rhs_1;
rhs_1 = result;
}
}
return result;
}
}
I also wrote a Applet for calculating PI.
http://www.myjavaserver.com/~torotime/vieta_formula.html
However,once I finished this applet, I have a new ideal that I can write it in javascript for more portable result...
applet sight~~~


Saturday, January 07, 2006

WakeOnLan for Java

import java.io.*;
import java.net.*;

public class WakeOnLan {

public static final int PORT = 9;

public static void main(String[] args) {

if (args.length != 2) {
System.out.println("Usage: java WakeOnLan ");
System.out.println("Example: java WakeOnLan 192.168.0.255 00:0D:61:08:22:4A");
System.out.println("Example: java WakeOnLan 192.168.0.255 00-0D-61-08-22-4A");
System.exit(1);
}

String ipStr = args[0];
String macStr = args[1];

try {
byte[] macBytes = getMacBytes(macStr);
byte[] bytes = new byte[6 + 16 * macBytes.length];
for (int i = 0; i < 6; i++) {
bytes[i] = (byte) 0xff;
}
for (int i = 6; i < bytes.length; i += macBytes.length) {
System.arraycopy(macBytes, 0, bytes, i, macBytes.length);
}

InetAddress address = InetAddress.getByName(ipStr);
DatagramPacket packet = new DatagramPacket(bytes, bytes.length, address, PORT);
DatagramSocket socket = new DatagramSocket();
socket.send(packet);
socket.close();

System.out.println("Wake-on-LAN packet sent.");
}
catch (Exception e) {
System.out.println("Failed to send Wake-on-LAN packet: + e");
System.exit(1);
}

}

private static byte[] getMacBytes(String macStr) throws IllegalArgumentException {
byte[] bytes = new byte[6];
String[] hex = macStr.split("(\\:|\\-)");
if (hex.length != 6) {
throw new IllegalArgumentException("Invalid MAC address.");
}
try {
for (int i = 0; i < 6; i++) {
bytes[i] = (byte) Integer.parseInt(hex[i], 16);
}
}
catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid hex digit in MAC address.");
}
return bytes;
}


}

Tuesday, December 27, 2005

Google Visit

This site can check the geographic location for ur visters

www.gvisit.com

Fill in ur site address

and copy the Script to ur site, e.g.



then u can trackback from the site given from Google. e.g.
http://www.gvisit.com/map.php?sid=aafff6d5240646d304ee6a4bfd9b2d3f

Done !!!

Friday, November 25, 2005

Java Regualr Expression for Alphabet only String

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
   public static void main(String[] args) {
      //[a-zA-Z] means from a to z or A to Z, * means many of none of them
      Pattern p = Pattern.compile("[a-zA-Z]*");
      Matcher m = p.matcher("aadddaaiiiii");
      boolean b = m.matches();
      System.out.println(b);
   }
}

Thursday, November 03, 2005

Javascripts

To add a print button to the HTML just adding the following link to ur page....

print this review

To add a link that return the user to the previous page ...

return Page

Tuesday, November 01, 2005

HKID Formula (HKID Number Check Digit) 香港身份證號碼計算

Click here for the English Version of HKID Formula 



香港身份證號碼有二個英文字母,一個六位數和一個加上括號的檢驗位。

你可用以下方法計算身份證號碼以確定身份證號碼的真確性。
請把身份證號上的英文字母用數字代表,如
空格=36 A = 10 B = 11 C = 12 D = 13 E = 14 F = 15
G = 16 H = 17 I = 18 J = 19 K = 20 L = 21
M = 22 N = 23 O = 24 P = 25 Q = 26 R = 27
S = 28 T = 29 U = 30 V = 31 W = 32 X = 33
Y = 34 Z = 35

方法:
1) 計算比重積和:

    A)如果為單字母開頭,如:E364912(5):
        E364912(5) = (空格)E364912(5)
        36 x 9 + 第一位x8 + 第二位x7 + 第三位x6 + 第四位x5 + 第五位x4 + 第六位x3 + 第七位x2 = 總和

    B)如果為雙字母開頭,如:AB987654(3):
       第一位x9 + 第二位x8 + 第三位x7 + 第四位x6 + 第五位x5 + 第六位x4 + 第七位x3 +第八位x2= 總和

    C)總和除以 11 得到餘數

2)計算檢驗位:
   A)如果餘數為0,檢驗位=0

   B)如果餘數為1,檢驗位=A

   C)如果餘數為2至10 [2—10]:
      檢驗位 = 11-餘數

例子:
身份證號碼:E364912(5)
(註:E 是第一位把它換成 14)

324 + 14x8 + 3x7 + 6x6 + 4x5 + 9x4 + 1x3 + 2x2 = 556

556 / 11 得餘數 6

11 - 6 = 5

所以這身份證號碼正確。

Tuesday, October 18, 2005

Top 10 Programmers Excuses

Source: http://www.cenriqueortiz.com/weblog/General/?permalink=Developers-Top-10-replies-when-code-doesnt-work.html

have fun !!!
Top 10 replies by developers when their programs don't work:
10. 'That's weird...'
9. 'It's never done that before.'
8. 'It worked yesterday.'
7. 'You must have the wrong version.'
6. 'It works, but it hasn't been tested.'
5. 'Somebody must have changed my code.'
4. 'Did you check for a virus?'
3. 'Where were you when the program blew up?'
2. 'Why do you want to do it that way?'

and finally ...

1. 'I thought I fixed that.'

Saturday, September 10, 2005

Remove your site from Search EngineS

Remove your entire website
If you wish to exclude your entire website from Google's index, you can place a file at the root of your server called robots.txt. This is the standard protocol that most web crawlers observe for excluding a web server or directory from an index. More information on robots.txt is available here: http://www.robotstxt.org/wc/norobots.html. Please note that Googlebot does not interpret a 401/403 response ("Unauthorized"/"Forbidden") to a robots.txt fetch as a request not to crawl any pages on the site.
To remove your site from search engines and prevent all robots from crawling it in the future, place the following robots.txt file in your server root:
User-agent: *
Disallow: /
To remove your site from Google only and prevent just Googlebot from crawling your site in the future, place the following robots.txt file in your server root:
User-agent: Googlebot
Disallow: /
Each port must have its own robots.txt file. In particular, if you serve content via both http and https, you'll need a separate robots.txt file for each of these protocols. For example, to allow Googlebot to index all http pages but no https pages, you'd use the robots.txt files below.
For your http protocol (http://yourserver.com/robots.txt):
User-agent: *
Allow: /
For the https protocol (https://yourserver.com/robots.txt): User-agent: *
Disallow: /


Note: If you believe your request is urgent and cannot wait until the next time Google crawls your site, use our automatic URL removal system. In order for this automated process to work, the webmaster must first create and place a robots.txt file on the site in question.
Google will continue to exclude your site or directories from successive crawls if the robots.txt file exists in the web server root. If you do not have access to the root level of your server, you may place a robots.txt file at the same level as the files you want to remove. Doing this and submitting via the automatic URL removal system will cause a temporary, 180 day removal of your site from the Google index, regardless of whether you remove the robots.txt file after processing your request. (Keeping the robots.txt file at the same level would require you to return to the URL removal system every 180 days to reissue the removal.)

Sunday, September 04, 2005

Flash Version of Google

Macromedia employee created a Flash version of Google Maps to demonstrate how much better it would be in Flash.

Not a bad idea.