Pages

2013年7月19日 星期五

如何在blog顯示code碼


  1. 在範本中修改html檔,在<header>中插入以下程式碼:
  2. <link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" rel="stylesheet" type="text/css"></link>
    <script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript">
    </script>
    
  3. 在範本中修改html檔,在<body>中加入
  4. onload='prettyPrint();' 
    
  5. 在範本中修改html檔中收尋 /* Post 並加入以下CSS的修改檔
  6. .post .code { 
      display: block; /* fixes a strange ie margin bug */
      font-family: Courier New; 
      font-size: 10pt; 
      overflow:auto; 
      background: #f0f0f0 url(http://yourweb_images_home/Code_BG.gif) left top repeat-y;
      border: 1px solid #ccc;
      padding: 10px 10px 10px 21px;
      max-height:200px;
      line-height: 1.2em;
    }
    
  7. 在文章的HTML檔在想顯示程式碼中加入以下標籤
  8. <pre class="prettyprint code">
    你的code碼
    </pre>
    
參考自:文章
不錯的參考資料:HTML Encode 網頁

Packet size 過大

在新增自己的Agent時,想自訂自己的packet 格式
首先要在test.h檔中

struct hdr_test{
 int type;//要加一個變數在這,不要去用到它,這樣packet header 的指標才不會出錯
 
 double send_time;
 char state;
 
 int size_;
        int& size() { return size_; }

 static int offset_;
 inline static int&offset(){return offset_;}
 inline static hdr_test* access(const Packet* p){
  return (hdr_test*)p->access(offset_);
 }
};
當初卡這裡卡超久, 這樣就就可以好好利用自己的packet了
 
 
Blogger Templates