随机森林RandomForestClassifier
利用多棵树对样本进行训练并预测的一种分类器
目标:
copy all files .pdf to _0.pdf
推荐使用rename.ul或mmv
1 | rename.ul -v -n ".pdf" "_0.pdf" *.pdf |
1 | for f in *.pdf; do pre="${f%.pdf}"; echo mv -- "$f" "${pre}_0.pdf"; done |
1 | rename -n 's/\.pdf$/_0$&/' *.pdf |
matches .pdf at the end of the filename
1 2. in the replacement, the match is prepended by ```_0```: ```_0$&
1 | sudo apt-get install mmv |
服务器上
1 | git init --bare repo |
repo相当于中转站,
配置一下remote之后,服务器上的程序git push到repo
然后本机再从repo上pull下来.
1 | # local |
官方文档1
2
3
4
5
6git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch path/to/your/file' HEAD
git push origin master --force
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
git config –global core.editor vim
当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout – file。
当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD file,就回到了场景1,第二步按场景1操作。
已经提交了不合适的修改到版本库时,想要撤销本次提交
HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset –hard commit_id。
穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。
要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本
git reset –hard HEAD^回到上一个版本
在Git中,用HEAD表示当前版本.
上一个版本就是HEAD^,上上一个版本就是HEAD^^,
当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。
1 |
|
/*代表当前目录(根目录)下全部
*代表所有
1 |
|
1 | git config --global credential.helper store |
使用下面的命令从远程仓库强制覆盖本地文件:1
2git fetch --all
git reset --hard origin/master
要下载一些其他分支的更改使用以下命令。
1 | git reset --hard origin/other_branch |
说明:-
Git fetch命令下载最新的更新远程,但不合并或本地文件变基址。
Git reset master分支重置你刚才取下的。该-hard选项更改的所有文件到你的工作树origin/master。
远程操作的第一步,通常是从远程主机克隆一个版本库,这时就要用到git clone命令。
1 | $ git clone <版本库的网址> |
比如,克隆jQuery的版本库。
1 | $ git clone https://github.com/jquery/jquery.git |
该命令会在本地主机生成一个目录,与远程主机的版本库同名。如果要指定不同的目录名,可以将目录名作为git clone命令的第二个参数。
1 | $ git clone <版本库的网址> <本地目录名> |
git clone支持多种协议,除了HTTP(s)以外,还支持SSH、Git、本地文件协议等,下面是一些例子。
1 | $ git clone http[s]://example.com/path/to/repo.git/ |
SSH协议还有另一种写法。
1 | $ git clone [user@]example.com:path/to/repo.git/ |
通常来说,Git协议下载速度最快,SSH协议用于需要用户认证的场合。各种协议优劣的详细讨论请参考官方文档。
为了便于管理,Git要求每个远程主机都必须指定一个主机名。git remote命令就用于管理主机名。
不带选项的时候,git remote命令列出所有远程主机。
1 | $ git remote |
使用-v选项,可以参看远程主机的网址。
1 | $ git remote -v |
上面命令表示,当前只有一台远程主机,叫做origin,以及它的网址。
克隆版本库的时候,所使用的远程主机自动被Git命名为origin。如果想用其他的主机名,需要用git clone命令的-o选项指定。
1 | $ git clone -o jQuery https://github.com/jquery/jquery.git |
上面命令表示,克隆的时候,指定远程主机叫做jQuery。
git remote show命令加上主机名,可以查看该主机的详细信息。
1 | $ git remote show <主机名> |
git remote add命令用于添加远程主机。
1 | $ git remote add <主机名> <网址> |
git remote rm命令用于删除远程主机。
1 | $ git remote rm <主机名> |
git remote rename命令用于远程主机的改名。
1 | $ git remote rename <原主机名> <新主机名> |
一旦远程主机的版本库有了更新(Git术语叫做commit),需要将这些更新取回本地,这时就要用到git fetch命令。
1 | $ git fetch <远程主机名> |
上面命令将某个远程主机的更新,全部取回本地。
git fetch命令通常用来查看其他人的进程,因为它取回的代码对你本地的开发代码没有影响。
默认情况下,git fetch取回所有分支(branch)的更新。如果只想取回特定分支的更新,可以指定分支名。
1 | $ git fetch <远程主机名> <分支名> |
比如,取回origin主机的master分支。
1 | $ git fetch origin master |
所取回的更新,在本地主机上要用”远程主机名/分支名”的形式读取。比如origin主机的master,就要用origin/master读取。
git branch命令的-r选项,可以用来查看远程分支,-a选项查看所有分支。
1 | $ git branch -r |
上面命令表示,本地主机的当前分支是master,远程分支是origin/master。
取回远程主机的更新以后,可以在它的基础上,使用git checkout命令创建一个新的分支。
1 | $ git checkout -b newBrach origin/master |
上面命令表示,在origin/master的基础上,创建一个新分支。
此外,也可以使用git merge命令或者git rebase命令,在本地分支上合并远程分支。
1 | $ git merge origin/master |
上面命令表示在当前分支上,合并origin/master。
git pull命令的作用是,取回远程主机某个分支的更新,再与本地的指定分支合并。它的完整格式稍稍有点复杂。
1 | $ git pull <远程主机名> <远程分支名>:<本地分支名> |
比如,取回origin主机的next分支,与本地的master分支合并,需要写成下面这样。
1 | $ git pull origin next:master |
如果远程分支是与当前分支合并,则冒号后面的部分可以省略。
1 | $ git pull origin next |
上面命令表示,取回origin/next分支,再与当前分支合并。实质上,这等同于先做git fetch,再做git merge。
1 | $ git fetch origin |
在某些场合,Git会自动在本地分支与远程分支之间,建立一种追踪关系(tracking)。比如,在git clone的时候,所有本地分支默认与远程主机的同名分支,建立追踪关系,也就是说,本地的master分支自动”追踪”origin/master分支。
Git也允许手动建立追踪关系。
1 | git branch --set-upstream master origin/next |
上面命令指定master分支追踪origin/next分支。
如果当前分支与远程分支存在追踪关系,git pull就可以省略远程分支名。
1 | $ git pull origin |
上面命令表示,本地的当前分支自动与对应的origin主机”追踪分支”(remote-tracking branch)进行合并。
如果当前分支只有一个追踪分支,连远程主机名都可以省略。
1 | $ git pull |
上面命令表示,当前分支自动与唯一一个追踪分支进行合并。
如果合并需要采用rebase模式,可以使用–rebase选项。
1 | $ git pull --rebase <远程主机名> <远程分支名>:<本地分支名> |
如果远程主机删除了某个分支,默认情况下,git pull 不会在拉取远程分支的时候,删除对应的本地分支。这是为了防止,由于其他人操作了远程主机,导致git pull不知不觉删除了本地分支。
但是,你可以改变这个行为,加上参数 -p 就会在本地删除远程已经删除的分支。
1 | $ git pull -p |
git push命令用于将本地分支的更新,推送到远程主机。它的格式与git pull命令相仿。
1 | $ git push <远程主机名> <本地分支名>:<远程分支名> |
注意,分支推送顺序的写法是<来源地>:<目的地>,所以git pull是<远程分支>:<本地分支>,而git push是<本地分支>:<远程分支>。
如果省略远程分支名,则表示将本地分支推送与之存在”追踪关系”的远程分支(通常两者同名),如果该远程分支不存在,则会被新建。
1 | $ git push origin master |
上面命令表示,将本地的master分支推送到origin主机的master分支。如果后者不存在,则会被新建。
如果省略本地分支名,则表示删除指定的远程分支,因为这等同于推送一个空的本地分支到远程分支。
1 | $ git push origin :master |
上面命令表示删除origin主机的master分支。
如果当前分支与远程分支之间存在追踪关系,则本地分支和远程分支都可以省略。
1 | $ git push origin |
上面命令表示,将当前分支推送到origin主机的对应分支。
如果当前分支只有一个追踪分支,那么主机名都可以省略。
1 | $ git push |
如果当前分支与多个主机存在追踪关系,则可以使用-u选项指定一个默认主机,这样后面就可以不加任何参数使用git push。
1 | $ git push -u origin master |
上面命令将本地的master分支推送到origin主机,同时指定origin为默认主机,后面就可以不加任何参数使用git push了。
不带任何参数的git push,默认只推送当前分支,这叫做simple方式。此外,还有一种matching方式,会推送所有有对应的远程分支的本地分支。Git 2.0版本之前,默认采用matching方法,现在改为默认采用simple方式。如果要修改这个设置,可以采用git config命令。
1 | $ git config --global push.default matching |
还有一种情况,就是不管是否存在对应的远程分支,将本地的所有分支都推送到远程主机,这时需要使用–all选项。
1 | $ git push --all origin |
上面命令表示,将所有本地分支都推送到origin主机。
如果远程主机的版本比本地版本更新,推送时Git会报错,要求先在本地做git pull合并差异,然后再推送到远程主机。这时,如果你一定要推送,可以使用–force选项。
1 | $ git push --force origin |
上面命令使用–force选项,结果导致远程主机上更新的版本被覆盖。除非你很确定要这样做,否则应该尽量避免使用–force选项。
最后,git push不会推送标签(tag),除非使用–tags选项。
1 | $ git push origin --tags |
git栈,在切换分支的时候,当前分支有未完成提交的代码,但又不想提交,一方面是因为代码没有完成,一方面是因为这样会在log中打印许多无用的日志信息。但是不提交就无法切换分支,于是git便开辟出来一个临时的仓库,这个仓库可以暂时存放最新修改过的代码。
git栈,可以存放多次修改,切换分支后这些存放的修改还在。
1 |
|
1 | git stash |
保存当前的工作进度,会分别对暂存区和工作区的状态进行保存。保存后工作区恢复到之前最后一次提交的状态
1 | git stash list |
显示进度列表。此命令显然显示了git stash 可以多次保存工作进度,并在恢复时候选择。
1 | git stash pop [--index] [] |
如果不使用任何参数,会恢复最新保存的工作进度,并将恢复的工作进度从存储的git栈列表中清除。
如果提供参数(来自git stash list显示的列表),则将工作进度恢复。恢复完毕也将从git栈删除工作进度。
1 | git stash [save [--patch] [-k|--[no]keep-index] [-q|--quiet] []] |
这条命令实际上是第一条git stash命令的完整版。
使用参数–patch会显示工作区和HEAD的差异,通过对差异文件的编辑决定在进度中最终要保存的工作区的内容,通过编辑差异文件可以在进度中排除无关内容。
使用-k或者–keep-index参数,在保存进度后不会将暂存区重置。默认会将暂存区和工作区强制重置。
1 | git stash apply [--index] [] |
除了不删除恢复的进度之外,其余和git stash pop 命令一样。
1 | git stash drop [] |
删除一个存储的进度。默认删除最新的进度。
1 | git stash clear |
删除所有存储的进度。
1 | sudo apt-get install curl vim exuberant-ctags git ack-grep |
fisa-vim-config/features.rst at master · fisadev/fisa-vim-config
Most important features include:
Plugins managed using Vim-plug! You can easily install or remove
plugins, and they are installed into .vim/plugged/
. More info
here
| Command | Description |
| ———————————– | —————————————————————— |
| PlugInstall [name ...] [#threads]
| Install plugins |
| PlugUpdate [name ...] [#threads]
| Install or update plugins |
| PlugClean[!]
| Remove unused directories (bang version will clean without prompt) |
| PlugUpgrade
| Upgrade vim-plug itself |
| PlugStatus
| Check the status of plugins |
| PlugDiff
| Examine changes from the previous update and the pending changes |
| PlugSnapshot[!] [output path]
| Generate script for restoring the current snapshot of the plugins |
Smart autocompletion as you type, sometimes using python
instrospection (completion of module names, instance methods and
attributes) and sometimes text-based (used words) (from version 4.0,
it’s even more intelligent!). And with neocomplcache, it even can
autocomplete with typos, thanks to the fuzzy completion settings.
,e
= open file (like the original :e) but with recursive andCtrl-t
!,g
= fuzzy symbol finder (classes, methods, variables,,G
,c
= fuzzy command finder (internal vim commands, or custom:GitDiff
,:diffthis
, and many other similar commands.,f
= fuzzy text finder on all the opened files. Example: if,m
= fuzzy finder of most recently used files.,we
, ,wg
, ,wc
, ,wf
and ,wm
= same as ,e
, ,g
, ,c
,,f
and ,wm
but initiate the search with the word under the,G
, ,wG
). Is useful,wg
as a “fuzzy go to definition” (if the,wG
if the definition is on,pe
= same as ,e
but initiates the search with the path,d
, or open the definition on a new,D
.,o
.F4
.F2
. This reads the current file\e
. In python, the error checking,r
uses the ack command (a kind of grep optimized for code,wr
does the same, but searching the word under the cursor.F3
, or open it with your,t
.:Pydoc
command.:Pydoc collections
(also works over the current word withShift-K
).n\ci
.Easy tab navigation:
tt
= new tab and leaves the cursor waiting to specify the filetn
or Ctrl-Shift-Right
= next tab.tp
or Ctrl-Shift-Left
= previous tab.tm
= move current tab to a specific position (or to the end iftl
= show a list of current tabs with their inner windows on ats
= duplicate current tab.The mappings starting with the t
letter work only on command mode,
but the mappings with Ctrl-Shift
work on both, command and insert
mode.
Easy window navigation using Alt-arrows
keys.
:ConqueTerm
. Examples::ConqueTerm python
, :ConqueTerm bash
.:w!!
.%
..vimrc
).cl
and press tab
(while intab
to navigate the snippet fields).Zen coding for html: generate lots of html code writing simple
and short expressions. Example:
1 | 1. write `#books>ul>li.book*5>a` |
Learn more on the plugin
site.
Git and other vcs integration, with commands such as::GitStatus
, :GitDiff
, :GitBlame
, :GitLog
, :GitCommit
, or
simply :Git
with your own command. Key mappings and syntax
highlighting for git displays. Displays icons on the side of each
line based on the result of a diff of the current file (example: if
you added a line and still didn’t commit the file, that line will
have a green +
on its side). And finally, when on a changed file
you can jump through changes using \sn
and \sp
.
i
. For example, you can change an entire indented code block withcii
, or the indented block and its header line with cai
(also[-
, to the end of the block with ]-
, and moreC
and M
. For example, you can change an entireciM
, or delete a class including its headerdaC
.\r
.\b
.Ctrl-p
and Ctrl-n
, and many\b
.:Isort
.~/.vim/dirs
).Ctrl-v
and Shift-v
Shift-Alt-arrows
, or even duplicate themD
.-
and you will see big green:YapfFullFormat
formats theCustom configs by folder add a .vim.custom
file in the
project’s root folder with whatever configs you want to customize
for that project. For example, if you have a project tree like this
example and you want to exclude folder_x
from FuzzyFinder, putlet g:ctrlp_custom_ignore["dir"] = g:ctrlp_custom_ignore["dir"] . '|\v[\/]folder_x$'
in the .vim.custom
file.
project ├── folder_1 ├── folder_2 ├── folder_x └── .vim.custom
1 | # coding:utf-8 |
常见文本编辑器都会提供剪切板来支持复制粘贴,Vim也不例外。 不同的是Vim提供了10类共48个寄存器,提供无与伦比的寄存功能。 最常用的y操作将会拷贝到默认的匿名寄存器中,我们也可以指定具体拷贝到哪个寄存器中。
一般来讲,可以用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
除了a-z26个命名寄存器,Vim还提供了很多特殊寄存器。合理地使用可以极大地提高效率。例如:
* ```"+p```可以粘贴剪切板的内容,
* ```":p```可以粘贴上一个Vim命令(比如你刚刚费力拼写的正则表达式),
* ```"/p```可以粘贴上一次搜索关键词(你猜的没错,正是normal模式下的/foo搜索命令)。
在Vim中可通过```:reg```来查看每个寄存器当前的值。
寄存器分类
Vim提供了10类寄存器,可在Vim中通过:help registers查看帮助。
1. 匿名寄存器 ""
2. 编号寄存器 "0 到 "9
3. 小删除寄存器 "-
4. 26个命名寄存器 "a 到 "z
5. 3个只读寄存器 ":, "., "%
6. Buffer交替文件寄存器 "#
7. 表达式寄存器 "=
8. 选区和拖放寄存器 "*, "+, "~
9. 黑洞寄存器 "_
10. 搜索模式寄存器 "/
# 1. 匿名寄存器
使用d, c, s, x等会删除字符的命令时,被删除字符会进入匿名寄存器""。 你可以认为""寄存器是一个指针,指向刚才被存到的寄存器。
在如何用Vim搭建IDE?一文中提到,Mac下可通过下列设置来让Vim共享系统剪切板, 就是这个原理:所有删除和拷贝操作默认都会到匿名寄存器。
set clipboard=unnamed1
2
3
4
5
6
7
8
9
10
11
12
13
14使用y命令未指定寄存器会存到"0寄存器中,同时""会与该寄存器保有同样的值。 这意味着你使用p和"p总会得到同样的结果。
# 2. 编号寄存器
编号寄存器从"0到"9共10个,其中"0保存着拷贝来的字符串,"1到"9保存着删除掉的字符串。 删除操作符包括s, c, d, x。 删除掉的字符串会被存到"1中,上次删除的则会被存到"2中。以此类推,Vim会保存你最近的9次删除。
* 只有整行整行的删除,和通过段落级别的移动指令(包括%,(,),/,`,?,n,N,{,}) 的删除才会被放到"1中。
* 当用户指定拷贝操作的寄存器时(如"ap),"0不会被写入;但删除操作一定会被写入到"1中。
>
"0寄存器很有用,比如我们copy了一段文本然后用它替换另一段文本。 这时默认寄存器""中的值就变成了被替换文本,如果还需要用copy的文本继续替换的话就需要"0p了。
# 3. 小删除寄存器
不足一行的小删除则会被放到小删除寄存器中("-),起作用的删除操作符也包括s, c, d, x。 例如:
dw # 删除一个词
d9l # 删除9个字符
cb # 向前更改一个词1
2
3
4与"0寄存器类似,当用户指定寄存器并进行删除时,"-不会被写入。
# 4. 命名寄存器
命名寄存器有"a到"z共26个,这些寄存器只有当我们指定时才会被使用。 其实我们在录制宏时,所有键盘操作会以字符串的形式存到寄存器中。 例如录制一个宏存到"a寄存器中,内容为更改当前行cc,改为foo字符串:
qaccfoo1
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然后执行:reg来查看寄存器,可以发现a寄存器的值是ccfoo。
小技巧:当使用小写字母进行操作时会覆盖当前寄存器内容,当使用大写字母进行操作时,会追加当前寄存器内容。
# 5. 只读寄存器
只读寄存器共3个,它们的值是由Vim提供的,不允许改变:
".:上次insert模式中插入的字符串。还记得吗?.命令可以重复上次操作,而".存储了上次插入。
"%:当前文件名,不是全路径,也不是纯文件名,而是从当前Vim的工作目录到该文件的路径。例如此时Harttle的Vim中,"%p的结果为_drafts/vim-registers.md。
"::上次命令模式下键入的命令。正如@a可以执行"a寄存器中的宏一样,":可以执行上次命令。
# 6. 交替文件寄存器
交替文件寄存器"#存储着当前Vim窗口(Window)的交替文件。交替文件(alternate file)是指 Buffer中的上一个文件,可通过Ctrl+^来切换交替文件与当前文件。
Window和Buffer有什么区别?参见Vim 多文件编辑:窗口一文。
# 7. 表达式寄存器
表达式寄存器"=主要用于计算Vim脚本的返回值,并插入到文本中。 当我们键入"=后光标会移动到命令行,此时我们可以输入任何Vim脚本的表达式。 例如3+2,按下回车并且p则会得到5。
这在我们调试Vim脚本时非常有用,比如调用一个函数看它是否有正确的返回值。
# 8. 选择和拖放寄存器
选择和拖放寄存器包括"*, "+, 和"~,这三个寄存器的行为是和GUI相关的。
"*和"+在Mac和Windows中,都是指系统剪切板(clipboard),例如"*yy即可复制当前行到剪切板。 以供其他程序中粘贴。其他程序中复制的内容也会被存储到这两个寄存器中。 在X11系统中(绝大多数带有桌面环境的Linux发行版),二者是有区别的:
"*指X11中的PRIMARY选区,即鼠标选中区域。在桌面系统中可按鼠标中键粘贴。
"+指X11中的CLIPBOARD选区,即系统剪切板。在桌面系统中可按Ctrl+V粘贴。
上文所述的Mac下set clipboard=unnamed会使得系统剪切板寄存器"*和Vim默认的匿名寄存器""始终保有同样的值,即Vim和系统共用剪切板。
有文本拖拽到Vim时,被拖拽的文本被存储在"~中。Vim默认的行为是将"~中内容插入到光标所在位置。 当然你可以给<DROP>做键盘映射。
# 9. 黑洞寄存器
黑洞寄存器"_,所有删除或拷贝到黑洞寄存器的文本将会消失。 这是为了在删除文本的同时不影响任何寄存器的值,"_通常用于Vim脚本中。
# 10. 搜索寄存器
搜索寄存器"/用于存储上一次搜索的关键词。Vim中如何进行搜索呢? 在normal模式下按下/即进入search模式,输入关键字并按下回车即可。
该寄存器是可写的,例如:let @/ = "harttle"将会把"harttle"写入该寄存器。 下次搜索时不输入搜索词直接回车便会搜索"harttle"。
命令行模式拷贝
值得一提的时,任何寄存器中的值都是可以拷贝到命令模式下的。
比如对于寄存器"a中的值,在normal模式下可以通过"ap来粘贴;在command-line模式下通过<Ctrl-R>a来粘贴。这一操作存在风险,因为寄存器中的值可能是从网页中拷贝来的。
如果寄存器中的字符串存在<Esc>字符或<CR>字符,则会时Vim回到normal模式, 并继续执行寄存器中的命令。为了防范剪切板劫持,可以添加下列的Vim配置:
inoremap `
该命令的解释请移步:http://vim.wikia.com/wiki/Pasting_registers