Markdown

段内换行

在一行的结尾插入两个或以上的空格

链接地址

链接和文字分开,例如google,baidu

1
2
3
4
[google],[baidu]

[google]:https://www.google.com
[baidu]:https://www.baidu.com

网址链接

用<>包围,例如1234@qq.com(GFM拓展语法可以自动识别,不需要用<>)

1
<1234@qq.com>

表情符号

  • :smile:: :smile:
  • :laughing:: :laughing:

表格

左对齐 居中对齐 右对齐
01 hello a
02 world b
1
2
3
4
| 左对齐 | 居中对齐 | 右对齐 |
| :--- | :--: | ---: |
| 01 | hello | a |
| 02 | world | b |

任务列表

  • [x] 已完成
  • [ ] 未完成
1
2
- [x] 已完成
- [ ] 未完成

锚点

1
- [tips-markdown](#tips-markdown)

拓展

  • 幻灯片:reveal.js
  • 写书:GitBook
  • 写邮件:MarkDown Here(浏览器插件)
  • vscode插件
    • Markdown Preview Pro:增加渲染功能
    • Markdown All in One:方便写作

MySql

数据库命令

1
2
3
4
5
6
7
8
9
10
# 创建数据库
create database database-name;
# 查看所有数据库
show databases;
# 查看数据库信息
show create database database-name;
# 删除数据库
drop database database-name;
# 使用数据库
use database-name;

数据表命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 创建数据表
# PRIMARY KEY 主键约束,用于唯一标识对应的记录
# FOREIGN KEY 外键约束
# NOT NULL 非空约束
# UNIQUE 唯一性约束
# DEFAULT 默认值约束,用于设置字段的默认值
create table table-name(
id int(11),
name varchar(20),
age int(11)
);
# 查看所有数据表
show tables;
# 查看数据表信息(表格)
desc table-name;
# 查看数据表信息(按照创建语句展示)
show create table table-name;
# 添加字段
alter table table-name add field-name field-type;
# 删除字段
alter table table-name drop field-name;
# 删除数据表
drop table table-name;

Java

安装

download

环境变量:新建JAVA_HOME填入C:\Program Files\Java\jre1.8.0_431

Path添加%JAVA_HOME%\bin

NVM

Windows安装

地址

Ubuntu Install

1
2
3
4
sudo apt-get update
sudo apt-get install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc

常用命令

1
2
3
4
5
6
# 显示可用的nodejs版本
nvm list [available]
# 安装nodejs版本
nvm install version
# 切换nodejs版本
nvm use version

NPM

设置镜像仓库

npm install --registry=https://registry.npmmirror.com


Tmux

Tmux基本命令

1
2
3
4
5
# 进入Tmux窗口
tmux
# 退出(并杀死当前会话/窗口/窗格)
exit
Ctrl+D

会话命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 新建会话
tmux new # session-name: 0,1,2...
tmux new -s session-name
# 离开会话
tmux detach # ctrl+b d
# 进入会话
tmux attach -t session-name
# 切换会话
tmux switch -t session-name
# 列出所有会话
tmux ls # ctrl+b s
# 杀死会话
tmux kill-session -t <session-name>
# 重命名会话
tmux rename-session -t session-name new-session-name # ctrl+b $

窗口命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 新建窗口
tmux new-window # ctrl+b c
tmux new-window -n window-name
# 切换窗口
tmux select-window -t window-name
# 为当前窗口重命名
tmux rename-window new-name # ctrl+b ,
# 切换到前/后一个窗口
ctrl+b p/n
# 切换到指定编号的窗口
ctrl+b number
# 从列表中选择窗口
ctrl+b w

窗格命令

一个窗口可以有多个窗格

1
2
3
4
5
6
7
8
9
# 划分上下两个窗格
$ tmux split-window # ctrl+b "
# 划分左右两个窗格
$ tmux split-window -h # ctrl+b %
# 光标切换到上方/下方/左边/右边窗格
$ tmux select-pane -U/D/L/R # ctrl+b ↑/↓/←/→
# 当前窗格前移/后移(交换)
$ tmux swap-pane -U/D # ctrl+b {/}

Ctrl+B命令

按下Ctrl+B后,再按下其它按键触发的快捷键

C-b ?显示如下帮助信息

所有快捷键帮助信息
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
C-b C-b     Send the prefix key                                                                                                                                                                                                  [70/70]
C-b C-o Rotate through the panes
C-b C-z Suspend the current client
C-b Space Select next layout
C-b ! Break pane to a new window
C-b " Split window vertically
C-b # List all paste buffers
C-b $ Rename current session
C-b % Split window horizontally
C-b & Kill current window
C-b ' Prompt for window index to select
C-b ( Switch to previous client
C-b ) Switch to next client
C-b , Rename current window [57/70]
C-b - Delete the most recent paste buffer
C-b . Move the current window
C-b / Describe key binding
C-b 0 Select window 0
C-b 1 Select window 1
C-b 2 Select window 2
C-b : Prompt for a command [43/70]
C-b ; Move to the previously active pane
C-b = Choose a paste buffer from a list
C-b ? List key bindings
C-b C Customize options
C-b D Choose a client from a list
C-b E Spread panes out evenly
C-b L Switch to the last client
C-b M Clear the marked pane
C-b [ Enter copy mode
C-b ] Paste the most recent paste buffer
C-b c Create a new window
C-b d Detach the current client
C-b f Search for a pane [30/70]
C-b i Display window information
C-b l Select the previously current window
C-b m Toggle the marked pane
C-b n Select the next window
C-b o Select the next pane
C-b p Select the previous window
C-b q Display pane numbers
C-b r Redraw the current client
C-b s Choose a session from a list
C-b t Show a clock
C-b w Choose a window from a list
C-b x Kill the active pane
C-b z Zoom the active pane [17/70]
C-b { Swap the active pane with the pane above
C-b } Swap the active pane with the pane below
C-b ~ Show messages
C-b DC Reset so the visible part of the window follows the cursor
C-b PPage Enter copy mode and scroll up
C-b Up Select the pane above the active pane
C-b Down Select the pane below the active pane
C-b Left Select the pane to the left of the active pane
C-b Right Select the pane to the right of the active pane
C-b M-1 Set the even-horizontal layout
C-b M-2 Set the even-vertical layout
C-b M-3 Set the main-horizontal layout
C-b M-4 Set the main-vertical layout [4/70]
C-b M-5 Select the tiled layout
C-b M-n Select the next window with an alert
C-b M-o Rotate through the panes in reverse
C-b M-p Select the previous window with an alert
C-b M-Up Resize the pane up by 5
C-b M-Down Resize the pane down by 5
C-b M-Left Resize the pane left by 5
C-b M-Right Resize the pane right by 5
C-b C-Up Resize the pane up
C-b C-Down Resize the pane down
C-b C-Left Resize the pane left
C-b C-Right Resize the pane right
C-b S-Up Move the visible part of the window up
C-b S-Down Move the visible part of the window down
C-b S-Left Move the visible part of the window left
C-b S-Right Move the visible part of the window right

VSCode

从JetBrains转战vscode了,顺便记录一下遇到的问题和常用的技巧

vscode连接远程服务器

可以直接安装这个插件整合包:Remote Development

接着使用ctrl+shift+p,键入remote-ssh相关命令就可以连接远程了

但是我遇到了问题:“过程试图写入的管道不存在”,解决方法:

  1. 使用管理员方式打开vscode
  2. 清空C:\Users\用户名\.ssh目录下的内容
  3. 连接的时候,记得立刻输入密码(如果报错就retry,继续输入密码连接)

更改缩进tab大小

How to change indentation in Visual Studio Code?

配置多个远程账号连接同个服务器

需要在ssh config文件中,配置不同Host名字

Vscode连接服务器后的终端无法输入,卡死

因为粘贴了不该粘贴的一大段文字,所以直接卡死了,本机连接到这个服务器用户的Vscode窗口的终端都无法使用了

参考

解决就是通过

1
2
3
4
# 找到当前用户的Vscode进程
ps -ef | grep vscode-server | grep wyh
# 逐一杀死
kill -9 id

Sublime

快捷键

  • ctrl+shift+p: 打开万能搜索框

插件

  • terminus: 内嵌的terminal命令行,有panel和tab两种模式

key-map

1
2
3
4
5
6
[
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["alt+q"], "command": "next_view_in_stack" },
{ "keys": ["alt+shift+q"], "command": "prev_view_in_stack" },
]

Maven

生命周期

仅列举主要的阶段

  • default lifecycle
    • validate: validate the project is correct and all necessary information is available
    • compile: compile the source code of the project
    • test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
    • package: take the compiled code and package it in its distributable format, such as a JAR.
    • integration-test: process and deploy the package if necessary into an environment where integration tests can be run
    • verify: run any checks to verify the package is valid and meets quality criteria
    • install: install the package into the local repository, for use as a dependency in other projects locally
    • deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
  • clean lifecycle: cleans up artifacts created by prior builds
  • site lifecycle: generates site documentation for this project

Clash

clash for windows软件

windows直接运行

linux运行:

1
2
3
4
5
6
7
8
9
10
# 使用
./clash -f ~/.config/clash/config.yaml

# clash运行后,使用系统代理(必要步骤)
# 配置的只是当前session的环境变量,使用其他bash窗口,则是没有配置这个环境变量的,需要重新配
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
# 测试
curl -L www.google.com
# 取消系统代理
unset http_proxy https_proxy all_proxy

git配置代理

1
2
3
4
5
# git
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890
git config --global --unset http.proxy
git config --global --unset https.proxy

docker配置代理

使用其他软件,例如docker,则需要在软件层面进行代理配置

参考

1
2
3
4
5
6
7
8
9
10
11
# 编辑配置
sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf

# 填入
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"

# 重启服务
sudo systemctl daemon-reload
sudo systemctl restart docker

windows docker配置代理

打开docker desktop 程序→ settings → Resources → Proxies

【windows】docker start 报错:An attempt was made to access a socket in a way forbidden by its access permissions

1
2
net stop hns
net start hns

同样的,又遇到了,又去搜索了解决方法差不多:https://stackoverflow.com/questions/65272764/ports-are-not-available-listen-tcp-0-0-0-0-50070-bind-an-attempt-was-made-to

1
2
3
net stop winnat
docker start container_name
net start winnat

【Python】解决 pip 开了网络代理之后无法安装包的问题(pip镜像无法访问)

NPM配置代理

1
2
3
4
5
6
7
8
npm config set proxy=http://127.0.0.1:7890
# 默认是https://registry.npmjs.org
npm config set registry=http://registry.npmjs.org
# 如果服务器没配置成上面的http服务器,那么还需要加https代理
npm config set https-proxy http://127.0.0.1:7890
# 关闭代理
npm config delete proxy
npm config delete https-proxy

虽然本地的ubuntu有可视化界面,但在终端中需要用代理的时候,还是需要这样启动终端的代理

比如用singularity命令:singularity build hicrayon.sif docker://nolandocker/hicrayon

这又让我想到,那么使用docker的时候,是不是也只要这样启用代理就行呢?答案是不行,docker应该走的更“深”层次的协议,还是需要像上面那样启用docker配置的代理

(所以clash可视化界面只能启用浏览器的代理?

1
export https_proxy=http://127.0.0.1:1234 http_proxy=http://127.0.0.1:1234 all_proxy=socks5://127.0.0.1:1234