Several times after I force-restart my Mac (recently in High Sierra), I found Safari lost all its saved passwords. It seems the Mac loses the keychain containing these passwords. The solution may be simple:
Go to System Preferences -> iCloud, if “Keychain” is unchecked, check it. Then all passwords should be accessible in Safari again.

This method is learned from

(change count=1024 for the size you need)

sudo -s
swapoff -a
dd if=/dev/zero of=/swapfile bs=1M count=1024
chmod 0600 /swapfile
mkswap /swapfile
swapon /swapfile

I upgraded my TS140 with new motherboard (B250), CPU (i7-7700K), power supply, and cooler. Here are some notes:

1. Standard MicroATX MB can be installed perfectly.

2. To conveniently connect SATA cables, it’s better to choose a MB with upward (instead of sideward) SATA connectors.

3. To connect the power front panel on TS140, refer to:
(1) the pins for TS140:
(2) the system panel connector (F_PANEL) on your new MB.

4. If using tower cooler, be careful of the total height. I use one with 125mm height.

  1. Download intellij-java-google-style.xml from GitHub:
  2. On Mac, IntelliJ Preferences -> Editor -> Code Style -> Java -> (Click “Gear” icon) -> Import Scheme -> Import IDEA code style XML

  1. Disable “duplicated code” detection
    • Settings → Editor → Inspections → General → Duplicated Code
    • (Or better) in the source code, use @SuppressWarnings(“Duplicates”)
    • Ref.: stackoverflow
  2. Show source file structure
    1. From menu: “View” -> “Tool Windows” -> “Structure”
    2. Quick key: CMD + 7
  3. Reformat all codes under a folder: in Project view, select the folder, then Code -> Reformat Code

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)