CMD常用命令
开关机
定时关机
shutdown -s -t 60
取消定时关机
shutdown -a
文件
md c:\test\myfolder
rd /s /q [盘符:\][路径\]新目录名
因为rd只能删除空的文件夹,而如果其中有子文件或子文件夹的时候就会停下来,这时我们加上/s就可以直接删除,但是删除过程中会提示你是否确定删除,对于懒癌患者我们有添加了/q,即quiet,安静模式;所以使用以上命令会完整删除你选中的整个文件夹。
创建空文件
type nul>a.txt
创建非空文件
echo myname>a.txt
删除
del a.txt
$client = new-object System.Net.WebClient
$client.DownloadFile('#1','#2')
#1:下载链接 #2:保存地址+文件名
网络
延迟和丢包率:ping ip/域名
Ping 测试 5 次:ping ip/域名 -n 5
保存为 .bat 可执行文件
我们可以将常用的命令输入记事本中,并保存为后缀为 .bat
的可执行文件。
以后只要双击该文件即可执行指定命令
将文件放入系统【启动】目录中,可以实现开机自动运行。
Git
新建文件夹命令是 mkdir+文件夹名
mkdir a
touch+文件名,直接新建一个文件
touch a.txt
编辑文件 vim 加文件名
vim a.txt
vim保存退出 冒号+wq
git基础
查看仓库状态
git status
初始化仓库
git init
git 提交文件
$ git add file1.txt
$ git add file2.txt file3.txt
如果不想提交以上文件,可以移除缓存
git rm --cached
提交以上缓存的文件,“写入关于提交内容的文字描述”
$ git commit -m "add 3 files."
git log 命令可以查看所有产生的 commit 记录
git add & git commit
看到这里估计很多人会有疑问,我想要提交直接进行 commit 不就行了么,为什么先要再 add
一次呢?首先 git add 是先把改动添加到一个「暂存区」,你可以理解成是一个缓存区域,临
时保存你的改动,而 git commit 才是最后真正的提交。这样做的好处就是防止误提交,当然
也有办法把这两步合并成一步,不过后面再介绍,建议新手先按部就班的一步步来。
git 分支
新建一个分支
git branch myTestBranch
切换分支
git checkout myTestBranch
新建一个a分支,并且自动切换到a分支
git checkout -b a
将分支合并到主分支master
1.切换到 master 分支;
2.执行 git merge a
# 可能会有冲突而合并失败,留个包袱,这个到后面进阶的时候再讲。
删除分支
git branch -d a
有些时候可能会删除失败,比如如果a分支的代码还没有合并到master,你执行 git branch -d
a 是删除不了的,它会智能的提示你a分支还有未合并的代码,但是如果你非要删除,那就
执行 git branch -D a 就可以强制删除a分支。
分支重命名
git branch -m命令可以对已经存在的branch重名了
新建版本标签
git tag v1.0
查看历史 tag 记录
git tag
切换到 v1.0 tag的代码状态
git checkout v1.0
向 GitHub 提交代码
生成SSH key
ssh-keygen -t rsa
接着连续三个回车键(不需要输入密码)
GitHub 上添加 SSH key
添加远程库
git remote add [shortname] [url]
Push & Pull
本地代码推到远程仓库(把master分支push到origin远程仓库)
git push origin master
把远程仓库的最新代码拉下来
git pull origin master
## 一般我们在 push 之前都会先 pull ,这样不容易冲突
create a new repository on the command line
echo "# hellow-world" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin https://github.com/joelan96/hellow-world.git
git push -u origin master
push an existing repository from the command line
git remote add origin https://github.com/joelan96/hellow-world.git
git branch -M master
git push -u origin master
$ git —help
$ git --help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index
sparse-checkout Initialize and modify the sparse-checkout
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Reset current HEAD to the specified state
switch Switch branches
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.
Latex
texdoc symbols 调用符号文档
ctrl+alt+j即可从代码跳到pdf。可以搜索latex sycnctex from cursor改成别的键
crtl+点击pdf即可反向查找,如图代码被白框包围。可以搜索Synctex:Keybinding 改成双击
setting.json配置文件
{
"latex-workshop.latex.recipes": [{
"name": "xelatex",
"tools": [
"xelatex"
]
}, {
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
"latex-workshop.latex.tools": [{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOCFILE%"
]
}, {
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
}, {
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
}, {
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}],
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.clean.fileTypes": [
"*.aux",
"*.bbl",
"*.blg",
"*.idx",
"*.ind",
"*.lof",
"*.lot",
"*.out",
"*.toc",
"*.acn",
"*.acr",
"*.alg",
"*.glg",
"*.glo",
"*.gls",
"*.ist",
"*.fls",
"*.log",
"*.fdb_latexmk"
],
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"java.configuration.checkProjectSettingsExclusions": false,
"editor.fontSize": 16,
"launch": {
"configurations": [],
"compounds": []
}
}
IDEA常用快捷键
顶部code 可以使用和查看所有快捷键
Alt+Enter 导入包,自动修正代码
Ctrl+Y 删除光标所在行
Ctrl+D 复制光标所在行的内容,插入光标位置下面
Ctrl+Alt+L 格式化代码
Ctrl+/ 单行注释
Ctrl+Shift+/ 选中代码注释,多行注释,再按取消注释
Alt+Ins 自动生成代码,toString,get,set等方法
Alt+Shift+ 上下箭头 移动当前代码行
**ctrl+alt+t Surround With快捷键
shift+f6 所有同名变量一起变
array.fori 数组遍历
array.forr 数组倒序遍历
Ctrl+”+/-”,当前方法展开、折叠
Ctrl+Shift+”+/-”,全部展开、折叠
Conda
# 升级conda
conda update conda
# 升级anconda(需先升级conda)
conda update anaconda
# 升级python
conda update python
# 安装包,并且安装包所依赖的包
!pip install missingno -U
# 利用.yml文件 创建虚拟文件
conda env create -f environment.yml -n new_env_name
二.创建虚拟环境的流程
1.在命令行输入
conda create -n xxx python=3.6
xxx为自己命名的虚拟环境名称,该文件可在Anaconda安装目录 envs文件下找到
2.使用激活(或切换不同python版本)的虚拟环境
python --version # 可以检查当前python的版本
Linux: source activate your_env_name(虚拟环境名称)
###Windows: conda activate your_env_name(虚拟环境名称)
三.对虚拟环境中安装额外的包
conda install -n your_env_name [package]
四.关闭虚拟环境
Linux: source deactivate
Windows: deactivate
五.删除虚拟环境
conda remove -n your_env_name(虚拟环境名称) --all
conda remove --name your_env_name package_name # 删除环境中的某个包
PYTHON几种常见获取帮助的方式
直接在执行命令窗口输入help()命令,可以连续的查询帮助文档。
help()
help> print
也可以直接使用help(print)方式
help(print)
import tkinter
print(dir(tkinter))
import tkinter
print(tkinter.__doc__)
Jupyter
在函数后面按入Shift+Tab组合键,查看对应的帮助文档
解决jupyter notebook无法找到虚拟环境的问题
1.首先进入到自己创建的虚拟环境(pytorch是虚拟环境的名字)
activate pytorch
2.在该环境下下载这个库
conda install ipykernel
conda install nb_conda
#我查了很多博主的文章,大部分都是虚拟环境缺这两个库,可能是版本原因,我只缺少了nb_conda这个库,下载之后就成功了。
3.打开jupyter notebook,我们就可以看到我们创建的虚拟环境pytorch了
jupyter notebook