博文

目前显示的是 2013的博文

MVVM & knockout.js

knockout.js helps you simplify dynamic JavaScript UIs using the Model-View-ViewModel (MVVM) pattern. http://learn.knockoutjs.com/#/?tutorial=intro This website is a set of interactive coding exercises to help you quickly learn how to benefit from knockout.js and MVVM.

set & generics in java

        set & generics Set<String> sSet = this.mTables.keySet();         for ( Object obj: sSet ) {           if(obj instanceof Integer ){               int i= (Integer)obj;            }else if(obj instanceof String ){              String s = (String)obj;              System.out.println(s);            }         }

java.util.logging

1 . logging.properties    A -- Default :          My logging.properties file is at C:\Program Files\Java\jdk1.6.0_23\jre\lib.    B -- To read config from a file by using code. InputStream lp = new BufferedInputStream(new FileInputStream( "./config/log.properties")); LogManager .getLogManager(). readConfiguration (lp); lp.close();    C -- To get config from a property. String propString = "myClass.level=FINE"; byte[] propBytes = propString.getBytes(); LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(propBytes)); 1.1 Example:   code :  //   this._log.log(Level.SEVERE, "getConnection:"+DBurl+":"+user, e); Out: SEVERE: getConnection:jdbc:oracle:thin:@127.0.0.1:1521/pdborcl:miis java.sql.SQLRecoverableException: ORA-01033 : ORACLE initialization or shutdown in progress ... ...  Reason : That is the connection to go Oracle12c1.  The DB pdborcl is no...

Minus operator versus 'not exists' for faster SQL query

From: h t t p s : // forums .oracle.com/thread/19816 It really depends on a bunch of factors. A MINUS will do a full table scan on both tables unless there is some criteria in the where clause of both queries that allows an index range scan. A MINUS also requires that both queries have the same number of columns, and that each column has the same data type as the corresponding column in the other query (or one convertible to the same type). A MINUS will return all rows from the first query where there is not an exact match column for column with the second query. A MINUS also requires an implicit sort of both queries NOT EXISTS will read the sub-query once for each row in the outer query. If the correlation field (you are running a correlated sub-query?) is an indexed field, then only an index scan is done. The choice of which construct to use depends on the type of data you want to return, and also the relative sizes of the two tables/queries. If the outer table ...

json and java

Take  a look FastJSON that is  JSON Processor. h t t p : / / c o d e . alibabatech.com/w i k i/display/FastJSON/Overview h t t p s : / / github .com/AlibabaTech/fastjson/ h t t p s : / / github .com/alibaba/fastjson

Runtime.exec() - 01

2. The sub process get inputting message from the main process   // testSubProcess.java import java.io.*; public class testSubProcess{   public static void main(String[] args){     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));     System.out.println("From the main process:"+ br.readLine());   } } //testMainProcess.java import java.io.*; public class testMainProcess{    public static void main(String[] args){       Runtime rt = Runtime.getRuntime();       Process p = rt.exec("java testSubProcess");      //ProcessBuilder pb = new ProcessBuilder("java", "testSubProcess");      //Process p = pb.start();       BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));       bw.flush();       bw.close();    } }

Typed Arrays WebGL

Typed Arrays is from WebGL. IE has supported it. The following url is demo http://ie.microsoft.com/testdrive/HTML5/TypedArrays/

Runtime.exec() -00

1.When Runtime.exec() won't From javaworld.com / javaworld/jw-12-2000/jw-1229-traps.html?page = 4, it is a great document. Navigate yourself around pitfalls related to the Runtime.exec() method By Michael C. Daconta, JavaWorld.com, 12/29/00 Listing 4.5 GoodWindowsExec.java import java.util.*; import java.io.*; class StreamGobbler extends Thread { InputStream is; String type; StreamGobbler(InputStream is, String type) { this.is = is; this.type = type; } public void run() { try { InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line=null; while ( (line = br.readLine()) != null) System.out.println(type + ">" + line); } catch (IOException ioe) { ioe.printStackTrace(); } } } public class GoodWindowsExec { p...

javascript & call

1, Test call function of Array var slice = Array.prototype.slice; alert("slice.call(NaN).length:"+slice.call(NaN).length);  //  result : 0 alert("slice.call({0:'foo',length:'10',9:'2'})[0]:"+slice.call({0:'foo',length:'10',9:'2'})[0]); // result : foo alert("slice.call({0:'foo',length:'10',9:'2'})[9]:"+slice.call({0:'foo',length:'10',9:'2'})[9]); // result : 2 alert("slice.call({0:'foo',length:'bar'})[0]:"+slice.call({0:'foo',length:'bar'})[0]); //result : undefined So, function call(arg) , "arg" is Set of name/value pairs, set enclosed by a pair of curly braces {} , "length" is length of array, others are order number of array. 2, Mouse position <script> function mouseMove(ev) {  ev= ev || window.event;   var mousePos = mouseCoords(ev);   //alert(ev.pageX);       document.get...

Tells Internet Explorer to display a webpage in IE10 mode, if possible

1. This example tells Internet Explorer to display a webpage in IE10 mode, if possible. <meta http-equiv="X-UA-Compatible" content="IE=10"> This example tells Internet Explorer to display a webpage in last IE mode or chrome core frame, if possible. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> is better. 2.  <meta name="viewport" content="width=device-width">, this is for mobile.  HTML5 Boilerplate: html5boilerplate.com h t t p s: // github.com / h5bp/html5-boilerplate/blob/v4.0.0/doc/README.md

css & lu li

1. 2.- 3.- 4.- 5.- 6. 7. 8. 9.- 10.- 11.: <style type="text/css"> <!--  for jQuery .li_bg1 { background:#6495ed; } .li_bg2 { background:#b0c4de; } .li_color1{ color: #fff;background:#6495ed;} li:hover{     background:rgb(180,70,120) center no-repeat; } --> <!-- #menu ul{list-style:none;margin:0px;} #menu ul li{float:left} //Let all "li" to be at a line. li {list-style-type:square;}     // :none/disc/circle/square/ demical /lower- alpha /uper-alpha/lower- roman /upper-roman li {list-style-image:url(images/star.png);}// none/url(); li {list-style-position:outside;}//inside/outside li {li-style:disc url(img/a.gif) inside;} //list-style-type/list-style-image/list-style-position --> </style> <script type="text/javascript">           //$("#list1 li:even").addClass("li_bg1");           //$("#list1 li:...

Escape for XML & JSON

/**  * @author Jin  * @version 1.0.0  */ public class XmlTool {     public final static String JSONPARSE="forJSONparse";     public XmlTool() {         super();     }     /**      * Replace the five special characters by five "predefined entities".      * The XML specification defines five "predefined entities" representing special characters,      * and requires that tool honor them.The entities can be explicitly declared in a DTD.      * The table below lists the five XML predefined entities. The "Name" column mentions the entity's name. The "Character" column shows the character.      * <p>      * Name     Character      * quot     "      * amp     &   ...

String to JSON Object using backslash escapes (Encode and Decode)

http://json.org A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes . A character is represented as a single character string. A string is very much like a C or Java string. In ECMA262 version 5 Javascript Object to JSON JSON to Javascript Object JSON.stringify() JSON.parse()  <script type="text/javascript">   var j='{"acct_id":100001,"acct_name":"na \\" me","email":"Jet \' mail"}';   var o=JSON.parse(j);   alert(o.acct_id+o.acct_name+o.email);   var jj='[{"acct_id":100000,"acct_name":"name0","email":"Jemail0"}]';    var oo=[];    oo=JSON.parse(jj);   alert(oo[0].acct_id+oo[0].acct_name+oo[0].email); //------         function getJsonObjLength(jsonObj){             var l=0;for(var i in jsonObj){l++;}return l;         }  ...

JQuery

Basic Syntax of JQuery: $(Selector).action() $: Indicates it is a jQuery. Selector: 3 types of name Id of an element (prefixed by # ). $(“#myButton”) - selects html element with id “ myButton ”. HTML element itself. $(“p”) - selects html paragraphs. CSS class (prefixed by . ( Period )) Etc. $(“.myclass”) - selects html elements which have their class ” myclass ”            //get the parent's the jQuery element.           var tblTmp =window.parent.$('#tt');           var data = window.parent.$.fn.panel.defaults.extractor(data);           var tmp = window.parent.$('<div></div>').html(data); Examples: $(":checkbox, :radio").click( showValues ) ; -for all <input type="checkbox" ...> and all < input type = "radio" ...> $("select").change( showValues ); -...

private variables in javascript

 (function(window){      //private variables     var name = "test";         var pieAGSI = function(){};     // get variable     pieAGSI.prototype.getName = function(){         return name;     };         // update variable     pieAGSI.prototype.setName = function(str){         name = str;     };         window.pieAGSI = pieAGSI;     })(window); // test var test = new pieAGSI(); document.write('<br>test.getName(): ' + test.getName()+"<br>");

Oracle 12c jdbc connect string for PDB

Ref :  h t t p s:// forums.oracle.com/thread/2566804 1 . link string in code # <!--指定连接数据库用的驱动 ojdbc6.jar--> database.driver=oracle.jdbc.OracleDriver #// oracle.jdbc.driver.OracleDriver is deprecated and replaced with oracle.jdbc.OracleDriver. #h t tp://download.oracle.com/otn_hosted_doc/jdeveloper/905/jdbc-javadoc/oracle/jdbc/OracleDriver.html # <!--指定连接数据库的路径--> # for oracle 11g database.url= jdbc:oracle:thin:@localhost:1521:orcl # for oracle 12c1 database.url= jdbc:oracle:thin:@//127.0.0.1:1522/pdborcl or database.url= jdbc:oracle:thin:@127.0.0.1:1522/pdborcl #<!--指定连接数据库的用户名--> database.username=test # <!--指定连接数据库的密码--> database.password=test <!--指定数据库使用的SQL--> hibernate.dialect=org.hibernate.dialect.Oracle9Dialect #org.hibernate.dialect.OracleDialect #Oracle10gDialect # <!--当show_sql属性为true时表示在程序运行时在控制台输出SQL语句,默认为false--> hibernate.show_sql=false oracle.maxConnection=100 oracle.expireTime=2400000 oracle.updateTim...

How to change default error page(status 404 - not found) in GlassFish 3.0.1-3.1.2.2 Community Edition?

Ref: h t t p: / / s tackoverflow . com/questions/3751566/how-to-change-default-error-pagestatus-404-not-found-in-glassfish-3-0-1-comm 1.Create a page 404.htm 2. and save it as 404.htm and put it to your $ { com . sun . aas . instanceRoot }/ docroot / Ex: / usr / share / glassfish3 / glassfish / domains / domain1 / docroot / 3 .Enter the following URL in the Browser. https : //ip_address:4848/web/configuration/virtualServerEdit.jsf?name=server&configName=server-config 4 .Add a new Property for "server" in "Virtual Servers". Name : send - error_1 Value : code = 404 path = $ { com . sun . aas . instanceRoot }/ docroot / 404.htm reason = Resource_not_found Description : 404 Error Page