Skip to content

Commit 061a290

Browse files
committed
github使用技巧
1 parent 77cbb09 commit 061a290

File tree

5 files changed

+132
-39
lines changed

5 files changed

+132
-39
lines changed

Java/并发.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
- [实现原理](#%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86-1)
6161
- [其他](#%E5%85%B6%E4%BB%96)
6262
- [Daemon Thread](#daemon-thread)
63-
- [参考链接](#%E5%8F%82%E8%80%83%E9%93%BE%E6%8E%A5)
63+
- [参考资料](#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99)
6464

6565
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
6666

@@ -1140,11 +1140,20 @@ Daemon的作用是为其他线程的运行提供便利服务,守护线程最
11401140

11411141

11421142

1143-
## 参考链接
1143+
## 参考资料
11441144

11451145
[线程中断](https://zhuanlan.zhihu.com/p/45667127)
11461146

11471147
[synchronized实现原理](https://www.cnblogs.com/paddix/p/5367116.html)
11481148

11491149
[指令重排导致单例模式失效](https://blog.csdn.net/jiyiqinlovexx/article/details/50989328)
11501150

1151+
1152+
1153+
> 本文已经收录到github仓库,此仓库用于分享Java相关知识总结,包括Java基础、MySQL、Spring Boot、MyBatis、Redis、RabbitMQ、计算机网络、数据结构与算法等等,欢迎大家提pr和star!
1154+
>
1155+
> github地址:https://github.com/Tyson0314/Java-learning
1156+
>
1157+
> 如果github访问不了,可以访问gitee仓库。
1158+
>
1159+
> gitee地址:https://gitee.com/tysondai/Java-learning

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137

138138
[Maven实战总结](工具/Maven实战.md)
139139

140+
[Github使用技巧](工具/Github指南.md)
141+
140142
[Jenkins一键部署](工具/jenkins.md)
141143

142144
[npm命令](工具/NPM.md)

工具/GitHub指南.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4+
5+
- [GitHub 的使用](#github-%E7%9A%84%E4%BD%BF%E7%94%A8)
6+
- [GitHub 搜索技巧](#github-%E6%90%9C%E7%B4%A2%E6%8A%80%E5%B7%A7)
7+
- [使用GitHub可以做什么](#%E4%BD%BF%E7%94%A8github%E5%8F%AF%E4%BB%A5%E5%81%9A%E4%BB%80%E4%B9%88)
8+
9+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
10+
11+
作为全球最大的~~代码托管~~同性交友平台,GitHub上面有着丰富的学习资源。
12+
13+
要使用GitHub,就要先学会使用Git。
14+
15+
Git又是什么呢?简单的说,**Git 是一个管理你的代码历史记录的工具。**
16+
17+
# GitHub 的使用
18+
19+
首先看下怎么使用GitHub。
20+
21+
- 注册一个GitHub账号,这样比较简单,不详细展开讲了。
22+
23+
- 创建一个新的仓库,用来存放项目。
24+
25+
![](https://gitee.com/tysondai/img/raw/master/image-20210822154700616.png)
26+
27+
- 或者你在GitHub上看到别人有一个超级无敌有趣的项目,可以直接fork过来,可以理解成复制过来,变成你自己的。之后你想怎么改就怎么改!
28+
29+
![image-20210822155107839](https://gitee.com/tysondai/img/raw/master/image-20210822155107839.png)
30+
31+
- 然后你可以通过Git命令行`git clone xxx`把项目clone到本地,在本地进行创作。
32+
33+
![](https://gitee.com/tysondai/img/raw/master/image-20210822155359118.png)
34+
35+
- 最后,在本地创作完成,可以使用`git commit -m xxx`提交到本地库,然后使用`git push`把修改推送到GitHub仓库。之后就可以在GitHub上面看到你修改的内容啦~
36+
37+
以上就是GitHub的基本使用方法,有一些细节没有写出来,但是关键的步骤都列举出来了~
38+
39+
# GitHub 搜索技巧
40+
41+
接下来说一下GitHub的搜索技巧,非常重要!
42+
43+
- 评价GitHub项目的两个重要的参数:star和fork。
44+
45+
![](https://gitee.com/tysondai/img/raw/master/image-20210822161003170.png)
46+
47+
比较优秀和热门的项目,star数目和fork数目都会比较多。我们可以根据这两个参数筛选出比较好的项目。使用`关键字 stars:>=xxx forks:>=xxx` 可以筛选出star和fork数目大于xxx的相关项目。
48+
49+
![](https://gitee.com/tysondai/img/raw/master/image-20210822161122586.png)
50+
51+
- 使用 `awesome 关键字`,可以筛选出比较高质量的学习、书籍、工具类或者插件类的集合。
52+
53+
![](https://gitee.com/tysondai/img/raw/master/image-20210822161608599.png)
54+
55+
- 在特定位置搜索关键词。有些关键词出现在项目的不同位置,比如项目名称、项目描述和README等。使用`关键词 in name/description/Readme`,可以搜索到相关的内容。比如使用`spring in name`,可以搜索到在项目名中包含spring的项目。
56+
57+
![image-20210822162144086](https://gitee.com/tysondai/img/raw/master/image-20210822162144086.png)
58+
59+
- 指定条件搜索关键词。如`tool language:java`搜索到的是包含关键字tool的Java项目,`tool followers:>1000`可以搜索到包含关键字tool,且follower数量大于1000的项目。
60+
61+
![](https://gitee.com/tysondai/img/raw/master/image-20210822163111390.png)
62+
63+
64+
65+
# 使用GitHub可以做什么
66+
67+
- 托管代码。GitHub 上记录这代码的修改历史,必要时可以进行回退;
68+
69+
- 搜索牛逼的开源项目,参与开源项目开发。这里分享下自己的一个开源仓库,用于分享Java核心知识,包括Java基础、MySQL、SpringBoot、Mybatis、Redis、RabbitMQ等等,面试必备。
70+
71+
https://github.com/Tyson0314/Java-learning
72+
73+
- 文档神器。可以为自己的项目建立wiki,可以用markdown语法写wiki;
74+
75+
![](https://gitee.com/tysondai/img/raw/master/image-20210822172419760.png)
76+
77+
- 使用GitHub pages建立个人静态网站,搞一个有自己域名的独立博客,想想都觉得开心。使用GitHub pages的好处是搭建简单而且免费,支持静态脚本,并且可以绑定自己的域名。具体可以参考:[GitHub Pages 建立个人网站详细教程 - 知乎 (zhihu.com)](https://zhuanlan.zhihu.com/p/58229299)
78+
79+
- 写书写文章,团队协作分工。
80+
81+
82+
83+
最后给大家分享一个GitHub仓库,上面放了200多本经典的计算机书籍,包括数据库、操作系统、计算机网络、数据结构和算法等,可以star一下,下次找书直接在上面搜索,仓库持续更新中~
84+
85+
GitHub地址:https://github.com/Tyson0314/java-books
86+
87+
如果github访问不了,可以访问gitee仓库。
88+
89+
gitee地址:https://gitee.com/tysondai/java-books
90+
91+

数据库/Mysql执行计划.md

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
22
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3-
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
3+
44

55
- [id](#id)
66
- [select_type](#select_type)
@@ -29,6 +29,7 @@
2929
- [using temporary](#using-temporary)
3030
- [filesort](#filesort)
3131
- [using join buffer](#using-join-buffer)
32+
- [参考资料](#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99)
3233

3334
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
3435

@@ -89,7 +90,7 @@ where blog_id = (
8990

9091
三个表依次嵌套,发现最里层的子查询 `id`最大,最先执行。
9192

92-
![explain-id](https://gitee.com/tysondai/img/raw/master/explain-id.png)
93+
![](https://gitee.com/tysondai/img/raw/master/explain-id.png)
9394

9495
## select_type
9596

@@ -105,13 +106,13 @@ where blog_id = (
105106

106107
查询的表名,并不一定是真实存在的表,有别名显示别名,也可能为临时表。当from子句中有子查询时,table列是 `<derivenN>`的格式,表示当前查询依赖 id为N的查询,会先执行 id为N的查询。
107108

108-
![explain-table](https://gitee.com/tysondai/img/raw/master/image-20210804083523885.png)
109+
![](https://gitee.com/tysondai/img/raw/master/image-20210804083523885.png)
109110

110111
## partitions
111112

112113
查询时匹配到的分区信息,对于非分区表值为`NULL`,当查询的是分区表时,`partitions`显示分区表命中的分区情况。
113114

114-
![explain-partitions](https://gitee.com/tysondai/img/raw/master/image-20210802022931773.png)
115+
![](https://gitee.com/tysondai/img/raw/master/image-20210802022931773.png)
115116

116117
## type
117118

@@ -121,25 +122,25 @@ where blog_id = (
121122

122123
当表仅有一行记录时(系统表),数据量很少,往往不需要进行磁盘IO,速度非常快。比如,Mysql系统表proxies_priv在Mysql服务启动时候已经加载在内存中,对这个表进行查询不需要进行磁盘 IO。
123124

124-
![explain-system](https://gitee.com/tysondai/img/raw/master/image-20210801233419732.png)
125+
![](https://gitee.com/tysondai/img/raw/master/image-20210801233419732.png)
125126

126127
### const
127128

128129
单表操作的时候,查询使用了主键或者唯一索引。
129130

130-
![explain-const](https://gitee.com/tysondai/img/raw/master/explain-const.png)
131+
![](https://gitee.com/tysondai/img/raw/master/explain-const.png)
131132

132133
### eq_ref
133134

134135
**多表关联**查询的时候,主键和唯一索引作为关联条件。如下图的sql,对于user表(外循环)的每一行,user_role表(内循环)只有一行满足join条件,只要查找到这行记录,就会跳出内循环,继续外循环的下一轮查询。
135136

136-
![explain-eq_ref](https://gitee.com/tysondai/img/raw/master/image-20210801232638027.png)
137+
![](https://gitee.com/tysondai/img/raw/master/image-20210801232638027.png)
137138

138139
### ref
139140

140141
查找条件列使用了索引而且不为主键和唯一索引。虽然使用了索引,但该索引列的值并不唯一,这样即使使用索引查找到了第一条数据,仍然不能停止,要在目标值附近进行小范围扫描。但它的好处是不需要扫全表,因为索引是有序的,即便有重复值,也是在一个非常小的范围内做扫描。
141142

142-
![explain-ref.png](https://gitee.com/tysondai/img/raw/master/explain-ref.png)
143+
![](https://gitee.com/tysondai/img/raw/master/explain-ref.png)
143144

144145
### ref_or_null
145146

@@ -149,31 +150,31 @@ where blog_id = (
149150

150151
使用了索引合并优化方法,查询使用了两个以上的索引。新建comment表,id为主键,value_id为非唯一索引,执行`explain select content from comment where value_id = 1181000 and id > 1000;`,执行结果显示查询同时使用了id和value_id索引,type列的值为index_merge。
151152

152-
![type-index_merge](https://gitee.com/tysondai/img/raw/master/image-20210802001215614.png)
153+
![](https://gitee.com/tysondai/img/raw/master/image-20210802001215614.png)
153154

154155
### range
155156

156157
有范围的索引扫描,相对于index的全索引扫描,它有范围限制,因此要优于index。像between、and、'>'、'<'、in和or都是范围索引扫描。
157158

158-
![explain-range.png](https://gitee.com/tysondai/img/raw/master/explain-range.png)
159+
![](https://gitee.com/tysondai/img/raw/master/explain-range.png)
159160

160161
### index
161162

162163
index包括select索引列,order by主键两种情况。
163164

164165
1. order by主键。这种情况会按照索引顺序全表扫描数据,拿到的数据是按照主键排好序的,不需要额外进行排序。
165166

166-
![type-index-orderBy](https://gitee.com/tysondai/img/raw/master/image-20210801225045980.png)
167+
![](https://gitee.com/tysondai/img/raw/master/image-20210801225045980.png)
167168

168169
2. select索引列。type为index,而且extra字段为using index,也称这种情况为索引覆盖。所需要取的数据都在索引列,无需回表查询。
169170

170-
![type-index-selectIndexColumn](https://gitee.com/tysondai/img/raw/master/image-20210801225942948.png)
171+
![](https://gitee.com/tysondai/img/raw/master/image-20210801225942948.png)
171172

172173
### all
173174

174175
全表扫描,查询没有用到索引,性能最差。
175176

176-
![explain-all](https://gitee.com/tysondai/img/raw/master/explain-all.png)
177+
![](https://gitee.com/tysondai/img/raw/master/explain-all.png)
177178

178179
## possible_keys
179180

@@ -221,13 +222,13 @@ CREATE TABLE `t_orderdetail` (
221222

222223
查询的列未被索引覆盖,where筛选条件非索引的前导列。对存储引擎返回的结果进行过滤(Post-filter,后过滤),一般发生在MySQL服务器,而不是存储引擎层。
223224

224-
![extra-using-where](https://gitee.com/tysondai/img/raw/master/image-20210802232729417.png)
225+
![](https://gitee.com/tysondai/img/raw/master/image-20210802232729417.png)
225226

226227
### using index
227228

228229
查询的列被索引覆盖,并且where筛选条件符合最左前缀原则,通过**索引查找**就能直接找到符合条件的数据,不需要回表查询数据。
229230

230-
![extra-using-index](https://gitee.com/tysondai/img/raw/master/image-20210802232357282.png)
231+
![](https://gitee.com/tysondai/img/raw/master/image-20210802232357282.png)
231232

232233
### Using where&Using index
233234

@@ -237,29 +238,29 @@ CREATE TABLE `t_orderdetail` (
237238

238239
- where筛选条件不符合最左前缀原则
239240

240-
![extra-using-where&index](https://gitee.com/tysondai/img/raw/master/image-20210802233120283.png)
241+
![](https://gitee.com/tysondai/img/raw/master/image-20210802233120283.png)
241242

242243
- where筛选条件是索引列前导列的一个范围
243244

244-
![extra-using-where&index](https://gitee.com/tysondai/img/raw/master/image-20210802233455880.png)
245+
![](https://gitee.com/tysondai/img/raw/master/image-20210802233455880.png)
245246

246247
### null
247248

248249
查询的列未被索引覆盖,并且where筛选条件是索引的前导列,也就是用到了索引,但是部分字段未被索引覆盖,必须回表查询这些字段,Extra中为NULL。
249250

250-
![extra-null](https://gitee.com/tysondai/img/raw/master/image-20210802234122321.png)
251+
![](https://gitee.com/tysondai/img/raw/master/image-20210802234122321.png)
251252

252253
### using index condition
253254

254255
索引下推(index condition pushdown,ICP),先使用where条件过滤索引,过滤完索引后找到所有符合索引条件的数据行,随后用 WHERE 子句中的其他条件去过滤这些数据行。
255256

256257
不使用ICP的情况(`set optimizer_switch='index_condition_pushdown=off'`),如下图,在步骤4中,没有使用where条件过滤索引:
257258

258-
![no-icp](https://gitee.com/tysondai/img/raw/master/no-icp.png)
259+
![](https://gitee.com/tysondai/img/raw/master/no-icp.png)
259260

260261
使用ICP的情况(`set optimizer_switch='index_condition_pushdown=on'`):
261262

262-
![icp](https://gitee.com/tysondai/img/raw/master/icp.png)
263+
![](https://gitee.com/tysondai/img/raw/master/icp.png)
263264

264265
下面的例子使用了ICP:
265266

@@ -268,17 +269,11 @@ explain select user_id, order_id, order_status
268269
from t_order where user_id > 1 and user_id < 5\G;
269270
```
270271

271-
![icp-demo](https://gitee.com/tysondai/img/raw/master/image-20210803084617433.png)
272+
![](https://gitee.com/tysondai/img/raw/master/image-20210803084617433.png)
272273

273274
关掉ICP之后(`set optimizer_switch='index_condition_pushdown=off'`),可以看到extra列为using where,不会使用索引下推。
274275

275-
![no-icp-demo](https://gitee.com/tysondai/img/raw/master/image-20210803084815503.png)
276-
277-
> [索引下推例子](https://www.cnblogs.com/Chenjiabing/p/12600926.html)
278-
>
279-
> [索引下推图解](https://www.cnblogs.com/zengkefu/p/5684101.html)
280-
>
281-
> [索引下推优化](https://www.cnblogs.com/zengkefu/p/5684101.html)
276+
![](https://gitee.com/tysondai/img/raw/master/image-20210803084815503.png)
282277

283278
### using temporary
284279

@@ -292,20 +287,16 @@ from t_order where user_id > 1 and user_id < 5\G;
292287
- select 查询字段不全是索引字段
293288
- select 查询字段都是索引字段,但是 order by 字段和索引字段的顺序不一致
294289

295-
![explain-filesort](https://gitee.com/tysondai/img/raw/master/image-20210804084029239.png)
290+
![](https://gitee.com/tysondai/img/raw/master/image-20210804084029239.png)
296291

297292
### using join buffer
298293

299294
Block Nested Loop,需要进行嵌套循环计算。两个关联表join,关联字段均未建立索引,就会出现这种情况。比如内层和外层的type均为ALL,rows均为4,需要循环进行4*4次计算。常见的优化方案是,在关联字段上添加索引,避免每次嵌套循环计算。
300295

301296

302297

303-
本文参考了一些优秀的博客,感兴趣的可以了解下:
298+
## 参考资料
304299

305300
- [Explain执行计划](https://juejin.cn/post/6844904163969630221#heading-7)
301+
- [索引下推例子](https://www.cnblogs.com/Chenjiabing/p/12600926.html) | [索引下推图解](https://www.cnblogs.com/zengkefu/p/5684101.html) | [索引下推优化](https://www.cnblogs.com/zengkefu/p/5684101.html)
306302

307-
308-
309-
码字不易,如果本文写的不错,可以点个赞,让我知道,支持我写出更好的文章!
310-
311-
我是程序员大彬 ,专注Java后端硬核知识分享,欢迎大家关注~

网络/网络.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
- [DNS解析](#dns%E8%A7%A3%E6%9E%90)
3232
- [加密算法](#%E5%8A%A0%E5%AF%86%E7%AE%97%E6%B3%95)
3333
- [CDN](#cdn)
34-
- [参考链接](#%E5%8F%82%E8%80%83%E9%93%BE%E6%8E%A5)
34+
- [参考资料](#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99)
3535

3636
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
3737

@@ -333,7 +333,7 @@ CDN用户访问流程:
333333

334334
最简单的CDN网络有一个负责全局负载均衡的DNS和各节点一台Cache,即可运行。DNS支持根据用户源IP地址解析不同的IP,实现就近访问CDN服务器。为了保证高可用性等,需要监视各节点的流量、健康状况等。一个节点的单台Cache承载数量不够时,才需要多台Cache,多台Cache同时 工作,才需要负载均衡器,使Cache群协同工作。
335335

336-
# 参考链接
336+
# 参考资料
337337

338338
计算机网络,谢希仁
339339

0 commit comments

Comments
 (0)