摘要: 带关键字的格式化 >>> >>> print "Hello %(name)s !" % {'name':'James'} Hello James ! >>> >>> print "Hello {name} !".format(name="James") Hello James ! >>> 使用dic 阅读全文
posted @ 2018-01-13 16:34 lixin[at]hitwh 阅读(516) 评论(0) 推荐(0) 编辑
摘要: - How do you take your caviar, sir? 鱼子酱还要吗,先生? - No caviar for me, thanks. Never did like it much. 不了,谢谢-我从不喜欢吃太多的鱼子酱- And where exactly do you live, 阅读全文
posted @ 2017-04-25 23:55 lixin[at]hitwh 阅读(5095) 评论(0) 推荐(0) 编辑
摘要: 一天的光滑数据 sub = [199.68, 187.16, 173.97, 159.85, 146.92, 135.29, 125.04, 114.86, 105.85, 97.93, 90.6, 84.19, 78.37, 72.85, 68.93, 66.59, 62.19, 58.59, 5 阅读全文
posted @ 2024-07-06 14:52 lixin[at]hitwh 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 思路 1. 对原始数据一阶求导,得到一阶导数数组。 2. 对一阶导数数组求标准差。导数的标准差提供了导数值的波动性,标准差越小,曲线越平滑。 平滑曲线 import numpy as np import matplotlib.pyplot as plt from matplotlib import 阅读全文
posted @ 2024-07-04 19:23 lixin[at]hitwh 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 原始数据 import matplotlib.pyplot as plt from matplotlib import font_manager fname="/usr/local/python3.6/lib/python3.6/site-packages/matplotlib/mpl-data/f 阅读全文
posted @ 2024-07-04 18:27 lixin[at]hitwh 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 构造时序数据 import numpy as np import matplotlib.pyplot as plt # 设置参数 period = 128 num_cycles = 5 total_length = period * num_cycles # 生成周期性信号(正弦波形) np.ran 阅读全文
posted @ 2024-07-04 17:56 lixin[at]hitwh 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 基于asciichartpy import asciichartpy data = [1, 2, 3, 4, 5, 4, 3, 2, 1] chart = asciichartpy.plot(data) print(chart) 基于sparklines import sparklines data 阅读全文
posted @ 2024-07-01 19:01 lixin[at]hitwh 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 1 记录函数执行耗时 1 def timeToRunWithParams(level, param_idx_lst): 2 def inner(func): 3 def wrapper(*args, **kwargs): 4 s_date = datetime.datetime.now() 5 re 阅读全文
posted @ 2022-11-16 11:38 lixin[at]hitwh 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 基本概念 TLS TLS(Transport Layer Security) 是保证数据在互联网上安全传输的加密协议;保证数据在传输的过程中中间的人无法解密,无法修改。TLS 要解决的问题就是,能证明你,是你。 非对称加密 现在使用的是非对称加密的技术。非对称加密会有两个秘钥,一个是公钥,一个是私钥 阅读全文
posted @ 2022-09-05 21:51 lixin[at]hitwh 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 前言 高并发场景下,为了保障服务的高可用(过载保护),除了使用消息中间件做流量削峰之外,还可以在网关侧做限流; 而令牌桶则是常见的限流算法,本文简单记录下。 Token bucket 令牌桶算法维基百科 主要思想 1. There is a bucket of a token that can ho 阅读全文
posted @ 2022-06-10 22:32 lixin[at]hitwh 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 前言 如何“优雅的轮询”,是生产环境中很常见一种场景, 所谓“优雅”,即在均衡分配的基础上,要保证连续的请求不能连续分配到某一个后端节点上; 可以理解为时间上的连续请求,要尽量分配到物理上的不同节点,避免某段时间内后端单台节点压力过大。 算法描述 On each peer selection we 阅读全文
posted @ 2022-05-27 17:32 lixin[at]hitwh 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 实现基本的进程守护功能 package main import ( "context" "fmt" "github.com/shirou/gopsutil/v3/process" "os" "os/exec" "os/signal" "syscall" "time" ) var CMD *exec. 阅读全文
posted @ 2021-09-09 11:48 lixin[at]hitwh 阅读(68) 评论(0) 推荐(0) 编辑