OS: 问题集
什么是进程?进程与线程的区别?操作系统中如何实现进程间的通信?多线程编程中什么是竞态条件,如何避免?什么是死锁?
Process: running program. It encapsulates the complete execution state of a running program — including memory, registers (like the program counter and stack pointer), and I/O resources like open files — that allows it to run independently and be managed by the operating system.
Thread: a unit of execution within a process. Unlike separate processes, threads share the same address space and can access the same data and resources.
...
Python Project Configurations
Python是如何查找模块的?有哪些查找路径?
Python 在导入模块时,会按照 sys.path 中的路径顺序查找模块。sys.path 默认包含:
当前脚本所在目录(examples/ 或 .,取决于执行方式)
PYTHONPATH 环境变量指定的目录
Python 标准库目录
site-packages(第三方库安装目录)
为什么 Python 不自动把执行目录(./)加入 sys.path?
避免隐式依赖
如果 Python 自动把执行目录加入 sys.path,可能会导致 不同环境下模块导入行为不一致(比如在 A/ 或 B/ 目录下运行同一个脚本,导入的模块可能不同)。
这会让代码的 可移植性变差。
防止命名冲突
如果 ./ 被自动加入 sys.path,可能会意外导入错误的模块(比如当前目录有一个 random.py,会覆盖 Python 标准库的 random)。
明确性优先
Python 倾向于 显式优于隐式(Explicit is better than implicit),所以模块查找 ...
强化学习(RL)入门
RL算法必须通过环境提供的反馈来学习。
体现强化学习本质的通用训练循环框架
通过标准化接口交互(所有RL库都遵循此设计):
env = YourEnv() # 初始化环境(如gym.make("CartPole-v1"))agent = YourAlgo() # 初始化算法(如PPO("MlpPolicy", env))for episode in range(1000): # 训练循环 obs, info = env.reset() done = False while not done: # 自动处理terminated/truncated action = agent.predict(obs) # 决策(本质:状态→动作) next_obs, reward, terminated, truncated, info = env.step(action) ...
Java Web
JSP 的本质?
JSP的本质:
JSP 文件本质上是一个特殊的 HTML 文件,里面可以嵌入 Java 代码
第一次访问JSP文件时会进行编译过程:
将 JSP 文件解析成纯 Java 代码
这个 Java 代码会被编译成 .class 文件
这个 .class 文件就是一个 Servlet 类
转换示例:
public class user_login_jsp extends HttpServlet { public void _jspService(HttpServletRequest request, HttpServletResponse response) { // 设置响应类型 response.setContentType("text/html;charset=UTF-8"); // 输出 HTML 开始部分 out.write("<html><body>"); // 执行 Java 代 ...
Register
X86_64 Registers
在x86-64架构中,16个通用寄存器的英文全称和功能确实可以帮助记忆。以下是它们的详细解析,按用途分类整理:
通用数据寄存器(Data Registers)
寄存器
全称
主要用途
RAX
Accumulator Register
累加器,用于算术运算和返回值
RBX
Base Register
基址寄存器,常用于内存寻址
RCX
Counter Register
循环/字符串操作计数器
RDX
Data Register
存储数据或I/O端口操作
扩展名:
32位:EAX (Extended Accumulator)
16位:AX (Accumulator)
8位:AH/AL (High/Low byte)
指针/索引寄存器(Pointer/Index Registers)
寄存器
全称
主要用途
RSP
Stack Pointer
栈顶指针(函数调用/返回)
RBP
Base Pointer
栈帧基址(局部变量定位)
RSI
Source Index
字符串/数组操 ...
服务器相关
SSH端口转发
如果直接用终端 SSH 连接远程服务器(不通过 VS Code),默认不会自动转发端口。此时你需要手动建立隧道:
local port forwarding:
ssh -L 7474:localhost:7474 your_username@remote_server_ip
这样才会将远程 7474 端口映射到本地。
remote port forwarding:
ssh -R 1080:localhost:1080 username@10.100.103.176
FRP反向代理工作原理
sequenceDiagram participant User participant FRPServer participant InternalServer InternalServer->>FRPServer: 连接控制通道 (7000) FRPServer-->>InternalServer: 分配外部端口 (60022) User->>FRPServer: 访问 frp.exampl ...
通俗数学理解
Neyman-Pearson框架下的假设检验的理解
为什么p<=αp <= \alphap<=α,可以拒绝原假设?
alpha代表容忍程度,也就是原假设为真时错误地拒绝它的最大概率(0.05),那么我们最多容忍有0.05的概率错误地拒绝原假设,也就是做100次抽样检验,最多容忍5次错误地拒绝原假设。当我们有了一些观测数据,我们算一下在原假设成立的情况下观测数据出现的概率是多少(p值)。如果p值很低(0.01),说明原假设成立的情况下观测数据非常离谱,那么有两种可能:一种是原假设确实不成立;另一种是原假设成立,但是出现了小概率事件。我们到底接受还是拒绝原假设呢?这时候我们错误地认为原假设不成立其实也不会带来很大的风险,因为这种情况发生的概率小于我们的容忍程度(0.05),所以可以拒绝原假设。
问题集:概率统计
统计推断的两大学派:频率派和贝叶斯派
统计有两大分支:统计描述 (Descriptive statistics)、统计推断 (Statistical inference)
The frequentist views probability as the long-run frequency of events, making inferences based on sample data. In contrast, the Bayesian treats probability as a measure of subjective belief, incorporating prior knowledge into its inferences. The key difference lies in their definitions and interpretations of probability, yet the two approaches can also complement each other.
Frequentist: Parameters ...
Algorithm
未读问题集:Algorithm
斐波那契数列有多少种解法+时间空间复杂度?
The Fibonacci sequence (each number = sum of two preceding ones: F(n) = F(n-1) + F(n-2)) has multiple solutions with varying time/space complexities:
(1) Recursive (Naive)
Time: O(2n)O(2^n)O(2n) – Exponential due to repeated calculations.
Space: O(n)O(n)O(n) – Call stack depth.
Code:def fib(n): return n if n <= 1 else fib(n-1) + fib(n-2)
(2) Memoization (Top-Down DP)
Time: O(n)O(n)O(n) – Each of n values computed once.
Space: O(n)O(n)O(n) – Storage f ...
同步 vs 异步:核心区别、适用场景与实现技术
1. 核心区别
维度
同步(Synchronous)
异步(Asynchronous)
执行顺序
代码顺序执行,必须等待当前操作完成
操作发起后立即继续执行,不等待结果
阻塞性
阻塞主线程(卡住后续代码)
非阻塞(其他任务可并行执行)
资源占用
高(线程/进程被占用等待)
低(单线程可处理多任务)
复杂度
简单直观
需要处理回调/Promise/事件机制
典型代码
const data = readFileSync()
readFile(() => { ... })
2. 适用场景
同步编程适合:
简单脚本:如配置文件读取、启动初始化
原子性操作:必须严格按顺序执行的步骤(如数据库事务)
CPU密集型任务:数学计算、加密解密(无I/O等待)
示例:
// 同步读取配置文件(启动时只需执行一次)const config = JSON.parse(fs.readFileSync('config.json'));server.start(config.por ...