-
Recent Posts
Archives
- July 2016
- June 2016
- May 2016
- March 2016
- January 2016
- November 2015
- October 2015
- August 2015
- July 2015
- June 2015
- May 2015
- April 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- October 2013
- September 2013
- August 2013
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- April 2011
- March 2011
- February 2011
Categories
My Tags
My Profile
Senior Software Engineer At Actuate
Meta
Monthly Archives: April 2014
how to create a responsive website
1. min-width with media query 123456789101112 /* Small screens (default) */ html { font-size: 100%; } /* Medium screens (640px) */ @media (min-width: 40rem) { html { font-size: 112%; } } /* Large screens (1024px) */ @media (min-width: 64rem) { … Continue reading
check if a sequence is a output sequence of a stack or not
assume you have a stack, you have a sequence A[n] : {1,2,3,4,5}, check if sequence B[n] : {5,4,3,2,1} is an output of stack or not. A : 1 2 3 4 5 B : 5 4 3 2 1 … Continue reading
pro js design pattern review 6–singleton and lazy loading
/* General skeleton for a lazy loading singleton, step 3. */ MyNamespace.Singleton = (function() { var uniqueInstance; // Private attribute that holds the single instance. function constructor() { // All of the normal singleton code goes here. … } return … Continue reading
js pro design patterh review 5–prototypal inheritance
var authorClone = clone(Author); alert(authorClone.name); // Linked to the primative Person.name, which is the // string ‘default name’. authorClone.name = ‘new name’; // A new primative is created and added to the // authorClone object itself. alert(authorClone.name); // Now … Continue reading
pro js design pattern review 4–classical inheritance
/* Class Person. */ function Person(name) { this.name = name; } Person.prototype.getName = function() { return this.name; } var reader = new Person(‘John Smith’); reader.getName(); /* Class Author. */ function Author(name, books) { Person.call(this, name); // Call the superclass’ constructor … Continue reading
pro js design pattern 3–static methods and attributes
see the source code : var Book = (function() { // Private static attributes. var numOfBooks = 0; // Private static method. function checkIsbn(isbn) { … } // Return the constructor. return function(newIsbn, newTitle, newAuthor) { // implements Publication // … Continue reading
pro js design pattern review 2–private , privileged and public method
privileged method is defined in the constructor, and it is public. it could access the private variable in the constructor, for each new instance, the privileged method would be copied, so it might has performance or memory leak issue. see … Continue reading
pro js design pattern 1 – interface
/** * usage : var Composite = new Interface(‘Composite’, [‘add’, ‘remove’, ‘getChild’]); */ var Interface = function(name, methods) { if(arguments.length != 2) { throw new Error(“Interface constructor called with ” + arguments.length + “arguments, but expected exactly 2.”); } this.name … Continue reading
pro javascript design pattern review–1.
/** * usage : var Composite = new Interface(‘Composite’, [‘add’, ‘remove’, ‘getChild’]); */ var Interface = function(name, methods) { if(arguments.length != 2) { throw new Error(“Interface constructor called with ” + arguments.length + “arguments, but expected exactly 2.”); } … Continue reading
Posted in Uncategorized
Leave a comment
the core algorithm of k-way merge
the code below is excerpt from an algorithm blog. This code snippet is the core algorithm of k-way merge, 1: while(true) 2: { 3: //求data中可用的最小的数字,并记录对应文件的索引 4: int min = data[0]; 5: // j 是文件索引 6: int j = 0; 7: … Continue reading