Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 14e632c

Browse files
git
1 parent 47120fa commit 14e632c

8 files changed

Lines changed: 406 additions & 64 deletions

File tree

‎Notes/.DS_Store‎

0 Bytes
Binary file not shown.

‎Notes/Output/Shell-MIT-6-NULL.md‎

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -469,35 +469,41 @@ while True:
469469

470470
##### tmux: terminal multiplexer
471471

472+
基于我的键位([配置文件](https://github.com/huangrt01/dotfiles/blob/master/tmux.conf))
473+
472474
- Sessions - a session is an independent workspace with one or more windows
473475

474476
- `tmux` starts a new session.
475477
- `tmux new -s NAME` starts it with that name. `tmux rename-session -t 0 database` 重命名
476478
- `tmux ls` lists the current sessions
477-
- Within `tmux` typing `<C-b> d/D` detaches the current session
479+
- Within `tmux` typing `<C-a> d/D` detaches the current session
478480
- `tmux a` attaches the last session. You can use `-t` flag to specify which
479481

480482
- Windows
481483

482484
\- Equivalent to tabs in editors or browsers, they are visually separate parts of the same session
483485

484-
- `<C-b> c` Creates a new window. To close it you can just terminate the shells doing `<C-d> / exit`
485-
- `<C-b> N` Go to the *N* th window. Note they are numbered
486-
- `<C-b> p` Goes to the previous window
487-
- `<C-b> n` Goes to the next window
488-
- `<C-b> ,` Rename the current window
489-
- `<C-b> w` List current windows
486+
- `<C-a> c` Creates a new window. To close it you can just terminate the shells doing `<C-d> / exit`
487+
- `<C-a> N` Go to the *N* th window. Note they are numbered
488+
- `<C-a> p` Goes to the previous window
489+
- `<C-a> n` Goes to the next window
490+
- `<C-a> ,` Rename the current window
491+
- `<C-a> w` List current windows
490492

491493
- Panes
492494

493495
\- Like vim splits, panes let you have multiple shells in the same visual display.
494-
495-
- `<C-b> "` Split the current pane horizontally
496-
- `<C-b> %` Split the current pane vertically
497-
- `<C-b> <direction>` Move to the pane in the specified *direction*. Direction here means arrow keys.
498-
- `<C-b> z` make a pane go full screen. Hit `<C-b> z` again to shrink it back to its previous size
499-
- `<C-b> [` Start scrollback. You can then press `<space>` to start a selection and `enter` to copy that selection.
500-
- `<C-b> <space> ` Cycle through pane arrangements.
496+
- 配置下可以用鼠标选取/缩放pane
497+
- `<C-a> -` Split the current pane horizontally
498+
- `<C-a> |` Split the current pane vertically
499+
- `<Alt> <direction>` Move to the pane in the specified *direction*. Direction here means arrow keys.
500+
- `<C-a> z` make a pane go full screen. Hit `<C-a> z` again to shrink it back to its previous size
501+
- `<C-a> [` Start scrollback. You can then press `<space>` to start a selection and `enter` to copy that selection.
502+
- `<C-a> <space> ` Cycle through pane arrangements.
503+
504+
* 其它操作
505+
* `<C-a> r ` reload配置文件
506+
* `Shift + Command + c`,配合iTerm2复制文件
501507

502508
* For further reading, [here](https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/) is a quick tutorial on `tmux` and [this](http://linuxcommand.org/lc3_adv_termmux.php) has a more detailed explanation that covers the original `screen` command. You might also want to familiarize yourself with [`screen`](http://man7.org/linux/man-pages/man1/screen.1.html), since it comes installed in most UNIX systems.
503509
* tmux是client-server的实现模式
@@ -542,7 +548,7 @@ alias dkcpstop="docker-compose stop"
542548
```
543549

544550
##### Dotfiles
545-
* [很详尽的tutorial](https://www.anishathalye.com/2014/08/03/managing-your-dotfiles/)
551+
* [Anish: 很详尽的tutorial](https://www.anishathalye.com/2014/08/03/managing-your-dotfiles/)
546552
* [有关dotfile的种种](https://dotfiles.github.io/)
547553
* [shell-startup的机理](https://blog.flowblok.id.au/2013-02/shell-startup-scripts.html)
548554

@@ -686,6 +692,8 @@ pidwait(){
686692
done
687693
}
688694
```
695+
* `history | awk '{ <img src="https://www.zhihu.com/equation?tex=1%3D%22%22%3Bprint%20substr%28" alt="1="";print substr(" class="ee_img tr_noresize" eeimg="1"> 0,2)}' | sort | uniq -c | sort -n | tail -n 10` 可得到使用频率最高的10个命令
696+
* [background port forwarding](https://mpharrigan.com/2016/05/17/background-ssh.html)
689697

690698

691699
#### Lecture 6.Version Control (Git)
@@ -695,6 +703,7 @@ pidwait(){
695703

696704
### Linux命令按字母分类
697705
#### a
706+
* awk: 一种控制台编程工具,寻找和处理pattern
698707
#### b
699708
* bg: resume后台暂停的命令
700709
#### c

‎Notes/Output/git.md‎

Lines changed: 167 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,167 @@
11
### Git
2-
* Git的理念
3-
* distributed version control system (DVCS)
4-
* The Platonic ideal is that each commit should compile and should move steadily towards more and more tests passing.
2+
* [Pro Git](https://git-scm.com/book/en/v2)
3+
* [Learn Git Branching](https://learngitbranching.js.org/?locale=en_US)
54
* [git handbook](https://guides.github.com/introduction/git-handbook/),里面有一些资源
65
* [完整doc文档](https://git-scm.com/docs)
76
* [resources to learn Git](https://try.github.io/)
87
* [如何fork一个私库](https://stackoverflow.com/questions/10065526/github-how-to-make-a-fork-of-public-repository-private)
98

10-
#### 重要命令
11-
* `git clone` creates a local copy of a project that already exists remotely. The clone includes all the project’s files, history, and branches.
12-
* --depth=1:clone速度慢的时候只clone最后一次commit
9+
#### VCS(version control system)
10+
##### Git的理念
11+
* distributed version control system (DVCS)
12+
* The Platonic ideal is that each commit should compile and should move steadily towards more and more tests passing.
13+
* ugly interface and beautiful design -> bottom-up地理解git
1314

14-
* `git add` stages a change. Git tracks changes to a developer’s codebase, but it’s necessary to stage and take a snapshot of the changes to include them in the project’s history. This command performs staging, the first part of that two-step process. Any changes that are staged will become a part of the next snapshot and a part of the project’s history. Staging and committing separately gives developers complete control over the history of their project without changing how they code and work.
15+
This [XKCD comic](https://xkcd.com/1597/) captures Git’s reputation:
16+
17+
<img src="https://raw.githubusercontent.com/huangrt01/Markdown-Transformer-and-Uploader/master/Notes/git/git.png" alt="git" style="zoom:100%;" />
18+
19+
##### Git's data model
20+
* Snapshots: 文件是blob,文件夹是tree,snapshot是top-level tree
21+
22+
* Modeling history: relating snapshots
23+
* a history is a directed acyclic graph (DAG) of snapshots
24+
* 一个snapshot可能有多个parent,比如merge
25+
* snapshot被称作commit
26+
* Data model, as pseudocode
27+
* Objects and content-addressing
28+
* `git cat-file -p` 显示对象信息
29+
* References:照顾可读性,和对象不同,它是mutable的
30+
* `master`表示主分支的最近commit
31+
* `HEAD`表示"where we currently are"
32+
* repositories = objects + references
33+
```python
34+
// a file is a bunch of bytes
35+
type blob = array<byte>
36+
37+
// a directory contains named files and directories
38+
type tree = map<string, tree | blob>
39+
40+
// a commit has parents, metadata, and the top-level tree
41+
type commit = struct {
42+
parent: array<commit>
43+
author: string
44+
message: string
45+
snapshot: tree
46+
}
47+
48+
type object = blob | tree | commit
49+
objects = map<string, object>
50+
def store(object):
51+
id = sha1(object)
52+
objects[id] = object
53+
54+
def load(id):
55+
return objects[id]
56+
```
57+
##### Staging area
58+
*`git add`联系
59+
* 意义在于摆脱snapshot和当前状态的绝对联系,使commit操作更灵活
60+
61+
62+
63+
#### Git command-line interface
64+
65+
##### Basics
66+
67+
- `git help <command>`: get help for a git command
68+
- `git init`: creates a new git repo, with data stored in the `.git` directory
69+
- `git status`: tells you what's going on
70+
- `git add <filename>`: adds files to staging area
71+
- `git commit`: creates a new commit
72+
- Write [good commit messages](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)!
73+
- Even more reasons to write [good commit messages](https://chris.beams.io/posts/git-commit/)!
74+
- `git log`: shows a flattened log of history
75+
- `git log --all --graph --decorate`: visualizes history as a DAG
76+
- `git diff <filename>`: show differences since the last commit
77+
- `git diff <revision> <filename>`: shows differences in a file between snapshots
78+
- `git checkout <revision>`: updates HEAD and current branch
1579

80+
##### Branching and merging
81+
- `git branch`: shows branches
82+
- `git branch <name>`: creates a branch
83+
- `git checkout -b <name>`: creates a branch and switches to it
84+
- same as `git branch <name>; git checkout <name>`
85+
- `git merge <revision>`: merges into current branch
86+
- `git mergetool`: use a fancy tool to help resolve merge conflicts
87+
- `git rebase`: rebase set of patches onto a new base
88+
89+
##### Remotes
90+
- `git remote`: list remotes
91+
- `git remote add <name> <url>`: add a remote
92+
- `git push <remote> <local branch>:<remote branch>`: send objects to remote, and update remote reference
93+
- `git branch --set-upstream-to=<remote>/<remote branch>`: set up correspondence between local and remote branch
94+
- `git fetch`: retrieve objects/references from a remote
95+
- `git pull`: same as `git fetch; git merge`
96+
- `git clone`: download repository from remote
97+
98+
##### Undo
99+
- `git commit --amend`: edit a commit's contents/message
100+
- `git reset HEAD <file>`: unstage a file
101+
- `git checkout -- <file>`: discard changes
102+
103+
##### Advanced Git
104+
- `git config`: Git is [highly customizable](https://git-scm.com/docs/git-config)
105+
- `git clone --depth=1`: shallow clone, without entire version history
106+
- `git add -p`: interactive staging
107+
- `git rebase -i`: interactive rebasing
108+
- `git blame`: show who last edited which line
109+
- `git stash`: temporarily remove modifications to working directory
110+
- `git bisect`: binary search history (e.g. for regressions)
111+
- `.gitignore`: [specify](https://git-scm.com/docs/gitignore) intentionally untracked files to ignore
112+
113+
#### Miscellaneous
114+
- **GUIs**: there are many [GUI clients](https://git-scm.com/downloads/guis)
115+
out there for Git. We personally don't use them and use the command-line
116+
interface instead.
117+
- **Shell integration**: it's super handy to have a Git status as part of your
118+
shell prompt ([zsh](https://github.com/olivierverdier/zsh-git-prompt),
119+
[bash](https://github.com/magicmonty/bash-git-prompt)). Often included in
120+
frameworks like [Oh My Zsh](https://github.com/ohmyzsh/ohmyzsh).
121+
- **Editor integration**: similarly to the above, handy integrations with many
122+
features. [fugitive.vim](https://github.com/tpope/vim-fugitive) is the standard
123+
one for Vim.
124+
- **Workflows**: we taught you the data model, plus some basic commands; we
125+
didn't tell you what practices to follow when working on big projects (and
126+
there are [many](https://nvie.com/posts/a-successful-git-branching-model/)
127+
[different](https://www.endoflineblog.com/gitflow-considered-harmful)
128+
[approaches](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)).
129+
- **GitHub**: Git is not GitHub. GitHub has a specific way of contributing code
130+
to other projects, called [pull
131+
requests](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests).
132+
- **Other Git providers**: GitHub is not special: there are many Git repository
133+
hosts, like [GitLab](https://about.gitlab.com/) and
134+
[BitBucket](https://bitbucket.org/).
135+
136+
#### Resources
137+
- [Pro Git](https://git-scm.com/book/en/v2) is **highly recommended reading**.
138+
Going through Chapters 1--5 should teach you most of what you need to use Git
139+
proficiently, now that you understand the data model. The later chapters have
140+
some interesting, advanced material.
141+
- [Oh Shit, Git!?!](https://ohshitgit.com/) is a short guide on how to recover
142+
from some common Git mistakes.
143+
- [Git for Computer
144+
Scientists](https://eagain.net/articles/git-for-computer-scientists/) is a
145+
short explanation of Git's data model, with less pseudocode and more fancy
146+
diagrams than these lecture notes.
147+
- [Git from the Bottom Up](https://jwiegley.github.io/git-from-the-bottom-up/)
148+
is a detailed explanation of Git's implementation details beyond just the data
149+
model, for the curious.
150+
- [How to explain git in simple
151+
words](https://smusamashah.github.io/blog/2017/10/14/explain-git-in-simple-words)
152+
- [Learn Git Branching](https://learngitbranching.js.org/) is a browser-based
153+
game that teaches you Git.
154+
155+
156+
* `git add` stages a change. Git tracks changes to a developer’s codebase, but it’s necessary to stage and take a snapshot of the changes to include them in the project’s history. This command performs staging, the first part of that two-step process. Any changes that are staged will become a part of the next snapshot and a part of the project’s history. Staging and committing separately gives developers complete control over the history of their project without changing how they code and work.
157+
* `git log --all --graph --decorate`
158+
* `git cat-file -p`: 显示对象信息
159+
* 40位Hash值,前2位是文件夹,后38位是文件名
160+
* 存在`.git/objects/`
161+
* [理解git常用命令原理](http://www.cppblog.com/kevinlynx/archive/2014/09/09/208257.html)
162+
* `git clone` creates a local copy of a project that already exists remotely. The clone includes all the project’s files, history, and branches.
163+
* --depth=1:clone速度慢的时候只clone最后一次commit
164+
* `git checkout master`: 丢弃未commit的变化
16165
* `git commit` saves the snapshot to the project history and completes the change-tracking process. In short, a commit functions like taking a photo. Anything that’s been staged with `git add` will become a part of the snapshot with `git commit`.
17166
* `git commit -am "m"`可以先add再commit,但前提是commit的文件都是tracked状态
18167

@@ -24,10 +173,21 @@
24173

25174
* `git pull` updates the local line of development with updates from its remote counterpart. Developers use this command if a teammate has made commits to a branch on a remote, and they would like to reflect those changes in their local environment.
26175

176+
* `git fetch`可以获取最新版本
177+
```shell
178+
git fetch origin master:tmp
179+
git diff tmp
180+
git merge tmp
181+
git branch -d tmp
182+
```
183+
27184
* `git push` updates the remote repository with any commits made locally to a branch.
28185
* `git push origin lab1:lab1`
29186
* `git push --set-upstream origin my-branch`,本地关联远程分支,用来省略上面一行的分支标注
30187

188+
* `git reset`
189+
* `git reset --hard` 回到上次commit的版本,配合`git pull`
190+
31191
* `git submodule add <url> /path`
32192
* clone之后初始化:`git submodule update --init --recursive`
33193
* 更新:`git submodule update --init --remote`

‎Notes/Output/《剑指offer》笔记.md‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,19 @@ CMyString& CMyString::operator=(const CMyString &str){
7070
```c++
7171
int findRepeatNumber(vector<int>& nums) {
7272
//时间复杂度O(n),空间复杂度O(1)
73-
int temp; int i=0;
73+
int save=-1; int i=nums[0];
7474
while(1){
75-
if(nums[i]==-1)return i;
76-
//用nums[i]保存是否遍历到i,如果nums[i]=-1说明找到了重复的元素
77-
temp=nums[i];
78-
nums[temp]=-1;
79-
if(temp==i){//避免死循环的情形,以nums.size()为模循环递增下标
80-
while(nums[temp]==-1)
81-
{temp=(++temp)%nums.size();}
82-
}
83-
i=temp;
75+
if(nums[i]==-1)return i; //用nums[i]保存是否遍历到i,如果nums[i]=-1说明找到了重复的元素
76+
if(nums[i]==save) return save; //前后两次相邻跳转重复的情形
77+
if(nums[i]==i){
78+
nums[i]=-1;
79+
while(nums[i]==-1) i=(++i)%nums.size(); //避免死循环的情形,以nums.size()为模循环递增下标
80+
}
81+
else{
82+
save=nums[i];
83+
nums[i]=-1;
84+
i=save;
85+
}
8486
}
8587
}
8688
```

‎Notes/Shell-MIT-6-NULL.md‎

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -469,35 +469,41 @@ while True:
469469

470470
##### tmux: terminal multiplexer
471471

472+
基于我的键位([配置文件](https://github.com/huangrt01/dotfiles/blob/master/tmux.conf))
473+
472474
- Sessions - a session is an independent workspace with one or more windows
473475

474476
- `tmux` starts a new session.
475477
- `tmux new -s NAME` starts it with that name. `tmux rename-session -t 0 database` 重命名
476478
- `tmux ls` lists the current sessions
477-
- Within `tmux` typing `<C-b> d/D` detaches the current session
479+
- Within `tmux` typing `<C-a> d/D` detaches the current session
478480
- `tmux a` attaches the last session. You can use `-t` flag to specify which
479481

480482
- Windows
481483

482484
\- Equivalent to tabs in editors or browsers, they are visually separate parts of the same session
483485

484-
- `<C-b> c` Creates a new window. To close it you can just terminate the shells doing `<C-d> / exit`
485-
- `<C-b> N` Go to the *N* th window. Note they are numbered
486-
- `<C-b> p` Goes to the previous window
487-
- `<C-b> n` Goes to the next window
488-
- `<C-b> ,` Rename the current window
489-
- `<C-b> w` List current windows
486+
- `<C-a> c` Creates a new window. To close it you can just terminate the shells doing `<C-d> / exit`
487+
- `<C-a> N` Go to the *N* th window. Note they are numbered
488+
- `<C-a> p` Goes to the previous window
489+
- `<C-a> n` Goes to the next window
490+
- `<C-a> ,` Rename the current window
491+
- `<C-a> w` List current windows
490492

491493
- Panes
492494

493495
\- Like vim splits, panes let you have multiple shells in the same visual display.
494-
495-
- `<C-b> "` Split the current pane horizontally
496-
- `<C-b> %` Split the current pane vertically
497-
- `<C-b> <direction>` Move to the pane in the specified *direction*. Direction here means arrow keys.
498-
- `<C-b> z` make a pane go full screen. Hit `<C-b> z` again to shrink it back to its previous size
499-
- `<C-b> [` Start scrollback. You can then press `<space>` to start a selection and `enter` to copy that selection.
500-
- `<C-b> <space> ` Cycle through pane arrangements.
496+
- 配置下可以用鼠标选取/缩放pane
497+
- `<C-a> -` Split the current pane horizontally
498+
- `<C-a> |` Split the current pane vertically
499+
- `<Alt> <direction>` Move to the pane in the specified *direction*. Direction here means arrow keys.
500+
- `<C-a> z` make a pane go full screen. Hit `<C-a> z` again to shrink it back to its previous size
501+
- `<C-a> [` Start scrollback. You can then press `<space>` to start a selection and `enter` to copy that selection.
502+
- `<C-a> <space> ` Cycle through pane arrangements.
503+
504+
* 其它操作
505+
* `<C-a> r ` reload配置文件
506+
* `Shift + Command + c`,配合iTerm2复制文件
501507

502508
* For further reading, [here](https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/) is a quick tutorial on `tmux` and [this](http://linuxcommand.org/lc3_adv_termmux.php) has a more detailed explanation that covers the original `screen` command. You might also want to familiarize yourself with [`screen`](http://man7.org/linux/man-pages/man1/screen.1.html), since it comes installed in most UNIX systems.
503509
* tmux是client-server的实现模式
@@ -542,7 +548,7 @@ alias dkcpstop="docker-compose stop"
542548
```
543549

544550
##### Dotfiles
545-
* [很详尽的tutorial](https://www.anishathalye.com/2014/08/03/managing-your-dotfiles/)
551+
* [Anish: 很详尽的tutorial](https://www.anishathalye.com/2014/08/03/managing-your-dotfiles/)
546552
* [有关dotfile的种种](https://dotfiles.github.io/)
547553
* [shell-startup的机理](https://blog.flowblok.id.au/2013-02/shell-startup-scripts.html)
548554

@@ -686,6 +692,8 @@ pidwait(){
686692
done
687693
}
688694
```
695+
* `history | awk '{1ドル="";print substr(0,2ドル)}' | sort | uniq -c | sort -n | tail -n 10` 可得到使用频率最高的10个命令
696+
* [background port forwarding](https://mpharrigan.com/2016/05/17/background-ssh.html)
689697

690698

691699
#### Lecture 6.Version Control (Git)
@@ -695,6 +703,7 @@ pidwait(){
695703

696704
### Linux命令按字母分类
697705
#### a
706+
* awk: 一种控制台编程工具,寻找和处理pattern
698707
#### b
699708
* bg: resume后台暂停的命令
700709
#### c

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /