-
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
Showing
14 changed files
with
361 additions
and
5 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,6 @@ | ||
node_modules | ||
dist | ||
.vitepress/dist | ||
.vitepress/cache | ||
|
||
# macOS | ||
.DS_Store |
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,4 +1,49 @@ | ||
export default { | ||
import { defineConfig } from 'vitepress' | ||
|
||
export default defineConfig ({ | ||
// 网站元数据 | ||
// 网站的lang属性 | ||
lang: 'zh-CN', | ||
// 显示在浏览器标签栏里的内容 | ||
title: '屠伟伟的博客空间', | ||
// 显示在浏览器标签栏里的后缀,false表示不启用后缀 | ||
titleTemplate: false, | ||
// 这将在页面HTML中呈现为<meta>标签 | ||
description: '人生,不过是一场体验。', | ||
// 如果您计划将站点部署到https://foo.github.io/bar/,那么您应该将base设置为'/bar/'。它应该总是以斜杠开头和结尾。 | ||
base: '/blog/', | ||
|
||
// 网站路由配置 | ||
// 当设置为true,VitePress将从URL中删除尾随的.html,需要服务器支持 | ||
cleanUrls: true, | ||
// 定义自定义目录<-> URL映射 | ||
rewrites: { | ||
'source/:page': 'destination/:page' | ||
}, | ||
|
||
// 网站build设置 | ||
// The directory where your markdown pages are stored, relative to project root | ||
srcDir: './src', | ||
base: '/blog/' | ||
} | ||
// srcExclude: ['', ''], | ||
outDir: './.vitepress/dist', | ||
cacheDir: './.vitepress/cache', | ||
// VitePress 不会因死链接而构建失败 | ||
ignoreDeadLinks: true, | ||
|
||
// 网站主题配置 | ||
// 根据系统自动决定是否使用dark模式 | ||
appearance: true, | ||
// 获取每个页面的最后更新时间 | ||
lastUpdated: true, | ||
// 使用VitePress的默认主题作为主题配置 | ||
themeConfig: { | ||
|
||
}, | ||
|
||
// 自定义配置 | ||
// markdown 相关配置 | ||
// markdown: { | ||
// // 在代码块中启用行号 | ||
// lineNumbers: true, | ||
// }, | ||
}) |
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,38 @@ | ||
# Google Android Developer 自学方案 | ||
|
||
|
||
|
||
#### 1. Kotlin 基础 | ||
|
||
- 面向编程人员的 Kotlin 训练营 [Kotlin Basic](https://developer.android.com/courses/kotlin-bootcamp/overview?hl=zh-cn) | ||
|
||
> 在“面向编程人员的 Kotlin 训练营”课程中,您将学习 Kotlin 的基础知识,并使用 IntelliJ IDEA 创建各种小程序。 | ||
|
||
|
||
- Udacity的免费课程 [Kotlin Bootcamp for Programmers](https://www.udacity.com/course/kotlin-bootcamp-for-programmers--ud9011) | ||
|
||
> 向 Google 的 Kotlin 专家学习 Kotlin 编程语言的基础知识。 Kotlin 是一种现代、简洁的 JVM 语言,支持函数式编程范例。无论您是 Java 开发人员还是其他面向对象语言的程序员,本课程都将教您基本的语言功能,这些功能使 Kotlin 如此受开发人员欢迎。在本课程结束时,您将获得使用 Kotlin 构建下一个项目所需的技能。 | ||
|
||
|
||
#### 2. 基于Kotlin的Android基础 | ||
|
||
- [Android Kotlin Fundamentals](https://developer.android.com/codelabs/kotlin-android-training-welcome?index=..%2F..android-kotlin-fundamentals#0) | ||
|
||
> 欢迎来到由 Google 开发者培训团队创建的 Android Kotlin 基础知识课程。本课程提供了一系列代码实验室,引导您了解使用 Kotlin 构建 Android 应用程序的基础知识。在本课程中,您将学习基本的 Android Kotlin 编程概念并构建各种应用程序。 | ||
|
||
|
||
- Udacity的免费课程 [Developing Android Apps with Kotlin](https://www.udacity.com/course/developing-android-apps-with-kotlin--ud9012) | ||
|
||
> 了解如何通过经过行业验证的工具和库用 Kotlin 构建和开发 Android 应用。尝试使用这些 Kotlin 技巧,更快速地创建 Android 应用,同时减少错误和代码。 | ||
|
||
|
||
#### 3. 使用 Kotlin 实现高级 Android 开发 | ||
|
||
[Advanced Android in Kotlin](https://developer.android.com/codelabs/advanced-android-kotlin-training-welcome?index=..%2F..advanced-android-kotlin-training#0) | ||
|
||
> 将您的 Android 编码技能提升到一个新的水平。该课程使用 Kotlin 编程语言,为您介绍 Android 上的通知、图形和动画,教您如何登录用户、向应用添加映射以及如何正确测试应用。每节课都包含一个在 GitHub 中提供解决方案代码的教程。 | ||
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,18 @@ | ||
# C 语言开发问题汇总 | ||
|
||
|
||
|
||
### vscode 远程开发时未定义 __USE_MISC 宏问题 | ||
|
||
找到vscode设置 -》工作区 -〉扩展 -》c/c++ -〉IntelliSense -》 | ||
|
||
在 `C_Cpp>Default:Compiler Args`设置项添加 `-D _DEFAULT_SOURCE` | ||
|
||
解释:`__USE_MISC`宏在`/usr/include/features.h`文件中定义,源代码如下: | ||
|
||
```c | ||
#if defined _DEFAULT_SOURCE | ||
# define __USE_MISC 1 | ||
#endif | ||
``` | ||
|
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,6 @@ | ||
# Optional 用法示例 | ||
|
||
[Guide To Java 8 Optional](https://www.baeldung.com/java-optional) | ||
|
||
TODO | ||
|
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,14 @@ | ||
# UML 设计图 | ||
|
||
## 用例图(UseCase) | ||
|
||
描述操作关系 | ||
|
||
|
||
|
||
## 时序图 | ||
|
||
|
||
|
||
## 类图 | ||
|
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,9 @@ | ||
# ThreadLocal | ||
|
||
> 参考了如下文章: | ||
> | ||
> - [使用ThreadLocal - 廖雪峰的官方网站](https://www.liaoxuefeng.com/wiki/1252599548343744/1306581251653666) | ||
> - | ||
#### 是什么 | ||
|
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,16 @@ | ||
# 安装和运行方面的问题 | ||
|
||
#### mysqld 与 mysqld_safe | ||
|
||
`mysqld` 和 `mysqld_safe` 都与 MySQL 数据库服务器相关,但在用途和功能上有一些区别。 | ||
|
||
1. **mysqld:** `mysqld` 是 MySQL 数据库服务器的实际执行文件。它负责处理数据库的实际操作,包括数据存储、查询处理、事务管理等。当您启动 MySQL 服务器时,实际上是在运行 `mysqld` 进程。您可以直接使用命令行或启动脚本来启动 `mysqld`。 | ||
|
||
2. **mysqld_safe:** `mysqld_safe` 是一个用于启动和监控 `mysqld` 进程的脚本。它提供了额外的功能,以确保 MySQL 服务器在运行时更稳定和可靠。具体功能包括: | ||
|
||
- **自动重启:** 如果 `mysqld` 进程因某些原因崩溃,`mysqld_safe` 可以检测到并尝试重新启动 `mysqld` 进程,以确保数据库的可用性。 | ||
- **日志记录和错误处理:** `mysqld_safe` 会监控 `mysqld` 的输出,捕获任何错误消息,并将其写入日志文件中,以便管理员能够诊断问题。 | ||
- **资源限制:** `mysqld_safe` 可以配置一些资源限制,如内存使用和打开文件数,以防止 `mysqld` 进程过度消耗系统资源。 | ||
- **后台运行:** 默认情况下,`mysqld_safe` 会将 `mysqld` 进程放在后台运行。 | ||
|
||
总之,`mysqld` 是 MySQL 数据库服务器的核心进程,而 `mysqld_safe` 是一个用于启动和监控 `mysqld` 进程的辅助脚本,旨在提供更好的稳定性和容错性。在启动 MySQL 服务器时,通常会使用 `mysqld_safe`,因为它可以帮助处理一些常见的问题,并在出现故障时自动重新启动数据库服务器。 |
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,154 @@ | ||
内核 网络 IO | ||
|
||
|
||
|
||
马士兵-周志垒老师《从TCP/IP,理解BIO、NIO、多路复用》课程笔记 | ||
|
||
1、OSI7层网络模型介绍 | ||
|
||
从低到高依次是:物理层、数据链路层、网络层、传输层、会话层、表示层、应用层 | ||
|
||
2、TCP/IP4层网络模型 | ||
|
||
从低到高依次是:数据链路层、网络层、传输层、应用层 | ||
|
||
关于各层的详细作用以及OSI和TCP/IP的对比分析并非本次的重点,本次是想通过网络模型作为切入点,提出一个问题。 | ||
|
||
平时编写的Java网络应用处于网络模型中的哪一层?答案是应用层,那么传输层及以下的层是谁实现的? | ||
|
||
答案是操作系统内核。 | ||
|
||
### 实验案列 | ||
|
||
```shell | ||
# 利用IO手动创建网络连接发送和接收数据的小实验 | ||
ll /proc/$$/fd | ||
# 建立连接 | ||
exec 8<> /dev/tcp/www.baidu.com/80 | ||
# 向连接写入数据 | ||
echo -e 'GET / HTTP/1.0\n\n' >& 8 | ||
# 接收数据 | ||
cat <& 8 | ||
# 关闭连接 | ||
exec 8<& - | ||
``` | ||
|
||
通过这样一个小实验可知,应用程序是通过IO与内核交互,由内核完成实际的数据发送与接收。所以熟悉IO、和内核对于程序员有重要意义。 | ||
|
||
我们通常听说过,TCP是面向连接的可靠传输协议。那么到底什么是**连接**呢?TCP又为什么可靠呢?带着这样的问题做接下来的实验。 | ||
|
||
```shell | ||
# 先打开一个终端,叫tty1,输入如下指令: | ||
tcpdump -nn -i eth0 host www.baidu.com | ||
# 再打开一个终端,叫tty2,输入如下指令: | ||
curl www.baidu.com | ||
# 然后可以在tty1中观察到类似如下的输出: | ||
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode | ||
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes | ||
16:47:10.048106 IP 172.17.43.138.52898 > 180.101.50.242.80: Flags [S], seq 148439528, win 29200, options [mss 1460,sackOK,TS val 1177771823 ecr 0,nop,wscale 7], length 0 | ||
16:47:10.063425 IP 180.101.50.242.80 > 172.17.43.138.52898: Flags [S.], seq 4184912591, ack 148439529, win 8192, options [mss 1452,sackOK,nop,nop,nop,nop,nop,nop,nop,nop,nop,nop,nop,wscale 5], length 0 | ||
16:47:10.063457 IP 172.17.43.138.52898 > 180.101.50.242.80: Flags [.], ack 1, win 229, length 0 | ||
# 上面就是3次握手的过程 | ||
16:47:10.063659 IP 172.17.43.138.52898 > 180.101.50.242.80: Flags [P.], seq 1:78, ack 1, win 229, length 77: HTTP: GET / HTTP/1.1 | ||
16:47:10.079171 IP 180.101.50.242.80 > 172.17.43.138.52898: Flags [.], ack 78, win 908, length 0 | ||
16:47:10.080068 IP 180.101.50.242.80 > 172.17.43.138.52898: Flags [P.], seq 1:1441, ack 78, win 908, length 1440: HTTP: HTTP/1.1 200 OK | ||
16:47:10.080078 IP 172.17.43.138.52898 > 180.101.50.242.80: Flags [.], ack 1441, win 251, length 0 | ||
16:47:10.080085 IP 180.101.50.242.80 > 172.17.43.138.52898: Flags [P.], seq 1441:2782, ack 78, win 908, length 1341: HTTP | ||
16:47:10.080089 IP 172.17.43.138.52898 > 180.101.50.242.80: Flags [.], ack 2782, win 274, length 0 | ||
16:47:10.080217 IP 172.17.43.138.52898 > 180.101.50.242.80: Flags [F.], seq 78, ack 2782, win 274, length 0 | ||
16:47:10.089536 IP 180.101.50.242.80 > 172.17.43.138.52898: Flags [P.], seq 1441:2782, ack 78, win 908, length 1341: HTTP | ||
16:47:10.089573 IP 172.17.43.138.52898 > 180.101.50.242.80: Flags [.], ack 2782, win 274, options [nop,nop,sack 1 {1441:2782}], length 0 | ||
16:47:10.095643 IP 180.101.50.242.80 > 172.17.43.138.52898: Flags [.], ack 79, win 908, length 0 | ||
16:47:10.095701 IP 180.101.50.242.80 > 172.17.43.138.52898: Flags [F.], seq 2782, ack 79, win 908, length 0 | ||
16:47:10.095719 IP 172.17.43.138.52898 > 180.101.50.242.80: Flags [.], ack 2783, win 274, length 0 | ||
16:47:13.115932 IP 180.101.50.242.80 > 172.17.43.138.52898: Flags [R], seq 4184915374, win 0, length 0 | ||
``` | ||
|
||
然后,我们来回答上面的问题,什么是连接?连接并不是真的有一根线连接着双方。所以,tcp3次握手后,就会在双方的内核空间开辟一片内存空间,存储我的ip:port <-->对方的ip:port,这样的信息有一个官方的抽象Socket。因为对于类UNIX系统而言,所有都是文件,所以创建连接或者说在内核空间中创建Socket对象后,会有一个指向它的文件描述符fd,上层应用程序持有fd,通过fd操作Socket发送和接收数据。可通过如下方式查看这个Socket。 | ||
|
||
```shell | ||
netstat -natp | ||
# 命令的输出: | ||
Active Internet connections (servers and established) | ||
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name | ||
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 942/sshd | ||
tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN 898/systemd-resolve | ||
tcp 0 0 172.17.43.138:22 39.144.38.45:35744 ESTABLISHED 1008/sshd: root [pr | ||
tcp 0 0 172.17.43.138:53378 100.100.45.106:443 TIME_WAIT - | ||
tcp 0 36 172.17.43.138:22 39.144.38.45:36090 ESTABLISHED 1299/sshd: root [pr | ||
tcp 0 0 172.17.43.138:33318 100.100.30.26:80 ESTABLISHED 1058/AliYunDun | ||
tcp 0 0 172.17.43.138:22 39.144.38.45:36086 ESTABLISHED 1190/sshd: root [pr | ||
tcp 0 0 172.17.43.138:22 39.144.38.45:36088 ESTABLISHED 1242/sshd: root [pr | ||
tcp6 0 0 :::5355 :::* LISTEN 898/systemd-resolve | ||
|
||
|
||
ss -at | ||
# 命令的输出 | ||
State Recv-Q Send-Q Local Address:Port Peer Address:Port | ||
LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:* | ||
LISTEN 0 128 0.0.0.0:hostmon 0.0.0.0:* | ||
ESTAB 0 0 172.17.43.138:ssh 39.144.38.45:35744 | ||
TIME-WAIT 0 0 172.17.43.138:53384 100.100.45.106:https | ||
ESTAB 0 36 172.17.43.138:ssh 39.144.38.45:36090 | ||
ESTAB 0 0 172.17.43.138:33318 100.100.30.26:http | ||
ESTAB 0 0 172.17.43.138:ssh 39.144.38.45:36086 | ||
ESTAB 0 0 172.17.43.138:ssh 39.144.38.45:36088 | ||
LISTEN 0 128 [::]:hostmon [::]:* | ||
``` | ||
使用Java新建一个ServerSocket后,没有执行accept()之前 | ||
此时也是可以通过`nc localhost 8080`连接的 | ||
此时通过`ss -na`命令查看到的 | ||
`recv-Q`是缓冲的没有被应用程序accept的连接数 | ||
`send_Q`是backlog,表示能缓冲多少个没被应用程序accept的连接 | ||
应用程序accept后,通过`netstat -natp`查看到的 `recv-Q`和`send_Q`就是缓冲数据的 | ||
java.net.ServerSocket#ServerSocket(int, int, java.net.InetAddress) | ||
java.net.SocketImpl#createPlatformSocketImpl | ||
根据是否存在`jdk.net.usePlainSocketImpl`属性,创建SocketImpl的子类, | ||
对于jdk17的源码:没有属性时,创建NioSocketImpl,否则创建PlainSocketImpl | ||
```mermaid | ||
sequenceDiagram | ||
title BIO Server Socket 调用时序图 | ||
actor User | ||
User->>ServerSocket:new ServerSocket(8080, 5) | ||
ServerSocket-->ServerSocket:setImpl() | ||
ServerSocket->>SocketImpl:SocketImpl.createPlatformSocketImpl(true) | ||
alt set -Djdk.net.usePlainSocketImpl=true | ||
SocketImpl->>ServerSocket:impl = new PlainSocketImpl(true) | ||
else not set -Djdk.net.usePlainSocketImpl | ||
SocketImpl->>ServerSocket:impl = new NioSocketImpl(server) | ||
end | ||
ServerSocket->>NioSocketImpl:getImpl(){impl.create(stream: true)} | ||
NioSocketImpl->>Net:FileDescriptor fd = Net.serverSocket(stream: true) | ||
Net->>Net.c:socket0(preferIPv6, stream, reuse, fastLoopback) | ||
Net.c->>Net:int fd | ||
Net->>NioSocketImpl:return IOUtil.newFD(int fd) | ||
NioSocketImpl-->NioSocketImpl:this.fd = fd | ||
ServerSocket-->ServerSocket:return this.impl | ||
ServerSocket->>NioSocketImpl:impl.bind("0.0.0.0/0.0.0.0", 8080) | ||
NioSocketImpl->>Net:Net.bind(this.fd, "0.0.0.0/0.0.0.0", 8080) | ||
Net->>Net.c:bind0(fd, preferIPv6, useExclBind, addr, port) | ||
ServerSocket->>NioSocketImpl:impl.listen(backlog: 5) | ||
NioSocketImpl->>Net:Net.listen(this.fd, backlog) | ||
Net->>Net.c:listen(fd, backlog) | ||
ServerSocket->>User:new ServerSocket instance | ||
``` | ||
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,19 @@ | ||
# Spring Boot 3 新特性 | ||
|
||
## HttpExchange 声明式客户端 | ||
|
||
## Java Record | ||
在 Java 中,Record 是一种特殊类型的 Java 类。可用来创建不可变类,语法简短。任何时候创建 Java 类,都会创建大量的样板代码,我们可能做如下: | ||
- 每个字段的 set,get 方法 | ||
- 公共的构造方法 | ||
- 重写 hashCode, toString(), equals()方法 | ||
|
||
Java Record 避免上述的样板代码,如下特点: | ||
- 带有全部参数的构造方法 | ||
- public 访问器 | ||
- toString(),hashCode(),equals() | ||
- 无 set,get 方法。没有遵循 Bean 的命名规范 | ||
- final 类,不能继承 Record,Record 为隐士的 final 类。除此之外与普通类一样 | ||
- 不可变类,通过构造创建 Record | ||
- final 属性,不可修改 | ||
- 不能声明实例属性,能声明 static 成员 |
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,2 @@ | ||
## 临时 Idea | ||
|
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,29 @@ | ||
# Neovim-01 入门 | ||
|
||
### 介绍 | ||
|
||
Neovim 是基于Vim开发的多模态文本编辑器。所谓多模态,就是在不同的模式下,按键的作用不一样。更多特性介绍以及和Vim的比较,请参考官网:https://neovim.io/ | ||
|
||
### 模式以及模式转换 | ||
|
||
Neovim有7种模式:普通模式、插入模式、 | ||
|
||
普通模式转到插入模式:a,i,o,O | ||
|
||
插入模式转到普通模式:Esc | ||
|
||
TODO:补充剩余模式以及模式转换流程图 | ||
|
||
```mermaid | ||
stateDiagram-v2 | ||
direction LR | ||
普通模式 --> 插入模式: 输入:a\i\o\O | ||
插入模式 --> 普通模式: 输入:Esc | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
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 +1,3 @@ | ||
# index | ||
|
||
[springboot3_new_feature](./SpringBoot/springboot3_new_feature) |