William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

Category Archives: Uncategorized

php MySQLi: MySQL Improved Extension

There are three main API options when considering connecting to a MySQL database server:

  1. PHP’s MySQL Extension
  2. PHP’s mysqli Extension
  3. PHP Data Objects (PDO)

Each has its own advantages and disadvantages. By default we use ‘PHP MySQL extension’. Here focus on the second – MySQLi extension:
The mysqli extension is built using the PHP extension framework, its source code is located in the directory ext/mysqli.

According to wiki, MySQLi is an improved version of the older PHP MySQL driver, offering various benefits.
The MySQLi extension provides various benefits with respect to its predecessor, the most prominent of which are:

  • An object-oriented interface
  • Support for prepared statements
  • Support for multiple statements
  • Support for transactions
  • Enhanced debugging support
  • Embedded server support

The following is a quick example from php.net/mysqli‘s document page:

$mysqli = new mysqli("example.com", "user", "password", "database");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") "
      . $mysqli->connect_error;

if (!$mysqli->query("DROP TABLE IF EXISTS test") ||
    !$mysqli->query("CREATE TABLE test(id INT, label CHAR(1))") ||
    !$mysqli->query("INSERT INTO test(id, label) VALUES (1, 'a')")) {
    echo "Table creation failed: (" . $mysqli->errno . ") " . $mysqli->error;

if (!($stmt = $mysqli->prepare("SELECT id, label FROM test ORDER BY id ASC"))) {
    echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;

if (!$stmt->execute()) {
     echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;

if (!($res = $stmt->get_result())) {
    echo "Getting result set failed: (" . $stmt->errno . ") " . $stmt->error;


JavaScript UI tips

Some tips for quick retrieving:

(1) MongoDB Windows GUI


(2) Node-Inspector / debugger

node-inspector: debug js, supervisor

(3) AngularJS

Karma / Testacular: JavaScript Test Runner
run in MINGW32 (git bash)

(4) Promise:

then(): http://promises-aplus.github.io/promises-spec/
Q(): https://github.com/kriskowal/q
It(callback) must use an explicit try block to catch the exception that JSON.parse might throw and must manually forward all errors to the subscriber. It also must take care not to call the subscriber inside the try block, since this would catch errors thrown by nodeback and throw them back at nodeback in the catch block. In general, writing callback-based functions that handle errors robustly is difficult and error-prone, and even if you do it right, rather verbose.
The second reward for using promises is that they implicitly guarantee that interfaces you create will be strictly asynchronous.

(5) log()
function log() {
  var local = /(localhost||192.168)/.test(location.href);
  if (local || typeof console.log === 'function') {
    console.log.apply(console, arguments);
(6) WebStorm:
1. Code Analysis
Inspect Codes...
script:src (tab)

2. Keyboard Shortcuts

3. Actions
4. Templates
save as: Live Templates

5. Refactoring
function creation:

6. Navigation
7. Local History / Version Control
Changes -> Log
git history

8. External Tools (appear in TOOLS tab)
adding yeoman:
- yo angular
- npm install
- bower install
- common
- controller
- directive
- filter
- main
- route
- service
- view
mingw32 terminal / command-line

9. File Watchers
Coffee Script
10. Plugins
(7) Yeoman.io

Yeoman 1.0 is more than just a tool. It’s a workflow; a collection of tools and best practices working in harmony to make developing for the web even better.

nodejs pic

Node.js: the good parts flows









(1) Parsing the Request Body
In HTTP, the request body is the part of the request that comes right
after the header. It can contain any content the application chooses
and is typically used to upload files, post forms, and pass remote
API arguments.

When posting forms, there are two types of request body encoding:
URL-encoded and multipart.
The URL-encoded format is similar to the query string format, and the multipart
encoding is a more complex format that is mainly used to upload files and pass
more complex data types.
When passing arguments to an API call that is hosted by your server, the remote
client can encode the call arguments as a JSON-encoded body.

All of these main types of encoding are specifi ed by the request content type string,
and you would have to switch between these body decoders depending on it.

(2) Parsing Cookies
Cookies are a standard used to store data as short strings on the web browser.
A server can send one or many cookies, and each cookie has a name.
The server can send one or more of these in the response of any request by using
Set-Cookie response headers. The web browser has to store each of them and send them
along as a single Cookie header on the following requests until the cookie expires.
The Cookie header has its own encoding mechanism because many name-value pairs can be
encoded there. Setting a cookie with a name of a cookie that is already stored on
the browser overrides the original cookie.

(3) Using a Session
Several third-party session stores allow you to use Memcache, Redis, and other
database servers as a session store for Connect.

If you use a memory store, the sessions won’t survive a process restart. If
you use a persistent session store, you will have an external service where
the sessions will be kept and survive a Node process restart. Also, using an external
session store allows you to force two or more Node processes to share the session
state, which means that if you use a load balancer, any request can hit any Node
process running your app at any given time and always have the session data
For this example, though, you will use the built-in and default memory store,
but you should use an external persistent store if your production setup involves
more than one Node process.

(4) What's these?
  • CSRF (cross-site request forgery) protection
  • Gzip compression
  • static file memory cache
  • virtual-host support, a request body size limiter
  • Session store using Redis, Memcache
  • provide JSONP support
  • render templates
  • support request timeout
  • integrate with various methods of authentication
  • support LESS (the CSS DSL)
  • HTML5 Web Workers

    HTML5 Web workers

    1. What Web Worker can do?
    • Caching data for use in your pages.
    • Processing large amounts of data in arrays or large JSON response from web service.
    • Managing a database connection along with adding and removing records for the main page.
    • Automated race track betting agent.
    • Analyzing video.
    • Spell checking the page s the user types.
    • Polling web services and alerting the main page when something happens.
    • Image processing of data in a canvas.
    • Code syntax or other language highlighting.
    • Pre-fetching data based on what your user is doing.
    • Managing advertising for your page.
    2. keys to use HTML5 Web Workers
    • Without Web Workers, Javascript is a single-threaded, meaning it can do only one thing at a time.
    • If you give a JavaScript program too much to do, you might get the slow script dialog.
    • Web workers handle tasks on a separate thread so your main JavaScript code can continue to run and your UI remains responsive.
    • The code for a Web worker is in a separate file from your page’s code.
    • Web workers don’t have access to any of the functions in the code in your page or the DOM.
    • The code in your page and the web worker communicate via messages.
    • To send a message to a worker, use PostMessage.
    • Your can send strings and objects to a worker via postMesage, you can’t send functions to a worker.
    • Receive messages back from workers by setting the worker’s onmessage property to a handler function.
    • A worker receives messages from the code in your page by setting its onmessage property to a handler function.
    • When a worker is ready to send back a result, it calls postMessage and passes the result as the argument.
    • Worker results are encapsulated in an event object and placed in the data property.
    • You can find out which worker sent the message using the event.target property.
    • Messages are copied, not shared, btw your main page code and the worker.
    • You can use multiple workers for large computations that can be split into multiple tasks, such as computing a fractal visualization or ray tracing an image.
    • Each worker runs in its own thread, so if your computer has a multicore processor, the workers are run in parallel, which increases the speed of the computation.
    • You can terminate a worker by calling worker.terminate() form the code in your page. This will abort the worker script. A worker can also stop itself by calling close().
    • Workers also have an onerror property. You can set this to an error handling function that will be called if your worker has a script error.
    • To include and use JavaScript libaries in your worker file, use importScripts.
      //You can also use importScripts with  JSONP.
      //Implement the callback you pass in the URL query in the worker file.
      function makeServerRequest() {
      function handleRequest(response) {
    • While workers do not have assess to the DOM or functions in your main codes, they can use XMLHttpRequest and Local Storage.

    bash Comparison Operators

    bash Comparison Operators

    Here is Bash comparison operators from http://tldp.org/LDP/abs/html/comparison-ops.html. I extracted for quick searching:

    A binary comparison operator compares two variables or quantities. Note that integer and string comparison use a different set of operators.

    integer comparison


    is equal to

    if [ "$a" -eq "$b" ]


    is not equal to

    if [ "$a" -ne "$b" ]


    is greater than

    if [ "$a" -gt "$b" ]


    is greater than or equal to

    if [ "$a" -ge "$b" ]


    is less than

    if [ "$a" -lt "$b" ]


    is less than or equal to

    if [ "$a" -le "$b" ]


    is less than (within double

    (("$a" < "$b"))


    is less than or equal to (within double parentheses)

    (("$a" <= "$b"))


    is greater than (within double parentheses)

    (("$a" > "$b"))


    is greater than or equal to (within double parentheses)

    (("$a" >= "$b"))

    string comparison


    is equal to

    if [ "$a" = "$b" ]


    Note the whitespace
    framing the =.

    if [ "$a"="$b" ] is
    not equivalent to the


    is equal to

    if [ "$a" == "$b" ]

    This is a synonym for =.


    The == comparison operator behaves differently
    within a double-brackets
    test than within single brackets.

    [[ $a == z* ]]   # True if $a starts with an "z" (pattern matching).
    [[ $a == "z*" ]] # True if $a is equal to z* (literal matching).
    [ $a == z* ]     # File globbing and word splitting take place.
    [ "$a" == "z*" ] # True if $a is equal to z* (literal matching).
    # Thanks, Stéphane Chazelas


    is not equal to

    if [ "$a" != "$b" ]

    This operator uses pattern matching within a [[ … ]] construct.


    is less than, in ASCII alphabetical

    if [[ "$a" < "$b" ]]

    if [ "$a" \< "$b" ]

    Note that the “<“ needs to be
    escaped within a
    [ ] construct.


    is greater than, in ASCII alphabetical order

    if [[ "$a" > "$b" ]]

    if [ "$a" \> "$b" ]

    Note that the “>” needs to be
    escaped within a [ ] construct.

    See Example 27-11 for an application of this
    comparison operator.


    string is null,
    that is, has zero length

     String=''   # Zero-length ("null") string variable.
    if [ -z "$String" ]
      echo "\$String is null."
      echo "\$String is NOT null."
    fi     # $String is null.


    string is not null.


    The -n test
    requires that the string be quoted within the
    test brackets. Using an unquoted string with
    ! -z, or even just the
    unquoted string alone within test brackets (see Example 7-6) normally works, however, this is
    an unsafe practice. Always quote
    a tested string.

    Example 7-5. Arithmetic and string comparisons

    #  Here "a" and "b" can be treated either as integers or strings.
    #  There is some blurring between the arithmetic and string comparisons,
    #+ since Bash variables are not strongly typed.
    #  Bash permits integer operations and comparisons on variables
    #+ whose value consists of all-integer characters.
    #  Caution advised, however.
    if [ "$a" -ne "$b" ]
      echo "$a is not equal to $b"
      echo "(arithmetic comparison)"
    if [ "$a" != "$b" ]
      echo "$a is not equal to $b."
      echo "(string comparison)"
      #     "4"  != "5"
      # ASCII 52 != ASCII 53
    # In this particular instance, both "-ne" and "!=" work.
    exit 0

    Example 7-6. Testing whether a string is null

    #  str-test.sh: Testing null strings and unquoted strings,
    #+ but not strings and sealing wax, not to mention cabbages and kings . . .
    # Using   if [ ... ]
    # If a string has not been initialized, it has no defined value.
    # This state is called "null" (not the same as zero!).
    if [ -n $string1 ]    # string1 has not been declared or initialized.
      echo "String \"string1\" is not null."
      echo "String \"string1\" is null."
    fi                    # Wrong result.
    # Shows $string1 as not null, although it was not initialized.
    # Let's try it again.
    if [ -n "$string1" ]  # This time, $string1 is quoted.
      echo "String \"string1\" is not null."
      echo "String \"string1\" is null."
    fi                    # Quote strings within test brackets!
    if [ $string1 ]       # This time, $string1 stands naked.
      echo "String \"string1\" is not null."
      echo "String \"string1\" is null."
    fi                    # This works fine.
    # The [ ... ] test operator alone detects whether the string is null.
    # However it is good practice to quote it (if [ "$string1" ]).
    # As Stephane Chazelas points out,
    #    if [ $string1 ]    has one argument, "]"
    #    if [ "$string1" ]  has two arguments, the empty "$string1" and "]" 
    if [ $string1 ]       # Again, $string1 stands unquoted.
      echo "String \"string1\" is not null."
      echo "String \"string1\" is null."
    fi                    # Again, gives correct result.
    # Still, it is better to quote it ("$string1"), because . . .
    string1="a = b"
    if [ $string1 ]       # Again, $string1 stands unquoted.
      echo "String \"string1\" is not null."
      echo "String \"string1\" is null."
    fi                    # Not quoting "$string1" now gives wrong result!
    exit 0   # Thank you, also, Florian Wisser, for the "heads-up".

    Example 7-7. zmore

    # zmore
    # View gzipped files with 'more' filter.
    if [ $# -eq 0 ] # same effect as:  if [ -z "$1" ]
    # $1 can exist, but be empty:  zmore "" arg2 arg3
      echo "Usage: `basename $0` filename" >&2
      # Error message to stderr.
      exit $E_NOARGS
      # Returns 85 as exit status of script (error code).
    if [ ! -f "$filename" ]   # Quoting $filename allows for possible spaces.
      echo "File $filename not found!" >&2   # Error message to stderr.
      exit $E_NOTFOUND
    if [ ${filename##*.} != "gz" ]
    # Using bracket in variable substitution.
      echo "File $1 is not a gzipped file!"
      exit $E_NOTGZIP
    zcat $1 | more
    # Uses the 'more' filter.
    # May substitute 'less' if desired.
    exit $?   # Script returns exit status of pipe.
    #  Actually "exit $?" is unnecessary, as the script will, in any case,
    #+ return the exit status of the last command executed.

    compound comparison


    logical and

    exp1 -a exp2 returns true if
    both exp1 and exp2 are true.


    logical or

    exp1 -o exp2 returns
    true if either exp1 or exp2 is

    These are similar to the Bash comparison operators
    && and ||, used
    within double brackets.

    [[ condition1 && condition2 ]]

    The -o and -a operators
    work with the test command or
    occur within single test brackets.

    if [ "$expr1" -a "$expr2" ]
      echo "Both expr1 and expr2 are true."
      echo "Either expr1 or expr2 is false."


    But, as rihad points out:

    [ 1 -eq 1 ] && [ -n "`echo true 1>&2`" ]   # true
    [ 1 -eq 2 ] && [ -n "`echo true 1>&2`" ]   # (no output)
    # ^^^^^^^ False condition. So far, everything as expected.
    # However ...
    [ 1 -eq 2 -a -n "`echo true 1>&2`" ]       # true
    # ^^^^^^^ False condition. So, why "true" output?
    # Is it because both condition clauses within brackets evaluate?
    [[ 1 -eq 2 && -n "`echo true 1>&2`" ]]     # (no output)
    # No, that's not it.
    # Apparently && and || "short-circuit" while -a and -o do not.

    The Top 10 Open-Source CRM Solutions

    I got a helpful article regarding on open-source CRM:

    The Top 10 Open-Source CRM Solutions

    The following are the contents I kept for further retrieving:

    The Top 10 Open-Source CRM Solutions

    By David Hakala

    Open-source software is not for businesses who want out-of-the-box complete applications, but it makes sense for companies that want to tailor every aspect of the CRM experience from the ground up.

    CRM buyers might have very few choices were it not for open-source applications. The CRM field is dominated by huge players such as Oracle Corp. and SAP, and the open-source model is perhaps the easiest way into the CRM market for new companies. Open-source CRM projects have been proliferating; SourceForge Inc. lists 369 active open-source CRM projects. The following 10 open-source CRM solutions have risen to the top of the list.

    1. SugarCRM Inc. is the 800-pound gorilla in the open-source CRM category. Founded in 2004 by John Roberts, Clint Oram and Jacob Taylor, the Sugar open-source code has been downloaded more than 3 million times. The company has received $26 million in venture financing and employs more than 100 people. More than 12,000 companies use SugarCRM including Honeywell International, Starbucks Corp., First Federal Bank and BDO Seidman LLP. SugarCRM is written in PHP and is compatible with the MySQL database.

    2. SplendidCRM Software Inc.’s development team formed in November 2005. The application is built on the Microsoft platform (Windows, ISS, SQL Server, C# and ASP). Designed for system integrators, SplendidCRM allows administrators to add user-customizable features such as .NET 2.0’s Themes, Web Parts and AJAX. SplendidCRM is positioned as a competitor to SugarCRM, as the two applications share many of the same features. For instance, both offer an Outlook plug-in and the ability to add custom fields.

    3. CentricCRM has been around for seven years and has achieved a great deal of stability and robustness. In June 2007, CentricCRM (renamed Concursive as of December 2007) received investment funding from Intel Capital, the venture capital arm of Intel Corp. CentricCRM is aimed at the small-business market, although it has scaled up within Fortune 500 companies. Its more complex features can be turned off if they are not needed, and the administrative console allows for a great deal of customization. The free version comes with five user licenses. Centric CRM is written in Java and is compatible with MySQL databases.

    4. Hipergate bills itself as “the most complete open-source Java CRM and groupware.” That’s a lot to pack into a single package, but this enterprise-class application seems to have it all. Its functional modules include collaboration and groupware; contact management; project management and support-issues tracking; an e-shopping module with multiple catalogs and payment processing; a content -management module; mass email distribution and tracking; a corporate library; roles-based security; queries and reports; and more. Written in Java and JSP, hipergate is operating system-independent. Databases with which it is compatible include Microsoft SQL Server, MySQL, Oracle and PostgreSQL.

    5. Compiere Inc. offers a complete ERP (Enterprise Resource Planning) and CRM application with support for marketing and sales, human resources, inventory control and more. There is even a full business-accounting package, something often seen in open-source software. Compiere received a $6 million injection of venture capital in June 2006. Compiere is written in Java, JavaScript and PL/SQL, and it is compatible with JDBC and Oracle databases.

    6. Vtiger CRM is built upon the LAMP/WAMP (Linux/Windows, Apache, MySQL and PHP) architecture, with the main development team based in Chennai, India. Vtiger CRM includes SFA (Sales Force Automation), customer-support and -service, marketing automation, inventory-management, multiple database support, security-management, product-customization, calendaring and email-integration features. It also offers add-ons (Outlook Plug-in, Office Plug-in, Thunderbird Extension, Customer Self-service Portal and Web Forms) and support for other add-ons. Vtiger is written in JavaScript, PHP and Visual Basic. It is compatible with ADOdb, MySQL and PostgreSQL databases.

    7. CentraView Inc.’s offering is a combination of contact management, SFA and CRM functions. Its source code is J2EE-based and builds on the MySQL database. The first version of CentraView was released in November 2004, for the Linux and Windows 2000/XP platforms. Today, the software is offered in both hosted and downloadable forms. Centraview CRM is written in Java and JSP and is compatible with MySQL databases.

    8. XRMS CRM is a Web-based application suite that incorporates human-resources management, SFA and CRM. It is an on-premise solution for the small to midsize company. XRMS CRM includes computer telephony integration and the ability to add plug-ins for programs such as Outlook. XRMS CRM is operating-system independent, and it is written in an interpreted language (PHP). Compatible databases include ADOdb, SQL-based, Microsoft SQL Server, MySQL and other network-based DBMS.

    9. Cream CRM is a multilingual application designed for media organizations. The application tracks sales orders, payments, shipments, services, online and print subscriptions, and the effectiveness of promotional campaigns. Modules allow communication with customers via newsletters, email and a Web interface. Cream CRM is an initiative of the Media Development Loan Fund’s Center for Advanced Media in Prague, Czechoslovakia. Cream CRM runs on FreeDSB, Linux and Windows 2000/XP. It is written in Java and JavaScript.

    10. Tustena CRM is a Microsoft-centric application written for enterprise-class organizations. It comes in three solutions: On Demand, Business and Open Source. On Demand is the hosted version, while the Business version is installed on clients’ site and features tech support. Users who opt for the Open Source version get the source code and can modify it as they wish, relying on the community for support. Tustena CRM is written in C#, ASP.NET and JavaScript. It is compatible with Microsoft SQL Server.

    Design Patterns

    Design Patterns

    Here are some information about Software Design Patterns, original from wikipedia, I put here for quick retrieving. Design patterns were originally grouped into the categories:

    1. Creational patterns
    2. structural patterns
    3. behavioral patterns
    4. Concurrency patterns
    Creational patterns
    Name Description In Design Patterns In Code Complete[17]
    Abstract factory Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Yes Yes
    Builder Separate the construction of a complex object from its representation allowing the same construction process to create various representations. Yes No
    Factory method Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses (dependency injection[18]). Yes Yes
    Lazy initialization Tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed. No No
    Multiton Ensure a class has only named instances, and provide global point of access to them. No No
    Object pool Avoid expensive acquisition and release of resources by recycling objects that are no longer in use. Can be considered a generalisation of connection pool and thread pool patterns. No No
    Prototype Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. Yes No
    Resource acquisition is initialization Ensure that resources are properly released by tying them to the lifespan of suitable objects. No No
    Singleton Ensure a class has only one instance, and provide a global point of access to it. Yes Yes

    Structural patterns
    Name Description In Design Patterns In Code Complete[17]
    Adapter or Wrapper or Translator. Convert the interface of a class into another interface clients expect. An adapter lets classes work together that could not otherwise because of incompatible interfaces. The enterprise integration pattern equivalent is the translator. Yes Yes
    Bridge Decouple an abstraction from its implementation allowing the two to vary independently. Yes Yes
    Composite Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. Yes Yes
    Decorator Attach additional responsibilities to an object dynamically keeping the same interface. Decorators provide a flexible alternative to subclassing for extending functionality. Yes Yes
    Facade Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. Yes Yes
    Flyweight Use sharing to support large numbers of similar objects efficiently. Yes No
    Front Controller The pattern relates to the design of Web applications. It provides a centralized entry point for handling requests. No Yes
    Module Group several related elements, such as classes, singletons, methods, globally used, into a single conceptual entity. No No
    Proxy Provide a surrogate or placeholder for another object to control access to it. Yes No

    Behavioral patterns
    Name Description In Design Patterns In Code Complete[17]
    Blackboard Generalized observer, which allows multiple readers and writers. Communicates information system-wide. No No
    Chain of responsibility Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it. Yes No
    Command Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. Yes No
    Interpreter Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language. Yes No
    Iterator Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. Yes Yes
    Mediator Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently. Yes No
    Memento Without violating encapsulation, capture and externalize an object’s internal state allowing the object to be restored to this state later. Yes No
    Null object Avoid null references by providing a default object. No No
    Observer or Publish/subscribe Define a one-to-many dependency between objects where a state change in one object results in all its dependents being notified and updated automatically. Yes Yes
    Servant Define common functionality for a group of classes No No
    Specification Recombinable business logic in a Boolean fashion No No
    State Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. Yes No
    Strategy Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Yes Yes
    Template method Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure. Yes Yes
    Visitor Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates. Yes No

    Concurrency are described using the concepts of
    delegation, aggregation, and consultation.

    Concurrency patterns
    Name Description In POSA2[20]
    Active Object Decouples method execution from method invocation that reside in their own thread of control. The goal is to introduce concurrency, by using asynchronous method invocation and a scheduler for handling requests. Yes
    Balking Only execute an action on an object when the object is in a particular state. No
    Binding properties Combining multiple observers to force properties in different objects to be synchronized or coordinated in some way.[21] No
    Double-checked locking Reduce the overhead of acquiring a lock by first testing the locking criterion (the ‘lock hint’) in an unsafe manner; only if that succeeds does the actual lock proceed.

    Can be unsafe when implemented in some language/hardware combinations. It can therefore sometimes be considered an anti-pattern.

    Event-based asynchronous Addresses problems with the asynchronous pattern that occur in multithreaded programs.[22] No
    Guarded suspension Manages operations that require both a lock to be acquired and a precondition to be satisfied before the operation can be executed. No
    Lock One thread puts a “lock” on a resource, preventing other threads from accessing or modifying it.[23] No
    Messaging design pattern (MDP) Allows the interchange of information (i.e. messages) between components and applications. No
    Monitor object An object whose methods are subject to mutual exclusion, thus preventing multiple objects from erroneously trying to use it at the same time. Yes
    Reactor A reactor object provides an asynchronous interface to resources that must be handled synchronously. Yes
    Read-write lock Allows concurrent read access to an object, but requires exclusive access for write operations. No
    Scheduler Explicitly control when threads may execute single-threaded code. No
    Thread pool A number of threads are created to perform a number of tasks, which are usually organized in a queue. Typically, there are many more tasks than threads. Can be considered a special case of the object pool pattern. No
    Thread-specific storage Static or “global” memory local to a thread. Yes

    Best Firefox add-ons for web developers

    Best Firefox add-ons for web developers

    I found a very help articles when google ‘Best Firefox add-ons for web developers’:


    Here is the 11 very useful Firefox plugins for web developers which I add my favoirte ‘FireShot‘.

    1. Web Developer
    2. Firebug
    3. MeasureIt
      This Firefox add-on has a single purpose: It gives you a ruler that you can use on any web page for measuring items. Since web design critically relies on the proper sizing of design elements, this is a valuable tool to add to your collection of Firefox add-ons.
    4. ColorZilla
      One thing that web designers frequently work with is color. This add-on includes a color picker (much like the one you see in Photoshop) and an eye dropper tool so that you can sample and identify the colors used on any web page. A similar Firefox add-on to check out is Rainbow Color Tools.
    5. CSS Usage
      CSS Usage is an extension for Firebug (thus requiring you to have Firebug installed) that uncovers unused CSS style rules. It works by identifying the CSS you use and don’t use, pointing out what unnecessary parts can be removed to keep your CSS files as lightweight as possible.
    6. Page Speed
      Page Speed is a browser extension (for Firefox and Chrome) developed by Google that analyzes a web page and tells you where improvements can be made to increase the site’s speed. It’s a great tool for testing a web design’s ability to render fast.
    7. HTML Validator
    8. IE Tab 2
    9. Screengrab
      Taking screenshots in the browser is a common task for web designers. Screengrab is a simple tool for taking full-page or partial-page screenshots. You can copy the screenshot to your clipboard, or save it to your hard drive as an image file.
    10. SEO Doctor
    11. FireShot



    I publish some of my codes samples in github.com: a good place to share codes.
    The URL is:


    All the 7 repositories are regarding on PHP, Perl, NodeJS, JavaScript, jQuery, CMS, ORM, OOP, LAMP.