Simple Server


Then in your terminal, make sure you are at the location of your server.js file. Then type: node server.js

Go to any browser and type in localhost:8888 and you should be able to hit it.

Also, be sure to end the server process when you want to turn on another server. ctrl-c should do it. If not look at all the processes of node and kill which ever one is still running that is taking up port 8888.

ctrl-z suspends it, which means it can still be running.

ctrl-c will actually kill it.

you can also kill it manually like this:
ps aux | grep node

Find the process ID (second from the left):

count recursively

Abstract class and virtual functions

mysql basic commands

The SHOW statement can be used to obtain information about several aspects of your databases and tables:

List the databases managed by the server:

List the tables in the current database or in a given database:

Note that SHOW TABLES doesn’t show TEMPORARY tables.
Display information about columns or indexes in a table:

The DESCRIBE tbl_name and EXPLAIN tbl_name statements are synonymous with SHOW COLUMNS FROM tbl_name.

Display descriptive information about tables in the current database or in a given database:

This statement was introduced in MySQL 3.23.0.

Display the CREATE TABLE statement that corresponds to the current structure of a table:

This statement was introduced in MySQL 3.23.20.

Several forms of SHOW take a LIKE ‘pat’ clause allowing a pattern to be given that limits the scope of the output. ‘pat’ is interpreted as a SQL pattern that can include the ‘%’ and ‘_’ wildcard characters. For example, the following statement displays the names of tables in the current database that begin with ‘geo’:

To match a literal instance of a wildcard character in a LIKE pattern, precede it with a backslash. Generally, this is done to match a literal ‘_’, which occurs frequently in database, table, and column names.

The mysqlshow command provides some of the same information as the SHOW statement, which allows you to get database and table information from the shell:

List databases managed by the server:

List tables in the named database:

Display information about columns in the named table:

Display information about indexes in the named table:

Display descriptive information about tables in the named database:

The mysqldump utility allows you to see the structure of your tables in the form of a CREATE TABLE statement (much like SHOW CREATE TABLE). When using mysqldump to review table structure, be sure to invoke it with the –no-data option so that you don’t get swamped with your table’s data!

If you omit the table name, mysqldump displays the structure for all tables in the database.

For both mysqlshow and mysqldump, you can specify the usual connection parameter options (such as –host or –user.)
Determining Which Table Types Your Server Supports

ISAM is the only type available before MySQL 3.23. From 3.23 on, MyISAM, MERGE, and HEAP are always available, and availability of the other types can be assessed by means of an appropriate SHOW VARIABLES statement:

If the output from the query shows that the variable has a value of YES, the corresponding table handler is enabled. If the value is something else or there is no output, the handler is unavailable. The use of the pattern have_inno% to determine InnoDB availability matches both have_innodb and have_innobase. (The latter form was used in MySQL 3.23.30 to 3.23.36 before being renamed to have_innodb.)

You can use table type information to determine whether your server supports transactions. BDB and InnoDB are the two transaction-safe table types, so check whether their handlers are enabled as described in the preceding discussion.

As of MySQL 4.1, the list of table types is available directly through the SHOW TABLE TYPES statement:

| Type | Support | Comment |
| MyISAM | DEFAULT | Default type from 3.23 with great performance |
| HEAP | YES | Hash based, stored in memory, useful for temporary tables |
| MERGE | YES | Collection of identical MyISAM tables |
| ISAM | YES | Obsolete table type; Is replaced by MyISAM |
| InnoDB | YES | Supports transactions, row-level locking and foreign keys |
| BDB | YES | Supports transactions and page-level locking |

The Support value is YES or NO to indicate that the handler is or is not available, DISABLED if the handler is present but turned off, or DEFAULT for the table type that the server uses by default. The handler designated as DEFAULT should be considered available.
Checking a Table’s Existence or Type

It’s sometimes useful to be able to tell from within an application whether or not a given table exists. You can use SHOW TABLES to find out:

If the SHOW statement lists information for the table, it exists. It’s also possible to determine table existence with either of the following statements:

Each statement succeeds if the table exists and fails if it doesn’t. The first statement is most appropriate for MyISAM and ISAM tables, for which COUNT(*) with no WHERE clause is highly optimized. (It’s not so good for InnoDB or BDB tables, which require a full scan to count the rows.) The second statement is more general because is runs quickly for any table type. Use of these queries is most suitable for use within application programming languages, such as Perl or PHP, because you can test the success or failure of the query and take action accordingly. They’re not especially useful in a batch script that you run from mysql because you can’t do anything if an error occurs except terminate (or ignore the error, but then there’s obviously no point in running the query at all).

To determine the type of a table, you can use SHOW TABLE STATUS as of MySQL 3.23.0 or SHOW CREATE TABLE as of MySQL 3.23.20. The output from both statements includes a table type indicator. For versions older than 3.23.0, neither statement is available; but then the only available table type is ISAM, so there is no ambiguity about what storage format your tables use.

Guided Access (Locking home button)

Guided Access is a new feature found in iOS 6, and enabled on iOS 6 beta 2, which allows you to enable a “kiosk mode” on your iDevice. This can be handy for users who use the iPads or iPhones as retail assistants, in stores, in restaurants, as menus, etc.

To enable Guided Access mode, simply head to the Settings app > General > Accessibility, and locate Guided Access under the Learning section. Once enabled, head to your app of choice, and triple tap the Home button to engage Guided Access mode. You will be required to enter a passcode for Guided Access to prevent end-users from aborting the app.

You also have the ability to restrict access to certain portions of the screen, the whole screen, and/or disable the motion controls within the app.

char array copying and pointer manipulation

Basically, the idea is that you DO NOT touch the original arrays. Instead, you declare two char pointers and point to them. Then, assign the data from source to destination as you move each pointer down the arrays.


destination is: ||
source is: |BLUR SAMPLE|
destination is: |B|
destination is: |BL|
destination is: |BLU|
destination is: |BLUR|
destination is: |BLUR |
destination is: |BLUR S|
destination is: |BLUR SA|
destination is: |BLUR SAM|
destination is: |BLUR SAMP|
destination is: |BLUR SAMPL|
destination is: |BLUR SAMPLE|
copy done. final destination is: |BLUR SAMPLE|

Installing OpenCV on Mac OS X 10.9.2 Maverick and running with xCode 5.0.2

Building openCV

i. Download the latest version of OpenCV for UNIX. At the time of writing this is version 2.4.8
ii. Execute the following commands one by one. Each command should complete without errors.

unzip the OpenCV-2.4.8 zip file in your /users/(your account directory)

Open your terminal and go into the unzipped opencv directory.

Basically we go into the opencv folder and make a folder called build. We go into that folder and do a cmake to create make files:




note: all the libraries will be in /users/rickytsao/opencv2.4.8/build/lib.
it will also be in your /usr/local/lib

Look in your /users/rickytsao/opencv2.4.8/modules/(module name)/include/opencv2/(modeul name) for your respective module header files.
The header files will be in /usr/local/include. If not, read below on how to copy it over.


dylib files

at this point, look at your /usr/local/lib

/usr/local/lib should have libopencv_***.dylib files such as libopencv_core.2.4.8.dybli, libopencv_imgproc.2.4.8.dylib…etc

If not, go to your /users/(your account)/opencv-2.4.8/build/lib
You will see all the dylibs in there. Copy and paste them into /usr/local/lib


Module header files

In your /usr/local/include you should see two folders: opencv and opencv2. If they are not there, copy them from /users/(your account)/opencv-2.4.8/include

In your /usr/local/include, you should now have opencv and opencv2.

The only problem is that the opencv2 is missing all the include files from the different libraries. In order to get them, you’d have to go through each library folder and copy them into /usr/local/include/opencv2

Hence let’s first copy the ‘core’ module header files.

Go to all the modules at /users/(your account)/opencv-2.4.8/modules
You’ll see all the module folders.
From there, go into core/include/opencv2 folder.
You’ll see the core folder with all the header files. Copy the whole core folder into /usr/local/include/opencv2


Keep copying all the module header files for:

After you are done, your /usr/local/include/opencv2 folder should look like this:


Sample xCode project

Build a Terminal Console app in xCode. File >> New >> Project >> Command Line Tool.
When the project is ready, right click on your project (the blue section where your project name is). You will see the build options show up on your right.

Search Paths

Go to Build Settings, and in the search bar, type in ‘search’. You’ll see the search paths show up.


Header Search Paths: /usr/local/include
User Header Search Paths: /usr/local/include
Always Search User Paths: Yes
Library Search Paths: /usr/local/lib

That way, your project knows where to look as far as the header files and the library source files.

Add the libraries to your project

Now right click on your project name in your navigation window and select “add files to…”. Navigate to /usr/local/lib or simply type ‘/usr/local/lib’ and include and the libopencv_****2.4.8.dylib modules. You should AT LEAST include core, imgproc, and highgui.

Linker errors

Sometimes, when you run the code, you might get linker errors. I solved them by going to Build Settings >> Apple LLVM 5.0 – Language – C++, and choosing ‘Compiler Default’ for C++ Standard Library.


We are finally done with setting it up!

the code

In your project, throw your includes files up first:

Draw a blue circle

Read an image from a location and display it on screen

When running for mobile in IOS

In your Build Settings, make sure you put:

no for Automatic Reference Counting
Objective-C++ for Compile Sources As
Compiler Default for C++ Standard Library

Synchronize on on a instance level (static)

I know that using the synchronize keyword before a method brings synchronization to that object.
That is, 2 threads running the same instance of the object will be synchronized.
However, since the synchronization is at the object level, 2 threads running different instances of the object will not be synchronized. So, if we have a static variable in a java class that is called by the method, we would like it to be synchronized across instances of the class.
The two instances are running in 2 different threads.

There are several ways to synchronize access to a static variable.

Use a synchronized static method. This synchronizes on the class object.

Explicitly synchronize on the class object.

Synchronize on some other static object.

Method 3 is the best in many cases because the lock object is not exposed outside of your class.

C++ parameter passing


Hello, World!

Outside ptrOne value is: 10

Outside ptrOne address is: 0x100103ad0

inside changeOne. Number is: 20

inside changeOne: Address is: 0x100103ae0

Outside ptrOne value is: 10

Outside ptrOne address is: 0x100103ad0

inside changeTwo function. Number is: 20

inside changeTwo function. Address is: 0x100103ad0

Outside ptrOne value is: 20

Outside ptrOne address is: 0x100103ad0

Inside changeThree function. Number is: 50

Inside changeThree function. Address is: 0x100103ad0

Outside ptrOne value is: 50

Outside ptrOne address is: 0x100103ad0

Inside changeFour function. Number is: 6680

Inside changeFour function. Address is: 0x100103af0

Outside ptrOne value is: 6680

Outside ptrOne address is: 0x100103af0

Inside changeFour function. Number is: 6680

Inside changeFour function. Address is: 0x100103b00

Outside ptrOne value is: 6680

Outside ptrOne address is: 0x100103b00