@@ -1,28 +0,0 @@
|
|||||||
# 算法笔记
|
|
||||||
|
|
||||||
## 排序算法对比
|
|
||||||
|
|
||||||
| 算法 | 平均 | 最坏 | 空间 | 稳定 |
|
|
||||||
|------|------|------|------|------|
|
|
||||||
| 冒泡排序 | O(n²) | O(n²) | O(1) | ✅ |
|
|
||||||
| 快速排序 | O(n log n) | O(n²) | O(log n) | ❌ |
|
|
||||||
| 归并排序 | O(n log n) | O(n log n) | O(n) | ✅ |
|
|
||||||
| 堆排序 | O(n log n) | O(n log n) | O(1) | ❌ |
|
|
||||||
|
|
||||||
## 快速排序示例
|
|
||||||
|
|
||||||
```python
|
|
||||||
def quicksort(arr):
|
|
||||||
if len(arr) <= 1:
|
|
||||||
return arr
|
|
||||||
pivot = arr[len(arr) // 2]
|
|
||||||
left = [x for x in arr if x < pivot]
|
|
||||||
mid = [x for x in arr if x == pivot]
|
|
||||||
right = [x for x in arr if x > pivot]
|
|
||||||
return quicksort(left) + mid + quicksort(right)
|
|
||||||
```
|
|
||||||
|
|
||||||
## 相关链接
|
|
||||||
|
|
||||||
- [图解算法站](http://47.121.181.112:10000/) — 交互式算法学习页面
|
|
||||||
- [LeetCode](https://leetcode.cn/) — 在线刷题
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
# Linux 常用命令
|
|
||||||
|
|
||||||
## 文件操作
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 查找文件
|
|
||||||
find / -name "*.conf" 2>/dev/null
|
|
||||||
|
|
||||||
# 磁盘使用
|
|
||||||
du -sh /var/log/*
|
|
||||||
df -h
|
|
||||||
|
|
||||||
# 实时查看日志
|
|
||||||
tail -f /var/log/syslog
|
|
||||||
```
|
|
||||||
|
|
||||||
## 进程管理
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 查看端口占用
|
|
||||||
ss -tlnp | grep :80
|
|
||||||
lsof -i :80
|
|
||||||
|
|
||||||
# 杀死进程
|
|
||||||
kill -9 $(lsof -t -i:80)
|
|
||||||
|
|
||||||
# 查看资源占用
|
|
||||||
htop
|
|
||||||
```
|
|
||||||
|
|
||||||
## 网络
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 测试连通性
|
|
||||||
curl -I https://example.com
|
|
||||||
traceroute example.com
|
|
||||||
|
|
||||||
# 防火墙 (ufw)
|
|
||||||
ufw allow 80/tcp
|
|
||||||
ufw status
|
|
||||||
```
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# Nginx 配置
|
|
||||||
|
|
||||||
## 基本模板
|
|
||||||
|
|
||||||
```nginx
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name docs.example.com;
|
|
||||||
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
# SPA 路由回退
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 静态资源缓存
|
|
||||||
location ~* \.(js|css|png|jpg|svg|woff2)$ {
|
|
||||||
expires 30d;
|
|
||||||
add_header Cache-Control "public, immutable";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Gzip 压缩
|
|
||||||
gzip on;
|
|
||||||
gzip_types text/plain text/css application/json application/javascript;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 常用操作
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 测试配置
|
|
||||||
nginx -t
|
|
||||||
|
|
||||||
# 重新加载(不中断服务)
|
|
||||||
nginx -s reload
|
|
||||||
```
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
# Docker 笔记
|
|
||||||
|
|
||||||
## 常用命令
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 构建镜像
|
|
||||||
docker build -t myapp:latest .
|
|
||||||
|
|
||||||
# 运行容器
|
|
||||||
docker run -d --name myapp -p 8080:80 myapp:latest
|
|
||||||
|
|
||||||
# 查看日志
|
|
||||||
docker logs -f myapp
|
|
||||||
|
|
||||||
# 进入容器
|
|
||||||
docker exec -it myapp sh
|
|
||||||
|
|
||||||
# 清理
|
|
||||||
docker system prune -f
|
|
||||||
```
|
|
||||||
|
|
||||||
## Docker Compose
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
image: nginx:alpine
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
volumes:
|
|
||||||
- ./html:/usr/share/nginx/html
|
|
||||||
restart: unless-stopped
|
|
||||||
```
|
|
||||||
|
|
||||||
## 小技巧
|
|
||||||
|
|
||||||
- 用 `--cache-from` 加速重复构建
|
|
||||||
- `.dockerignore` 排除 `.git`、`node_modules` 等
|
|
||||||
- 多阶段构建减小镜像体积
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
# Git 工作流
|
|
||||||
|
|
||||||
## 常用命令
|
|
||||||
|
|
||||||
| 命令 | 说明 |
|
|
||||||
|------|------|
|
|
||||||
| `git status` | 查看工作区状态 |
|
|
||||||
| `git add -A` | 暂存所有变更 |
|
|
||||||
| `git commit -m "msg"` | 提交 |
|
|
||||||
| `git push origin main` | 推送到远端 |
|
|
||||||
| `git pull --rebase` | 拉取并变基 |
|
|
||||||
| `git stash` | 暂存未提交的改动 |
|
|
||||||
|
|
||||||
## 分支策略
|
|
||||||
|
|
||||||
```
|
|
||||||
main ──●──●──●──●──●── (生产)
|
|
||||||
\ /
|
|
||||||
feature/xxx ──●──●──●── (功能分支)
|
|
||||||
```
|
|
||||||
|
|
||||||
- `main` 分支始终可部署
|
|
||||||
- 功能分支从 `main` 拉出,完成后 Merge Request 合入
|
|
||||||
- 合并前至少一人 Review
|
|
||||||
@@ -82,12 +82,7 @@ nav:
|
|||||||
- 首页: index.md
|
- 首页: index.md
|
||||||
- 项目:
|
- 项目:
|
||||||
- project/index.md
|
- project/index.md
|
||||||
- Git 工作流: project/git-workflow.md
|
|
||||||
- Docker 笔记: project/docker-notes.md
|
|
||||||
- 架构:
|
- 架构:
|
||||||
- architecture/index.md
|
- architecture/index.md
|
||||||
- Linux 常用命令: architecture/linux-commands.md
|
|
||||||
- Nginx 配置: architecture/nginx-config.md
|
|
||||||
- 算法:
|
- 算法:
|
||||||
- algorithm/index.md
|
- algorithm/index.md
|
||||||
- 算法笔记: algorithm/algorithms.md
|
|
||||||
|
|||||||
Reference in New Issue
Block a user