Sunday, December 03, 2006

Quake 3 's InvSqrt

float InvSqrt (float x){
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i >> 1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}

Math explanation here (PDF)

Thursday, November 23, 2006

Send File !?!? 沒有困難 ~~~

Ha, I find the simple input is just a PDF file, so to check the programe is correct or not, just remain the output to .bin file..

Source Code Later !!

Sunday, November 12, 2006

Download from You Tube

"View Page Source” and do a text search for

player2.swf?video_id=

For example the internal prolonged video identification code may be:

b4Knsa7kBPE&l=48&t=OEgsToPDskI3D6CVWsTxEa4BzcTHKXc7
&s=E04B5F8107785BA4:8A51374783A7BCE6

Keep in mind that the code between “&t=” and “&s=” may be session-sensitive and changed every time the video is accessed.

To save the video, the URL path format is

http://www.youtube.com/get_video?video_id=prolonged_video_identification_code

Set the range of SQL result

SQL LIMIT

如果在某項查詢結果中,我們想要的僅是其中一部份時,可以使用 LIMIT 來限制資料被讀取的筆數。
例如,找出座號最前面的五位學生姓名:

SELECT realname FROM student ORDER BY num LIMIT 0, 5

在此例中,LIMIT 後方的 0 代表「從第 0 筆資料開始」,5 表示「取出 5 筆資料」。

Monday, October 30, 2006

Here's some code for blurring an image:

float[] kernelData = new float[9];
for (int i = 0; i < kernelData.length; i++)
{
kernelData[i] = 0.15f;
}
ConvolveOp blur = new ConvolveOp(new Kernel(3, 3, kernelData));
BufferedImage blurryImage = new BufferedImage(w, h, w, h,
BufferedImage.TYPE_INT_ARGB);
blurryImage.createGraphics().drawImage(imageToBlur, blur, 0, 2);

Add time stamp to picture using Java

public static void addDate(File inputFile) throws Exception {
String inputFilename = inputFile.getPath();
System.out.println("Starting with '" + inputFilename + "'");
BufferedImage input = ImageIO.read(inputFile);
Graphics2D graphics = (Graphics2D) input.createGraphics();
Date lastModified = new Date(inputFile.lastModified());
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String dateStamp = sdf.format(lastModified);
int fontSize = (int) (0.4 * input.getHeight() / 10.0);
Font font = new Font("Arial", Font.BOLD, fontSize);
graphics.setFont(font);
int height = graphics.getFontMetrics().getHeight();
int width = graphics.getFontMetrics().stringWidth(dateStamp);

BufferedImage dateImage = new BufferedImage(2 * fontSize + width, 2
* fontSize + height, BufferedImage.TYPE_INT_ARGB);
Graphics2D dateGraphics = (Graphics2D) dateImage.getGraphics().create();
dateGraphics.setColor(new Color(0, 0, 0, 0));
dateGraphics.setComposite(AlphaComposite.Src);
dateGraphics.fillRect(0, 0, width, height);

dateGraphics.setComposite(AlphaComposite.SrcOver);
dateGraphics.setFont(font);
dateGraphics.setColor(Color.black);
dateGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
GlyphVector gv = font.createGlyphVector(dateGraphics
.getFontRenderContext(), dateStamp);
// dateGraphics.drawString(dateStamp, fontSize, fontSize);
dateGraphics.translate(fontSize, 2 * fontSize);
for (int i = 0; i < gv.getNumGlyphs(); i++) {
Shape glyph = gv.getGlyphOutline(i);
dateGraphics.setStroke(new BasicStroke(fontSize / 10));
dateGraphics.draw(glyph);
}
float[] kernel = new float[25];
for (int i = 0; i < kernel.length; i++)
kernel[i] = 1.0f / kernel.length;
ConvolveOp cOp = new ConvolveOp(new Kernel(5, 5, kernel));
BufferedImage blurred = cOp.filter(dateImage, null);
dateGraphics.dispose();

int iWidth = input.getWidth();
int iHeight = input.getHeight();
int cHeight = iWidth * 2 / 3;
int dHeight = (iHeight - cHeight) / 2;

int y = (iHeight - dHeight) - blurred.getHeight();
int x = iWidth - blurred.getWidth();

graphics.drawImage(blurred, x - fontSize, y - 2 * fontSize, null);
graphics.setFont(font);
graphics.setColor(Color.white);
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.drawString(dateStamp, x, y);
graphics.dispose();

int lastDotIndex = inputFilename.lastIndexOf('.');
String outputFilename = inputFilename.substring(0, lastDotIndex)
+ ".new" + inputFilename.substring(lastDotIndex);
FileOutputStream out = new FileOutputStream(outputFilename);
/* encodes image as a JPEG data stream */
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(input);
param.setQuality(0.9f, true);
encoder.setJPEGEncodeParam(param);
encoder.encode(input);
System.out.println("Ending with '" + inputFilename + "'");
}

Of course, it's not a pinnacle of Java2D programming, nor was it intended to. Since i don't have any imaging-related java.net project, i'm not intending to polish it to perfection. It even uses classes in the com.sun.image.codec.jpeg package. Hereby it is released to the public domain - feel free to use, reuse and abuse it in any way - but don't come back if your nuclear reactor stops functioning because of this :)

The result is quite OK:

Tuesday, October 24, 2006

Add new Features to Java

Fun :) Very funny :)

A much fair comparsion should be Rudy vs Groovy vs Python vs Perl.

Java should and it should be much complex than Ruby becuz of its strong typing system.

However, some of the Ease of Development(EoD) of Ruby can be absorded by Java, to richer Java's expression prower without damaging the strong typing system.

For example:
'yield return' can save your works from creating a new array to store the results in list.

Direct "regular expression' support like what Javascript does can save works from createing/managing Pattern, Matcher Objects.

Lambda provide better DSL support in Java.

...... etc.

You may(are going to) say: 'Hey !!! we the community don't need them all. Seriously, I dun need them.'

Okay, who asked for GC, Object-Oriented programming support, RTTI, Bytecode and Cross platform support ???

Back to just 3 years back now, I think sun is the one person who support GC. If you read the javalobby and even the Sun's Java REF DB. NOBODY think GC is good, everybody just try to reinforce the 'delete' key into the language.

Now, I think 99% of us agreed that GC is a must.
(hey, u disagree !!! Why?? I'm Sorry, I forget that C programmers do read javalobby :)

We're lucky that we get some smart folks to do the R&D for us. Sometime even all of us think that something go wrong, maybe its bucz (we're)||(the things) is wrong.

I'm not telling you that the community is making the wrong decisions to any change in java language( I agree that the current generic implementation sucks). Spring, iBat, Tomcat...etc from the java community are the masterpiece. But sometime people object to the new language changes just bcuz:

I dun understand it
I dun like it BUCZ I dun learned it b4
I dun use it I dunno the advantage of it
I just simple dislike changes
I have a good reason blah blah...

I know many people (of course just surrounding me, U is not the one) hate something just bcuz they dun understand it. This is a psychology topic I learned in uni:
If someone put a unopenable, sealed, opaque large box in your house with no good reason and order you to not open it. At the beginning u should be curious about it. But later on experts found out two very funny results:

1) treat it as normal, the box is here just like it should be.

2) lock/hidden/throw/remove/return the box. Someone even called the police. Why? bcuz people afraid the stuffs inside the box. if the box is similar to a human size 50% people think a dead body inside. if the size is similar to the 21" TV 30% of people afraid that it is dirty $$ ....so on.

Now, the reaction of the java community is similar. Why add closure????? it is damager??? why ??? I dunno why.....

Well, dun start a flame war that Java shouldn't add XXXXX. This is not related to this topic.

What I want to say is the main purpose of comparing Java and Rudy is to show that java is bad or show that xxx features from ruby should be added to java bucz java is weak in this use case.

I PERDICT:

I THINK ALL RUBY FEATURES WILL BE ADDED TO JAVA SOON OR LATER.

u: omg/suck/shit, I want clear and simple java only, dun change java into ruby.

Hey, hold one. U misunderstand me. I means JRuby == power of ruby + power of java

What !?!? It doesn't look like Java.

Then look for Groovy == ruby power + Java syntax

What ?!?!?! You just want part of the ruby in java.
Please move to other post that talk about adding new features like closure .... etc.

It is meaningless to compare the color and size of an apple and orange.
Go and make something like Rudy vs Perl --- Why Perl sucks? Or C# vs Java why people always think C# is easier? Or Java vs VB.Net why Java can’t replace VB for the past 10 ten is much educational and meaningful that Java vs Ruby – Why Strong typed language always look sucks in front of dynamic typed language.

Friday, September 22, 2006

如何用google檢索密碼

實際上用google檢索密碼非常的容易,就像一個朋友曾經講的,設定檢索關鍵詞非常重要,我的經驗有以下幾點,與大家交流:

1 任何想查的+password(注意 +號不打),而且PASSWORD在西文中都是相同的,不會漏檢,不像username有很多詞能夠替代,比如userID,userlogin等等。
2 在查到初步結果後,用google的高級檢索,具體設定每頁的檢索結果,然後用IE頁面上的編輯→查找→「PASSWORD」,可以大大提高檢索效率。
3 最關鍵的是主題詞設定,這裡還是強調不要僅僅用刊物名+password查,會漏掉很多寶貝。用「medicine journal password」,「medicine databases password」,「health journal/databases password」,「medical e-journal password」,「medicine e-resourse password」或者直接用「Ovid journal password 」「proquest password」「ebsco password」等等來查。
4上述方法就是高手常用的一般方法,有的朋友還用別人找到的密碼反查,也有很好的效果,這種竅門應該值得提倡。
5 實際上如此檢索仍有漏洞,因為西方文獻檢索的書目編排與中文不同,很多我們認為天經地義屬於醫學的類目不在「medicine」下,因此造成漏檢,比如護 理、精神病以及生物學往往自成體系,與「medicine」並列,因此除了上述檢索式外,還應該用「. ..... password」查,這裡仍然賣個關子,實際上聰明人已經知道該怎樣去做了.
6 當然還有其他更絕的方法,留待以後再講吧.

首先聲明,這只是我自己的經驗,不一定適合大家。
找期刊或數據庫密碼,當然www.google.com,就用「期刊名(數據庫) +password」就可以了,通常username有很多形式,比如「username」「useraccount」「useer ID」等等,只有password不變,因此上述方法就可以了。注意在google頁面上進入高級檢索,對上述檢索式進一步修訂,通常google只分頁 顯示800個條目,這已經夠你找的了,一般每次你用不同的檢索式都會有驚喜。
上述方法能夠很快使你成為中級戰友的,而且越來越不用求人。我想這是很多中級戰友的共同體會,這也是我為什麼討厭有的新手一進來就嚷嚷要密碼,自己沒有試過最好試完以後再說。
當學會這種方法以後,實際上你會越來越迷上找密碼,有些朋友公佈的密碼和另一些人重複就不足為奇了。
至於用代理服務器甚至hecker軟件,並不足取,也沒必要,但代理服務器的好處是一旦擁有,別無所求,可以一勞永逸的「吃飽吃好」,再無密碼失效的煩惱。

繼續我們之前的話題:
1 千萬重視在檢索密碼時的某些PDF格式文件,常常有驚人的發現,我有兩個密碼就是通過這種方法查到的,趕緊下載閱讀PDF閱讀軟件吧。
2 很多朋友在查密碼的時候會發現非英語國家的圖書館密碼,這就是目前的現狀——歐洲國家的文明與科學開化程度決定的。因此如果你進入到一個非英語的圖書館, 要學會用當時頁面某些詞作為關鍵詞回到GOOGLE檢索,會有發現的,舉例說明MEDICINE在德文 或丹麥語中為「MEDIZINE」。
3 強調對檢到的網頁不要輕言無效,由於GOOGLE的時效性,某些頁面已經被調整了,因此如果高度懷疑會有密碼的話,一定要勤於研究。這也是為什麼我不願意隨便公開密碼,或痛恨隨便洩露密碼的原因,因為這是艱苦搜索換來得。
4 說來說去,檢索密碼的關鍵在於檢索詞,目前的引擎技術或搜索引擎沒有大的區別,就我的經驗來看,GOOGLE是首選,因為其頁面明確標明PASSWORD,易於快速尋找,不像某些引擎。

通過檢索發現國外的密碼公佈在94~2001上半年是比較多的,前期連數據庫都有,後期以個別期刊的密碼為主,也就是說數據庫的管理越來越嚴,入口限制的很厲害,看來未來的發展應該是以期刊入口為主了。這方面還是應該有所準備的好。
台灣/南韓的密碼好像很容易得到,真正好用的也不少,但我以前比較輕視台灣/南韓,這一點,FRIEND88作的非常好,向他祝賀!

大家請看以下內容(來http://libinfo.uark.edu/eresources/eresources.asp )就知道以前我所說的不虛,與醫學有關的都在Science & Technology 大條目下,又細分為:
Agriculture & Food | Biology | Botany | Chemistry | Computer Science | Engineering | Environmental Dynamics | Geology | Kinesiology | Mathematics | Medicine | Nursing | Physics | Psychology | Statistics | Zoology。
因此如果僅以medicine檢索,就會漏掉不少很有價值的信息,特別是漏掉的專業的,損失慘重也。

我曾用過的密碼檢索詞
medicine journal ID pw
chemWEB.COM PASSWORD
Virtuelle Bibliothek PASSWORD
「Online Full Text Resources password」
「health sciences library password 」
「OvidLWW password」
「medizin bibliothek password」
「medizin Volltext password」
「medizin literatur password」
「health ejournals password 」
「medizin elektronik password」
Medizin Bibliothek Datenbank Benutzername Kennwort
medicina BIBLIOTECA password
médecine PéRIODIQUES éLECTRONIQUES password
health ejournals password
American Journal of Medicine OnLine FULL TEXT Journals username password
medicine journal fulltext username
大家如果有興趣可參考我以前的貼子,自設關鍵詞,在GOOGLE上檢索,慢慢的就明白原來如此簡單、有趣...艱苦、吐血...

A GOOD NETSITE
http://www.tcd.ie/Library/People/Mark.Walsh/JournalA.html
http://210.119.137.155/journal/journal_main_06.html
http://www.galaxyofhealth.com/journals.html
http://www.hamdenlibrary.org/reference.html

和多朋友都知道「medicine journal username password」....或者進一步擴充上述檢索詞,能夠找到很多有價值的地址。
實際上有一種竅門,可以減少工作量:
既然我們在找全文雜誌密碼,那麼有全文網址的地方一定會登載一些醫學界經典雜誌,比如新英格蘭、自然等雜誌的密碼和用戶名,我們只要用一本經典雜誌名+username password就能事半功倍,例如:
username password "American Heart Journal"
就能大有收穫,如果再對上述檢索式修飾一下,比如:
username password "American Heart Journal" site:ac.jp
就將檢索範圍限制在日本的大學中(建議少用ac,直接用site:jp就行)

tips:
1. 注意,日本和韓國圖書館多用「userid password」或「USERID PWD」,這一點要注意。
2. 上面提到的檢索式中,那個「經典雜誌」的選擇很重要,不要用自然或新英格蘭醫學,要用美國心臟雜誌、美國婦產科雜誌...你選擇什麼雜誌與你的檢索收穫成正比,如果幸運的話,能夠有驚人發現,包括ovid以及目前肯定沒有被公開的全文密碼站點!!!
3. 上述檢索式還能夠對時間進行限制,更減少工作量。
4. 雜誌名一定要用雙引號!

http://www.bcrp.pcarp.usp.br/recursos_onlineB-D.htm
www.unicaen.fr/unicaen/service/scd/periodiques-integral.htm
http://www.acta.nl/page_nl.asp?pid=26

http://lib.ghil.com/ej/c.htm 站內有很多雜誌,而且鏈接也作的非常精美!值得推薦,但是這些都掩飾不住其中的奧妙:
凡是雜誌倩影旁邊有綠色筆記本樣標記,就代表「fulltext」,將鼠標放在該雜誌上,就會顯示出雜誌的用戶名與密碼!試一試吧!

www.lib.nctu.edu.tw/n_service/joulist.htm
http://216.239.33.100/search?q=c ... =zh-CN&ie=UTF-8
http://goserv.iis.sinica.edu.tw/LIB/USERS/sevena.html

目前經過驗證,最簡單有效的密碼檢索式應該是:
"medicine journal password OR pw OR pwd "american heart journal" -telnet -forget -forgot -required"
說明:以上檢索在GOOGLE中進行
1. 檢索目的在於查找能夠提供絕大多數醫學雜誌的username password的網頁,通常醫學核心雜誌沒有不是帶有"醫學雜誌"稱謂的,故選擇american 和journal.
2. "password OR pw OR pwd" 在於password是password的衍生(當然還有一兩個,這裡保密),絕大多數不會超過這三個詞,不像username 有user name\user login\userlogin\accunt\nickname\userid\user ID...等等衍生.不利於精檢.
3. "American Heart Journal"則仁者見仁,智者見智,也可以選其他最知名雜誌名稱,大大提高檢出率,並顯著減少工作量.
4 -TELNET 代表刪去帶有telnet的頁面,因為很多醫學站點提供的telnet根本永不上,常常與期刊雜誌混淆.其他刪減原因自明.
5. 當然你還可以增刪,包括限定時間,國家,語言,或加入語法

Wednesday, August 30, 2006

Map

http://www.cmcgov.com/ESRI/mapobjects.htm

http://extranet.mapinfo.com/products/Overview.cfm?productid=1900&productcategoryid=1,2,3]

MapExtreme

downLoad mapxtremejava.key from internet.
then put "mapxtremejava.key" into these directionaies:
C:\Program Files\MapInfo\MapXtreme-4.7.1\lib\server
C:\Program Files\MapInfo\MapXtreme-4.7.1\Tomcat-4.1\webapps\mapxtreme471\WEB-INF\classes

Monday, July 03, 2006

如何使用 Sysprep 工具將成功的 Windows XP 部署作業自動化

http://support.microsoft.com/?scid=kb;zh-tw;302577

Sysprep 參數

您可以將下列選用參數與 Windows XP 中的 Sysprep 命令搭配使用:
-activated - 不要重設 Windows 產品啟用的寬限期。只有當您已經在原廠啟用 Windows 安裝,才能使用此參數。

重要 您用來啟用 Windows 安裝的產品金鑰,必須和貼在該部特定電腦的真品證明書貼紙上的產品金鑰相符合。
-audit - 將電腦重新啟動至「原廠」模式,不需要產生新的安全識別碼 (SID),也不需要處理 Winbom.ini 檔案 [OEMRunOnce] 區段中的任何項目。只有當電腦已經處於「原廠」模式時,才能使用此命令列參數。
-bmsd - 將所有可用的大型存放裝置填入 [SysprepMassStorage] 區段中。
-clean - 清除 Sysprep.inf 檔案中 [SysprepMassStorage] 區段所使用的重要裝置資料庫。
-factory - 在啟用網路的狀態下重新開機,不要顯示「Windows 歡迎畫面」或迷你安裝程式。如果要更新驅動程式、執行隨插即用列舉、安裝程式、進行測試、用客戶資料來設定電腦,或是想要在工廠環境中變更其他設定,此參數會很有用。對於那些使用磁碟映像 (或複製) 軟體的公司來說,「原廠」模式可以減少所需的映像數目。

當您在「原廠」模式中完成所有工作之後,請使用 -reseal 參數來執行 Sysprep.exe 檔案,以準備將電腦交給使用者。
-forceshutdown - 在 Sysprep.exe 檔案完成之後關閉電腦。

注意 如果電腦具有 ACPI BIOS,但是無法依照 Sysprep.exe 檔案的預設方式正常關機,就可以使用此參數。
-mini - 設定 Microsoft Windows XP Professional 使用迷你安裝程式,而不是使用「Windows 歡迎畫面」。此參數對 Microsoft Windows XP Home Edition 沒有作用,首次執行 Microsoft Windows XP Home Edition 時一定是出現「Windows 歡迎畫面」。

請注意,如果您計畫要使用 Sysprep.inf 檔案將迷你安裝程式自動化,必須使用 -mini 參數來執行 Sysprep 工具,或是按一下以選取 GUI 介面中的 [迷你安裝程式] 核取方塊。根據預設,如果您沒有選擇執行迷你安裝程式,Windows XP Professional 就會執行「Windows 歡迎畫面」。
-noreboot - 不需要重新啟動電腦或準備進行複製,就可以修改登錄項目 (SID、OemDuplicatorString 及其他登錄項目)。此參數主要是用來進行測試,特別是用來查看登錄是否已正確修改。Microsoft 不建議您使用此選項,因為在執行了 Sysprep.exe 檔案之後再來對電腦進行變更,可能會使 Sysprep.exe 檔案所完成的準備工作變成無效。請勿在生產環境中使用此參數。
-nosidgen - 在不產生新的 SID 的情況下執行 Sysprep.exe 檔案。如果您不想要複製您正在執行 Sysprep.exe 檔案的電腦,或者如果您想要預先安裝網域控制站,就必須使用此參數。
-pnp - 在迷你安裝程式執行期間,執行完整的隨插即用裝置列舉與安裝。如果第一次執行時出現的是「Windows 歡迎畫面」,則此命令列參數沒有作用。

只有在您必須偵測並安裝舊式、非隨插即用的裝置時,才使用 -pnp 命令列參數。請不要在只使用隨插即用裝置的電腦上使用 sysprep -pnp 命令列參數。否則,您將會增加第一次執行所需的時間,而且對使用者而言沒有任何額外的好處。

注意 如果無法避免使用未簽署的驅動程式,請將 UpdateInstalledDrivers=yes 參數與 OemPnPDriversPath=DriverSigningPolicy=ignore 一起搭配使用,而不要使用 -pnp 命令列參數,以便能提供更完整的安裝。
-quiet - 執行 Sysprep.exe 檔案,但是不要在螢幕上顯示確認訊息。如果您要將 Sysprep.exe 檔案自動化,此參數會很有用。例如,如果您計畫要在自動安裝程式完成之後立即執行 Sysprep.exe 檔案,請將 sysprep -quiet 命令新增到 Unattend.txt 檔案的 [GuiRunOnce] 區段中。
-reboot - 強迫電腦自動重新開機,然後依照指定方式啟動「Windows 歡迎畫面」、迷你安裝程式或「原廠」模式。如果您想要稽核電腦並確認第一次執行時的運作正確,此參數會很有用。
-reseal - 清除「事件檢視器」記錄,並準備將電腦交給客戶。在下一次重新啟動電腦時,依照設定會啟動「Windows 歡迎畫面」或迷你安裝程式。如果您執行 sysprep -factory 命令,必須將此項安裝的封裝作業當成預先安裝程序中的最後一個步驟。如果要執行這項操作,請執行 sysprep -reseal 命令,或按一下 [Sysprep] 對話方塊中的 [重新封裝] 按鈕。

Thursday, June 15, 2006

Wednesday, June 14, 2006

Monday, May 08, 2006

Google's services

Google Ad Sense https://www.google.com/adsense/

Google AdWords https://adwords.google.com/select

Google分析 http://google.com/analytics/

Google问答 http://answers.google.com/

GoogleBase http://base.google.com/

Google博客搜索 http://blogsearch.google.com/

Google书签 http://www.google.com/bookmarks/

Google图书搜索 http://books.google.com/

Google日历 http://google.com/calendar/

Google目录 http://catalogs.google.com/

Google代码 http://code.google.com/

Google桌面工具条 http://deskbar.google.com/

Google桌面 http://desktop.google.com/

Google网页目录 http://www.google.com/dirhp

Google地球 http://earth.google.com/

Google股票 http://finance.google.com/

Google网上论坛 http://groups.google.com/

Google图片搜索 http://images.google.com/

Google实验室 http://labs.google.com/

Google本地搜索 http://local.google.com/

Google地图 http://maps.google.com/

Google火星 http://www.google.com/mars/

Google移动 http://mobile.google.com/

Google月球 http://moon.google.com/

Google电影 http://www.google.com/movies

Google音乐 http://www.google.com/musicsearch

Google新闻 http://news.google.com/

Google软件包 http://pack.google.com/

Google网页创作 http://pages.google.com/

Google个性化主页 http://www.google.com/ig

Google个性化搜索 http://labs.google.com/personalized

Google阅读器 http://www.google.com/reader

Google学术搜索 http://scholar.google.com/

Google搜索历史 http://www.google.com/searchhistory

Google短信服务 http://www.google.com/sms/

Google提示 http://www.google.com/webhp?complete=1

GoogleTalk http://talk.google.com/

Google工具条 http://toolbar.google.com/

Google旅行计划者 http://www.google.com/transit

Google翻译工具 http://www.google.com/translate_t

Google视频 http://video.google.com

Google网页加速器 http://webaccelerator.google.com

Google Web API http://www.google.com/apis

Google网页搜索 http://www.google.com

Saturday, April 01, 2006

Hong Kong Java User Group

Homepage:
https://hkjug.dev.java.net/

News group:
news://news.3home.net/3comp.programming.java

Friday, February 24, 2006

Masking Console System.in in 1.5 or b4

/*   '\010' <== is the delete ASCII */

import java.io.*;

class EraserThread implements Runnable {
  private boolean stop;

  /**
   *@param The prompt displayed to the user
   */
  public EraserThread(String prompt) {
      System.out.print(prompt);
  }

  /**
   * Begin masking...display asterisks (*)
   */
  public void run () {
     stop = true;
     while (stop) {
        System.out.print("\010*");
  try {
     Thread.currentThread().sleep(1);
        } catch(InterruptedException ie) {
           ie.printStackTrace();
        }
     }
  }

  /**
   * Instruct the thread to stop masking
   */
  public void stopMasking() {
     this.stop = false;
  }
}

Sunday, February 05, 2006

Using Native Application to open file

This may be of interest to you. I have been looking around the web and found on a post that it is possible to open the real Acrobat viewer from Java, although it is O/S specific.
  • For windows :
  • Runtime.getRuntime().exec(new String[]{ "rundll32", "url.dll,FileProtocolHandler", "filename.pdf" });
  • For a mac:
  • Runtime.getRuntime().exec(new String[]{"open", "filename.pdf" });

Wednesday, February 01, 2006

JDK 1.4 Logging

The JDK defines 5 handlers:

* StreamHandler : sends messages to an OutputStream
* ConsoleHandler: sends messages to System.err
* FileHandler: sends messages to a file
* SocketHandler: sends messages to a TCP port
* MemoryHandler: buffers messages in memory

Sun has defined two formatters:

* SimpleFormatter: defines a simple message format containing among other things a timestamp
* XMLFormatter: a message in XML format

A logger with a ConsoleHandler with low priority level:

Logger logger1 = Logger.getLogger("abc.def");
logger1.setLevel(Level.FINEST);
ConsoleHandler c1 = new ConsoleHandler();
c1.setLevel(Level.FINEST);
logger1.addHandler(c1);

A logger with a FileHandler using a home made formatter:

Logger logger2 = Logger.getLogger("abc.def.ghi");
logger2.setLevel(Level.CONFIG);
FileHandler f2 = new FileHandler("%h/mylog.txt", 10000, 2, false);
f2.setFormatter(new MyFormatter());
f2.setLevel(Level.CONFIG);
logger2.addHandler(f2);


Formatters

Every handler must have a formatter defined, and the API has pre-defined a SimpleFormatter and an XMLFormatter which both extend the abstract class Formatter. You may define your own formatter if you like, and it's actually quite simple. You only have to implement the format method. This method receives an instance of the LogRecord class which contains several properties. format returns a string with the data that should be logged. In the next example I've made a formatter that returns the most important properties from the LogRecord:

import java.util.*;
import java.util.logging.*;

public class MyFormatter extends Formatter {
public String format(LogRecord record) {
return
"LogRecord info:\n" +
"Level: " + record.getLevel() + '\n' +
"LoggerName: " + record.getLoggerName() + '\n' +
"Message: " + record.getMessage() + '\n' +
" " + record.getMillis() + '\n' +
"Sequence Number: " + record.getSequenceNumber() + '\n' +
"SourceClassName: " + record.getSourceClassName() + '\n' +
"SourceMethodName: " + record.getSourceMethodName() + '\n' +
"ThreadID: " + record.getThreadID() + '\n';
}
}

Tuesday, January 31, 2006

Key-g-en Site

Key--g-en site:
http://windows.crack-cd.com/Windows_XP_Product_Key_Viewer.html

http://www.theserials.com/serial/serial_flash_8.html

国外一个免费空间,100M,支持Jsp,Asp等动态语言

www.freewebs.com
注意: 刚开始只有50M静态的,第9天就变成动态的.

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;
}


}