This is reading notes on Professional C++ by Marc Gregoire.

  1. In switch statement, expression must be integer type.
    1. Why can’t be string? Because C++ does not recognize string as a type. Ref:
  2. Array initialization
    1. in C style:
      1. int myArray[3] = {0}; // all 0
      2. int myArray[3] = {1}; // first 1, other two 0
      3. int myArray[] = {0,1,2}; // an array of 3 elements, [0;1;2]
    2. in C++ style:
      1. array<int, 3> myArray = {0, 1, 2}
    3. For array of variable length, use vector
  3. Range-based for loop
    1. for (int i : myArray)
  4. __func__ is implicitly declared (i.e. can be used as function name directly inside of a function) as:
    1. static const char __func__[] = “func-name”;
  5. Alternative function syntax (with trailing return type):
    1. auto func(int i) -> int // {…}
  6. Function return type deduction (use compiler to figure out return type)
    1. auto func(int i) // {…}
    2. all returns should resolve to the same type
    3. in recursive calls, first return must be non-recursive
  7. Type inference
    1. by auto:
      1. auto result = func();
    2. by decltype:
      1. int x = 1; decltype(x) y = 2;
  8. const int i = 1 is not equal to #define i 1
  9. int *j; later *j is called “dereference”
  10. C++ coding style:
  11. Better only use static_cast (according to Ira Pohl)

If you don’t want fields such as “[Online]”, “Available: …” appear in IEEEtran bibliography items:

1. Go to installation folder of IEEEtan bst.
(on my Mac OS with Texlive, the folder is /usr/local/texlive/2016/texmf-dist/bibtex/bst/IEEEtran)

2. Backup and then edit IEEEtran.bst, search “FUNCTION XXX” (XXX could be “inproceedings”, “inbook”, etc.), and comment out “format.url output”

3. run “texhash”

4. recompile .bib and .tex files.



1. Smooth nonlinearities:
(tf.nn.)sigmoid, tanh, elu, softplus, softsign

2. Continuous but not everywhere differentiable:
(tf.nn.)relu, relu6

3. Random regularization:

e.g. for tf.contrib.learn.DNNClassifier, the default activation function in __init__ is relu:

__init__( ..., activation_fn=tf.nn.relu, ...)


1. Multiple level APIs:
(1) lowest level: TensorFlow Core, if you need fine controls on the model
(2) higher levels: built on Core, easier to use, e.g. tf.contrib.learn

2. Tensor: an array of primitive values. Rank: how many dimensions. Shape: a vector, containing the numbers of elements in each dimension.
e.g. [[[1., 2., 3.]], [[7., 8., 9.]]] has rank 3, shape [2,1,3]

3. Import library

import tensorflow as tf

Continue reading

If there is “Error connecting to database” error, and the access.log file is huge (several GB), and there are many “POST /xmlrpc.php” or “POST /wp-login.php” in it, it’s brute force attack.

How to stop it?

I. Use password to protect wp-login.php

1. Generate file ./htpasswd, e.g. use, put it in folder (e.g. /var/www)
Note: could use the following command to generate random password first

openssl rand -base64 6

2. Add the following code in .htaccess under where the wp-login.php is (usually the root folder of WordPress installation)

# Stop Apache from serving .ht* files
<Files ~ "^\.ht">
Order allow,deny
Deny from all

# Protect wp-login
<Files wp-login.php>
AuthUserFile [ABSOLUTE PATH]/.htpasswd
AuthName "Private access"
AuthType Basic

Reference: Brute Force Attacks on

II. Stop access to xmlrpc.php

If xmlrpc is not used, just block access to it. In .htaccess file, add

<Files xmlrpc.php>
order deny,allow
deny from all

The following steps work on Ubuntu 16.04.

1. Get source from

2. Install Android SDK 23, SDK Build-tools 23.0.1, Android Support Repository


4. In root folder, execute (note: if need to build modified code, first comment out the git part)


5. If error “Could not find autoconf 2.13”, install autoconf-2.13 from source. e.g. on Ubuntu 16.04:

tar -xvzf autoconf-2.13.tar.gz
cd autoconf-2.13/
./configure --program-suffix=2.13
sudo make install'

6. If error “ccache not found”,

apt-get install ccache