6/30/2016

Setup Outlook

Default font should be: Arial Size: 9

Change how the original message appears in replies and forwards:
Preference -> Composing -> Indent each line of the original message and Attribution of original message: Custom On [DATE], [NAME] <[ADDRESS]> wrote:

Email account -> Advanced -> Folders -> Don't save a copy of sent messages

6/27/2016

Commonly used commands to fix Virtualbox (Ubuntu and GPU related issues)

Fixed Virtualbox by running:
sudo apt-get remove --purge nvidia-*
sudo apt-get install ubuntu-desktop


sudo rm /etc/X11/xorg.conf

=========================

sudo apt-get install gnome-session ubuntu-desktop

sudo apt-get install --reinstall linux-image-$(uname -r)

sudo apt-get --reinstall install libgl1-mesa-glx

# Also check ~/.xsession-errors
# /var/log/Xorg.0.log
# /var/log/lightdm/lightdm.log
# /var/log/lightdm/x-0-greeter.log

# If no menu bar
setsid unity

sudo apt install --reinstall lightdm
sudo apt install --reinstall nvidia-XXX
sudo apt install --reinstall xserver-xorg
sudo apt install --reinstall xserver-xorg-core

sudo apt install --reinstall gnome-session

sudo dpkg-reconfigure xserver-xorg

# Unable to mount the Guest Additsudo mkdir --p /media/cdrom
sudo mount -t auto /dev/cdrom /media/cdrom/
cd /media/cdrom/
sudo sh VBoxLinuxAdditions.run

How to change gerrit font

Just change your browser's font:
Firefox: Content -> Font & Colors -> San-serif and Monospace

Chrome: San-serif and Monospace

6/20/2016

Background color that I like

Light orange background: #F5E7D1 (RGB: 245, 231, 209)
Light blue background: #DFF5FD (RGB: 223,245,253)
Dark red text color: #A52A2A
Dark green: #006400
Orange: #ff7f00
Dark blue: #2684BE
Nvidia green: #76B900 (RGB: 118, 185, 0)

6/15/2016

EMACS frequently commonly used commands

ctrl-g quit the current operation
ctrl-x ctrl-s: save
ctrl-x ctrl-w: save as
ctrl-x ctrl-c: exit
ctrl-x b: change buffer or type in a name to new a buffer
ctrl-x k: kill buffer
alt-x revert-buffer: reload buffer from file
alt-x goto-line: go to line
ctrl space: copy mode
ctrl-w: cut
alt-w: copy
ctrl-y: paste
ctrl-x u: undo
ctrl-x 3: split window
ctrl-x f: open file
ctrl-s: search

alt-e: to edit the search string
alt-% (alt-shift-3): find/replace
ctrl-v: scroll down
alt-v: scroll up
alt-x customize-face: change the color of the syntax coloring of the current cursor word
alt-x list-faces-display: to change different colors
alt-x linum-mode: show line number
ctrl-c ctrl-c: to comment a block
alt-;: to uncomment a block
ctrl space to select region, then ctrl-x tab: to indent a block. ctrl-x tab again to indent again
ctrl space to select region, then ctrl-u -2 then ctrl-x tab: to unindent a block
alt-x python-mode: to turn on python, text-mode or c++-mode etc
ctrl-u: repeat the following commands 4 times
ctrl-u 2: repeat the following commands 2 times
To give a command a numeric argument of, say, 12, type C-u 12 before typing the command. If you type slowly, you'll see: C-u 1 2-
# Comment a block
alt-x python-mode, select region, then alt-x comment-region
ctrl-j: new line and auto indent
alt-/: auto complete words

alt-d: delete a word forward
alt-delete: delete a word backward
ctrl-k: delete a line
ctrl-shift-backspace: delete the current whole line
alt-f: move a word forward
alt-b: move a word backward
alt-x toggle-truncate-lines: wrap text off
ctrl-x ctrl-+: increase font size
ctrl-x ctrl--: decrease font size
whitespace-mode: toggle whitespace mode
alt-x ediff: diff two files
ctrl-x z: continue once the previous command
alt-x zap-to-char: delete everything up to a specific character
vc-annotate: display the git blame information

# Change split windows size:
C-x } (enlarge-window-horizontally) does likewise, horizontally.
C-x { (shrink-window-horizontally) is also bound by default

Following one of these commands with repeat (C-x z to initiate, and just z for continued repetition).


Navigating Parentheses:
  ctrl-alt-n     forward-list  Move forward over a parenthetical group 
  ctrl-alt-p     backward-list  Move backward over a parenthetical group 
  ctrl-alt-f     forward-sexp Move forward over a balanced expression
  ctrl-alt-b     backward-sexp  Move backward over a balanced expression
  ctrl-alt-k     kill-sexp  Kill balanced expression forward
  ctrl-alt-SPC   mark-sexp  Put the mark at the end of the sexp.

Set comment region charactert:
Alt-: (setq comment-start "#~")

In the directory view mode: (dired)
C: copy file
D: delete file or folder
R: rename file or folder
+: create a folder
q: quit the dir mode
m: mark file
u: unmark file
U: unmark all files
%m: regexp mark files
^: go to parent dir
>: move to the next subdir
<: font="" move="" prev="" subdir="" the="" to="">

Debug Shortcuts

Eclipse:
Step Info: F5
Step Over: F6
Step Return: F7
Continue: F8

6/14/2016

Use Jetty to serve static content

ResourceHandler resourceHandler2 = new ResourceHandler();
resourceHandler2.setDirectoriesListed(true);
resourceHandler2.setResourceBase("/path/to/static_files");
ContextHandler staticContextHandler2 = new ContextHandler("/html");
staticContextHandler2.setHandler(resourceHandler2);

...

handlerList handlers = new HandlerList();
handlers.addHandler(servletContextHandler);
handlers.addHandler(staticContextHandler2);

httpServer.setHandler(handlers);

How to automount Linux drives

# Use 'blkid' to print the universally unique identifier for a
# device;
# Or sudo fdisk -l

Find the UUID, it may look like this UUID="9210-C510"

sudo gedit /etc/fstab

UUID=3e7208a2-670c-4c33-846f-50fc4e75c340 /mnt/wd0 ext4 defaults,errors=remount-ro 0 0

UUID=7d0ddfee-ec78-4425-805d-dee5b9ef7cf8 /mnt/wd1 ext4 defaults,errors=remount-ro 0 0

Then, run
sudo mount -a to execute the file


Bonus: how to manually mount a drive
sudo mount -t ext4

/mnt/wd0

Commonly used Linux Aliases

EDITOR='TERM=xterm-256color emacs -nw';
export EDITOR
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qt5.5.0/5.5/gcc_64/lib
alias loadmac='sudo mount -t vboxsf -o dmode=755,fmode=644,uid=$UID,gid=$(id -g) Share ~/machome'
                                                                
export PS1='[\D{%Y/%m/%d} \t]${debian_chroot:+($debian_chroot)}\[\033[00;34m\]\u@\h\[\033[00m\]: \[\033[00;31m\]\w\[\033[00m\]\$ '
export CLICOLOR=1
export LS_COLORS='rs=0:di=01;34:mh=00:pi=40;33:so=00;97;44:do=00;97;44:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:*.tar=00;97;44:*.tgz=00;97;44:*.arc=00;97;44:*.arj=00;97;44:*.taz=00;97;44:*.lha=00;97;44:*.lz4=00;97;44:*.lzh=00;97;44:*.lzma=00;97;44:*.tlz=00;97;44:*.txz=00;97;44:*.tzo=00;97;44:*.t7z=00;97;44:*.zip=00;97;44:*.z=00;97;44:*.Z=00;97;44:*.dz=00;97;44:*.gz=00;97;44:*.lrz=00;97;44:*.lz=00;97;44:*.lzo=00;97;44:*.xz=00;97;44:*.bz2=00;97;44:*.bz=00;97;44:*.tbz=00;97;44:*.tbz2=00;97;44:*.tz=00;97;44:*.deb=00;97;44:*.rpm=00;97;44:*.jar=00;97;44:*.war=00;97;44:*.ear=00;97;44:*.sar=00;97;44:*.rar=00;97;44:*.alz=00;97;44:*.ace=00;97;44:*.zoo=00;97;44:*.cpio=00;97;44:*.7z=00;97;44:*.rz=00;97;44:*.cab=00;97;44:*.jpg=00;97;44:*.jpeg=00;97;44:*.gif=00;97;44:*.bmp=00;97;44:*.pbm=00;97;44:*.pgm=00;97;44:*.ppm=00;97;44:*.tga=00;97;44:*.xbm=00;97;44:*.xpm=00;97;44:*.tif=00;97;44:*.tiff=00;97;44:*.png=00;97;44:*.svg=00;97;44:*.svgz=00;97;44:*.mng=00;97;44:*.pcx=00;97;44:*.mov=00;97;44:*.mpg=00;97;44:*.mpeg=00;97;44:*.m2v=00;97;44:*.mkv=00;97;44:*.webm=00;97;44:*.ogm=00;97;44:*.mp4=00;97;44:*.m4v=00;97;44:*.mp4v=00;97;44:*.vob=00;97;44:*.qt=00;97;44:*.nuv=00;97;44:*.wmv=00;97;44:*.asf=00;97;44:*.rm=00;97;44:*.rmvb=00;97;44:*.flc=00;97;44:*.avi=00;97;44:*.fli=00;97;44:*.flv=00;97;44:*.gl=00;97;44:*.dl=00;97;44:*.xcf=00;97;44:*.xwd=00;97;44:*.yuv=00;97;44:*.cgm=00;97;44:*.emf=00;97;44:*.ogv=00;97;44:*.ogx=00;97;44:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36::ex=0;35:ln=01;102:'
# Set Hadoop-related environment variables
export HADOOP_HOME=/usr/local/hadoop
export PATH="$PATH:$HOME/bin:$HADOOP_HOME/bin:/usr/local/apache-maven-3.3.9/bin"

alias scp='scp -3'
alias emacs='TERM=xterm-256color emacs -nw'
alias up='cd ..'
alias up2='cd .. && cd ..'
alias up3='cd .. && cd .. && cd ..'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias bcc='bazel build'
alias eclipse='~/Documents/eclipse/eclipse'

alias gdiff='git log -p -n 1'
alias gfiles='git log -n 1 --name-only'
alias g='git'
alias gb='git branch'
alias gs='git status'
alias gr='git review'
alias gm='git checkout master'
alias gc='git checkout'

alias fs='env WINEPREFIX="/home/liangzou/.wine" wine "/home/liangzou/.wine/drive_c/Program Files (x86)/FastStone Image Viewer/FSViewer.exe"'
alias h='history'
alias cls='clear'
alias knowledge='firefox "link to the knowledge.txt online file"'
alias hfs="hadoop fs"
alias hls="fs -ls"
alias bashrc="scite ~/.bashrc &"
alias l='ls --color'
alias ll='ls -lh --color'
alias lname='ls | tr "\n" "\n"'
alias emacs='TERM=xterm-256color emacs -nw'
alias e='emacs'
alias ew='LC_CTYPE=zh_CN.UTF-8 /usr/bin/emacs -fh -geometry 180x0'
# If HDPI screen
# alias ew='GDK_SCALE= /usr/bin/emacs -fh --geometry 90x40'
# For X11 forwarding app
alias xew='/usr/bin/emacs --geometry 90x52 -q --load ~/.x11emacs'
alias b='bazel'
alias s='scite'
alias start='nemo'
# for cygwin
# alias start='cygstart'
alias eclipse='~/Documents/eclipse/eclipse'
alias d='docker'
alias dm='docker-machine'
alias intellij='~/Documents/idea-IC-145.597.3/bin/idea.sh &'
alias n='nodejs'
alias k='kubectl'
alias chrome='/opt/google/chrome/chrome'
alias tm='trash'
alias loadbuildenv='docker run -it --rm -v /home/$USER:/main/user 776923679937.dkr.ecr.us-west-2.amazonaws.com/buildenv:latest'
alias r='pkill -HUP -f "cinnamon --replace"'
alias a='aws'
alias t='tree'
alias large='export GDK_SCALE=2'
alias xeclipse='GDK_DPI_SCALE=2 eclipse' 
alias gbackup='g push origin HEAD:refs/for/master%wip'
alias sftptunnel='ssh -D 8001 -p 2002 deepmap'
alias sshtunnel='ssh -L 8002:depot0:22 -p 2002 deepmap'
alias sshvrtunnel='ssh -L 8065:10.1.20.65:22 -p 2002 deepmap'

alias m='netease-cloud-music --force-device-scale-factor=2'
alias screen='TERM=xterm-256color screen'

alias fixterminal='stty sane'

alias work='cd ~/gitreview/deepmap'
alias workbase='cd ~/gitreview/deepmap/deepmap-base'
alias vpn='cd ~/bin/ && sudo ./cclient.sh start --load'
alias evpn='expressvpn'
alias winr='taskkill /F /IM explorer.exe && start explorer.exe'

alias phonec='adb connect 10.12.7.179:7612 && scrcpy --push-target /storage/emulated/0/Download/ --turn-screen-off'
alias phoneh='adb connect 192.168.124.22:7612 && scrcpy --push-target /storage/emulated/0/Download/ --turn-screen-off'
alias re='retext'
alias p='python'


# Change cursor to red
echo -ne '\e]12;#ff0000\a'

# Add a function to change title
function bb() {
      echo -ne "\e]0;$1\a"

}

function ediff() {
  if [ "X${2}" = "X" ]; then
    echo "USAGE: ediff "
  else
    # The --eval flag takes lisp code and evaluates it with EMACS
    emacs --eval "(ediff-files \"$1\" \"$2\")"
  fi
}

# Git branch bash completion
if [ -f ~/.git-completion.bash ]; then
  . ~/.git-completion.bash

  # Add git completion to aliases
  __git_complete g __git_main
  __git_complete gc _git_checkout
  __git_complete gm __git_merge
  __git_complete gp _git_pull

fi


------

DO NOT COPY TO .bashrc // Reference:
0   = default colour
1   = bold
4   = underlined
5   = flashing text
7   = reverse field
31  = red
32  = green
33  = orange
34  = blue
35  = purple
36  = cyan
37  = grey
40  = black background
41  = red background
42  = green background
43  = orange background
44  = blue background
45  = purple background
46  = cyan background
47  = grey background
90  = dark grey
91  = light red
92  = light green
93  = yellow
94  = light blue
95  = light purple
96  = turquoise
97  = white
100 = dark grey background
101 = light red background
102 = light green background
103 = yellow background
104 = light blue background
105 = light purple background
106 = turquoise background

6/11/2016

jQuery frequently used syntax

// Gets all tags in a div
$('#divId img')

Or if the div jQuery object is available
$div.find('img')

// Ajax calls. Don't use $.get or $.post because they don't have error handling
$.ajax();

// Gets attribute
$('#divid').attr('src')
$('#divid').attr('src', 'img.jpg')
$('#divid').attr('width')

// CSS
$('#divid').css('visibility', 'visible');
$('#divid').css('visibility', 'hidden');
$('#divid').css('left', '100px');
$('#divid').css('width', '100px');

// Gets/Sets the html
$('$divid').html()
$('$divid').html('')

// Gets the DOM element
$('#divid').get()  // an array of elements
$('#divid img').get(0)

// Change element class. NOT .attr('className', 'selected')
$('#divid').addClass('selected');
$('#divid').removeClass('selected');

// Add listener
$('#divid').on('click', function() {});
$('#divid').off('lick', function() {});
#(document).on('click', function() {});

// Creates a div
$('<div></div>').addClass('line').appendTo('body');

// Remove a div
$('#divid').remove();

// Select option
$('#selectid').append(new Option(text, value));

$('#selectid').val() to get the selected value.

6/02/2016

How to use javadoc

You need to cd to your package directory and then run command:

javadoc -d 
or
// to generate all packages
find . -type f -name "*.java" | xargs javadoc -d