-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
littleji
committed
Feb 10, 2025
1 parent
32254ae
commit ad3e0e0
Showing
256 changed files
with
3,025 additions
and
17,622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
zola | ||
zola.exe | ||
zola-v0.19.2-x86_64-pc-windows-msvc.tar.gz | ||
zola-v0.19.2-x86_64-unknown-linux-gnu.tar.gz | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
+++ | ||
title = "建站中的一些问题" | ||
date = 2016-05-10 09:50:20 | ||
updated = 2025-02-06 17:00:00 | ||
description = "" | ||
|
||
[taxonomies] | ||
tags = ["OPS"] | ||
|
||
[extra] | ||
quick_navigation_buttons = true | ||
toc = true | ||
mermaid = true | ||
|
||
+++ | ||
|
||
## 概述 | ||
* 主要是为了更好的记录建站中遇到的问题,一方面备忘,一方面来为后来者提供方便 | ||
|
||
## 问题 | ||
|
||
### 自定义域名跳转到对应的GitPage页 | ||
* 首先需要在对应的域名解析服务器上添加两条记录如下所示 | ||
|
||
|
||
记录类型 | 主机记录 | 记录值 | ||
------------- | ------------- | ------------- | ||
A | @ | 192.30.xxx.xxx | ||
A | @ | 192.30.xxx.xxx | ||
|
||
* 在对应的XXX.github.io repository下加入一个以CNAME命名的文件,并在其中写入你的自定义域名如`baidu.com` 切记不要加`www`,之后等待生效即可 | ||
|
||
### 当发现css js等静态文件加载较慢 | ||
* 这种时候可以使用 七牛等云加速产品来保证网页的加载速度,七牛每个月有一些免费流量,只是有的时候还不如github上的文件加载速度快 | ||
* 更改前端库cdn 为国内的cdn | ||
* 更改google的字体库位 useso | ||
* 几个推荐的前端库 | ||
* [BootCDN](http://www.bootcdn.cn/?) 这一个好像就够用了 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
+++ | ||
title = "邻接矩阵,邻接列表一些基本概念和应用(Adjacency list and Adjacency matrix)" | ||
date = 2016-05-12 13:38:20 | ||
updated = 2025-02-08 17:00:00 | ||
description = "" | ||
|
||
[taxonomies] | ||
tags = ["算法与数据结构(Algorithm&DataStructure)"] | ||
|
||
[extra] | ||
quick_navigation_buttons = true | ||
toc = true | ||
mermaid = true | ||
+++ | ||
|
||
### 邻接矩阵 | ||
|
||
#### 概述 | ||
邻接矩阵,其只要是用来存储一个图结构. | ||
|
||
首先一个无向图如下所示 | ||
|
||
<div align=center> | ||
<img class="little" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/28/6n-graph2.svg/185px-6n-graph2.svg.png" /> | ||
</div> | ||
<div align=center> | ||
<img class="little" src="https://upload.wikimedia.org/math/c/a/e/caec49086f2faf102df7972d0dcde54b.png" /> | ||
</div> | ||
|
||
#### 性质 | ||
|
||
##### 无向图的邻接矩阵对称矩阵 | ||
由上图发现该图其实是个对称矩阵,这是由无向图的性质决定的,无向图的各个顶点之间的连线是具有相互性的,于是每有一个顶点之间的连线就要延伸出一组关系,表现在邻接矩阵上就是对称点的值相同(a12 = a21 依次类推) | ||
|
||
##### 邻接矩阵的大小=顶点数*顶点数 | ||
很容易了解,一个图的顶点数决定了其对应邻接矩阵的大小,例如上图是个6个顶点的图,则对应的矩阵需要6*6的大小方可表达其结构 | ||
|
||
##### 数据压缩的属性 | ||
* 由于事实上每一组顶点关系只需要一位来来表达,处理一个有4个顶点的图仅仅需要 4*4/8个=2个字节,这是很节省空间的,如果是一个无向图的话,所需要的空间则可以再减少一半的空间 4*4/16个=1个字节,通过这个方法已经接近信息论中表达一个n个顶点所需要字节数的下界. | ||
* 但是也存在一些问题,例如其可能需要存储那些本来不存在的边 | ||
|
||
### 邻接链表 | ||
|
||
#### 概述 | ||
邻接链表也是一种表达图的方式 | ||
假设有无向图如下所示 | ||
<div align=center> | ||
<img class="little" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/Simple_cycle_graph.svg/120px-Simple_cycle_graph.svg.png" align=center > | ||
</div> | ||
|
||
则相对应的表示为三个list{b,c},{a,c},{a,b} | ||
但是换出去空间的节省后,查询时间也会相应的边长 | ||
例如:查询a与b是否有关系需要首先定位到a的链表{b,c},再对这个链表进行遍历,如果没有b,也就说明对其进行了完整的遍历,浪费了较多的时间,当然可以采用快速搜索的方式进行优化 | ||
|
||
|
||
* 事实上邻接列表还有一点是其应用在大型稀疏矩阵中,因为邻接矩阵不需要浪费空间来表达那些不存在的边缘 | ||
|
||
##### 参考: | ||
* [Adjacency_matrix](https://en.wikipedia.org/wiki/Adjacency_matrix) | ||
* [Adjacency_list](https://en.wikipedia.org/wiki/Adjacency_list) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
+++ | ||
title = "Centos7下git较为完整安装与配置,解决git clone速度慢等问题(Almost perfect git configuration)" | ||
date = 2016-11-15 13:50:00 | ||
updated = 2025-02-08 17:00:00 | ||
description = "" | ||
|
||
[taxonomies] | ||
tags = ["OPS"] | ||
|
||
[extra] | ||
quick_navigation_buttons = true | ||
toc = true | ||
mermaid = true | ||
+++ | ||
## 概述(abstract) | ||
Github最近又开始不稳定,而在bower等安装的过程中会利用到其上面的源, 在包的下载总会因为网络或者的问题,导致中断安装,而每次重新安装的时间较长. | ||
为了让大家不再因为此浪费时间,给大家一些可能有用的配置建议. | ||
|
||
## 具体配置(configuration) | ||
|
||
### 卸载和安装最新(remove and update git) | ||
``` | ||
mkdir /root/APP | ||
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel -y | ||
yum install gcc perl-ExtUtils-MakeMaker -y | ||
yum remove git -y | ||
cd /home/zeppelin/prerequisites | ||
wget https://www.kernel.org/pub/software/scm/git/git-2.10.2.tar.gz#you can look for the lastest version of git and replace 2.10.2 | ||
tar xzf git-2.10.2.tar.gz | ||
cd git-2.10.2 | ||
make prefix=/root/APP/git all | ||
make prefix=/root/APP/git install | ||
echo "export PATH=$PATH:/root/APP/git/bin" >> /etc/profile | ||
source /etc/profile | ||
git config --global url."https://".insteadOf git:// | ||
git --version | ||
``` | ||
|
||
### 使用较快的hosts(use faster host for github.com) | ||
``` | ||
#add the below hosts into your /etc/hosts | ||
192.30.253.118 gist.github.com | ||
192.30.253.119 gist.github.com | ||
``` | ||
|
||
|
||
|
||
|
76 changes: 76 additions & 0 deletions
76
content/blog/20161128Don'tForgetTheResultMapWhenYouUseMybatis.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
+++ | ||
title = "别忘了使用Mybatis ResultMap(Don't forget the ResultMap when you use Mybatis)" | ||
date = 2016-11-28 19:50:20 | ||
updated = 2025-02-08 17:00:00 | ||
description = "" | ||
|
||
[taxonomies] | ||
tags = ["ORM"] | ||
|
||
[extra] | ||
quick_navigation_buttons = true | ||
toc = true | ||
mermaid = true | ||
+++ | ||
## 问题 | ||
最近需要使用Mybatis来操作MySQL,由于入门就随意的拿来一篇入门介绍和官方的教程,照着走一遍,奈何写好了Mapper,Bean,以及配置好数据库,以及对应的xml后会发现无论如何也无法得到实例化后的Bean.事实上,并没有一些bug信息,也没有抛异常. | ||
|
||
### 解决1 | ||
判断是否是数据库本身的连接的问题. | ||
尝试更改mybatis的数据库mysql配置 => 数据库连接没问题 | ||
|
||
### 解决2 | ||
判断是否是数据库得命令没有正常执行 | ||
查找mysql的general日志,发现没有,于是查看general的设置使用下面的命令 | ||
``` | ||
show variables like '%gener%'; | ||
``` | ||
返回下面的信息 | ||
``` | ||
+------------------+-------------------------------------------------+ | ||
| Variable_name | Value | | ||
+------------------+-------------------------------------------------+ | ||
| general_log | OFF | | ||
| general_log_file | /tmp/mysql/general.log | | ||
+------------------+-------------------------------------------------+ | ||
``` | ||
打开general_log | ||
``` | ||
set global general_log=on; | ||
``` | ||
如果需要自定义日志的路径,同理设置不再赘述. | ||
使用`tail -F /tmp/mysql/general.log` 监控mysql的查询信息 | ||
运行自己得mybatis 测试用例,可以看到上面的命令打印到了控制台,结果如下: | ||
``` | ||
161129 18:01:33 15 Connect [email protected] on test | ||
15 Query /* mysql-connector-java-5.1.38 ( Revision: fe541c166cec739c74cc727c5da96c1028b4834a ) */SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS tx_isolation, @@wait_timeout AS wait_timeout | ||
15 Query SELECT @@session.autocommit | ||
15 Query SET character_set_results = NULL | ||
15 Query SET autocommit=1 | ||
15 Query SET autocommit=0 | ||
15 Query SELECT * FROM t_cloud_uba_vm_action WHERE C_ID = 1 | ||
15 Query SET autocommit=1 | ||
``` | ||
说明数据库的命令执行也没问题 | ||
|
||
### 解决3 | ||
回想起,自身项目与参考的项目唯一的不同就是Bean不同,MySQL表不同 | ||
将Bean中的属性名称完全与MySQL一一对应,运行后解决 | ||
|
||
## 总结 | ||
查看mybatis的Result_Maps文档,发现定义了一个Java Bean后,select语句会精确的匹配JavaBean中的属性,然后映射到结果集.这个就是关键所在,当然可以不完全的对应起来,不过需要 ResultMap来,使用select语句的别名,最终匹配到对应的属性上,如下所示 | ||
``` | ||
<select id="selectUsers" resultType="User"> | ||
select | ||
user_id as "id", | ||
user_name as "userName", | ||
hashed_password as "hashedPassword" | ||
from some_table | ||
where id = #{id} | ||
</select> | ||
``` | ||
|
||
|
||
|
||
## 参考 | ||
[http://www.mybatis.org/mybatis-3/zh/sqlmap-xml.html#Result_Maps](http://www.mybatis.org/mybatis-3/zh/sqlmap-xml.html#Result_Maps) |
126 changes: 126 additions & 0 deletions
126
content/blog/20161128UseMultilinePluginToDecodeAWholeJsonFile.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
+++ | ||
title = "使用LogStash中的multiline插件来进行json文件解析(use the multiline plugin to decode a whole json file)" | ||
date = 2016-11-28 09:50:20 | ||
updated = 2025-02-08 17:00:00 | ||
description = "" | ||
|
||
[taxonomies] | ||
tags = ["Logstash"] | ||
|
||
[extra] | ||
quick_navigation_buttons = true | ||
toc = true | ||
mermaid = true | ||
+++ | ||
## 概述(abstract) | ||
如果希望得到配置文件请直接查看"配置(configuration)" if you just want to get the configure file of logstash,so just look at "Configuration". | ||
最近需要通过logstah处理json格式的日志,最好的结果是配置配置Logstash中的config,用用其他轮子插件,自动化的解析.例如这样一段待分析的信息: | ||
``` | ||
{ | ||
"tenantslst": [ | ||
{ | ||
"total_memory_mb_usage": "3.2711112E-5", | ||
"total_vcpus_usage": "6.3888889E-8", | ||
"start": "2016-08-26T08:56:34.596973", | ||
"tenant_id": "70be30112729411dr92acda6ae5ae0215", | ||
"stop": "2016-08-26T08:56:34.596996", | ||
"total_hours": "6.388889E-8", | ||
"total_local_gb_usage": "6.388889E-8" | ||
} | ||
], | ||
"quotalst": [ ] | ||
} | ||
``` | ||
最终解析得结果如下: | ||
``` | ||
"body" => { | ||
"tenantslst" => [ | ||
[0] { | ||
"total_memory_mb_usage" => "3.2711112E-5", | ||
"total_vcpus_usage" => "6.3888889E-8", | ||
"start" => "2016-08-26T08:56:34.596973", | ||
"tenant_id" => "70be30112729411dr92acda6ae5ae0215", | ||
"stop" => "2016-08-26T08:56:34.596996", | ||
"total_hours" => "6.388889E-8", | ||
"total_local_gb_usage" => "6.388889E-8" | ||
} | ||
], | ||
"quotalst" => [] | ||
} | ||
``` | ||
## 问题1(trouble No.1) | ||
在处理日志的时候会遇到这样的问题:logstash 默认会将所监视文件的每一行进行拆分,并单独的作为一个文事件于是就有一个完整的json file 被拆成了数个事件,这违背初衷,所以首先解决其自动拆分的问题. | ||
multiline的插件就是为此而生,下面贴出multiline的简单的配置: | ||
``` | ||
multiline{ | ||
pattern => "^haha" | ||
#negate => true | ||
what => "previous" | ||
max_age => 5 | ||
} | ||
``` | ||
|
||
#### 解释1 | ||
pattern:表示组成多行的json中, 每一行都具有什么样的特征,这个特征通过正则表达式进行匹配,如果匹配成功则认定此为多行块中的一行 | ||
what:有两个值 "previous"和"next", 如果是previous,则将该行归到上面一个多行块中,如果是next,则归到下面一个代码块中 | ||
max_age:如果没有再有新行添加到多行中,那么在max_age后,这个多行块将被推送,默认是5,单位是秒 | ||
|
||
## 问题2(trouble No.2) | ||
现在我们通过multiline插件获得了一个多行json块,剩下的就是将这个json串解析. | ||
这个比较简单,logstash 中的filter有 json 这个插件,配置上就可以搞定,前提是之前的json必须是一个合规的json串 | ||
下面贴出其配置项 | ||
``` | ||
json{ | ||
source => "message" | ||
target => "body" | ||
} | ||
``` | ||
|
||
#### 解释2 | ||
source 就是存储json串的字段,默认是message字段 | ||
最好是将该字段分析后删除,可以使用mutate这个插件,并开启remove_field这个选项,否则不仅分析后的数据进入到了es,原json串也进入,导致存储的数据,占用双倍的空间. | ||
并且该选项也是支持正则表达式的. | ||
``` | ||
filter { | ||
mutate { | ||
remove_field => [ "foo_%{somefield}" ] | ||
} | ||
} | ||
``` | ||
|
||
## 完整的配置 | ||
|
||
``` | ||
input { | ||
file { | ||
path => "/path/to/log" | ||
type => "some_type" | ||
start_position => beginning | ||
sincedb_path => "/dev/null" | ||
} | ||
} | ||
filter { | ||
multiline{ | ||
pattern => "^\{|\s|\}" | ||
#negate => true | ||
what => "previous" | ||
max_age => 5 | ||
} | ||
json{ | ||
source => "message" | ||
target => "body" | ||
} | ||
mutate { | ||
remove_field => [ "foo_%{somefield}" ] | ||
} | ||
} | ||
``` | ||
|
||
## 参考 | ||
|
||
[Multiline Plugin](https://www.elastic.co/guide/en/logstash/current/plugins-filters-multiline.html#plugins-filters-multiline) | ||
|
||
|
||
|
||
|
Oops, something went wrong.