Virtual - Technology & Digital World
This section covers all technology-related knowledge: development tools, programming languages, system administration, and digital infrastructure.
Contents
Development Tools
- Editor - Vim/Neovim and VSCode configuration & usage
- Git - Version control workflows and best practices
Programming Languages
System Administration & DevOps
- Linux - System administration and command line
- CentOS - CentOS-specific setup and configuration
- S3 - AWS S3 and cloud storage solutions
- Telegram - Bot development and automation
Philosophy
The "virtual" world encompasses all digital technologies, tools, and systems that exist in software and networks. This includes everything from text editors and programming languages to cloud infrastructure and automation tools.
Development
Editor Configuration & Usage
This guide covers setup and usage for various editors, primarily focusing on Vim/Neovim with VSCode as an alternative.
Vim/Neovim Setup
Installation
Amazon Linux 3
sudo yum groups install -y Development\ tools
sudo yum install -y cmake python34-{devel,pip}
sudo pip-3.4 install neovim --upgrade
(
cd "$(mktemp -d)"
git clone https://github.com/neovim/neovim.git
cd neovim
make CMAKE_BUILD_TYPE=Release
sudo make install
)
Amazon Linux 2
sudo yum install openssl-devel
wget https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4.tar.gz
tar -xvzf cmake-3.31.4.tar.gz
cd cmake-3.31.4
./bootstrap && make && sudo make install
export PATH="/usr/local/bin:$PATH"
git clone https://github.com/neovim/neovim
cd neovim
git checkout stable
make CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make install
Configuration
Basic Vim with Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Basic ~/.vimrc
:
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'google/vim-colorscheme-primary'
Plugin 'vim-airline/vim-airline'
call vundle#end()
filetype plugin indent on
" Navigation shortcuts
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
nmap <C-n> :NERDTree<CR>
nmap <C-p> :CtrlP<CR>
" Appearance
syntax on
set t_Co=256
set background=dark
colorscheme primary
set number
LazyVim
- Add Rust support: run
:LazyExtra
- Check missed notifications:
:messages
- Close buffer:
<leader>bd
(where<leader>
is space) - Jump to function:
<leader>ss
- Navigation:
<c-o>
,<c-i>
,gd
Essential Operations
Basic Commands
Mode | Command | Description |
---|---|---|
Normal | i / a | Insert before/after cursor |
Normal | v | Visual mode |
Any | <ESC> | Return to normal mode |
Copy/Paste/Delete
Command | Description |
---|---|
yy | Copy whole line |
yaw | Copy all word |
2yy | Copy next 2 lines |
p / P | Paste after/before |
2dd | Delete next 2 lines |
"+ | System clipboard register |
Window & Buffer Management
Command | Description |
---|---|
:ls | List buffers |
:b N | Go to buffer N |
C-w s/v | Split window horizontally/vertically |
C-w c | Close current window |
C-w o | Close all other windows |
C-w = | Make all windows equal size |
C-w T | Move window to new tab |
gt | Next tab |
:tabc | Close current tab |
Navigation
Command | Description |
---|---|
:e %:h[TAB] | Edit from current file's directory |
C-o / C-i | Navigate jump list backward/forward |
:ju | Show jump list |
gd | Go to definition (LazyVim) |
VSCode Configuration
Rust Integration
Update settings.json
:
{
"rust-analyzer.server.path": "/Users/lky/.cargo/bin/rust-analyzer"
}
Quick Reference
Getting Started
- Hit
<ESC>
when confused - Use
i
to insert,<ESC>
to navigate - Basic workflow: navigate → edit → save → repeat
Essential Help
:h [command]
- Show help for command:q
- Quit:w
- Save:wq
- Save and quit
References
git
Local auth
The easiest way to avoid creating a token.
brew install gh
gh auth login
Branches
description | command |
---|---|
checkout branch | git checkout <branch name> |
create branch | git branch <branch name> |
remove local branch | git branch -D <branch name> |
remove remote branch | git push origin --delete <branch name> |
list branch | git branch |
sync local branch to remote origin/main | git fetch origin && git merge origin/main |
Commits
description | command |
---|---|
take the most recent commit and add new staged change to it | git commit --amend |
remove all untracked files including ignored | git clean --fdx |
uncommit change but keep files | git reset --soft HEAD^ |
remove all untracked files | git restore . |
move head to a commit and discard changes after | git reset --hard <COMMIT_ID> |
force syncing remote to local | git push --force |
rebase to main | git checkout main && git pull && git checkout <FEATURE> && git rebase main |
merge to main | use sqash and merge |
Files
description | command |
---|---|
move changes to stash | git stash |
move changes out of stash | git stash pop |
revert a file to its state in main | git checkout origin/main [filename] |
Misc
description | command |
---|---|
pretty log | git log --all --decorate --oneline --graph |
emoji | https://gitmoji.dev/ |
Programming
Rust
References
Tokio
Q n A
- What does
Send
mean?Send
means that when.await
suspends the thread, the result can be moved to another thread (the caller thread).Rc
is a type that cannot beSend
.Sync
means a type can be concurrently accessed through immutable references.Cell
isSend
but notSync
because it can be modified through an immutable reference. - What's the benefit of
bytes::Bytes
overVec<u8>
?clone()
onBytes
does not clone the data. It is roughly anArc<Vec<u8>>
. - Difference between sync mutex
std::sync::Mutex
and async mutexttokio::sync::Mutex
? Sync mutex will block current thread while waiting but async mutex won't. - The problem with sync mutex is that when multiple threads are contending (i.e. competing) for a mutex, only one will be working while others are all waiting. To solve this problem:
- Switching to a dedicated task to manage state and use message passing
- shard the mutex
- restructure code to avoid mutex
- Sending with oneshot channel does not require await. Result of success or failure is known immediately.
- rust async functions are state machines. It will check the contained future's
poll()
and decide if go to the next state, or check back later.
Stream
Follow this tutorial to learn how to create a stream. Especially the implementation of into_stream()
Trait
Blanket implementations
implementations of a trait on any type that satisfies the trait bounds are called blanket implementations and are use extensively in the rust standard library. For example, the standard library implements the ToString
trait on any type that implements the Display
trait. The impl
block in the standard library looks similar to this code:
#![allow(unused)] fn main() { impl <T: Display> ToString for T {} }
System
Linux
Linux commands. From the book of A Practical Guild to Linux Commands, Editors and Shells.
stdio
File descriptor 0 (stdin), 1 (stdout), 2 (stderr).
>
is short for1>
, meaning redirecting standard output.<
is short for0<
redirects standard input.2>
redirects stardard error.
Example
$ cat y
This is y
$ cat x
cat: x: No such file or directory
$ cat x y
This is y
cat: x: No such file or directory
pipe only sends stdout not stderr
$ cat x y | tr "[a-z]" "[A-Z]"
cat: x: No such file or directory
THIS IS Y
In the next example, 1>
redirects stdout to hold, then 2>&1
declares file descriptor 2 to be a duplicate of file descriptor 1, so both stdout and stderr are redirected to hold. Notice that 1>
should happen first.
$ cat x y 1> hold 2>&1
$ cat hold
cat: x: No such file or directory
This is y
In the next example, 2>&1
means also send stderr to stdout. Then pipes stdout to tr
$ cat x y 2>&1 | tr "[a-z]" "[A-Z]"
CAT: X: NO SUCH FILE OR DIRECTORY
THIS IS Y
2>&1 |
can be shortened as |&
pipe |
- tunnels the output (stdout only) of left to right.
Example:
$ cat abstract
cab
$ cat abstract | tr abc ABC
CAB
$ tr abc ABC < abstract
CAB
&&
and ||
, cmd1 && cmd2
means run cmd2
if cmd1
succeeds. cmd1 || cmd2
means run cmd2
if cmd1
fails.
adding &
means running the command in the background.
kill
can kill a job with PID or job number.
$ ps
11829 pts/10
$ kill 11829
$ jobs
[1]
$ kill %1
Bash
./whoson
the ./
tells the shell to look for an executable file in the working dir.
#!/bin/bash
tells the system which shell to use. #!
is called hashbang or shebang
-e
will cause bash to exit when command fails. -u
will cause bash to display a message and exit when it tries to expand an unset variable.
d & e & f
will run d
and e
in the background and run f
in the foreground.
[1]- Done d
[2]+ Done e
The +
means it's the last job. -
means it's the job before the last one.
Setup CentOS machine (AWS Amazon Linux 2023)
Installations
-
zsh
sudo yum install zsh
- set zsh as default by editing
/etc/passwd
sudo yum install git
- install OhMyZsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
- install PowerLevel10k:
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
- change theme to it in
~/.zshrc
:ZSH_THEME="powerlevel10k/powerlevel10k"
source ~/.zshrc
- install zsh-autosuggestions: ref
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
- install zsh-syntax-highlighting: ref
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
-
tmux
git clone https://github.com/gpakosz/.tmux.git ~/.tmux
ln -s ~/.tmux/.tmux.conf ~/.tmux.conf
- add to zshrc:
work() { tmux new-session -A -s ${1:-work}; }
# ~/.tmux.conf
# make delay shorter
set -sg escape-time 0
### key bindings ###
bind r source-file ~/.tmux.conf \; display ".tmux.conf reloaded!"
# quickly open a new window
bind N new-window
# synchronize all panes in a window
bind y setw synchronize-panes
# pane movement shortcuts
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# enable mouse support for switching panes/windows
set -g mouse on
#### copy mode : vim ####
# set vi mode for copy mode
setw -g mode-keys vi
# copy mode using 'Esc'
unbind [
bind Escape copy-mode
# paste using 'p'
unbind p
bind p paste-buffer
set-option -g default-shell "/bin/zsh"
-
github
curl -Lo gh-cli.rpm https://github.com/cli/cli/releases/download/v2.30.0/gh_2.30.0_linux_arm64.rpm
sudo yum install -y ./gh-cli.rpm
-
docker
sudo dnf update -y
sudo dnf install -y docker
sudo systemctl enable docker
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
1. mosh
# Install dependencies
sudo yum groupinstall "Development Tools" -y
sudo yum install openssl-devel protobuf-devel ncurses-devel zlib-devel perl cmake -y
# Download and build Mosh
curl -L -O https://github.com/mobile-shell/mosh/releases/download/mosh-1.3.2/mosh-1.3.2.tar.gz
tar -xzf mosh-1.3.2.tar.gz
cd mosh-1.3.2
./configure
make
sudo make install
S3 + Remote File System
S3
To keep S3 in sync with local fs, use the AWS CLI. For example, we have a s3 directory s3://s3-yoshi/kongming_snapshot
. Then run this command to sync.
aws s3 sync s3://s3-yoshi/kongming_snapshot ~/kongming_snapshot
Before this, acquire the key and secret by clicking user name on the top right corner in AWS console, and select credentials. Then add them as env var in .zshrc
.
export AWS_ACCESS_KEY_ID=<ID> && export AWS_SECRET_ACCESS_KEY=<KEY>
Remote desktop
- In mac, the mounted external drive is in
/Volumes
directory. Then go to settings, general, and choose to share the external drive. - In the client machine, right click on finders, select "connect to server" and pick the shared directory. This directory will show up under
/Volumes/
then.
Telegram
How to create a bot and send messages to group
- create a bot use BotFather, get the bot token
- create a group and add
Get ID Bot
- send a message in the group chat with
\my_id @<BOT_NAME>
, there will be aYour Group Chat ID: <GOURP_CHAT_ID>
. - use the bot token and group chat id to send messages to the group
Real - Physical World & Human Knowledge
This section covers knowledge about the physical world, human learning, and real-world domains.
Contents
Learning & Methods
- Learning Techniques - Effective learning methodologies and study techniques
Professional Knowledge
Philosophy
The "real" world encompasses physical phenomena, human biology and psychology, learning processes, and knowledge that applies to tangible, real-world situations. This includes learning methodologies, medical knowledge, and other domains rooted in physical reality.
Methodology
Talks about how to do things effectively.
Work
-
Focus - Eliminate distractions:
- Keep a clean desk with minimal items
- Use fewer tools to avoid context switching
- Find quiet spaces away from notifications and conversations
- Avoid multi-tasking
- Block 1-2 hours for focused work, then take breaks
-
Energy Management - Identify your peak hours when you're most alert (typically 2-4 hours after waking) and schedule demanding work during these times. Work in 90-120 minute cycles with 15-20 minute breaks to match your natural energy rhythms.
-
Reflection - Periodically improve the process by reprioritizing work and finding ways to further improve efficiency.
Learn
Four key steps to learn a technique.
- Select a concept and map your knowledge
- Teach it to a 12-year-old
- Review and refine
- Test and archive
Step 1 Select a concept and map your knowledge
Start with a blank page. Write everything you know about your chosen topic.
Explain it to a 12-year-old
Review and refine
When you find weak spots, return to the source material. Study those sections until you can explain them simply.
Test and Archive
Test your understanding by teaching someone else. Once satisfied, archive your simple explanation in a learning binder for periodic review.
Medical
Central Retinal Vein Obstruction
Terminologies
-
edema: swelling due to fluid buildup
-
Etiology: the cause or origin of disease or condition
-
ischemic: ischemic refers to a condition caused by restricted blood flow to a part of the body, usually due to blockage in blood vessels. This lack of blood flow reduces oxygen supply to tissues, which can lead to damage or dysfunction.
-
macula: The macula is the cental part of the retina, located at the back of the eye. It is responsible for sharp, detailed central vision and color perception. The macula contains a high concentration of cone photoreceptor cells, which help in recognizing fine details, such as reading, recognizing faces and seeing colors vividly.
Epidemology and Etiology
Pathophysiology
Important Clinical Signs
Differential Diagnosis
Diagnostic Evaluation
-
Intravenous fluorescein angiography: This is to inject fluorescein dye into a vein, which then travels to the blood vessels in the retina. Normally the dye fills the arteries first, then veins without delay. A delay in retinal venous filling sugests an issue with blood flow through the veins, which is commonly seen in conditions like CRVO. Intra-retinal leakage of dye means that the blood vessels are leaking fluid into the retina, which is a sign of vascular damage or breakdown of the blood-retinal barrier.
-
OCT: reveals the presence or absense of macular edema. PAMM (paracentral accute middle maculopathy, a specific OCT finding that indicates ischemia affecting the deep capillary plexus) is a sign of retinal ischemia.
Stories 📚
真实世界中的故事与人生感悟
关于这个分类
这里收录了各种有趣的故事、历史典故和人生感悟。通过故事的形式,我们可以更好地理解历史、人性和社会现象。
故事特色
- 历史重现:用现代视角重新诠释历史事件
- 人性思考:通过故事探讨人性的复杂与美好
- 现实映射:古代故事与现代生活的巧妙对比
- 幽默风趣:用轻松的语言讲述深刻的道理
阅读体验
每个故事都经过精心整理,采用:
- 🎭 分幕结构:清晰的章节划分
- 💡 现代元素:贴近当代的表达方式
- 🎯 深度思考:故事背后的人生哲理
- 📖 易读性:适合各种场景阅读
"故事是人类最古老的学习方式,也是最温暖的传承载体。"