Home

numpy

numpy create array np.sctypes x = np.array([1, 2, 3, 4]) print(type(x)) print(x.ndim) print(x.shape) 元素类型 x.dtype y = np.array(data, dtype=np.int) y.astype(np.complex) np.zeros((2, 3)) np.ones((2, 3)) np.full((2, 3), -1) np.empty((2, 3)) np.zeros_like(x) np.full_like(x) 单位矩阵 np.identity(3) 对角矩阵 np.diag([1, 2, 4], k=-...

Read more

Life Exercise

训练前须知 呼吸原则: 用力时呼气(如卷起身体时),还原时吸气(如躺下时)。 质量 > 数量: 动作标准比个数更重要,感受腹部发力而非颈部或腰部代偿。 动作一:基础卷腹 —— 打造上腹线条 这是最安全的上腹动作,能有效避免颈椎受伤。 做法: 仰卧,双腿弯曲踩地,双手交叉放胸前或轻托耳后(不要用力掰头)。 呼气,用上腹的力量将肩胛骨抬离地面,下背部保持贴地。 在顶峰保持2秒感受挤压,吸气缓慢下放。 组数: 3组,每组15-20次。 动作二:反向卷腹 —— 强化下腹力量 下腹部是很多人的薄弱点,这个动作能精准刺激。 做法: 仰卧,双腿并拢抬起,大腿垂直于地面,小腿平行于地面(桌面姿势)。 呼气,用下腹力量将臀部微微卷离地面,想象用膝盖去碰胸口。 在顶峰停顿,吸气缓慢下放...

Read more

Python profiler

python profiler py-spy cpu profiler py-spy top --pid 255 tracemalloc 1. 基础用法:查看内存增长最多的地方 tracemalloc.start() # 开启内存跟踪 def my_function(): data = [x for x in range(1000000)] # 生成大量数据 return data my_function() # 获取当前内存快照 snapshot = tracemalloc.take_snapshot() top_stats = snapshot.statistics('lineno') # 按行统计 print("[Top 10 内存占用最多...

Read more

Hardware test

Hardware test memtest86+ stress smartmontools sysstat hdparm vnstat nload mpstat -P ALL 1 iostat -x 1 nload Reference

Read more

mongodb

mongodb db.serverStatus().connections dt.serverStatus().locks; rs.printReplicationInfo(); rs.printSlaveReplicationInfo(); rs.printSecondaryReplicationInfo(); db.currentOp({ “waitingForLock”: true }); db.setProfilingLevel(1, 50) db.system.profile.find().sort({ ts: -1 }).limit(5).pretty() db.mycollection.find({ field: value }).explain(“executio...

Read more