Sunday, 25 September 2016

Make VIM into an IDE



(1) ctags

$sudo apt-get install exuberant-ctags

> Now go to the directory with the source files, go into it, not one level out it. And use:
    $ctags -R *

  -R indicates recursively, which means the subdirectories are also searched. And we can see a new file naned "tags".

Here are some useful cmds for ctags:

Ctrl + ]
Ctrl + t
:tag function_name 
:ta function_name












ref:
http://blog.csdn.net/daniel_ustc/article/details/8299096
https://andrew.stwrt.ca/posts/vim-ctags/



Friday, 23 September 2016

Ubuntu Chinese Pingying Characters not Coming Out


When I just added Pingying Input and tried to type, there is no characters coming out for choosing. Here is the solution:

terminal$:  ibus-daemon -drx

This basically re-start the ibus process.

Ubuntu Chinese Pingying Characters not Coming Out


When I just added Pingying Input and tried to type, there is no characters coming out for choosing. Here is the solution:

terminal$:  ibus-daemon -drx

This basically re-start the ibus process.

Wednesday, 21 September 2016

How to use #if 0 ... #endif


#if 0
...
#endif

basically tells the compiler that there is no need to compile this part of codes.

Usage:
(1) There might be something needed LATER in the program but we don't yet know exactly how this part works. So just leave it there now without compiling it.

(2) When we want to comment a block of codes using /* ... */, but there are some other comments in this block using  /* ... */, the only option we have is use #if 0 to avoid the compilation of it.

(3) Testing and debugging

#if 0
{original program...}
#else{new program...}
#endif


if we need to change back to the original program, just change the 0 back to 1.

ref:
http://www.programmer-club.com.tw/ShowSameTitleN/c/29150.html

Tuesday, 13 September 2016

Particle Photon Getting Started


Step 1:
To install Node.js, type the following command in your terminal:
Then install the Node package manager, npm:
Create a symbolic link for node, as many Node.js tools use this name to execute.
Now we should have both the Node and npm commands working:
$ npm install -g particle-cli
Step 2:
sudo npm install -g particle-cli


Ref:
http://www.hostingadvice.com/how-to/install-nodejs-ubuntu-14-04/#ubuntu-package-manager
https://docs.particle.io/guide/tools-and-features/cli/photon/


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Trouble shooting, after an particle-cli upgrade, I am getting two errors look like:

        /usr/local/lib/node_modules/particle-cli/commands/Key Commands.js:213 

and the other similar one.

This is because the node version is too old. So we have to (1) upgrade node (2) remove particle-cli (3) re-install particle-cli again.

(1) in order to install the latest node
   1 Install npm:
sudo apt-get install npm
  1. Install n
sudo npm install n -g
  1. Get latest version of node
sudo n latest

(2) remove and re-install particle-cli
sudo npm remove -g particle-cli
sudo npm install -g particle-cli


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I setup a brand new computer again.

Step 1:
sudo apt-get install nodejs-legacy
sudo apt-get install npm
You wont get the latest version but we are going to upgrade them in a minute.

Step 2:
Update them.
sudo npm cache clean -f
sudo npm install -g n
sudo n latest

Step 3:
bash <( curl -sL https://particle.io/install-cli )
Wait a while and that's IT!!!


ref:
https://github.com/spark/particle-cli/issues/176
http://stackoverflow.com/questions/34974535/install-latest-nodejs-version-in-ubuntu-14-04
http://www.hostingadvice.com/how-to/update-node-js-latest-version/
https://docs.particle.io/guide/tools-and-features/cli/photon/