8/27/2012

Hostgator email can't send to hosted domain

這是個奇怪的症狀, 在 Hostgator 上, 我自己有個發信的 Module, 可以發信給任何 Domain, 唯獨自己 Hosted 的 Domain 不行.

幾經測試, 就是不 work, 最後聯絡 Hostgator Tech Support, 才得到解決.

狀況是這樣的, 當我們在 Hostgator 上 Add Domain 時, 系統會 Default 把 Hosted Domain 加到 Mail Server 中. 即使我們不使用 Hostgator 的 Mail  Server, 但是當我們的發信 module send 給 hosted domain 的 account 時, 就會自己跑到 Local Server 上, 永遠也發布出去.

解決辦法, 就是 Contact Hostgator, 請他們把 domain name 從 Local Mail Server 中移除, 不然永遠沒轍.

8/20/2012

Hostgator Session Timeout 太快的問題

最近在 Hostgator 上碰到個問題, User Login 進去後, 很快就 Session timeout, 被踢出來, 不明其原因. 又加上是 Shared Web Hosting, 根本沒有辦法去改到 IIS 的設定.

有一說是因為 Application Pool 不定時回收, Default 設定是五分鐘, 當 Application Pool 回收時, 會自動把所有的 Session Reset, 所以就 Timeout 掉了.

問題來了, 我又不能去改 IIS 設定, 那該如何處理? 

後來找到一篇文章, 上面提到的方式, 可以解決我的問題 ==> 就是它

他的 Solution 就是去 Web.config 裡面加上一組 machinekey, 就解決了.

這裡有個 machinekey generator, 用它產生 Machine Key 然後貼到 Web.config 中的 <System.web> Section 中, 在 Hostgator 被 Timeout 掉的問題就解決了!


8/15/2012

C# : How to Identify a Nullable Type

在 .Net Coding 中, 我常會用 class destructor 把一些 Resource Release 掉.

因為 .Net 本身有 Garbage Collection 的功能, 所以只要把已經 Allocate Resources 的 Object 指定為 Null 或是 Empty, 原來 Allocate 的 Resources 就變成無主孤兒,  將會被 Garbage Collection 回收.

問題來了, 不是每個 Type 都是 Nullable, 要如何判斷 Nullable, MS 在 MSDN 中提供了方法, 裡面還有些 Trick.

請參考: http://msdn.microsoft.com/en-us/library/ms366789.aspx

Use the following code to determine whether a Type object represents a Nullable type. Remember that this code always returns false if the Type object was returned from a call to GetType, as explained earlier in this topic.
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) {…}

8/08/2012

ProFTPD can not be connected via Filezilla

最近在 Ubuntu Server 上安裝了 proFTPD, 準備給公司 HKG 同事將來可以交換資料, 但是發現一旦用了 FileZilla 的 FTP Client 來連線, 就會出現
Failed to retrieve directory listing.
的錯誤訊息. 而且改用其他的 FTP Client 來連線, 就可以使用, 相當奇怪.

經過網路 Search, 找到 Solution, 在 ProFTPD 的 configure File 中, 加入下列片段即可

<ifmodule mod_facts.c="mod_facts.c">
FactsAdvertise off
</ifmodule>

4/30/2012

How to Forward Your Network Solutions Domain Name to a Free Blog Service

原文件網址: Click here

In order to point your domain name to a free blog service, like Blogger.com or Wordpress.org, you will need to make modifications to your domains Advanced DNS records.

Be sure you have read the instructions provided by your free blogging service. For example, Blogger.com will ask you to utilize a name server called "ghs.google.com".

Network Solutions has always allowed domains to be pointed to IP addresses (A Records) or Host Aliases (CNAME records).  This feature is enhanced by redirecting the "@ none" A Record to the "www" CNAME.    Simply put, we are pointing yourdomain.com to www.yourdomain.com. 

Here's how.
  1. Within Account Manager, select My Domain Names
  2. Select the domain name that you want to manage
  3. In the green box, select Change Where Domain Points
  4. Select Advanced DNS, then Continue
  5. First, edit the A Records by selecting Edit A Records.  For the "@ none" enter the following IP address 205.178.189.129, clear the records for the "www" and "* (All others)", then select Continue 
  6. Second, edit the Host Aliases (CNAME records) by selecting Edit CNAME Records.  Enter "www" in the Alias column.  Leave TTL set to 7200 but on the same line, enter the name servers provided by the blogging service in the Other Host section (for blogger.com, this name server would be ghs.google.com)
Select Continue

4/29/2012

Install JDK/JRE on Ubuntu 12.04

Install JRE: 原文網址

   
     Quick Note:
  1. Open a Terminal sudo apt-get purge openjdk* 
  2. Download update to date JRE from Oracle 
  3. tar -xvf ~/Downloads/jre-7u3-linux-i586.tar.gz sudo mkdir -p /usr/lib/jvm/jre1.7.0 
  4. sudo mv jre1.7.0_03/* /usr/lib/jvm/jre1.7.0/ 
  5. sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0/bin/java 0 
  6. mkdir ~/.mozilla/plugins 
  7. /usr/lib/jvm/jre1.7.0/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

Install JDK: 原文網址

   
     Quick Note:
  1. Open a Terminal
  2. sudo apt-get purge openjdk*
  3. Download update to date JDK from Oracle
  4. tar -xvf ~/Downloads/jdk-7u3-linux-i586.tar.gz
  5. sudo mkdir -p /usr/lib/jvm/jdk1.7.0 
  6. sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
  7. sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1 
  8. sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
  9. mkdir ~/.mozilla/plugins
  10. ln -s /usr/lib/jvm/jre1.7.0/lib/i386/libnpjp2.so ~/.mozilla/plugins/
  11. ln -s /usr/lib/jvm/jre1.7.0/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

How to delete Ubuntu Unity history log?

原文請參考這一篇: http://askubuntu.com/questions/86544/delete-entire-history-of-the-dash

必須用下列指令安裝 activity-log-manager

sudo apt-get install activity-log-manager

一旦安裝完畢之後, 直接執行, 就可以針對 log 的項目加以控管, 並且刪除不必要的 Log 動作.

xdebug 在 Eclipse 不 work 的狀況

長久以來, 自從 Eclipse 換到 3.5 以後, xdebug 一直不能在 PHP 中使用.

今天偶然發現, 把一個設定加在 /etc/php5/conf.d/xdebug.ini 中即可.


zend_extension=/usr/lib/php5/20090626/xdebug.so
zend_debugger.allow_hosts=127.0.0.1, 192.168.9.0/255
zend_debugger.expose_remotely=always
xdebug.remote_enable=1 
;xdebug.remote_host="127.0.0.1"
;xdebug.remote_port=12345
;xdebug.remote_handler="dbgp"
;xdebug.remote_mode="req"
;xdebug.remote_connect_back=1

上面是從 Internet 找人家的檔案來改, 一個個 try 過之後, 發現只要 xdebug.remmote_enable=1, 就可以使用了.

4/11/2012

Get Database Table Field Name

有的時候, DB Table 的 fields 太多, 要慢慢打嫌多, 又怕打錯, 所以從 DB 中抓出來是最保險的. 底下指令可以這個動作,

For MSSQL:

SELECT * FROM information_schema.columns WHERE table_name = 'TableName'; 

For MYSQL:

SHOW [FULL] COLUMNS {FROM | IN} tbl_name [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr]

4/10/2012

Classifieds Ad software - OSClass on Hostgator

朋友公司在找分類廣告軟體, 我找到兩個看起來不錯的, 都是 Open Source.

OSClass : http://osclass.org/

OpenClassifieds : http://open-classifieds.com/

其中 OSClass 已經安裝到 Hostgator 上測試, 看起來蠻 Ok 的.

在安裝到 Hostgator 的過程中, 一開始都有 500 Internal Server Error 出現, 找了半天, 找到原因.

如果有些目錄或檔案設定權限時, Group 或 Others 有 Write 權限的話, Hostgator 的 Server 就會出現 Error.

所以 Download OSClass 下來後, 先把檔案解開, 權限都改成 755, 再 Upload 到 Hostgator 上安裝, 就不會出現 500 Internal Error 了.

4/02/2012

ASP.Net Menu Control work in Chrome

當使用 ASP.net Menu 元件, 在 Chrome 中不 work 時, 要在程式中加入下列這段 Code.


protected void Page_PreInit(object sender, EventArgs e) 
{
             // This is necessary because Safari and Chrome browsers don't display the Menu 

                control correctly.
             // All webpages displaying an ASP.NET menu control must inherit this class.
             if (Request.ServerVariables["

http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
                 Page.ClientTarget = "uplevel"; 
}