2011/12/22

Apache2 Server 的啟用/重啟


Apache 常用小知識

Apache 的主要設定檔是 httpd.conf ,其他的設定檔都是被 Include 進來的;
Apache 的首頁目錄以 DocumentRoot 決定,首頁檔案則以 DirectoryIndex 決定;
Apache 可以透過虛擬主機的設定以指定不同主機名稱到不同的 DocumentRoot 下;
Apache 是多執行緒的軟體,可以啟動多個程序來負責 WWW。主要的模組有 prefork 及 worker, 最大可連線的數量以 MaxClients 來決定。
若要正確的讓瀏覽器顯示網頁的編碼格式,最好在網頁上宣告語系,並將 Apache 的設定檔 httpd.conf 內的 AddDefaultCharset 設定值取消;
在 Apache 可瀏覽的目錄權限設定上 (Options 參數),最好將 Indexes拿掉;
透過 AllowOverride 與 .htaccess 可讓使用者在自己管理的目錄下制訂自己的風格;
Apache 本身提供一個 apachectl (RedHat/CentOS) / rcapache (SUSE等) 的 script 讓使用者得以快速管理其 apache 的服務;
HTTP 使用的是明碼傳送,目前 WWW 可利用 SSL 等機制來進行資料加密的傳輸。資料如果比較重要時,務必以 SSL 或者是保護目錄來保護。




Apache2 Server 的啟用/重啟

對於不同的 Linux Distributions,Apache 啟用的方式略有不同,主要有三種(apachectl, httpd, apache2):


1.
Shell>> /usr/local/apache2/bin/apachectl -k start (Red Hat)
2.
Shell>> /usr/local/apache2/bin/httpd -k start (when you don't have apachectl in Red Hat)



3.

Shell>> /etc/init.d/apache2 start (Ubuntu, Debian, SUSE)

apachetcl和httpd的路徑可能因安裝方式而有不同,請注意。但在某些情況下不用輸入路徑。
http://mepopedia.com/?page=146

2011/12/21

取得jQueryUI Tabs的當前tab panel

節選並翻譯自http://stackoverflow.com/questions/300078/jquery-ui-tabs-get-currently-selected-tab-index 雖然該帖子已經有些時日,不過我沒有發現有人提及這個方案: 如果不在Tab的事件(tab events ,http://jqueryui.com/demos/tabs/#events )中,如何取得當前tab ( "selected tab" )--當前選中的tab的下面的顯示內容的panel。我有一個簡單的方式... 


  1. var curTab = $( '.ui-tabs-panel:not(.ui-tabs-hide)' );  

你可以很容易的得到索引號index, 完全正確, 下面是其文檔中提及的方式 


  1. var $tabs = $( '#example' ).tabs();  
  2. var selected = $tabs.tabs( 'option' ,  'selected' );  // => 0  


不過你可以用我說的方式來獲取索引號index 或者其他任何當前panel的屬性.. 

  1. var curTab = $( '.ui-tabs-panel:not(.ui-tabs-hide)' ),  
  2.     curTabIndex = curTab.index(),  
  3.     curTabID = curTab.prop( "id" ),  
  4.     curTabCls = curTab.attr( "class" );  

2011/12/20

被遺忘的 toFixed()

javascript 的 toFixed(n) 可以將數字round up 到小數點後n 個位

var num = 0;

num = new Number(21);
num.toFixed(1) --> 21.0

num = new Number(21.3456);
num.toFixed(0) --> 21
num.toFixed(2) --> 21.35
num.toFixed(4) --> 21.3456

2011/12/14

java replaceAll with $

as $ is one of the symbol used in regular expression
it will fail at replpace all


solution

replace all $ to \\$
String a = "$38 Apple";
a = a.replaceAll("\\$", "\\\\\\$");

replace
String b = "testing testing REPLACE_ME testing testing";
String finalStr= start.replaceAll("REPLACE_ME", a);