Distributed Systems

1. Overview A distributed system is one in which the failure of a coumputer you didn’t even know existed can render your own computer unusable. UCB 团队在 2009 年发表的论文 Above the Clouds: A Berkeley View of Cloud Computing,预测了云计算机的价值、演进和普及的进程;而 2019 年的论文 Cloud Programming Simplified: A Berkeley View on Serverless Computing,则提出了一种新的猜测:“无服务会发展成未来云计算的主要形式”,无服务架构下的用户不再需要关心细节,而极大解放生产力。 ...

Apr 05, 2023 · 33 min · Jiancong Zhu

Dotfiles

oh-my-zsh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 # ~/.zshrc #brew install --cask font-jetbrains-mono-nerd-font If you come from bash you might have to change your $PATH. # export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH # Path to your Oh My Zsh installation. export ZSH="$HOME/.oh-my-zsh" # Set name of the theme to load --- if set to "random", it will # load a random theme each time Oh My Zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes ZSH_THEME="robbyrussell" # Set list of themes to pick from when loading at random # Setting this variable when ZSH_THEME=random will cause zsh to load # a theme from this variable instead of looking in $ZSH/themes/ # If set to an empty array, this variable will have no effect. # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) # Uncomment the following line to use case-sensitive completion. # CASE_SENSITIVE="true" # Uncomment the following line to use hyphen-insensitive completion. # Case-sensitive completion must be off. _ and - will be interchangeable. # HYPHEN_INSENSITIVE="true" # Uncomment one of the following lines to change the auto-update behavior zstyle ':omz:update' mode disabled # disable automatic updates # zstyle ':omz:update' mode auto # update automatically without asking # zstyle ':omz:update' mode reminder # just remind me to update when it's time # Uncomment the following line to change how often to auto-update (in days). # zstyle ':omz:update' frequency 13 # Uncomment the following line if pasting URLs and other text is messed up. # DISABLE_MAGIC_FUNCTIONS="true" # Uncomment the following line to disable colors in ls. # DISABLE_LS_COLORS="true" # Uncomment the following line to disable auto-setting terminal title. DISABLE_AUTO_TITLE="true" # Uncomment the following line to enable command auto-correction. # ENABLE_CORRECTION="true" # Uncomment the following line to display red dots whilst waiting for completion. # You can also set it to another string to have that shown instead of the default red dots. # e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" # Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) # COMPLETION_WAITING_DOTS="true" # Uncomment the following line if you want to disable marking untracked files # under VCS as dirty. This makes repository status check for large repositories # much, much faster. # DISABLE_UNTRACKED_FILES_DIRTY="true" # Uncomment the following line if you want to change the command execution time # stamp shown in the history command output. # You can set one of the optional three formats: # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" # or set a custom format using the strftime function format specifications, # see 'man strftime' for details. # HIST_STAMPS="mm/dd/yyyy" # Would you like to use another custom folder than $ZSH/custom? # ZSH_CUSTOM=/path/to/new-custom-folder # Which plugins would you like to load? # Standard plugins can be found in $ZSH/plugins/ # Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. plugins=( git zsh-autosuggestions zsh-syntax-highlighting ) source $ZSH/oh-my-zsh.sh # User configuration # export MANPATH="/usr/local/man:$MANPATH" # You may need to manually set your language environment # export LANG=en_US.UTF-8 # Preferred editor for local and remote sessions # if [[ -n $SSH_CONNECTION ]]; then # export EDITOR='vim' # else # export EDITOR='nvim' # fi # Compilation flags # export ARCHFLAGS="-arch $(uname -m)" # Set personal aliases, overriding those provided by Oh My Zsh libs, # plugins, and themes. Aliases can be placed here, though Oh My Zsh # users are encouraged to define aliases within a top-level file in # the $ZSH_CUSTOM folder, with .zsh extension. Examples: # - $ZSH_CUSTOM/aliases.zsh # - $ZSH_CUSTOM/macos.zsh # For a full list of active aliases, run `alias`. # # Example aliases # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" export LANG="en_US.UTF-8" export LC_ALL="en_US.UTF-8" alias l="eza -Hlahb --git" alias ll="eza -Hlahb --git" eval "$(/opt/homebrew/bin/brew shellenv)" # Canonical hex dump; some systems have this symlinked command -v hd > /dev/null || alias hd="hexdump -C" # macOS has no `md5sum`, so use `md5` as a fallback command -v md5sum > /dev/null || alias md5sum="md5" # macOS has no `sha1sum`, so use `shasum` as a fallback command -v sha1sum > /dev/null || alias sha1sum="shasum" # Recursively delete `.DS_Store` files alias cleanup="find . -type f -name '*.DS_Store' -ls -delete" # Print each PATH entry on a separate line alias path='echo -e ${PATH//:/\\n}' # Extract archives -- usage: extract <file> function extract () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar e $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip "$1" ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; *) echo "'$1' cannot be extracted via extract()" ;; esac else echo "'$1' is not a valid file" fi } export HOMEBREW_NO_AUTO_UPDATE=1 export ZSH_WAKATIME_PROJECT_DETECTION=true alias uvs="source .venv/bin/activate" alias uvv="uv venv --python 3.12" alias uvi="uv init" alias uva="uv add" alias uvf="uvx ruff format" alias uvp="ux pip" alias python="python3" alias pip="pip3" # Make vim the default editor. export EDITOR='vim' alias vi="nvim" alias vim="nvim" # Enable persistent REPL history for `node`. export NODE_REPL_HISTORY=~/.node_history; # Allow 32³ entries; the default is 1000. export NODE_REPL_HISTORY_SIZE='32768'; # Use sloppy mode by default, matching web browsers. export NODE_REPL_MODE='sloppy'; # Make Python use UTF-8 encoding for output to stdin, stdout, and stderr. export PYTHONIOENCODING='UTF-8'; # Highlight section titles in manual pages. export LESS_TERMCAP_md="${yellow}"; # Don’t clear the screen after quitting a manual page. #export MANPAGER='less -X'; export MANPAGER="sh -c 'awk '\''{ gsub(/\x1B\[[0-9;]*m/, \"\", \$0); gsub(/.\x08/, \"\", \$0); print }'\'' | bat -p -lman'" # Avoid issues with `gpg` as installed via Homebrew. # https://stackoverflow.com/a/42265848/96656 export GPG_TTY=$(tty); # Hide the “default interactive shell is now zsh” warning on macOS. export BASH_SILENCE_DEPRECATION_WARNING=1; export PATH=$PATH:/Users/zjc/.local/bin eval "$(zoxide init --cmd cd zsh)" eval "$(starship init zsh)" eval "$(atuin init zsh --disable-up-arrow)" Alacritty 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 # ~/.config/alacritty/alacritty.toml [colors] draw_bold_text_with_bright_colors = true [[keyboard.bindings]] chars = "\u0002," key = "Comma" mods = "Command" [[keyboard.bindings]] chars = "\u0002s" key = "K" mods = "Command" [[keyboard.bindings]] chars = "\u00021" key = "Key1" mods = "Command" [[keyboard.bindings]] chars = "\u00022" key = "Key2" mods = "Command" [[keyboard.bindings]] chars = "\u00023" key = "Key3" mods = "Command" [[keyboard.bindings]] chars = "\u00024" key = "Key4" mods = "Command" [[keyboard.bindings]] chars = "\u00025" key = "Key5" mods = "Command" [[keyboard.bindings]] chars = "\u00026" key = "Key6" mods = "Command" [[keyboard.bindings]] chars = "\u00027" key = "Key7" mods = "Command" [[keyboard.bindings]] chars = "\u00028" key = "Key8" mods = "Command" [[keyboard.bindings]] chars = "\u00029" key = "Key9" mods = "Command" [[keyboard.bindings]] chars = "\u00020" key = "Key0" mods = "Command" [[keyboard.bindings]] chars = "\u0002L" key = "L" mods = "Command" [[keyboard.bindings]] chars = "\u0002[" key = "LBracket" mods = "Command" [[keyboard.bindings]] chars = "\u0002p" key = "LBracket" mods = "Command|Shift" [[keyboard.bindings]] chars = "\u0002%" key = "D" mods = "Command" [[keyboard.bindings]] chars = "\u0002\"" key = "D" mods = "Command|Shift" [[keyboard.bindings]] chars = "\u0002d" key = "W" mods = "Command|Shift" [[keyboard.bindings]] chars = "\u0002n" key = "RBracket" mods = "Command|Shift" [[keyboard.bindings]] chars = """ \u001B:w """ key = "S" mods = "Command" [[keyboard.bindings]] chars = "\u0002c" key = "T" mods = "Command" [[keyboard.bindings]] chars = "\u0002!" key = "T" mods = "Command|Shift" [[keyboard.bindings]] chars = "\u0002x" key = "X" mods = "Command" [[keyboard.bindings]] chars = "\u0002z" key = "Z" mods = "Command" [[keyboard.bindings]] chars = "\u0002\u001B[D" key = "Left" mods = "Command" [[keyboard.bindings]] chars = "\u0002\u001B[C" key = "Right" mods = "Command" [[keyboard.bindings]] chars = "\u0002\u001B[B" key = "Down" mods = "Command" [[keyboard.bindings]] chars = "\u0002\u001B[A" key = "Up" mods = "Command" [[keyboard.bindings]] action = "ScrollPageUp" key = "PageUp" mode = "~Alt" mods = "Shift" [[keyboard.bindings]] action = "ScrollPageDown" key = "PageDown" mode = "~Alt" mods = "Shift" [[keyboard.bindings]] action = "ScrollToTop" key = "Home" mode = "~Alt" mods = "Shift" [[keyboard.bindings]] action = "ScrollToBottom" key = "End" mode = "~Alt" mods = "Shift" [general] live_config_reload = true [terminal] [colors.bright] black = "0x676767" blue = "0x6871ff" cyan = "0x5ffdff" green = "0x78e364" magenta = "0xff76ff" red = "0xe4544e" white = "0xd0d0d0" yellow = "0xe5e152" [colors.cursor] cursor = "0xfffefe" text = "0xc7c7c7" [colors.normal] black = "0x000000" blue = "0x0225c7" cyan = "0x00c5c7" green = "0x00c200" magenta = "0xc930c7" red = "0xcf2004" white = "0xc7c7c7" yellow = "0xc7c400" [colors.primary] background = "0x000000" foreground = "0xc7c7c7" [cursor.style] blinking = "On" shape = "Beam" [cursor.vi_mode_style] shape = "Beam" [env] TERM = "xterm-256color" [font] size = 14.0 [font.normal] family = "JetBrainsMono Nerd Font Mono" style = "Regular" [scrolling] history = 100000 multiplier = 3 [selection] save_to_clipboard = false semantic_escape_chars = ''',│`|:"' ()[]{}<> ''' [terminal.shell] args = ["new-session", "-A", "-D", "-s", "main"] program = "/opt/homebrew/bin/tmux" [window] decorations = "full" decorations_theme_variant = "Dark" dynamic_padding = true dynamic_title = true opacity = 0.97 title = "Alacritty" [window.dimensions] columns = 120 lines = 34 [keyboard] Starship 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 # ~/.config/starship.toml format = """ [░▒▓](#a3aed2)\ [  ](bg:#a3aed2 fg:#090c0c)\ [](bg:#769ff0 fg:#a3aed2)\ $directory\ [](fg:#769ff0 bg:#394260)\ $git_branch\ $git_status\ [](fg:#394260 bg:#212736)\ $kubernetes\ $c\ $cmake\ $golang\ $python\ $nodejs\ $rust\ $java\ $conda\ $direnv\ $env_var\ $sudo\ $jobs\ $battery\ $status\ $cmd_duration\ [](fg:#212736 bg:#1d2230)\ $time\ [ ](fg:#1d2230)\ \n$character""" [directory] style = "fg:#e3e5e5 bg:#769ff0" format = "[ $path ]($style)" truncation_length = 3 #truncation_symbol = "…/" [directory.substitutions] "Documents" = "󰈙 " "Downloads" = " " "Music" = " " "Pictures" = " " [git_branch] symbol = "" style = "bg:#394260" format = '[[ $symbol $branch ](fg:#769ff0 bg:#394260)]($style)' [git_status] style = "bg:#394260" format = '[[($all_status$ahead_behind )](fg:#769ff0 bg:#394260)]($style)' # format = '([$all_status$ahead_behind]($style))' conflicted = '🏳' ahead = '🏎💨' behind = '😪' diverged = '😵' up_to_date = '✅' untracked = '😞' stashed = '📦' modified = '📝' staged = '++\($count\)' renamed = '👅' deleted = '🗑 ' [nodejs] symbol = "" style = "bg:#212736" format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)' [rust] symbol = "" style = "bg:#212736" format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)' [golang] symbol = "" style = "bg:#212736" format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)' [php] symbol = "" style = "bg:#212736" format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)' [time] disabled = false time_format = "%R" # Hour:Minute Format style = "bg:#1d2230" format = '[[  $time ](fg:#a0a9cb bg:#1d2230)]($style)' [line_break] disabled = false [username] show_always = true style_user = "bg:#2e3440" style_root = "bg:#9A348E" format = '[$user]($style)' disabled = false [os] style = "bg:#9A348E" disabled = true # Disabled by default [c] symbol = " " style = "bg:#212736" format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)' [python] symbol = " " style = "bg:#212736" format = '[[ ${symbol}${pyenv_prefix}(${version})(\($virtualenv\)) ](fg:#769ff0 bg:#212736)]($style)' # format = '\[[${symbol}${pyenv_prefix}(${version})(\($virtualenv\))]($style)\]' [docker_context] symbol = " " style = "bg:#5e81ac" format = '[ $symbol $context ]($style) $path' [elixir] symbol = " " style = "bg:#212736" format = '[ $symbol ($version) ]($style)' [elm] symbol = " " style = "bg:#212736" format = '[ $symbol ($version) ]($style)' [haskell] symbol = " " style = "bg:#212736" format = '[ $symbol ($version) ]($style)' [java] symbol = " " style = "bg:#212736" format = '[ $symbol ($version) ]($style)' [julia] symbol = " " style = "bg:#212736" format = '[ $symbol ($version) ]($style)' [nim] symbol = " " style = "bg:#212736" format = '[ $symbol ($version) ]($style)' [scala] symbol = " " style = "bg:#212736" format = '[ $symbol ($version) ]($style)' [character] # success_symbol = '[ ➜](#6272a4)' # error_symbol = '[ ➜](bold red)' success_symbol = '[ >](#6272a4)' error_symbol = '[ >](bold red)' #style = "bg:#6272a4" [cmd_duration] min_time = 500 style = "bg:#212736" # format = ' [$duration](#6272a4)' format = '[ $duration]($style)' tmux 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 set -g mouse on set -g base-index 1 setw -g pane-base-index 1 set -g visual-activity off set -g visual-bell off set -g visual-silence off setw -g monitor-activity off set -g bell-action none # modes setw -g clock-mode-colour colour5 setw -g mode-style 'fg=colour1 bg=colour18 bold' # panes set -g pane-border-style 'fg=colour19 bg=colour0' set -g pane-active-border-style 'bg=colour0 fg=colour9' # statusbar set -g status-position bottom set -g status-justify left set -g status-style 'bg=colour18 fg=colour137 dim' set -g status-left '' set -g status-right '#[fg=colour233,bg=colour19] %d/%m #[fg=colour233,bg=colour8] %H:%M:%S ' set -g status-right-length 50 set -g status-left-length 20 # window setw -g window-status-current-style 'fg=colour1 bg=colour19 bold' setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F ' setw -g window-status-style 'fg=colour9 bg=colour18' setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold' # messages set -g message-style 'fg=colour232 bg=colour16 bold'

Feb 17, 2023 · 13 min · Jiancong Zhu

TinySQL Implementation

本次实现是关于 PingCap Talenet Plan 2022 TinySQL 学习营相关的实验解题思路。本次实验可以作为 CMU 15-445 的补充,主要内容为每周的讲座+通过Lab的所有测评 Case ,总体实现难度并不高,以下是每个 Project 实现的具体思路细节。 ...

Aug 13, 2022 · 7 min · Chasing1020

Amend Hugo Theme Even

By default, the theme even doesn’t support the search and copy to the clipboard button which is proposed in issues#289 and issues#399. So I have finished implementing the features. 1. Search Initially, you should add the output of JSON in your ./config.toml file. 1 2 [outputs] home = ["HTML", "RSS", "JSON"] Then create the file ./themes/even/layouts/_default/index.json and add these lines. Then make sure you can see the output in the localhost:1313/index.json. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 {{- $.Scratch.Add "index" slice -}} {{- range $index, $element := .Site.RegularPages.ByTitle -}} {{if ne .Params.tags nil}}{{if ne .Plain nil}} {{- $.Scratch.Add "index" (dict "id" $index "date" .Date "tags" .Params.tags "categories" .Params.categories "title" .Title "permalink" .Permalink "contents" .Plain ) -}} {{end}}{{end}} {{- end -}} {{- $.Scratch.Get "index" | jsonify -}} And add file ./themes/even/static/js/search.js. I have stored the search object so just need to load the file one time once you enter the search page. ...

Jul 04, 2022 · 5 min · Chasing1020

About Computer Science

It is a yearly “divide major” season, and now I am looking back at the series of computer science questions and answers I have browsed in Zhihu during my freshman year, and I feel a lot of emotions. I have been thinking about it for a long time, and this is the first time I have seen such numerous questions and discussions about computer science, hence I write about this post. If you find any bugs or grammar issues, please don’t hesitate to contact me to fix them. Anyway, thanks again for accepting my poor English. ...

Jun 19, 2022 · 14 min · Chasing1020