Pane

  • spilt horizontally: Ctrl-b %
  • split vertically: Ctrl-b "
  • navigate between panes: Ctrl-b <arrow key>
  • close: Ctrl-d
  • make a pane go full screen: Ctrl-b z
  • shrink it back to its previous size: Ctrl-b z again
  • resize pane in direction: Ctrl-b esc-<arrow key>

Window

  • create new window: Ctrl-b c
  • navigate: Ctrl-b p / Ctrl-b n / Ctrl-b <number>
  • close: Ctrl-d
  • rename: Ctrl-b ,

Read More

This article is about the process of defining archiecture, components, modules, interfaces and data for a system to satisfy specified requirement, the structure mainly used for system design interview.

Clarify the problem (Scenario)

Clarify the problem or in another word, scenarios and use cases (include corner cases).
Below is an example for a video streaming service:

  • Register/log in, play video, or video recommendation
  • Prioritize all the scenarios and deep dive into it.
  • Play video
    • (1) Generate channel
    • (2) Get all videos in the channel
    • (3) Play videos in the channel

Requirements include functional and non-functional requirements. non-functional requirements includes: scalability, performance, availability, security.

Due to the limit of time, we should prioritize and identify which ones are critical. and for non-functional, we could discuss some trade-offs. For example, a system highly optimized for read operations might have slower write operations.

Read More

There is a template for binary search, by using which you do not need to think too much about the boundary and how to narrow down the interval / how to calculate mid value.

1
2
3
4
5
6
7
8
9
10
11
// check null …
int s = 0, e = array.size() - 1;
while (s + 1 < e) {
int mid = s + ((e - s) >> 1);
if (array[mid] == target) { ... }
if (array[mid] > target) { e = mid; }
else { s = mid; }
}
// check value
if (array[s] == target) { ... }
else if (array[e] == target) { ... }

Compared with normal binary search, the difference is that it cannot find the optimum value at while loop, instead, it sustains two possible value, and then check them after loop.

Read More

  1. Install HomeBrew

    1
    ruby -e "$(curl --insecure -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. brew install mysql

  3. Start mysql service: mysql.server start

  4. Set password: mysql_secure_installation

  5. Login: mysql -u root -p

Install scala

  1. Download scala-X.XX.tgz from the official site.
  2. Unzip archive and move it to /usr/local folder
    If you step into ./bin folder, you could use ./scala to run it.
  3. Open your .bash_profile file :
    sudo nano ~/.bash_profile
  4. Add scala/bin folder to your PATH
    export PATH=/usr/local/scala/bin:$PATH
    Control + X to save and restart.
  5. Check successful by typing Scala in terminal
    If you see below, then Scala is successfully installed.
    1
    2
    Welcome to Scala 2.12.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_121).
    Type in expressions for evaluation. Or try :help.

Read More