Skip to content

Commit 32d72f8

Browse files
author
wu_jia_tong
committed
stru: move real index.html to root.
1 parent 0d984c9 commit 32d72f8

File tree

214 files changed

+105085
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+105085
-16
lines changed

404.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>
2+
404 Not Found
3+
<h1>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- 音视频通话
66
- jupyterlab重定向等
77
- 网站推荐
8-
- 在www/blogs下面的md文件自动渲染展示,代码高亮
8+
- 在blog下面的md文件自动渲染展示,代码高亮
99
- 足迹地图
1010
- 丝滑侧边栏
1111

@@ -19,4 +19,4 @@
1919
3.若要使用jupyterLab,则还需要在localhost:8888启动jupyterLab。
2020

2121
# 发布博文
22-
将md文件放在www/blog下就好啦
22+
将md文件放在blog目录下就好啦

aboutUs.html

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>寻感 - 寻找无穷创作灵感</title>
8+
<link rel="shortcut icon" href="img/logo.png">
9+
<link rel="stylesheet" href="css/style.css">
10+
<link rel="stylesheet" href="css/font.css">
11+
<script src="js/reg.js"></script>
12+
</head>
13+
<body onload="loaduser()" id="home">
14+
<div class="container">
15+
<!-- 在页面中加入一个容器 -->
16+
<div class="left-box" id="left-box"></div>
17+
18+
<script>
19+
// 检测是否为移动设备
20+
function isMobileDevice() {
21+
return window.innerWidth / window.innerHeight < 1.2; // 使用宽高比来判断,小于1.2认为是移动设备
22+
}
23+
24+
// 设置左侧栏宽度
25+
function setLeftBoxWidth() {
26+
const leftBox = document.getElementById('left-box');
27+
const handler = document.querySelector('.handler');
28+
const containerWidth = document.querySelector('.container').offsetWidth;
29+
const menuButton = document.getElementById('menu-button');
30+
31+
if (isMobileDevice()) {
32+
leftBox.style.width = '0';
33+
handler.style.left = "5px";
34+
handler.classList.add('close');
35+
menuButton.style.display = 'block';
36+
} else {
37+
// 使用容器宽度的20%作为侧边栏宽度,最小210px
38+
const sidebarWidth = Math.max(containerWidth * 0.02, 210);
39+
leftBox.style.width = sidebarWidth + 'px';
40+
handler.style.left = (sidebarWidth + 5) + "px";
41+
handler.classList.remove('close');
42+
menuButton.style.display = 'none';
43+
}
44+
}
45+
46+
// 使用 JavaScript 动态加载 left-box.html
47+
fetch('leftbox.html')
48+
.then(response => response.text())
49+
.then(data => {
50+
document.getElementById('left-box').innerHTML = data;
51+
const items = document.querySelectorAll('.item');
52+
items[5].style.backgroundColor = 'rgba(255, 255, 255, 0.2)';
53+
54+
// 初始设置宽度
55+
setLeftBoxWidth();
56+
57+
// 监听窗口大小变化
58+
window.addEventListener('resize', setLeftBoxWidth);
59+
60+
// 添加菜单按钮点击事件
61+
const menuButton = document.getElementById('menu-button');
62+
const leftBox = document.getElementById('left-box');
63+
const handler = document.querySelector('.handler');
64+
65+
menuButton.addEventListener('click', function() {
66+
this.classList.toggle('active');
67+
if (leftBox.style.width === '0px') {
68+
leftBox.style.width = '210px';
69+
handler.style.left = "215px";
70+
handler.classList.remove('close');
71+
} else {
72+
leftBox.style.width = '0';
73+
handler.style.left = "5px";
74+
handler.classList.add('close');
75+
}
76+
});
77+
})
78+
.catch(error => console.error('Error loading left-box.html:', error));
79+
</script>
80+
81+
82+
<div class="right-box" style="font-family:myfont;overflow-y: scroll;background-color: rgb(248, 248, 255);">
83+
<!-- 添加菜单按钮 -->
84+
<div class="right-top">
85+
<div class="menu-button" id="menu-button">
86+
<span></span>
87+
<span></span>
88+
<span></span>
89+
</div>
90+
<span>关于我们</span>
91+
</div>
92+
<div id="aboutusmain" style="font-family: myfont;margin-top: 50px;width: 70%;">
93+
网页作者:Buttonwood
94+
<br><br>
95+
<img src="img/IMG_1418(20220220-144042).JPG" width="20%">
96+
<div id="aboutuslist">
97+
98+
</div>
99+
<div class="reason" style="height: 200px;">
100+
<h1>
101+
关于这个网站的诞生
102+
</h1>
103+
<!-- <p style="text-decoration: line-through;">-->
104+
<!-- 包含一切-->
105+
<!-- </p>-->
106+
<p>
107+
对于设计网站,作者在进行一些设计的时候,发现想做的东西要么是有
108+
想做的东西但是不能很好的呈现,要么是素材过于稀少,观周围
109+
朋友们,发现都有如此的问题,那么我就想,我把解决这个问题
110+
做成一个网站,不就解决了很多人的需求,于是这个集各种神奇
111+
灵感网站于一身的网站就诞生了,就在左侧设计网站里面!
112+
对于足迹地图部分,特别感谢我的朋友lst,在他的启发下,我开发了这个网站并维护下去。
113+
</p>
114+
</div>
115+
<div class="reason" >
116+
<h1>
117+
作者联系方式?
118+
</h1>
119+
<p>
120+
wx:BUTT0NW00D (注意是零不是字母O)<br>
121+
ph:13509663771 <br>
122+
123+
qq:1332192071 <br>v
124+
欢迎骚扰
125+
<br><br><br><br><br><br><br>
126+
</p>
127+
</div>
128+
129+
130+
</div>
131+
<div class="handler">
132+
133+
</div>
134+
</div>
135+
</div>
136+
</body>
137+
</html>

blog/Cursor侧边栏消失.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### 解决 VSCode Cursor 侧边栏消失的问题
2+
3+
在使用 VSCode 时,有时可能会遇到 **Cursor 侧边栏(Activity Bar)消失** 的情况,导致左侧的图标(如资源管理器、搜索、源代码管理等)无法显示。本文将介绍如何恢复 VSCode 的侧边栏,并确保它始终可见。
4+
5+
## **解决方法**
6+
7+
1. **打开 VSCode 设置**
8+
9+
*`Ctrl + ,`(Mac 上 `Cmd + ,`)打开设置界面。
10+
11+
1. **搜索 `Activity Bar`** ,找到 `Activity Bar: Orientation` 选项。
12+
2. **确保值设置为 `vertical`**
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Plutus:基于Rust的无锁高频交易引擎设计
2+
3+
## 引言
4+
5+
Plutus是一个基于Rust开发的高频交易引擎,其核心设计理念是"单线程+协程"的架构模式。通过巧妙利用Rust的所有权系统和协程特性,实现了高效且安全的高频交易系统。
6+
7+
## 核心设计特点
8+
9+
### 1. 单线程架构
10+
11+
Plutus采用单线程设计,避免了多线程带来的同步开销和复杂性。通过`set_thread_affinity`将程序绑定到特定CPU核心,确保性能的稳定性:
12+
13+
```rust
14+
set_max_priority().unwrap_or_default();
15+
set_thread_affinity(0).unwrap_or_default();
16+
17+
```
18+
19+
### 2. 无锁设计
20+
21+
使用`Rc<UnsafeCell>`实现无锁设计:
22+
23+
```rust
24+
pub struct SenderWrapper<W> {
25+
sender: Rc<UnsafeCell<W>>,
26+
}
27+
28+
```
29+
30+
这种设计的优势:
31+
32+
- 避免了传统锁机制带来的性能开销
33+
- 通过Rust的所有权系统保证内存安全
34+
- 适合单线程场景下的高效数据共享
35+
36+
### 3. Monoio协程
37+
38+
采用Monoio作为协程运行时:
39+
40+
```rust
41+
#[monoio::main(timer_enabled = true)]
42+
async fn main() {
43+
// ...
44+
}
45+
46+
```
47+
48+
Monoio的优势:
49+
50+
- 基于io-uring的高效异步IO
51+
- 零成本抽象
52+
- 适合高频交易场景
53+
54+
### 4. 高性能时间处理
55+
56+
实现了基于RDTSC指令的高精度时间获取:
57+
58+
```rust
59+
#[cfg(feature = "aws_time")]
60+
mod monotonic {
61+
#[cfg(target_os = "linux")]
62+
use core::arch::x86_64::_rdtsc;
63+
64+
#[inline]
65+
pub fn time_ns() -> i64 {
66+
let tsc = monotonic_clock();
67+
((tsc as f64 / CPU_FREQ) * 1_000_000_000.0) as i64
68+
}
69+
}
70+
71+
```
72+
73+
### 5. 高效的数据结构
74+
75+
使用`FxHashMap`作为主要数据结构:
76+
77+
```rust
78+
pub struct Strategy {
79+
exchanges: FxHashMap<ExchangeType, Exchange>,
80+
data: FxHashMap<(ExchangeType, Symbol), BboTicker>,
81+
// ...
82+
}
83+
84+
```
85+
86+
## 性能优化
87+
88+
### 1. 整数运算优化
89+
90+
将浮点数运算转换为整数运算,提高性能:
91+
92+
```rust
93+
fn get_size(symbol: &Coin) -> f64 {
94+
let base = match symbol {
95+
Coin::BTC => 2, // 0.002 * 1000
96+
Coin::ETH => 40, // 0.04 * 1000
97+
// ...
98+
};
99+
base as f64 * 0.001
100+
}
101+
102+
```
103+
104+
### 2. 内存优化
105+
106+
- 使用`smallvec`减少堆分配
107+
- 预分配HashMap容量
108+
- 避免不必要的内存拷贝
109+
110+
### 3. 网络优化
111+
112+
- 使用WebSocket长连接
113+
- 实现了高效的代理支持
114+
- 支持TLS加密
115+
116+
## 安全性设计
117+
118+
### 1. 类型安全
119+
120+
利用Rust的类型系统确保交易逻辑的正确性:
121+
122+
```rust
123+
#[derive(Debug, Clone, Default, PartialEq)]
124+
enum Position {
125+
Long,
126+
Short,
127+
#[default]
128+
Empty,
129+
}
130+
131+
```
132+
133+
### 2. 错误处理
134+
135+
完善的错误处理机制:
136+
137+
```rust
138+
async fn execute_arbitrage(&mut self, symbol: &Symbol) {
139+
// ...
140+
if order_result.is_ok() {
141+
// 处理成功情况
142+
} else if let Err(err) = order_result {
143+
// 错误恢复机制
144+
self.fix_binance_position(symbol).await;
145+
}
146+
}
147+
148+
```
149+
150+
## 实际应用
151+
152+
Plutus在实际交易中展示了优异的性能:
153+
154+
- 支持多交易所套利
155+
- 毫秒级延迟
156+
- 稳定的订单执行
157+
- 完善的仓位管理
158+
159+
## 总结
160+
161+
Plutus通过"单线程+协程"的架构设计,结合Rust的安全特性和高性能特性,实现了一个高效、安全的高频交易引擎。其核心优势在于:
162+
163+
1. 无锁设计带来的性能提升
164+
2. 协程带来的高效并发
165+
3. Rust类型系统带来的安全性
166+
4. 优化的数据结构和算法
167+
168+
这种设计特别适合高频交易场景,能够提供稳定的性能和可靠的安全性。
169+
170+
---

0 commit comments

Comments
 (0)