Popular Posts
Enable SSL connection for Jsoup import org.jsoup.Connection; import org.jsoup.Jsoup; import javax.net.ssl.*; import java.io.IOException; import java.security.KeyManagement... Simple Web snapshot import java.util.Date; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.graphics.GC; import org.e... Tired of Hibernate? Try JDBI in your code JDBI Quick sample ICategoryDAO.java : create a data access interface (implement is not required) package com.prhythm.erotic.task.data....
Stats
runas
RUNAS 使用方法:

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
        /user: program

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
        /smartcard [/user:] program

   /noprofile        指定使用者的設定檔不該載入。
                     這會導致應用程式載入速度更快,
                     但可能引起一些應用程式運作失常。
   /profile          指定應該載入使用者的設定檔。
                     這是預設值。
   /env              使用目前的環境,不用使用者設定的環境。
   /netonly          如果指定的憑證是供遠端存取時才使用。

   /savecred         使用之前由使用者儲存的認證。
                     此選項在 Windows XP Home Edition 上無法使用
                     而且會被略過。
   /smartcard        當智慧卡提供了認證時使用。

   /user              格式如下 USER@DOMAIN 或 DOMAIN\USER
   program         EXE 的命令列。範例如下

範例:
> runas /noprofile /user:mymachine\administrator cmd
> runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"
> runas /env /user:user@domain.microsoft.com "notepad \"my file.txt\""

注意:  只有在提示時,才輸入使用者密碼。
注意:  USER@DOMAIN 與 /netonly 不相容。
注意:  /profile 與 /netonly 不相容。
jQuery : post/get using data() as param object
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Recursive call when post request</title>
<script type="text/javascript" src="jquery-1.5.1.js"></script>
<script type="text/javascript">
    $(function() {
        var count = 0;
        $('input:button').click(function() {
            // identity
            count++;
            var tick = count;
            // post url
            var url = '${contextPath}/';
            // post param
            var param = $(this).data();
            console.log(param);
            $('<div>(' + tick + ') Post to : ' + url + '</div>').appendTo(document.body);
            $.post(url, param, function(data) {
                $('<div style="color:blue;">(' + tick + ') Ajax works successfully.</div>').appendTo(document.body);
            });
        });
    });
</script>
</head>
<body>
<input type="button" value="click to post" data-action="test" data-name="bruce" data-age="31" />
</body>
</html>
ボタンをクリックすると、data()のオブジェクトがハンドルを値を持っているため、postするときにハンドルは再び執行することになる。つまり、クリック事件は繰り返しする。この現象を避けるには、ハンドル/イベントを削除しなければならない。
jQuery validte : regex rule
$.validator.addMethod(
    "regex",
    function(value, element, regexp) {
        var check = false;
        var re = new RegExp(regexp);
        return this.optional(element) || re.test(value);
    },
    "Please check your input."
);
$("textbox").rules("add", { regex: "^[a-zA-Z'.\s]{1,40}$" })
Data URI schema
work.bmp URL: Data URI:
<img src="data:image/bmp;base64,Qk02BAAAAAAAADYAAAAoAAAAEAAAABAAAAABACAAAAAAAAAAAAASCwAAEgsAAAAAAAAAAAAAAAAACwAAACIAAAAtAAAALQAAAC0AAAAtAAAALQAAAC0AAAAtAAAALQAAAC0AAAAtAAAALQAAAC0AAAAiAAAACyFHYZwkTmvyJE5r8iROa/IkTmvyJE5r8iROa/IkTmvyJE5r8iROa/IkTmvyJE5r8iROa/IkTmvyJE5r8iFHYZwmUG3yUY6y/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/1GOsv8mUG3yKFJv8lGOsv9NfqT/TX6k/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/01+pP9RjrL/KFJv8ipVcvJRjrL/TX6k/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/01+pP9NfqT/UY6y/ypVcvItWHXyUY6y/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/01+pP9NfqT/TX6k/1GOsv8tWHXyMFt58lGOsv9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PAAAAPxJREFUeNpiZEAD2X4qIOo/A3bACCKmbroDF2BhwA0Y0fhYDWXsy3fuA9IpyIKfPn1m5ePj/U1IDAjmsPz79y/FzVWK9+8fZAvEQQQHqlpUMWYWRoZdu5+lgAxgeP3iJ8PXL38ZSAHcPMwMIL0sf//+A2v+9OEPA6kApJfp79+/DOQCkF6WF69e8zx/+YosAxgZGXlYBAX4v5jqy/Ji88LxC9fBtJmuOgMzMxOKHJ8AC8Ppi4+/sPz5g9vvlgaaeF0A0sv0h4IwAOmlOBCZQFFBvgHAaAQlBnIBOCF9+f571c4Dl8PIMeDbz7+rQDmOG5rQuUnU/xWIXwIEGADy0nItvNe4lQAAAABJRU5ErkJggg==" />
Data URI schema
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
SqlCommand (Sample)
new SqlCommand() //
.setDebugMode(true)
.setConnection(Connector.get())
.setCommandText("SELECT" +
        "    e.entry_id," +
        "    e.entry_name," +
        "    e.entry_english_name," +
        "    e.entry_description," +
        "    e.entry_sop_path," +
        "    e.entry_cordon," +
        "    e.role_name," +
        "    e.entry_enabled," +
        "    e.group_id," +
        "    e.group_name" +
        " FROM mv_wrk e" +
        " WHERE" +
        "    (&entry_id IS NULL OR UPPER(e.entry_id) LIKE UPPER(&entry_id))" +
        "    AND (&entry_name IS NULL OR UPPER(e.entry_name) LIKE UPPER(&entry_name))" +
        "    AND (&entry_english_name IS NULL OR UPPER(e.entry_english_name) LIKE UPPER(&entry_english_name))" +
        "    AND (&entry_enabled IS NULL OR e.entry_enabled = &entry_enabled)" +
        " ORDER BY e.entry_id ASC")
.addParameter("&entry_id", OracleDataType.VARCHAR2)
.addParameter("&entry_name", OracleDataType.VARCHAR2, null)
.addParameter(new SqlParameter("&entry_english_name", OracleDataType.VARCHAR2))
.addParameter(new SqlParameter("&entry_enabled", OracleDataType.NUMBER).setValue(null))
.setAdapter(new QueryAdapter() {
    @Override
    public void executedQuery(SqlArgument arg) throws Exception {
        ResultSet rs;
        if ((rs = ((QueryArgument) arg).resultset) == null)
            return;

        while (rs.next()) {
            System.err.println(DataMap.fill(rs));
        }
    }
})
.query();
batch
new SqlCommand()
.setDebugMode(true)
.setDebugOut(System.err)
.setConnection(ConnectionUtil.get())
.addCommand("/* 1. &name 2. &aid  3. &time */ INSERT INTO access_log VALUES(&aid, &name, &time)", CommandType.Text, CommandMode.Batch)
.addCommand("SELECT * FROM access_log WHERE rownum < &rows ORDER BY time DESC")
.addParameter("&rows", OracleDataType.INT, 5)
.setAdapter(new QueryListener() {
    @Override
    public boolean executingQuery(SqlArgument arg) throws Exception {
        if (arg.first && arg.mode == CommandMode.Batch)
            for (int i = 0; i < 3; i++) {
                arg.addBatchParameters(
                    new SqlParameter("&name", OracleDataType.VARCHAR2, "bruce"),
                    new SqlParameter("&aid", OracleDataType.VARCHAR2, UUID.randomUUID().toString()),
                    new SqlParameter("&time", OracleDataType.DATE, DateTime.now().toTimestamp())
                );
            }

        return true;
    }

    @Override
    public void executedQuery(SqlArgument arg) throws Exception {
        if (arg.first) {
            UpdateArgument ua = (UpdateArgument) arg;
            System.err.println(Arrays.toString(ua.batchResult));
        } else {
            QueryArgument argument = (QueryArgument) arg;
            if (argument.resultset != null)
                while (argument.resultset.next()) {
                    System.err.println(DataMap.fill(argument.resultset));
                }
        }
    }
})
.query();
Change IP of listener
listener.ora
# listener.ora Network Configuration File: C:\oracle\product\10.1.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oracle\product\10.1.0\db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
      )
    )
  )

Start/stop oracle
REM This batch file is used to start/stop the oracle instance
REM Simply invoke oracle.bat start/stop
cls
@ECHO off
REM ******************************************************************
REM ** Batch file used to stop/start oracle services
REM ******************************************************************

SET _db_=10g_home1
SET _sid_=CCIMES


if(%1)==(start) GOTO START
if(%1)==(stop) GOTO STOP
echo Invalid use. Usage is oracle.bat stop/start
GOTO END


:START
REM ** START the oracle services
echo Starting Oracle Services
REM change the instance/listener names to match what is in your services list
NET START OracleCSService
NET START OracleOraDB%_db_%iSQL*Plus
NET START OracleOraDb%_db_%TNSListener
NET START OracleService%_sid_%
NET START OracleDBConsole%_sid_%
REM NET START OracleJobScheduler%_sid_%
REM NET START "Oracle INNOVATEST VSS Writer Service"
echo Oracle Services Started
GOTO END


:STOP
echo Stopping Oracle Services
REM change the instance/listener names to match what is in your services list
REM NET STOP "Oracle INNOVATEST VSS Writer Service"
REM NET STOP OracleJobScheduler%_sid_%
NET STOP OracleDBConsole%_sid_%
NET STOP OracleOraDb%_db_%TNSListener
NET STOP OracleService%_sid_%
NET STOP OracleOraDB%_db_%iSQL*Plus
NET STOP OracleCSService
echo Oracle Services Stopped
GOTO END


:END
Word break tag : <wbr/> (HTML5)
The HTML <wbr> tag is used defines potential line break point if needed. This stands for Word BReak.

This is used with the <nobr> tag, <wbr> advises the extended browser when it may insert line break in an otherwise nonbreakable sequence of text. Unlike the <br> tag, which always causes line break, even within <nobr>- tagged segment, the <wbr> tag works only when placed inside <nobr>- tagged content segment and causes line break only if the current line has already extended beyond the browser's display window margins.

test:

Words without breaks

ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

Words with breaks

ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
no object DCH for MIME type multipart/mixed
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/related; 
 boundary="----=_Part_0_9042915.1299319807397"
 at javax.activation.ObjectDataContentHandler.writeTo(Unknown Source)
 at javax.activation.DataHandler.writeTo(Unknown Source)
 at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1383)
 at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1743)
 at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:888)
 ... 4 more
There is something wrong with MailCap, javamail can not find a handler for such multipart/mixed part.
And the solution is add mime programmingly:
MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
CommandMap.setDefaultCommandMap(mc);