前言

简单存放一些软件配置项、使用方式、shell 命令等。

软件类

1. conda

1.1 环境管理

  • 检查本地环境
    1
    conda env list
  • 激活环境
    1
    conda activate environmentName
  • 退出环境
    1
    conda deactivate
  • 创建环境
    1
    conda create --name environmentName python=version

1.2 包管理

  • 安装包
    1
    2
    3
    conda install package1, package2, package3
    conda install packageName=version
    conda install -n environmentName packageName
  • 更新包
    1
    conda update packageName
  • 查看包
    1
    2
    conda list
    conda list -n environmentName
  • 删除包
    1
    conda remove packageName

工具类

1. .prettierrc.json

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
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": true,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf",
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"bracketSameLine": false,
"vueIndentScriptAndStyle": false,
"embeddedLanguageFormatting": "auto",
"jsxSingleQuote": true,
"overrides": [
{
"files": "*.{json,json5}",
"options": {
"printWidth": 100,
"singleQuote": false,
"trailingComma": "none"
}
},
{
"files": "*.{yaml,yml}",
"options": {
"singleQuote": false,
"tabWidth": 2
}
},
{
"files": "*.html",
"options": {
"printWidth": 120,
"htmlWhitespaceSensitivity": "ignore"
}
},
{
"files": "*.md",
"options": {
"proseWrap": "always",
"printWidth": 100
}
},
{
"files": "*.sql",
"options": {
"printWidth": 100,
"keywordCase": "upper",
"identifierCase": "lower",
"linesBetweenQueries": 1,
"useTabs": true,
"tabWidth": 4
}
}
]
}

2. .vimrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
" 显示行号
set number
" 高亮当前行
set cursorline
" 语法高亮
syntax on
" 自动缩进
set autoindent
" Tab 转换成空格
set expandtab
set tabstop=4
set shiftwidth=4
" 搜索时忽略大小写
set ignorecase
" 输入时实时搜索
set incsearch
" 显示匹配括号
set showmatch
" 启动鼠标支持(滚动、选择)
set mouse=a
" 共享系统剪贴板
set clipboard=unnamed

3. .npmrc

1
2
3
proxy=http://127.0.0.1:10808
https-proxy=http://127.0.0.1:10808
registry=http://registry.npmmirror.com

4. .sqlfluff

[!NOTE]

sqlfluff 是基于 Python 的 SQL 格式化工具,在 VSCode 中有对应的插件,.sqlfluff 是其对应的 ini 格式的配置文件。

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
[sqlfluff]
templater = raw
dialect = mysql
large_file_skip_byte_limit = 0
# 输出内容
verbose = 1
# 忽略不可修复的错误
ignore_unfixable = True
# 最大长度
max_line_length = 0
# 如果长行末尾有注释,移动到前一行
trailing_comments = before
rules = AL01,AL02,AL03,AL04,AL05,AL08,AL09,AM01,AM02,AM03,AM05,AM06,CP01,CP03,CP04,CP05,CV01,CV02,CV03,CV05,CV06,CV07,CV08,CV10,CV11,CV12,LT02,LT03,LT04,LT05,LT06,LT07,LT08,LT09,LT10,LT11,LT12,LT13,LT15,RF01,RF02,RF03,RF04,RF05,RF06,ST01,ST02,ST03,ST04,ST05,ST06,ST07,ST08,ST09,ST10,ST11

# 缩进
[sqlfluff:indentation]
indent_unit = tab
tab_space_size = 2
indented_joins = False
indented_ctes = False
indented_using_on = False
indented_on_contents = False
indented_then = False
indented_then_contents = False
allow_implicit_indents = True
template_blocks_indent = False

# 对齐表达式
[sqlfluff:layout:type:alias_expression]
spacing_before = align
; align_scope = bracketed
; align_within = select_clause
[sqlfluff:layout:type:comparison_operator]
line_position = leading
[sqlfluff:layout:type:binary_operator]
line_position = leading
[sqlfluff:layout:type:select_clause]
line_position = leading
spacing_before = alone
# 窗口函数配置
; [sqlfluff:layout:type:over_clause]
; line_position = trailing
# 函数配置
[sqlfluff:layout:type:function_name]
spacing_before = single:inline

# 逗号前置
[sqlfluff:layout:type:comma]
line_position = leading
# where 前置
[sqlfluff:layout:type:where_clause]
keyword_line_position = leading
# partition by 前置
[sqlfluff:layout:type:partitionby_clause]
keyword_line_position = leading
line_position = inline
# order by 前置
[sqlfluff:layout:type:orderby_clause]
keyword_line_position = leading
line_position = inline
# group by 前置
[sqlfluff:layout:type:groupby_clause]
keyword_line_position = leading
line_position = inline

# AL01 表别名强制书写 AS
[sqlfluff:rules:aliasing.table]
aliasing = explicit
# AL02 列别名强制书写 AS
[sqlfluff:rules:aliasing.column]
aliasing = explicit
# AL04 表别名唯一检测
# AL05 表别名未使用检测
[sqlfluff:rules:aliasing.unused]
alias_case_check = case_insensitive
# AL08 每个子句中的列别名应该是唯一的
# AL09 列别名不应该自别名
# AM01 带有 GROUP BY 的 SELECT 语句中,DISTINCT 使用不明确,有问题
# AM02 使用 UNION ALL 或者带有 DISTINCT 更好
# AM03 ORDER BY 子句中,列的排序方向不明确,要么都设置方向
# AM05 使用的 JOIN 子句应该完全限定类型
[sqlfluff:rules:ambiguous.join]
fully_qualify_join_types = inner
# AM06 在 GROUP BY ORDER BY 子句中列引用不一致
[sqlfluff:rules:ambiguous.column_references]
group_by_and_order_by_style = explicit
# CP01 关键字大小写
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = upper
# CP03 函数名大小写
[sqlfluff:rules:capitalisation.functions]
extended_capitalisation_policy = upper
# CP04 布尔值空值字面量大小写
[sqlfluff:rules:capitalisation.literals]
capitalisation_policy = upper
# CP05 数据类型大小写
[sqlfluff:rules:capitalisation.types]
extended_capitalisation_policy = upper
# CV01 不等于统一只使用一种形式
[sqlfluff:rules:convention.not_equal]
preferred_not_equal_style = c_style
# CV02 使用 COALESCE 而不是 IFNULL
# CV03 选择子句中的尾随逗号,比如说 FROM 前最后一个列引用后还有没有逗号 forbid 为没有
[sqlfluff:rules:convention.select_trailing_comma]
select_clause_trailing_comma = forbid
# CV05 使用统一方式比较 NULL
# CV06 语句必须以分号结尾
[sqlfluff:rules:convention.terminator]
multiline_newline = True
require_final_semicolon = True
# CV07 顶级语句不能被包裹在括号内
# CV08 使用 LEFT JOIN 而不是 RIGHT JOIN
# CV10 使用统一的引号
[sqlfluff:rules:convention.quoted_literals]
force_enable = False
preferred_quoted_literal_style = single_quotes
# CV11 使用统一的类型转换函数
[sqlfluff:rules:convention.casting_style]
preferred_type_casting_style = cast
# CV12 使用 JOIN ON 而不是 WHERE 连接表
# LT01 空格间距
# LT02 缩进
# LT03 运算符位置,首、尾
# LT04 逗号位置,首、尾
# LT05 行太长
[sqlfluff:rules:layout.long_lines]
ignore_comment_clauses = True
ignore_comment_lines = True
# LT06 函数名后紧跟括号
# LT07 WITH 子句的结束括号应该另起一行
# LT08 公共子查询结束括号后应该保留一个空行
# LT09 选择的目标列应该另起一行,除非只有一个
[sqlfluff:rules:layout.select_targets]
wildcard_policy = multiple
# LT10 SELECT 修饰符 DISTINCT 必须和 SELECT 同一行
# LT11 UNION 运算符前后换行
# LT12 SQL 文件末尾保留一个空行
# LT13 SQL 文件开头不能有空行
# LT14 关键字子句应该统一在头或者尾换行
# LT15 不允许连续很多空行
[sqlfluff:rules:layout.newlines]
maximum_empty_lines_between_statements = 1
maximum_empty_lines_inside_statements = 1
# RF01 引用列不能引用未在 FROM 子句中出现的对象
[sqlfluff:rules:references.from]
force_enable = False
# RF02 如果 SELECT 语句引用了多个表或者视图,那么列的引用需要进行限定,不能冲突
[sqlfluff:rules:references.qualification]
subqueries_ignore_external_references = True
# RF03 在单表的查询中,列的引用也应该保持一致
[sqlfluff:rules:references.consistent]
force_enable = False
single_table_references = consistent
# RF04 关键字不能作为标识符
[sqlfluff:rules:references.keywords]
quoted_identifiers_policy = none
unquoted_identifiers_policy = all
# RF05 标识符中不允许使用特殊字符
[sqlfluff:rules:references.special_chars]
allow_space_in_identifier = False
quoted_identifiers_policy = none
unquoted_identifiers_policy = all
# RF06 不需要带引号的标识符,取消引号
[sqlfluff:rules:references.quoting]
case_sensitive = True
prefer_quoted_identifiers = False
prefer_quoted_keywords = True
# ST01 在 CASE WHEN 语句中不要写 ELSE NULL,没有用
# ST02 取消不必要的 CASE WHEN 语句
# ST03 删除没有使用的公共子查询
# ST04 CASE WHEN 语句中取消不必要的嵌套 CASE,ELSE 扁平化
# ST05 JOIN|FROM 语句不允许包含子查询,改用公共子查询 CTE
[sqlfluff:rules:structure.subquery]
forbid_subquery_in = both
# ST06 在 SELECT 中先放通配符,后放简单的目标列
# ST07 在 JOIN 语句中,明确使用 ON xx = xx ,而不使用 USING
# ST08 取消 DISTINCT 与括号一起的使用
# ST09 在 JOIN 语句中,按照先后引用表的顺序书写 ON 先出现表.xx = 后出现表.xx
[sqlfluff:rules:structure.join_condition_order]
preferred_first_table_in_join_clause = earlier
# ST10 取消冗余的常量表达式
# ST11 删除 SELECT 中的未引用但是却连接了的表

脚本命令

1. VPS 路由测试(backtrace

1
2
3
4
# 回程路由一键测试
curl https://raw.githubusercontent.com/zhanghanyun/backtrace/main/install.sh -sSf | sh
# 去程测试
traceroute 1.2.3.4