2015/07/31

Httpsrvr.dll在Apache for Windows的設定

按  HTTPSRVR with Apache 的說明:
1. Install Apache (I will assume default directory structure for 2.0.52).
2. Copy 'httpsrvr.dll' to your /apache2/cgi-bin directory.
3. In httpd.conf, change the 'Options None' (again assuming defaults for 2.0.52) in to 'Options ExecCGI'.
4. AddHandler isapi-isa .dll to your httpd.conf.
5. Restart Apache. 


補充實作的設定段:
#
# "/xampp/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
# Options None

    AllowOverride None
    Options ExecCGI
    Order allow,deny
    Allow from all
 AddHandler isapi-isa .dll






2015/07/27

Delphi字串計數函式

已經忘記是什麼時候遇到需要計算重複字的次數問題
前陣子想到才上Google來找,因為關鍵字仍然不方便搜尋,所以轉錄在這裡。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
uses
  StrUtils;

function Occurrences(const Substring, Text: string): Integer;
var
  offset: Integer;
begin
  result := 0;
  offset := PosEx(Substring, Text, 1);
  while offset <> 0 do
  begin
    inc(result);
    offset := PosEx(Substring, Text, offset + length(Substring));
  end;
end;

資料來源:

2015/07/23

TDataSetProvider 的一個 Bugs

追 VCL Code 才找到問題主因……
procedure TDataPacketWriter.AddIndexDefs(DataSet: TDataSet; const Info: TInfoArray);
...
        { Get the DEFAULT_ORDER }
        if not (poRetainServerOrder in Options) then
          DefIdx := (DataSet as IProviderSupport).PSGetDefaultOrder // EListError: List index out of bounds (-1)
        else
          DefIdx := nil;
...

但裡頭是組合語言,我已經沒辦法了,只能回避囉!

延伸閱讀:

2015/07/21

TByte 和 TByteDynArray 的轉換

TByteDynArray 同等 TByte

意外發現 TBytesStream 這個類別

但發現不能做 TBytesStream.Create(TByteDynArray)
不過卻可以寫成這樣:
TBytesStream.Create(TByte(TByteDynArray))

據說後來有改正這個缺點。

see also:

2015/06/16

Delphi 和 CB 的雲端技術,安全嗎?

在「都加密了,還怕什麼?」這篇有提到關於雲端技術常被探討的安全性議題。

可以知道
  • 只要採用合適的加密法以及自訂的傳輸方式,可以使雲端應用更安全。
  • 不是公開制定的協議,被駭客盯上的可能性機乎為零。

或許以 DataSnap 這種小眾市場上,稍加封裝就可以讓安全性大幅提升。

當然,Borland / EMBT 如果有開後門的話就另當別論了(笑)

2015/06/08

REST DataSnap: Server Methods Lifecycle 的差別之處

REST DataSnap 的 Server methods Lifecycle 有:Session, Invocation, Server 三種選項。


Session:
每個 IP 只會固定配置一個實體,直到 Client 離線後釋放。


Invocation:
每次連線都會配置一個新的實體,到 Client 離線後釋放。


Server:
只有一個實體,給所有 Client 使用,類似 Com-based 的 Threading Model : Apartment




其它的教學連結:
  • Delphi Labs: DataSnap XE - Server Methods Lifecycle         
  • DelphiLabsDataSnapLifecyclePart1        
  • DelphiLabsDataSnapLifecyclePart2