2011年8月10日 星期三

To decorate java code in google blogger with SyntaxHighlighter

  • Go to SyntaxHighlighter and download ( I used 3.0.83 release )
  • Unzip the file you download and  upload 
               the files(shCore.js、shBrushJava.js) in syntaxhighlighter_3.0.83\scripts               and (shCore.css、shCoreEclipse.css、shThemeEclipse.css) in syntaxhighlighter_3.0.83\styles
              to your web space ( On-line ) or https://sites.google.com/site/yours/

                                             I upload these files to my google site

 




                                              change the template in your blogger




add some html code as below

 
save the setting!

So , now you can decorate your code in blogger !
In editor of blogger , as following
<pre class="brush:java" name="code" >
      java code
</pre >

It is easy to use for html and javaScript and so on as above . See the configuration of SyntaxHighlighter for more advanced feature.









2011年8月8日 星期一

GWT Note 2

Event and Event handler

有四種方式來實作UI介面與事件觸發處理的關係
1.handler獨立成一個class,這樣會多很多class file不好review code和維護。
public class GwtEvents implements EntryPoint {
   ...
   public void onModuleLoad() {
     textfield = new TextBox();
     textfield.addKeyUpHandler(new MyHandler(this));
     ...
   }//end onModuleLoad
}//end class

public class MyHandler implements KeyUpHandler {
   ...
   public void onKeyUp(KeyUpEvent event) {
   ...
   }
}//end class

2.直接實作handler
public class GwtEvents implements EntryPoint, KeyUpHandler {
   ...
   public void onModuleLoad() {
     textfield = new TextBox();
     textfield.addKeyUpHandler(this);
     ...
    }

   public void onKeyUp(KeyUpEvent event) {
   ...
   }

}//end class


3. (Named)Inner class
public class GwtEvents implements EntryPoint { 
   public void onModuleLoad() { 
      textfield = new TextBox(); 
      textfield.addKeyUpHandler(new MyHandler()); 

   private class MyHandler implements KeyUpHandler { 
     public void onKeyUp(KeyUpEvent event) { 
     ... 
    } 

   }//end onModuleLoad 
}//end class 
4.Anonymous inner classes
public class GwtEvents implements EntryPoint { 
   ... 
   public void onModuleLoad() { 
     textfield = new TextBox(); 
     textfield.addKeyUpHandler(new KeyUpHandler() { 
     @Override 
     public void onKeyUp(KeyUpEvent event) { 
      ... 
     } 
    }); 
   }//end onModuleLoad 
}//end class 
請依情況選擇2、3的作法,避免用方法4。

GWT Note 1

今天遇到一個很怪的情況,怎麼加xxx.gwt.xml在已含有*.gwt.xml的project內就是會跑不起來,訊息如下:
[ERROR] [gwtevents1] - Unable to find 'gwtevents1.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
...
[ERROR] [gwtevents4] - Unable to find 'gwtevents4.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

這四個新加入的都出現一樣的錯誤,後來才找到問題:就是不要跑原先存留在eclipse內的執行設定,也就是刪除舊的執行設定 Run => Run Configurations => delete old configuration 或對project按右鍵=>Run As => Web Application

這種問題的解決挺難找的= = ,如果習慣用ant或maven來build,不要仰賴eclipse就不會遇到這種鳥事。

2011年8月5日 星期五

GWT Note

最近開始進入GWT的開發模式,所以一定會有不熟悉的地方,也就容易產生錯誤。
這邊就來把遇到的問題記起來吧!

在eclipse建立一個練習的GWT專案後,想要在這個專案跑一個以上的entry http://www.blogger.com/img/blank.gifpoint,http://www.blogger.com/img/blank.gif所以就會有一個以上的xxx.gwt.xml,那不想讓這兩個module(GWT是定義一個module一個entry point,討論1、2)包到彼此的client code,很簡單的方式就是切不同的path(或說package)

for example :
gwtapp1.gwt.xml
...
<module rename-to='gwtapp1'>
<source path='client/app1'/>
</module>

gwtapp2.gwt.xml
...
<module rename-to='gwtapp2'>
<source path='client/app2'/>
</module>

就是path不同,這樣就不會把gwtapp1的clinet code也被compile成gwtapp2的code了!

注意rename-to的值就是war內的一個目錄專放java to javaScipt的地方,還有就是path是用 / 斜線(slash or forward slash。 \ 反斜線是叫 backslash),我一開始是用"點" 所以會被google plugin的compiler說 "GWT compilation failed" 。= =;;;

2011年7月15日 星期五

Linux 換個power supply開不了機


公司某PC power supply壞了,過幾天換上新的後居然開不了機,
出現mkrootdev: label / not found
mount : error 2 mounting ext3
....
...
Kernel panic - not syncing:Attempted to kill init !
<如圖>

後來是因為CMOS電池也沒電,BIOS恢復default , BIOS沒調正確的硬碟代號,也就是原本是SATA的硬碟變成IDE硬碟,然後進入boot後就啟動失敗。改成有認成sda1就恢復了。OH~

/var 快塞爆了

今天發現server上/var快爆滿了
去查了一下到底是誰
du -s /var/* |sort -rn | head -5
才發現是/var/spool/clientmqueue 內有太多信因為sendmail沒啟動導致一些信沒寄出給root
加上似乎ssh被hacker瘋狂嘗試登入,然後一堆告警的訊息產生並通知給root。
用ls | xargs rm -rf 可以清除裡面龐大數量的檔案。除了這種訊息當然也可以去確保你的crontab的排程是否有加到> /dev/null 2>&1就不會有一些資料進到這個queue目錄內。
最後還是可以做個擋不正當的行為IP的人進入系統。

2011年5月9日 星期一

JSON memo

JSON 就是JavaScript Object Notation的縮寫名稱,是一個通用的資料交換格式。
用它比XML的好處就是快,因為冗餘的東西少(XML太多多餘的tag),encode與decode就變的快,
相對的client and server用的記憶體少,處理資料變快,也就讓資料在傳輸之間需要的頻寬變得少且傳達速度快。

規則:
object是一個無序的name/value pairs,開始於左大括號( { ),結束於右大括號( } ),name與value是以分號( : )做分割,每個name/value pairs是以逗號做區隔( , )。

array是一個有序的values集合,開始於左中括號( [ ),結束於右中括號( ] ),values是以逗號做區隔( , )。

value 可以是包在雙引號( " )內的string,number, 或 true or false or null, or an object or an array

number只可以是10進位與16進位

還有一些內容可以看這或官網

一個討論用什麼工具來處理JSON的LINK

COVID-19 確診經歷紀實

原本以為真的是天選之人,就算先前家裡兩個小孩都確診都逃過了(可能有中獎但無症狀吧),不過就在2023年六月18日破解自認為天選之人的"心態",為什麼可以確認就是這天中獎的呢?因為在前都是居家上班,到人多的室內場所都會戴口罩,就剛好這天傍晚原本只想說要去附近的國...