Monday, March 12, 2018

Install node.js binaries




  1. Download the node.js binaries here:
    https://nodejs.org/en/download/
  2. Extract the file:
    $ tar xvf node-v8.10.0-linux-armv7l.tar.xz
  3. (optional) Move the binaries to target path:
    $ move node-v8.10.0-linux-armv7l /usr/local/lib/nodejs/
  4. Set path in ~/.profile
    # Nodejs
    export NODEJS_HOME=/usr/local/lib/nodejs/node-v8.10.0
    export PATH=$NODEJS_HOME/bin:$PATH
Now source .profile, mkdir nodejs_test, npm init should create package.json. You can try 
$ npm install express -save
to see if npm is working properly.

Monday, March 05, 2018

Typing Chinese (Cangjie) in Ubuntu 16.04


  1. In "Language Support", make sure "IBus" is selected for Keyboard input method system.
  2. Install / Remove Languages, add "traditional Chinese"
  3. # sudo apt install ibus-table-cangjie3
  4. Log Out/Log In (Important, or else below cangjie3 won't show up)
  5. In "Text Entry", click "+" to add Input sources (Chinese (cangjie3)
  6. Change "Switch to next source using:" to e.g Ctrl+Space



Then you can type cangjie!

Tuesday, October 03, 2017

arm cross compiler from Ubuntu apt


For ARM cross compiling, I had been using the Code Sourcery from Mentor Graphics. However the Mentor Graphics ARM compiler became non-free and there are two versions of free gcc compilers default in Ubuntu repository:
  • arm-linux-gnueabi-
  • arm-none-eabi-
Here are the commands to install them(as of today's Ubuntu Xenial 16.04)
$ sudo apt-get install gcc-arm-linux-gnueabi 
or
$ sudo apt-get install gcc-arm-none-eabi 
or
$ sudo apt-get install gcc-arm-linux-gnueabihf 
Enjoy!

Wednesday, August 16, 2017

LLVM

It took me a while to understand what is LLVM so I gave it a tried. It turns out... basically in layman's term it's a compiler like gcc

I went to their website and downloaded a lot of stuff.. then figured out that in Ubuntu you can try clang (which is the LLVM compiler in Ubuntu) with a single command:
$ sudo apt-get install llvm
So if you really don't want to use gcc like everyone else... then you should use LLVM..   sounds cool?


Sunday, June 11, 2017

Ubuntu Trusty userspace command to put system to suspend

 
Below is the Ubuntu Trusty userspace command to put system to suspend.
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Put the above command into the keyboard shortcut can immediately put your desktop to sleep upon entering the shortcut key.

Friday, March 24, 2017

vi indents consist of 4 space characters instead of tab

put the following line to .vimrc for indents that consist of 4 space characters but are entered with the tab key
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
tabstop

The width of a hard tabstop measured in "spaces" -- effectively the (maximum) width of an actual tab character.

shiftwidth

The size of an "indent". It's also measured in spaces, so if your code base indents with tab characters then you want shiftwidth to equal the number of tab characters times tabstop. This is also used by things like the =, > and < commands.

softtabstop

Setting this to a non-zero value other than tabstop will make the tab key (in insert mode) insert a combination of spaces (and possibly tabs) to simulate tab stops at this width.

expandtab

Enabling this will make the tab key (in insert mode) insert spaces instead of tab characters. This also affects the behavior of the retab command.

smarttab

Enabling this will make the tab key (in insert mode) insert spaces or tabs to go to the next indent of the next tabstop when the cursor is at the beginning of a line (i.e. the only preceding characters are whitespace).

Monday, March 13, 2017

An engineer's value

An engineers's value is not defined by one's education level, but defined as a product of one's ability to solve problems and skills to make one's boss happy.

$ = solve problem * boss's happiness

Tuesday, February 28, 2017

I frequently work on my source trees which is managed by git version control.  For many times I worked on several files then I figured I was working on the incorrect checkout.   Then I found out git provides some bash scripts which helps to auto complete your branch name and show the current branch name in the bash prompt (PS1).

However, in the git appendix A it shows a very ugly PS1 script.  I like my original bash PS1 with the branch name and auto-complete, followed by the brach name in bright color.   I paste my code here to remind myself and hopefully can help other people whom want to do the same.


  1. Download git-completion.bash from git source code.  This file auto complete(using <tab> key) your branch name in your bash prompt:
    $ wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
  2. Download git-prompt.sh . This script shows your current branch name:
    $ wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
  3. $ source git-completion.bash
    $ source git-prompt.sh
    $ export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\[\e[96m\]$(__git_ps1 "(%s)")\[\e[0m\]\$ '

Then it should turn PS1 like my prompt below:
gideon@gideon-i5:~/catkin_ws/src/turtlebot(indigo)$

To include the above scripts everytime you start your bash, change your .bashrc.   I put the following lines to my .bashrc
source ~/.git-completion.bash
source ~/.git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
# PS1 with git (line wrap issue fixed!!)
export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\[\e[96m\]$(__git_ps1 "(%s)")\[\e[0m\]\$ '
As a note, in Bash, the <Esc> character can be expressed with the following syntaxes:

  • \e
  • \033
  • \x1B

For example, \e[31m shows the following characters in Red color.  The ”\e[0m” sequence removes all attributes which can be used end the bash coloring.  However, these <Esc> and color characters breaks the bash windone line wrap counts.  That is why you need \[ and \] to state to bash that those are non-printing characters.

Yes those are not for human.... and if you understand what I said.... get a life!


References

https://git-scm.com/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Bash
http://misc.flogisoft.com/bash/tip_colors_and_formatting
http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/nonprintingchars.html

Friday, February 24, 2017

xhost+ Fix “Cannot Open Display” Error

The below commands will let you do xforwording with good speed, but very poor security.  Recommended to use this only in a trusted network.

Allow clients to connect from any host
$ xhost +

Enable X11 forwarding
$ ssh username@hostname -X

Wednesday, December 14, 2016

Gazebo in web browser


http://gazebosim.org/gzweb

Gzweb is installed on the server-side. Once the server is set up and running, clients can interact with the simulation simply by accessing the server's URL on a web browser.

It's pretty cool.  Try it!