Popular Posts
ADD ... THEN ... UNTIL ... data: begin of SERIES, N1 type I value 10, N2 type I value 20, N3 type I value 30, N4 type I value 40, ... Join related table and count rows or sum sql server 2005 count rows: SELECT * FROM Table1 LEFT JOIN     (SELECT Level1ID, COUNT(Level2ID) AS Total FROM Table2 GROUP BY Level1ID) AS... Remove file not in list
Stats
Showing posts with label Memo. Show all posts
Showing posts with label Memo. Show all posts
jQuery.validationEngine
The following attribute's value will be loaded for the relative validation rule:
data-errormessage-value-missing
  • required
  • groupRequired
  • condRequired
data-errormessage-type-mismatch
  • past
  • future
  • dateRange
  • dateTimeRange
data-errormessage-pattern-mismatch
  • creditCard
  • equals
data-errormessage-range-underflow
  • minSize
  • min
  • minCheckbox
data-errormessage-range-overflow
  • maxSize
  • max
  • maxCheckbox
data-errormessage-custom-error
  • custom
  • ajax
  • funcCall
data-errormessage
  • a generic fall-back error message

Validators
  • required : Speaks for itself, fails if the element has no value. This validator can apply to pretty much any kind of input field.
  • groupRequired : At least one of the field of the group must be filled. It needs to be given a group name that is unique across the form.
  • condRequired : This makes the field required, but only if any of the referred fields has a value.
  • custom[regex_name] : Validates the element's value to a predefined list of regular expressions.
  • custom[function_name] : Validates the element's value to a predefined function included in the language file (compared to funcCall that can be anywhere in your application),
  • funcCall[methodName] : Validates a field using a third party function call. If a validation error occurs, the function must return an error message that will automatically show in the error prompt.
  • ajax[selector] : Delegates the validation to a server URL using an asynchronous Ajax request. The selector is used to identify a block of properties in the translation file, take the following for example.
  • equals[field.id] : Checks if the current field's value equals the value of the specified field.
  • min[float] : Validates when the field's value is less than, or equal to, the given parameter.
  • max[float] : Validates when the field's value is more than, or equal to, the given parameter.
  • minSize[integer] : Validates if the element content size (in characters) is more than, or equal to, the given integer. integer <= input.value.length
  • maxSize[integer] : Validates if the element content size (in characters) is less than, or equal to, the given integer. input.value.length <= integer
  • past[NOW, a date or another element's name] : Checks if the element's value (which is implicitly a date) is earlier than the given date. When "NOW" is used as a parameter, the date will be calculate in the browser. When a "#field name" is used ( The '#' is optional ), it will compare the element's value with another element's value within the same form. Note that this may be different from the server date. Dates use the ISO format YYYY-MM-DD
  • future[NOW, a date or another element's name] : Checks if the element's value (which is implicitly a date) is greater than the given date. When "NOW" is used as a parameter, the date will be calculate in the browser. When a "#field name" is used ( The '#' is optional ), it will compare the element's value with another element's value within the same form. Note that this may be different from the server date. Dates use the ISO format YYYY-MM-DD
  • minCheckbox[integer] : Validates when a minimum of integer checkboxes are selected. The validator uses a special naming convention to identify the checkboxes as part of a group.
  • maxCheckbox[integer] : Same as above but limits the maximum number of selected check boxes.
  • creditCard : Validates that a credit card number is at least theoretically valid, according the to the Luhn checksum algorithm, but not whether the specific card number is active with a bank, etc.

Custom Regex
  • phone
  • url
  • email
  • date
  • number
  • integer
  • ipv4
  • onlyNumberSp
  • onlyLetterSp
  • onlyLetterNumber
Custom prompt position
  • data-prompt-position : topLeft, topRight, centerRight, bottomLeft, bottomRight, inline
Ignore validate
IDES 4.7 Installation
  1. 電腦名稱不能使用特殊名稱(bin/etc/var ...)
  2. 網路卡-> File and Printer Sharing for Microsoft Networks ->網路應用程式的資料輸送量最大化
  3. 安裝jdk1.4 (不升級)
  4. 設置JAVA_HOME
  5. 調高虛擬記憶體
  6. 安裝oracle
  7. 清空暫存資料夾 (%USERPROFILE%\Local Settings\Temp, %SystemRoot%\TEMP)
  8. 時間修改為2029年避免過期, 過晚的時間會發生無法安裝
  9. 載入export data時, 會檢查exportXX的data資料夾, 將exportXX以網路磁碟機的方式顯示在根目錄
Statement.executeBatch() always returns an array of value -2
The elements in the array returned by the method executeBatch may be one of the following:
  1. A number greater than or equal to zero -- indicates that the command was processed successfully and is an update count giving the number of rows in the database that were affected by the command's execution
  2. A value of -2 -- indicates that the command was processed successfully but that the number of rows affected is unknown
    If one of the commands in a batch update fails to execute properly, this method throws a BatchUpdateException, and a JDBC driver may or may not continue to process the remaining commands in the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to process commands or never continuing to process commands. If the driver continues processing after a failure, the array returned by the method BatchUpdateException.getUpdateCounts will contain as many elements as there are commands in the batch, and at least one of the elements will be the following:
  3. A value of -3 -- indicates that the command failed to execute successfully and occurs only if a driver continues to process commands after a command fails
reference : executeBatch
Dump MySQL & restore
$ mysqldump -u root -x --all-databases > dump.sql
$ mysqldump -u root データベース名 > dump.sql
$ mysql -u root -p < dump.sql 
$ mysql -u root データベース名 < dump.sql 
jQuery metadata
$(document).ready(function(){
    var data = $("#message").metadata();
    var i; 
    for(i in data){
        $("#message").append("<div>"+i+"="+data[i]+"</div>");
    }
});
<div id="message" class="mess {firstName:'Bruce',lastName:'Tsai'}"></div>
jQuery validate
利用 css (class屬性), 只能處理預設驗證規則(required, email....)
*Account :
*e-mail :
利用 rules 加入驗證規則與自訂錯誤訊息
Cell Phone :
驗證成功與失敗時的處置
Age1 :
Age2 :
新增移除規則
Test email1:
Test email2:
搭配 Matadata 在 class 屬性中設定驗證規則
Number1 :
自訂驗證規則
Number2 :
Social ID :
驗證規則依存性
address :
(function(){
    $("#form01").validate({
        debug: true  // 除錯模式
    });
    
    $("#form02").validate({
        rules: {
            cellphone: {  // form.name
                required: true,
                digits: true,
                minlength: 5
            }
        },
        messages: {
            cellphone: {  // form.name
                required: "請填寫電話!",
                digits: "請填寫電話號碼!",
                minlength: $.format("至少填入 {0} 個數值")  // 對應驗證的參數
            }
        },
        debug: true
    });
    
    $("#form03").validate({
        submitHandler: function(form){
            alert("Age1 value : " + $("#age1").val());
            form.submit();
            //$(form).ajaxSubmit();
        },
        invalidHandler: function(form, validator){
            var errors = validator.numberOfInvalids();
            alert($.format("錯誤數 : {0}", errors));
        }
    });
    
    $("#form04").validate();
    $("#testemail1").rules("add", {required:true});
    
    $("#form05").validate();
    
    // 新增驗證規則, 作法一
    $.validator.methods.lessThanSquare = function(value, element, param){
        // @value 輸入的值
        // @element 驗證的目標元件
        // @param 設定規則時的參數
        return value * value < param;
    };
    // 新增驗證規則, 作法二
    $.validator.addMethod("testSocialId", function(value, element, param){
        return /\w\d{9}/.test(value);
    }, "身份證號驗證錯誤");
    $("#form06").validate({
        rules: {
            number2: {
                required: true,
                digits: true,
                lessThanSquare: 100
            },
            socialid: {
                required: true,
                testSocialId: true
            }
        },
        messages: {
            number2: {
                lessThanSquare: "數值錯誤"
            }
        }
    });
    
    $("#form07").validate({
        rules: {
            address: {
                required: "#requiredaddresscheck:checked"
            }
        }
    });
})();
EL 隱式物件
類別 識別符號 描述
JSP pageContext PageContext 實例對應於目前頁面的處理
作用網域 pageScope 與頁面作用網域屬性的名稱和值相關聯的 Map 類別
requestScope 與請求作用網域屬性的名稱和值相關聯的 Map 類別
sessionScope 與Session作用網域屬性的名稱和值相關聯的 Map 類別
applicationScope 與應用程式作用網域屬性的名稱和值相關聯的 Map 類別
請求參數 param 依名稱儲存請求參數的主要值的 Map 類別
paramValues 將請求參數的所有值作為 String 陣列儲存的 Map 類別
請求標頭 header 依名稱儲存請求標頭主要值的 Map 類別
headerValues 將請求標頭的所有值作為 String 陣列儲存的 Map 類別
Cookie cookie 依名稱儲存請求附帶的 cookie 的 Map 類別
初始化參數 initParam 依名稱儲存 Web 應用程式內容初始化參數的 Map 類別
Conditional comments of IE
<!--[if gte IE 5]>
<marquee scrollAmount=3 direction=up width=200 height=150 style="background-color:lightyellow; border:1px solid black">
<p><img src="http://javascriptkit.com/dot.gif"> Two wrongs don’t make a right. -Cheales<p><img src="http://javascriptkit.com/dot.gif"> A bird in the hand is worth two in the bush. -Heywood <p><img src="http://javascriptkit.com/dot.gif"> The opposite of love is indifference. -Erin<p><img src="http://javascriptkit.com/dot.gif"> All is well that ends well. -Shakespeare
</marquee>
<![endif]-->
reference : http://www.javascriptkit.com/howto/cc2.shtml
Extension method
class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(StringExtension.UrlEncodeMethod("中文"));
        Console.WriteLine("中文".UrlEncode());
        Console.Read();
    }
}


static class StringExtension
{
    public static string UrlEncodeMethod(string s)
    {
        return HttpUtility.UrlEncode(s);
    }

    public static string UrlEncode(this string s)
    {
        return HttpUtility.UrlEncode(s);
    }
}
SVN Version control
Visual SVN
http://www.visualsvn.com/
TortoiseSVN 
http://tortoisesvn.net/
AnkhSVN 
http://ankhsvn.open.collab.net/

AnkhSVN で外部 diff

ツール >> AnkhSVN >> Edit the AnkhSVN configuration

DiffExePath
"C:\Program Files\WinMerge\WinMergeU.exe" -e -x -ub "%base" "%mine"
MergeExePath
"C:\Program Files\TortoiseSVN\bin\TortoiseMerge.exe" /base:"%base" /theirs:"%theirs" /mine:"%mine" /merged:"%merged"
refernect : http://d.hatena.ne.jp/MillyC/20071010/1192006340

backup/restore

從原有的Subversion (svn)備份出來,並還原到新的Subversion Server 上。

備份Subversion 的repository 並將備份檔傳到要還原的機器上。

1. svnadmin dump /path/to/project/ >/tmp/project.dump

2. scp -rp /tmp/project.dump user@192.168.1.1:/tmp/

還原

1. mkdir -p /path/to

2. svnadmin create /path/to/project

3. svnadmin load /path/to/project < /tmp/project.dump

4. chmod own.own /path/to/project -R
Try catch in SQL Server 2005
BEGIN
    BEGIN TRANSACTION 
    BEGIN TRY
        // QUERY HERE
    END TRY
    BEGIN CATCH
        PRINT ERROR_MESSAGE();
        ROLLBACK
    END CATCH
END
.net closure
Thread t = new Thread(() =>
    {
        while (true)
        {
            Console.WriteLine(DateTime.Now);
            Thread.Sleep(1000);
        }
    }
);

t.Start();
reference : http://diditwith.net/2007/02/09/WhatsInAClosure.aspx
Stopwatch
Stopwatch sw = new Stopwatch();
sw.Start();
for (int i = 0; i < 500000; i++)
{
    List<string> list = new List<string>();
}
sw.Stop();
Console.WriteLine(sw.Elapsed);
Console.Read();
Eclipse axis sample
package tw.gov.cp.sample;

import java.util.Scanner;

import org.apache.axis.message.MessageElement;
import org.w3c.dom.Element;

import tw.gov.cp.gsp2.CP2ResponseOfRSResult;
import tw.gov.cp.gsp2.GSP2_RS_Service_01Soap;
import tw.gov.cp.gsp2.GSP2_RS_Service_01SoapProxy;
import tw.gov.cp.gsp2.GSP2_RS_Service_01SoapStub;

public class AxisSample {

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        // Get token1 by user input.
        System.out.print("Enter token1 : ");
        String token1 = scanner.next();
        // Get service id by user input.
        System.out.print("Enter service id : ");
        String serviceId = scanner.next();

        GSP2_RS_Service_01SoapProxy proxy = new GSP2_RS_Service_01SoapProxy();
        // Endpoint is defualt setted as
        // 'http://www.xxx.xxx.tw/GSP2WS/RSMediator01.asmx'.
        // For different endpoint. Use setEndpoint method or constructor to set
        // new WSDL.

        GSP2_RS_Service_01Soap soap = proxy.getGSP2_RS_Service_01Soap();
        GSP2_RS_Service_01SoapStub stub = (GSP2_RS_Service_01SoapStub) soap;
        // Set toke1 and service id to soap header authorization
        stub.setAuthHeader(token1, serviceId);

        // Get result from server.
        CP2ResponseOfRSResult result = proxy.getProfileColumns();
        System.out.printf("returned message : %s%n", result.getMessage());
        System.out.printf("returned code : %d%n", result.getCode());
        System.out.println();

        if (result.getResult() != null) {
            MessageElement[] messages = result.getResult().getProfileCollection().get_any();
            for (MessageElement msg : messages) {
                // key
                Element keyNode = ((MessageElement) msg.getFirstChild()).getAsDOM();
                // value
                Element valueNode = ((MessageElement) msg.getLastChild()).getAsDOM();
                // Print all return value
                System.out.printf("%s = %s%n", keyNode.getTextContent(), valueNode.getTextContent());
            }
        }
    }

}
String to byte array
string to byte array
Encoding.UTF8.GetBytes(str);
byte array to string
Encoding.UTF8.GetString(bytes);