• 2020-3-7

# How we manage icons in Rocket.Chat?

• 2020-3-6
1. Add a new SVG icon file into app/ui-master/public/icons folder
2. Run the automation script node ../generateSprite.js to generate icons.svg from those SVG files in the above folder. (the SVG's filename is exactly the icons' identifier)
3. In the meteor.startup callback function, using Asset.getText to download icons.svg file as plain text to the client first, and then with the help of injectIntoBody function to insert the entire content as raw text into the body.

Note: the generated icons.svg the file contains multiple icons, where we use the tag symbol as a delimiter.

# Remove default ABC input method on Mac

• 2020-3-5

## TL;DR

Delete the dict that represents the ABC method and it will take effect after rebooting the system.

# Vim & VSCode Advanced - Day 7

• 2020-3-4

## Vim

1. :tabo[nly] Close all tabs except the active one; :tabnew Create a new tab; :tabNext Move to the next tab; :tabprevious Move to the previous tab;
2. :pwd Print the current working directory
3. Use / search to move the sursor faster
4. Use relative line numbers.
5. :his[tory] to list command history
6. Text Obejcts: i/a/ys/cs + w/s/p/]/)/"/'/t
7. Parameterized Text Objects:
• f, F => "find" the next character
• t, T => up to the next character
• / => Search (up to the next character)

## Code

1. command+t Search symbol in the file
2. command+shift+t Search symbol in the workspace
3. command+b Show/Hide activity bar
4. ctrl+p Go to file
5. command+p Git: push changes to the remote

# Vim Advanced - Day 6

• 2020-3-3
1. C-n In the native Vim, we can use this shortcut to achieve keyword completion. But in the VSCodeVim the behavior is something different because completion is the killer feature equipped with VSCode that you don't need to type any extra keys to open completion window. So C-n here means toggling cursor among all available candidates.
2. The Vim supports scp protocol and you can use vim scp://aliyun/Downloads/app.js to edit app.js file under ~/Downloads directory in your remote aliyun machine.
3. Local Bookmarks Management
• :marks [a-zA-Z] List all bookmarks (or specified bookmarks only)
• m+a-z Create a local bookmark
• m+A-Z Create a global bookmark
• +a-zA-Z Jump to the bookmark
Combined with the powerful C-o (Jump backward the cursor's location) and C-i (Jump forward the cursor's location), we can move the cursor from place to place easily.

# Vim Advanced - Day 5

• 2020-3-2
1. g+i insert at the end of last change
2. Insert Mode: C-o command execute command and return to Insert Mode
3. g+J: like "J", but without inserting spaces
4. :reg {arg} show the contents of registers mentioned in {arg}, using spaces to separate multiple args
5. Y, g+g: yank N lines into a register
6. ]+p: like p, but adjust indent to current line
7. [+p: like P, but adjust indent to current line
8. g+p: like p, but leave cursor after the new text
9. g+P: like P, but leave cursor after the new text
10. u undo last change
11. C-r redo last change
12. U restore last changed line

# Vim Advanced - Day 4

• 2020-3-1
1. Number+| Jump to the column Number
2. Visual mode: o toggle cursor position between the beginning and the end of the highlighting
3. Visual mode: c-q or c-v enter visual-block mode
4. Visual mode: g+v start highlighting on previous visual area
5. Notice the key l. We always use this key to move right but forget another function that it has - It represents the character under cursor. That is to say, if you want to perform an operation on the char under cursor, we can use l to represent it. For instance, we can use y+s+l+surroundings enclose the char with the surroundings we provided.
6. g+m to the middle of the line

# Vim Advanced - Day 3

• 2020-2-29
1. g+a Show ASCII value of character under cursor
2. <+< Shift lines to left
3. >+> Shift lines to right
4. C-a Increase number under cursor
5. y+s+text-object+surrondings Enclose the text object with surroundings
6. c+s+text-object+old-surrondings+new-surrondings Change the surrondings of the text object
7. d+s+text-object+surrondings ReMove the surroundings of the text object
8. V enter visual line mode first; S+surrondings add surrondings linewise. (for instance, V C <p class='important'>)
9. Nouns: w: word; s: sentence; p: paragraph; t tag;
10. D Remove the text after the cursor of the current line, which is similar to C (C will also enter into insert mode)
11. * Search for other instances of the word under your cursor
12. ^ Move to the first non-blank character in the line, which is a little different from 0 (Move to the beginning of the line)

# How to redirect stdout/stderr to file?

• 2020-2-28

One common pattern that you perhaps saw before is using 2>&1, which means redirect stderr to stdout. Combined with it, we can use > or >> to redirect both stdout/stderr to some file.

Note: the different between > and >> is that > will overwrite the previous content of the file and >> will append the text at the bottom of the previous file.

## &>

The bash 4 gives you another option to finish the same task as we described before:

The above command will redirect both stdout and stderr to a file.

## Writes output both to the screen and a file

Sometimes we'd like to write the stdout/stderr to some file and keep the output on the screen at the time. What should we do in this situation?

One useful command that helps us to do this task is the tee. The tee command writes the output to the screen (stdout/stderr) and to the file in the meanwhile. For example:

The above command will print the current date on the scrren and save it the file.

One common need that we want to achieve is print the original output of the command to the screen and do some operations (for instance, we pass it as input to the sed to do the substitution).

The below example will writes the output of the first command and remove the color codes (eg. [39m) using sed and then save the substituted one to the file:

PS: The native sed command in the BSD systems (eg. MacOS) do not support -u option, which will force the output to be line buffered. A more detailed explanation of this option is appended below:

sed -u: Force output to be line buffered, printing each line as it becomes available. By default, output is line buffered when standard output is a terminal and block buffered otherwise. See setbuf(3) for a more detailed explanation.

PSS: -r option of sed` is aimed to use extended regular expression syntax.