LSTM预测股价

可行性

根据历史K线图使用HMM或LSTM预测未来一周的股价可行吗?

根据历史K线图使用HMM(隐马尔可夫模型)或LSTM(长短期记忆网络)来预测未来一周的股价在理论上可行,但在实际应用中面临一些挑战。以下是可行性分析及每种方法的优缺点:

1. 隐马尔可夫模型 (HMM)

HMM是一种基于概率的模型,适合用于捕捉数据中的隐含状态转移。它假设价格波动的模式可以由一些隐藏的状态(如上升、下降、震荡)控制。

可行性分析

  • 优点

    • HMM适合用于建模序列数据,并且可以捕捉不同市场状态(比如牛市、熊市)的转换。
    • 它在处理小样本数据时比LSTM更有效,因为它不需要大量的数据和长序列的训练。
    • 可以分析某些特定K线形态(如持续上涨或连续下跌)是否会出现在特定的隐状态中,从而捕捉趋势。
  • 缺点

    • HMM的假设过于简单,它假定状态之间是独立的,无法捕捉更复杂的时间依赖结构。
    • HMM对市场突发事件等非线性因素的应对较弱,可能导致预测误差大。
    • 股价的变化是高度非线性的,而HMM更适合线性和简单的状态转移,不一定能很好地适应复杂的金融数据。

可行性结论
使用HMM预测短期趋势或方向性波动具有一定可行性,但对于具体的价格预测效果有限。

2. 长短期记忆网络 (LSTM)

LSTM是一种专门用于处理序列数据的神经网络,能捕捉长时间的依赖关系,在处理金融时间序列数据(如股价)时有较好的表现。

可行性分析

  • 优点

    • LSTM能够记住长序列中的关键模式,适合用来捕捉股价的长期和短期依赖关系。
    • LSTM不需要对数据进行特征工程,可以直接使用原始的K线图数据(如开盘价、收盘价、最高价、最低价等)进行训练。
    • 在引入技术指标、成交量、市场情绪等辅助特征后,LSTM可以有效地整合这些信息,提高预测精度。
  • 缺点

    • 需要大量的数据和长时间的训练才能得到有效模型,而如果训练数据不足,模型的泛化能力较差。
    • LSTM容易过拟合,需要谨慎调整超参数并引入正则化方法来避免过拟合。
    • 金融市场中存在很多随机性和不可预测的事件,LSTM虽然能捕捉数据中的模式,但在应对随机性较强的短期价格波动时效果有限。

可行性结论
使用LSTM预测短期股价走势具有一定可行性,特别是在数据量较大、并且加入了多种特征信息的情况下。LSTM可以作为股价方向性预测的辅助工具,但并不能完全准确预测股价的具体数值。

实际操作建议

若使用HMM或LSTM来预测股价,可以结合以下方法来提升预测效果:

  1. 数据预处理和特征工程:除了K线图中的价格数据,可以引入成交量、技术指标(如RSI、MACD等)作为辅助特征。
  2. 分层建模:HMM可以用于识别市场状态(上升、下降、震荡),然后在每个状态下使用LSTM进行进一步的短期股价预测。这样可以有效地结合两种模型的优点。
  3. 模型评估与验证:可以使用交叉验证来评估模型的预测效果,特别是对LSTM模型,防止过拟合。
  4. 设置合理的预测期望:由于市场存在大量随机性,即使是最先进的模型也无法做到100%的预测准确率,因此应将模型预测结果作为辅助决策的参考,结合风险控制策略来管理投资组合。

加入多因子信息

LSTM除了量价外可以加入其它因子的数据吗,比如基本面因子,技术面因子,市场情绪因子等来增加预测准确性

是的,LSTM除了量价数据外,还可以加入基本面因子技术面因子市场情绪因子等其他数据源,以提高预测准确性。这些因子能够提供股价趋势更多维的背景信息,让LSTM模型可以捕捉到更多元的市场动因和复杂的时间依赖性关系。下面分别介绍这些因子如何整合到LSTM模型中。

1. 基本面因子

基本面因子反映了公司的财务健康状况、盈利能力和运营效率等。常见的基本面因子包括市盈率(PE)、市净率(PB)、每股收益(EPS)、净利润增长率、资产负债率等。

  • 数据处理:基本面数据通常是按季度或年度发布的,而量价数据是日频数据。可以对基本面因子进行插值或保持前值(forward-fill),使其与日频数据对齐。
  • 因子选择:可以通过相关性分析或特征筛选,选择对股价波动有显著影响的关键基本面因子。
  • 加入方式:将这些因子作为LSTM模型的附加特征,将每一个因子与每日量价数据组合成一个时间序列输入模型。

2. 技术面因子

技术面因子通常基于历史价格和成交量衍生而来,用于捕捉市场的技术形态、动能和趋势。常用的技术面因子包括移动平均线(MA)、相对强弱指数(RSI)、移动平均趋同背离指标(MACD)、布林带等。

  • 因子计算:技术指标可以在量价数据的基础上进行预先计算。根据需要选取不同的周期(如5日、20日、60日等)计算多种技术指标。
  • 因子标准化:技术指标的数值跨度较大,标准化或归一化处理后可以提高模型的收敛速度和稳定性。
  • 加入方式:将技术指标添加为附加的时间序列输入特征。与量价数据同时输入LSTM模型,以捕捉趋势和动能。

3. 市场情绪因子

市场情绪因子反映投资者的心理和市场的预期,通常来自新闻、社交媒体、投资者情绪指数等非结构化数据。常见的市场情绪因子包括VIX指数(市场恐慌指数)、社交媒体情绪得分、新闻情感分析等。

  • 情绪数据获取与处理
    • VIX指数:可以直接获取该指数的每日数据。
    • 新闻或社交媒体情绪:可以使用NLP方法对金融新闻或社交媒体内容进行情感分析,将正向、负向情绪得分量化为情绪因子。
  • 因子频率:情绪因子可以是每日更新,也可以根据新闻事件的频率来更新。
  • 加入方式:将情绪得分作为每日新增的特征列输入LSTM模型,帮助捕捉市场心理对价格的短期影响。

4. 宏观经济因子

宏观经济因子反映整体经济环境,可能间接影响股价波动。常用的宏观因子包括利率、通货膨胀率、GDP增长率、失业率等。

  • 数据预处理:这些数据通常是月度或季度数据,需要插值或前值填充。
  • 加入方式:将宏观经济因子作为长周期特征输入,可以帮助模型识别股价在不同经济周期下的趋势特征。

综合考虑:多因子LSTM模型设计

在设计包含多因子的LSTM模型时,需要合理组合和处理不同因子的时间频率。一个典型的多因子LSTM模型流程如下:

  1. 数据准备和对齐:将不同时间频率的因子数据对齐,必要时使用插值或前值填充。
  2. 特征工程和选择:进行特征选择或降维处理,剔除冗余或影响不显著的因子,确保模型输入维度合理。
  3. 标准化和归一化:对所有输入因子进行标准化或归一化,避免不同数值范围导致模型收敛问题。
  4. LSTM模型结构设计
    • 输入层:多因子序列输入层,包含量价数据、技术面、基本面、情绪面和宏观经济因子。
    • LSTM层:可以堆叠多层LSTM层,增强模型对长短期依赖的捕捉能力。
    • 全连接层:LSTM层的输出通过全连接层,生成最终预测结果。
  5. 训练与验证:将数据分为训练集、验证集和测试集,优化模型超参数(如学习率、层数、单元数等),并使用交叉验证等方法评估模型效果。

示例代码框架

以下是一个包含多因子的LSTM模型的代码框架,假设量价数据、基本面因子、技术面因子和市场情绪因子已处理为DataFrame格式并对齐。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense, Dropout
from tensorflow.keras.optimizers import Adam

# 1. 数据准备
# 将数据加载并合并为一个DataFrame(假设已对齐日期)
data = pd.read_csv('multi_factor_data.csv', index_col='Date')
X = data.drop(columns=['target_price']).values
y = data['target_price'].values

# 2. 数据标准化
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

# 3. 构造时间序列样本
sequence_length = 60 # 60天的时间序列窗口
X_seq, y_seq = [], []
for i in range(len(X_scaled) - sequence_length):
X_seq.append(X_scaled[i: i + sequence_length])
y_seq.append(y[i + sequence_length])

X_seq, y_seq = np.array(X_seq), np.array(y_seq)

# 4. 构建LSTM模型
model = Sequential([
LSTM(50, return_sequences=True, input_shape=(X_seq.shape[1], X_seq.shape[2])),
Dropout(0.2),
LSTM(50, return_sequences=False),
Dropout(0.2),
Dense(25),
Dense(1)
])

# 编译模型
model.compile(optimizer=Adam(learning_rate=0.001), loss='mean_squared_error')

# 5. 训练模型
history = model.fit(X_seq, y_seq, epochs=50, batch_size=32, validation_split=0.2)

# 6. 预测未来价格
predicted_prices = model.predict(X_seq[-1].reshape(1, X_seq.shape[1], X_seq.shape[2]))
print("未来价格预测值:", predicted_prices)

注意事项

  • 数据量要求:LSTM对数据量要求较高,建议使用较长时间段的历史数据以获得稳定的模型效果。
  • 过拟合风险:引入多种因子会增加模型复杂性,需要通过正则化(如Dropout)和调参来避免过拟合。
  • 实际验证:在测试集上进行实际验证,使用MSE、MAE等指标评估预测效果,优化模型参数。

通过引入多因子数据,LSTM模型在股价预测中的表现可以显著提升,但其效果还取决于因子选择和模型调优的质量。

波动率预测

预测未来一周的股价和波动率哪个更可行?

未来一周的股价预测和波动率预测相比,波动率预测通常更可行,原因如下:

  1. 波动率相对稳定且具有一定的规律:波动率在短期内往往受到已知的事件驱动,比如财报发布、经济数据公布、重要会议(如美联储会议)等。这些事件往往对市场波动产生显著影响,使波动率在事件前后具有相对规律性,而价格本身的走向(上涨或下跌)则更难预测。

  2. 波动率模型更成熟:金融市场中有许多基于统计的波动率模型,比如GARCH(广义自回归条件异方差)模型和EGARCH模型,这些模型通常能够捕捉波动率的自相关性和异方差性特征,而股价本身则因为价格波动的方向性更加随机,难以用单一模型描述。

  3. 波动率对市场情绪的反应更加直接:波动率可以被视为市场情绪的反映,它通常会在市场恐慌情绪增加或不确定性加剧时上升,而当市场情绪趋于平稳时下降。因此,短期内影响市场情绪的因素在预测波动率时作用较大,而股价的方向则容易受到更多不确定因素的影响。

  4. 股价受多种不确定因素影响:股价在短期内的变化既包括基本面(如财务数据、经济指标)影响,也受到技术面(技术指标、交易量)和市场情绪的波动。尤其是外部不确定事件(如突发的国际事件、政策变动)会对股价产生随机性冲击,使得短期内股价预测的准确性大大降低。

实际操作中的应用

  • 如果投资者想要根据波动率进行操作,可以关注VIX指数(代表市场波动预期的指标)或个股的隐含波动率,并利用期权或其他衍生品进行波动性交易。
  • 股价预测方面,虽然一周的股价变动难以精准预测,但可以根据技术指标(如移动平均、布林带等)和市场情绪指标来设定区间预测,配合风险控制策略来减少损失。

因此,若选择预测未来一周的市场动态,基于波动率的预测更可靠,也更适用于设计防御性或对冲型策略。

具体如何预测下周的波动率走势

预测下周的波动率走势通常基于历史数据的统计模型、市场事件和情绪分析,以下是具体的步骤和方法:

1. 数据准备

  • 收集历史数据:获取标的资产的价格数据(如日收盘价、最高价、最低价)以及市场波动率数据(如VIX指数、隐含波动率)。频率可以按日、每小时或更高频率,取决于模型的需求。
  • 计算历史波动率:使用数据计算历史波动率,通常有多种方法,如日收益率的标准差、移动窗口下的年化波动率等。

2. 选择并构建模型

2.1. GARCH模型系列

GARCH(广义自回归条件异方差)模型用于捕捉波动率的波动性和自相关性,是金融市场常用的波动率预测模型之一。常见的GARCH模型包括:

  • GARCH(1,1):假设波动率依赖于前一日的波动率和残差平方,可以捕捉波动率的聚集效应。
  • EGARCH(指数GARCH):相比标准GARCH模型,EGARCH允许波动率为非对称性,也就是说,当市场出现极端负面变化时,波动率上升更快。
  • GJR-GARCH:进一步增加了对市场下跌或上涨时波动率不同反应的处理。

步骤

  • 将历史波动率数据或价格收益率序列输入模型,以拟合参数。
  • 使用模型输出未来一周每日波动率的预测值。
  • 根据模型的拟合效果,分析未来一周波动率是否会呈现上升或下降趋势。

2.2. 隐含波动率模型

隐含波动率反映了市场对未来波动的预期。可以使用期权市场的隐含波动率(如VIX或个股的隐含波动率)来预测未来波动率。

  • 期权数据分析:提取期权价格,计算不同到期时间和行权价格的隐含波动率,并根据不同期限的隐含波动率结构(IV Term Structure)推测短期波动率的变化。
  • 分析隐含波动率曲面(Volatility Surface):观察隐含波动率的高低变化,通常波动率曲面形状的变化预示着市场波动的预期。

2.3. 基于事件的波动率预测

  • 分析下周的市场事件:例如财报、经济数据发布、重要政策会议等事件会直接影响波动率。可以通过事件日历对波动率做出判断,比如美联储决议日,市场通常预期波动率上升。
  • 历史相似事件的波动率模式:对过去类似事件的市场反应进行分析。比如,若观察到每次非农就业数据发布日波动率显著上升,则本次非农数据发布日也可能出现类似情况。

3. 市场情绪与技术指标分析

  • 波动率指数(如VIX):通常情况下,VIX较高表明市场对未来波动的预期上升;较低则代表市场相对乐观。
  • 技术指标
    • ATR(平均真实波幅):利用ATR指标衡量当前市场波动范围,结合趋势判断未来波动趋势。
    • 布林带:当价格靠近布林带上轨时,可能会出现回调,而接近下轨时,波动率可能增加。

4. 整合预测结果

  • 多模型综合分析:可以将GARCH模型输出的波动率预测和隐含波动率预测结合,判断它们的预测结果是否一致,增强预测可靠性。
  • 事件风险修正:如果下周有重要的市场事件,将其对波动率的潜在影响加入预测,调整最终波动率预测值。

5. 风险管理和模型验证

  • 验证模型有效性:基于历史数据回测模型,评估其预测精度和可靠性。
  • 设定风险控制:在制定交易策略时,基于预测的波动率区间设置止损、止盈和对冲措施,以应对模型失误或突发市场变化。

示例:预测的简单案例

假设上周VIX指数上升,且下周美联储有重要会议,历史数据显示美联储会议后波动率通常会有所上升。可以利用GARCH模型预测波动率上升的具体程度,同时结合隐含波动率观察市场的预期,并得出下周波动率可能上升的结论。

用python写一个预测SPX下周波动率的代码

要用Python预测S&P 500(SPX)的下周波动率,我们可以使用历史波动率数据和GARCH模型。以下是一个示例代码,通过获取SPX的历史数据,使用arch包来构建和训练GARCH模型,并预测下周的波动率。

首先确保安装所需的Python库:

1
pip install yfinance arch

步骤:

  1. 获取历史数据:使用yfinance获取SPX的日收盘价数据。
  2. 计算收益率:将收盘价转换为对数收益率。
  3. 构建和训练GARCH模型:利用arch库的GARCH模型进行拟合。
  4. 预测下周的波动率:生成未来5天的波动率预测。

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import yfinance as yf
import numpy as np
import pandas as pd
from arch import arch_model
import matplotlib.pyplot as plt

# 1. 获取历史数据
# 使用yfinance下载S&P 500的历史数据
data = yf.download('^GSPC', start='2018-01-01', end='2023-10-01')
data = data['Adj Close']

# 2. 计算对数收益率
returns = np.log(data / data.shift(1)).dropna()

# 3. 构建GARCH模型
# 使用对数收益率的序列来拟合GARCH模型
model = arch_model(returns, vol='Garch', p=1, q=1)
model_fit = model.fit(disp='off')
print(model_fit.summary())

# 4. 预测未来5天的波动率(假设是未来一周的波动率)
forecast_horizon = 5
volatility_forecast = model_fit.forecast(horizon=forecast_horizon)

# 提取预测的波动率均值(年化)
predicted_volatility = volatility_forecast.variance.values[-1, :]
predicted_volatility_annualized = np.sqrt(predicted_volatility * 252)

# 5. 输出下周的波动率预测
print("未来5天(1周)每日预测波动率(年化):")
for i, vol in enumerate(predicted_volatility_annualized):
print(f"第{i+1}天:{vol:.2%}")

# 6. 可视化
plt.figure(figsize=(10, 5))
plt.plot(data.index, returns, label='Daily Returns', color='blue')
plt.plot(data.index[-forecast_horizon:], np.sqrt(predicted_volatility) * np.sqrt(252), label='Predicted Volatility', color='red')
plt.title('S&P 500 Returns and Predicted Volatility (Annualized)')
plt.legend()
plt.show()

代码说明

  • 数据获取yfinance提供了SPX(标普500)的历史数据。我们使用Adj Close来计算日收益率。
  • GARCH模型:GARCH(1,1)模型通常用于捕捉金融时间序列的条件波动性。该模型适合短期预测,因为它能够捕捉波动性聚集的特征。
  • 波动率预测model_fit.forecast提供了未来5天的波动率预测。我们把每日预测的波动率年化,方便解读。
  • 可视化:将收益率和预测波动率绘制在图中,便于观察预测的波动率走势。

结果

代码输出未来一周的每日波动率预测(年化形式),以及波动率变化趋势的图表。

202408

xargs 多个命令

cd /data/temp && find . -type f -mmin +1 | xargs -I {} sh -c 'rsync -avP {} bak-data-server:/home/bakdata/ && rm -f {}'

https://www.youtube.com/watch?v=JgKbe5tcgZ0

新特性解读 | MySQL 8.0 增强逻辑备份恢复工具介绍
https://zhuanlan.zhihu.com/p/267294729

MySQL Shell UTIL 对象附带的备份工具:

  • 随 MySQL 8.0.21 最新版本捆绑发布,自带多线程备份以及多线程恢复功能, 可以直接替代 mysqldump/mysqlpump。
  • dump_instance/dumpInstance 用来多线程备份 MySQL 整个单机实例
  • dump_schemas/dumpSchemas 用来多线程备份 MySQL 单个数据库
  • load_dump/loadDump 用来多线程恢复之前两个工具导出的数据集文件

MySQL Shell 使用指南
https://www.jianshu.com/p/954a011c36f7

安装 mysql-shell,不要用 snap 安装

snap list
sudo snap remove mysql-shell
wget https://dev.mysql.com/get/mysql-apt-config_0.8.32-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.32-1_all.deb
sudo apt-get update
sudo apt-get install mysql-shell

MySQL 核心模块揭秘 | 28 期 | 什么时候释放锁?
https://mp.weixin.qq.com/s/egrrGrjpgX5tMw_xtWY9fw

  • select、update、delete 语句执行过程中,不管 where 条件是否命中索引,也不管是等值查询还是范围查询,只要扫描过的记录,都会加行锁。
  • 和 update、delete 不一样,select 只在需要加锁时,才会按照上面的逻辑加锁。
  • 可重复读(REPEATABLE-READ)、可串行化(SERIALIZABLE)两种隔离级别,
    • 只要加了锁,不管是表锁还是行锁,都要等到事务提交或者回滚即将完成时才释放(手动加的表锁除外)。
  • 读未提交(READ-UNCOMMITTED)、读已提交(READ-COMMITTED)两种隔离级别,
    • 如果发现记录不匹配 where 条件,会及时释放行锁。

PG 查看表大小
SELECT pg_size_pretty(pg_total_relation_size(‘public.xxx’)),
pg_size_pretty(pg_relation_size(‘public.xxx’)),
pg_size_pretty(pg_indexes_size(‘public.xxx’));

+----------------+----------------+----------------+
| pg_size_pretty | pg_size_pretty | pg_size_pretty |
+----------------+----------------+----------------+
| 2827 GB        | 1188 GB        | 133 GB         |
+----------------+----------------+----------------+

去掉重音

>>> import unidecode
>>> unidecode.unidecode('Ольга Павлова')
"Ol'ga Pavlova"
>>> unidecode.unidecode('Эмиль Проказов')
"Emil' Prokazov"

一文掌握逻辑门器件选型要点,国产替代哪家强?
https://zhuanlan.zhihu.com/p/658295483

74系列逻辑门系列的特点

  • (1)74:早期产品,目前仍在使用,逐渐被淘汰;
  • (2)74H:74的改进型,属于高速TTL产品,其与非门传输时间达到10ns左右,但是电路静态功耗较大,逐渐被淘汰;
  • (3)74S:TTL的高速型肖特基系列,采用抗饱和肖特基二极管,速度较高但是品种较少,非主流;
  • (4)74LS:LS是低功耗肖特基,速度比HC系列的略快,属于TTL类的主要产品系列,工作于5V电压,品种和参加非常多,性价比高,在中小规模电路中应用普遍,LS输入开路为高电平,LS 输入端没有上拉或下拉要求,输出端体现下拉强上拉弱。
  • (5)74HC:HC是高速CMOS标准逻辑电路系列,具有与74LS-系列同等工作度和CMOS固有的低功耗和宽电源电压范围(2V~6V),HC的输入电阻很高,开路状态下电平不定,因此输入端要求有上下拉电阻来确定空置时的电平,电阻取值范围1K~10KΩ;
  • (6)74HCT:输入输出与LS系列兼容,但是功耗低;
  • (7)74AS:是74S的后继产品,速度进一步提升到1.5ns,因此也成为“先进超高速肖特基”系列;
  • (8)74ALS:“先进的低功耗肖特基”系列,属于74LS系列的后继产品,工作频率可达50MHz,典型速度4ns,典型功耗1mW,但是价格较高;
  • (9)其他:74F采用高速肖特基电路,74AC是带缓冲功能的逻辑门。

https://www.bilibili.com/video/BV12e411L7QB/?spm_id_from=333.788&vd_source=fefee58242775b49fd927c748741105d

并发导入 8000 个文件到数据库的调度策略,多进程调度方案:
1、起多个进程,每个进程处理一个文件列表,命令行参数传入 start_file_id 和 end_file_id
2、处理某个文件时用 {file_id}.progress 保存该文件处理进度
3、进程读取每读取 100 行 bulk insert 一次,成功后将行号写入进度文件
4、如果进程停止后重启,根据当前处理文件的 file_id 读取进度,continue 掉已处理的行
5、处理完一个文件后,将 {file_id}.progress 重命名为 {file_id}.done
6、进程处理某个文件时,如果存在对应 {file_id}.done 文件则跳过该文件
7、全程无锁无共享,可随时重启,随时从头跑,不重不漏

查看进度

for f in  progress/*.progress;do echo $f,`cat $f`; done;
ls -l progress/*.done | wc -l

加索引报错, tmp 所在磁盘满

mysql> alter table x add index ix_id(id);
ERROR 1030 (HY000): Got error 100 - 'InnoDB error' from storage engine

基于MySQL和Otter实现生产环境安全的数据同步及查询
https://baijiahao.baidu.com/s?id=1789028486868642783&wfr=spider&for=pc

  • 3、异地机房同步(是Otter最大的亮点之一,可以解决国际化问题把数据从国内同步到国外提供用户使用,在国内场景可以做到数据多机房容灾)
  • 4、双向同步(双向同步是在数据同步中最难搞的一种场景,Otter可以很好的应对这种场景,Otter有避免回环算法和数据一致性算法两种特性,保证双A机房模式下,数据保证最终一致性)
    • 1)避免回环算法 (通用的解决方案,支持大部分关系型数据库)
    • 2)数据一致性算法 (保证双A机房模式下,数据保证最终一致性,亮点)

ADHD Test

  • how often do you have trouble wrapping up the final details of a project, once the challenging parts have been done?
  • how often do you have difficulty getting things in order when you have to do a task that requires organization?
  • how often do you have problems remembering appointments or obligations?
  • when you have a task that requires a lot of thought, how often do you avoid or delay getting started?
  • how often do you fidget or squirm with your hands or feet when you have to sit down for a long time?
  • how often do you feel overly active and compelled to do things, like you were drven by a motor?
  • how often do you make careless mistakes when you have to work on a boring or difficult project?
  • how often do you have diffiulty keeping your attention when you are doing boring or repetitive work?
  • how often do you have diffiulty keeping your attention when you are doing boring or repetitive work?
  • how often do you have difficulty concentrating on what people say to you, event when they are speaking to you directly?
  • how often do you misplace or have difficulty fiding things at home or at work?
  • how often are you distracted by activity or noise around you?
  • how often dou you leave your seat in meetings or other situations in which you are expected to remain seated?
  • how often do you feel restless or fidgety?
  • how often do you have difficulty unwinding and relaxing when you have time to yourself?
  • how often do you find yourself talking too much when you are in social situations?
  • when you’re in a conversation, how often do you find yourself finishing the sentences of the people you are talking to,before they can finish tehm themselves?
  • how often do you have difficulty waiting your turn in situations when turn taking is required?
  • how often do you interrupt others when they are busy?

Deep Tech, Explained
From AI to quantum computing and bioengineering, deep tech is being used to solve tomorrow’s problems today.
https://builtin.com/artificial-intelligence/deep-tech

Deep tech, or deep technology, describes the work of companies developing innovations that surpass technological benchmarks and push the boundaries of current technology.

While deep tech companies are often involved in fields like artificial intelligence, biotechnology and quantum computing, the category also includes companies operating in agriculture, aerospace, green energy, mobility and more. Some have become household names, like Moderna, Tesla and Impossible Foods.

【Rethinking IT】如何结合 Unifi 和 MikroTik 设备打造家庭网络
https://sspai.com/post/81572

https://github.com/rcoh/angle-grinder
Angle-grinder allows you to parse, aggregate, sum, average, min/max, percentile, and sort your data. You can see it, live-updating, in your terminal. Angle grinder is designed for when, for whatever reason, you don’t have your data in graphite/honeycomb/kibana/sumologic/splunk/etc. but still want to be able to do sophisticated analytics.

数据库 name 列去重

# 把需要去重的列排序后导出导磁盘
mysql> select name INTO OUTFILE '/data/mysqltmp/name.csv' from t order by name;

# 用 uniq -c 命令过滤出出现过一次的 name,因为已经排序,所以不需要 sort 命令
$ pv name.csv | uniq -c| awk '$1==2{print $2,$1}' > duplicate_name.txt
29.1GiB 0:01:40 [ 297MiB/s] [==============================================================================================>] 100%

The first 20 hours – how to learn anything | Josh Kaufman | TEDxCSU
https://www.youtube.com/watch?v=5MgBikgcWnY

agrind

 tail -f /var/log/nginx/access.log | agrind '* | parse "* * * * * * \"*,*\" * * \"* * *\"" as time,status,request_time,_,_,_,ip,_,_,_,method,url,http_version|count,p90(request_time) by url'

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
 609028 ubuntu    20   0 5102012   1.8g   4620 S 100.0  11.6  28:43.72 agrind

Data compression in Mysql
https://medium.com/datadenys/data-compression-in-mysql-6a0668af8f08

Is Black Myth Wukong Worth Buying
https://www.youtube.com/watch?v=yFF8FWBKSzI

使用Zstandard(zstd)压缩优化备份脚本,实现低负载备份网站数据
https://www.yunloc.com/2438.html

滴滴落地ZSTD压缩算法的实践分享
https://t.it168.com/article_6816820.html

ZSTD(Zstandard)底层基于FSE编码实现,具有出色的压缩和解压速度。ZSTD算法的实现经过了高度优化,通过SIMD等指令集能够充分利用硬件并行性,同时编码过程大量依赖位移运算来完成状态的切换,以此提高处理速度。ZSTD采用字典压缩算法,通过引用字典中的匹配项,能够大大减少重复数据的存储空间,提高压缩比。与此同时,ZSTD采用多级压缩策略,在不同的压缩级别中应用不同的压缩算法,能够在不同的应用场景中灵活地平衡速度和压缩比。

https://python-zstandard.readthedocs.io/en/latest/concepts.html

Counting & Timing
https://code.flickr.net/2008/10/27/counting-timing/

https://docs.vivgrid.com/quick-start

一文学会 OpenAI 的函数调用功能 Function Calling
https://zhuanlan.zhihu.com/p/641239259

https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models

一个人,13年,70个创业项目,独立开发的超级传奇
https://mp.weixin.qq.com/s/T1MGR6yTh_3Z9nU3U9G-Yw

https://cookbook.openai.com/examples/structured_outputs_intro

question = "how can I solve 8x + 7 = -23"

{
   "steps": [
      {
         "explanation": "First, we need to isolate the term with x on one side of the equation, so we subtract 7 from both sides.",
         "output": "8x + 7 - 7 = -23 - 7"
      },
      {
         "explanation": "Simplify both sides. The 7 and -7 on the left-hand side cancel each other out, leaving 8x, and -23 - 7 simplifies to -30.",
         "output": "8x = -30"
      },
      {
         "explanation": "To solve for x, divide both sides of the equation by 8, which is the coefficient of x.",
         "output": "8x/8 = -30/8"
      },
      {
         "explanation": "Simplify -30/8 by reducing the fraction. Divide both numerator and denominator by their greatest common divisor, which is 2.",
         "output": "x = -15/4 or x = -3.75"
      }
   ],
   "final_answer": "x = -3.75"
}

古龙:最放浪的人,最贞洁的小说
https://m.thepaper.cn/baijiahao_9272512

https://github.com/rany2/edge-tts

Programmable Music
http://overtone.github.io/
音乐制作小 Tips:善用 DAW 软件和 MIDI 信号
https://www.sohu.com/a/682533469_121124710

https://b23.tv/MxZntYv

举世流行的作谱应用
https://musescore.org/zh-hans

MuseScore is an open source and free music notation software.
https://github.com/musescore/MuseScore

https://learn.microsoft.com/en-us/azure/ai-services/speech-service/rest-text-to-speech?tabs=streaming
ogg-16khz-16bit-mono-opus
ogg-24khz-16bit-mono-opus
ogg-48khz-16bit-mono-opus

音频编解码器 - Opus
https://www.jianshu.com/p/be8d40b61171
支持的特性包括:

  • 比特率从 6kb/s 到 510 kb/s
  • 采样率从 8kHz(窄带)到 48kHz(全频段)
  • 帧大小从 2.5ms 到 60ms
  • 支持恒定比特率(CBR)和可变比特率(VBR)
  • 从窄带到全频带的音频带宽
  • 支持语音和音乐
  • 支持单声道和立体声
  • 支持多达255个通道(多流帧)
  • 动态可调比特率,音频带宽和帧大小
  • 良好的稳健性和隐蔽性
  • 浮点和定点实现

从 Flask 切到 FastAPI 后,起飞了!
https://blog.csdn.net/m0_59596937/article/details/136383593

Nuxt.js是一个非常强大的框架,但是并不是所有类型的网页都必须使用SSR技术。由于使用SSR需要服务端渲染每一个请求,对服务器资源要求高,尤其是高并发访问的情况,会大量占用服务端CPU资源。我们需要根据业务需求来决定使用什么技术栈去开发页面。

1.SSR
如果项目首屏是动态数据的,对首屏速度要求高且很在乎在搜索引擎的排名,可以考虑使用SSR。

2.SSG
如果项目首屏数据与用户不是强关联的、内容相对稳定的且需要SEO的可以考虑使用预渲染 SSG(Static Site Generation),Nuxt也可以做SSG,避免服务端的渲染压力。

3.CSR
如果网站只是内部产品不需要SEO,或者项目较小不太在意首屏性能的,或者项目是富交互和动态内容的应用,那么还是直接用Vue是最明智的选择。可以通过优化项目体积及其他优化方法如:骨架屏或者添加loading图等方式来优化用户体验。

原文链接:https://blog.csdn.net/m0_55119483/article/details/131491881

binlog 过期天数

mysql> show variables like '%expire%';
+--------------------------------+---------+
| Variable_name                  | Value   |
+--------------------------------+---------+
| binlog_expire_logs_auto_purge  | ON      |
| binlog_expire_logs_seconds     | 2592000 |
| disconnect_on_expired_password | ON      |
| expire_logs_days               | 0       |
+--------------------------------+---------+
4 rows in set (0.01 sec)

mysql> select 2592000/60/60/24;
+------------------+
| 2592000/60/60/24 |
+------------------+
|  30.000000000000 |
+------------------+
1 row in set (0.00 sec)

set global binlog_expire_logs_seconds=4*24*60*60;
show binary logs;
purge binary logs to 'mysql80-bin.000164';
purge binary logs before '2021-22-20 22:00:00';

将Vue项目迁移到Nuxt
https://zhuanlan.zhihu.com/p/664801054

既然加法是基于群论的,为什么小学不先学群论? - ReversedT的回答 - 知乎
https://www.zhihu.com/question/639591755/answer/3366904561

https://cn.vuejs.org/guide/reusability/composables#what-is-a-composable

说说响应式和函数式
https://blog.csdn.net/jjclove/article/details/124388096

dump mysql to parquet then query by duckdb

# install duckdb and csv2parquet
wget https://github.com/duckdb/duckdb/releases/download/v1.1.0/duckdb_cli-linux-amd64.zip && unzip duckdb*.zip
cargo install csv2parquet
# dump data from mysql to parquet
mysql -h mysql-server -u readonly -p db -Bne 'select * from t limit 1000000;' | pv -p --timer --rate --bytes |csv2parquet -d '       ' /dev/stdin test.parquet
# query pqrquet by duckdb
duckdb -s 'select count(*) from "test.parquet"'

curl <FILE_URL> | csv2parquet /dev/stdin /dev/stdout | aws s3 cp - <S3_DESTINATION>
csv2parquet --header false test.csv  test.parquet

[Python] Incrementally using ParquetWriter keeps data in memory (eventually running out of RAM for large datasets)
https://github.com/apache/arrow/issues/26073

This post is for you. It’s for everybody who plans to write some kind of HTTP service in Go. You may also find this useful if you’re learning Go, as lots of the examples follow good practices. Experienced gophers might also pick up some nice patterns.
https://grafana.com/blog/2024/02/09/how-i-write-http-services-in-go-after-13-years/

Instructors’ Guide to Raft
https://thesquareplanet.com/blog/instructors-guide-to-raft/

Students’ Guide to Raft
https://thesquareplanet.com/blog/students-guide-to-raft/

MySQL 输出到文件

pager cat >/tmp/test.txt 
nopager

埃隆·马斯克认为每个孩子都应该了解的50种认知偏见
https://36kr.com/p/1745363984445063

https://github.com/slimtoolkit/slim
Don’t change anything in your container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)

Python环境管理大比拼:pip、Conda、Pyenv、Rye、Virtualenv、PDM、Poetry等工具
https://new.qq.com/rain/a/20240303A055WM00

uv-速度飞快的pip替代
https://zhuanlan.zhihu.com/p/689976933

在Linux系统中,恢复已删除的.log文件的难度取决于多个因素,包括文件系统类型、文件删除后是否被覆盖等。以下是一些可能的恢复方法:

  1. 使用extundelete
    如果你使用的是ext3ext4文件系统,可以尝试使用extundelete工具。

    • 首先,卸载该分区(如果可以的话),然后运行:

      1
      extundelete /dev/sdX --restore-file /path/to/your/file.log
    • 这将尝试恢复该文件并将其保存到当前目录。

  2. 使用photorec
    photorec是一个更通用的恢复工具,可以尝试恢复各种类型的文件。

    • 安装testdisk,它包含了photorec

      1
      sudo apt install testdisk
    • 然后运行photorec并按照提示选择分区和文件类型进行恢复。

  3. 检查备份
    如果你有定期备份,可以从备份中恢复该文件。

  4. 查看日志轮转
    如果系统使用了日志轮转(如logrotate),可能会在某个位置保存旧的日志文件。可以检查/var/log目录下是否有相关的备份文件。

请注意,文件删除后,新的数据写入可能会覆盖原有的数据,降低恢复的成功率。因此,尽快采取恢复措施会更有效。

VScode CPU 占用过高 | search.follow false & exclude nodemodules
https://www.cnblogs.com/dhjy123/p/11906142.html

python bloom filter
from pybloom_live import BloomFilter

# 创建布隆过滤器,设置最大元素数量和误判率
bloom = BloomFilter(capacity=1000, error_rate=0.1)

# 添加元素
bloom.add("apple")
bloom.add("banana")

# 检查元素
print("apple" in bloom)   # 输出: True
print("banana" in bloom)  # 输出: True
print("cherry" in bloom)  # 输出: False(可能为假阳性)

按行号分隔

split --additional-suffix=.csv -d --numeric-suffixes=0 --suffix-length=3 -l 200000 abc.csv abc_ 

sed 打印第 n-m 行并显示原始行号
sed -n ‘4388879,4388883{=;p}’ a.txt

_csv.Error: line contains NUL 错误

sed -i 's/\x0//g' scileads-phone-numbers-with-source.all.filtered.csv

binlog 提取某个表的操作

mysqlbinlog --database=your_database --tables=your_database.your_table /path/to/binlog.000001 > /path/to/output.sql

en2024

In a world where the internet has become an integral part of our daily lives, there’s a remarkable opportunity to immerse ourselves in foreign languages without ever leaving the comfort of our screens.

we can seamlessly integrate language learning into our web browsing activities. In this article, we’ll explore the top Chrome extensions that can help you learn a new language while you surf the web.

Improve your skills on your own, effectively and enjoyably, by watching films and series in the language you study.

Language Reactor is a powerful toolbox for learning languages. It helps you to discover, understand, and learn from native materials. Studying will become more effective, interesting, and enjoyable! (formerly called ‘Language Learning with Netflix’)

202406

Python One Billion Row Challenge — From 10 Minutes to 4 Seconds
https://archive.is/a644q

Processing One Billion Rows in PHP!
https://dev.to/realflowcontrol/processing-one-billion-rows-in-php-3eg0

mysql 中如下 json 字段

{
   "status": "OK",
   "results": [
      {
         "types": [
            "locality",
            "political"
         ],
         "place_id": "ChIJpdtYF6azhkcRmu5nCgU7BtM",
         "formatted_address": "20874 Busnago, Province of Monza and Brianza, Italy",
         "address_components": [
            {
               "types": [
                  "locality",
                  "political"
               ],
               "long_name": "Busnago",
               "short_name": "Busnago"
            },
            {
               "types": [
                  "administrative_area_level_3",
                  "political"
               ],
               "long_name": "Busnago",
               "short_name": "Busnago"
            },
            {
               "types": [
                  "administrative_area_level_2",
                  "political"
               ],
               "long_name": "Province of Monza and Brianza",
               "short_name": "MB"
            },
            {
               "types": [
                  "administrative_area_level_1",
                  "political"
               ],
               "long_name": "Lombardy",
               "short_name": "Lombardy"
            },
            {
               "types": [
                  "country",
                  "political"
               ],
               "long_name": "Italy",
               "short_name": "IT"
            },
            {
               "types": [
                  "postal_code"
               ],
               "long_name": "20874",
               "short_name": "20874"
            }
         ]
      }
   ]
}

要取 types 里包含 administrative_area_level_3 的上级节点的 long_name 值

select 
    country_code,
    location,response->>'$.results[0].formatted_address' formatted_address,
    json_unquote(
        json_extract(
            response,
            concat(
                '$.results[0]',
                REGEXP_REPLACE(
                    JSON_SEARCH(
                        response->>'$.results[0]',
                        'one', 
                        'administrative_area_level_1'
                    ),
                    '"|\\$|\\.types\\[[0-9]]',''
                ),
                '.long_name')
        )
    ) administrative_area_level_1 
from t limit 10;
  1. 先用 JSON_SEARCH 得到 administrative_area_level_1 的路径,类似 $.address_components[3].types[0]
  2. 用 REGEXP_REPLACE 替换掉前面的 $ 和最后的 .types[0]
  3. 用 concat 拼接所需的 json path,类似 $.results[0].address_components[2].long_name
  4. 用 json_extract 取出所需要的值
  5. 用 json_unquote 去掉结果两侧的引号

乱码替换

>>> re.sub(r'x(\w\d)x(\w\d)',lambda x: bytes.fromhex(x.group(1)+x.group(2)).decode('utf-8'),'Logrosxc3xa1n')
'Logrosán'
>>> re.sub(r'x(\w\d)x(\w\d)',lambda x: bytes.fromhex(x.group(1)+x.group(2)).decode('utf-8'),'Trxc3xa9mentines')
'Trémentines'
>>> re.sub(r'x(\w\d)x(\w\d)',lambda x: bytes.fromhex(x.group(1)+x.group(2)).decode('utf-8'),'Trxc3xa9lazxc3xa9')
'Trélazé'
>>> re.sub(r'x(\w\d)x(\w\d)',lambda x: bytes.fromhex(x.group(1)+x.group(2)).decode('utf-8'),'Jxc3xa4msxc3xa4nkoski')
'Jämsänkoski'
>>> re.sub(r'x(\w\d)x(\w\d)',lambda x: bytes.fromhex(x.group(1)+x.group(2)).decode('utf-8'),'Sxc3xb8llerxc3xb8d')
'Søllerød'
>>> re.sub(r'x([0-9a-fA-F]{1,2})x([0-9a-fA-F]{1,2})',lambda x: bytes.fromhex(x.group(1)+x.group(2)).decode('utf-8'),'Sxc3xb8llerxc3xb8d')

‘Søllerød’

手搓一个最小的 Agent 系统 — Tiny Agent
https://zhuanlan.zhihu.com/p/699732624

  • MetaGPT: 本质类似于公司的组织架构,横向同一层级的工作模式,可能是COT、TOT、GOT,纵向深度有不同的层级,如role、action、action node等
  • React: 就像是个不是特别聪明的孩子,要把想法写出来,然后去综合所有想法和观察,接着再做出相应的动作。
  • Reflexion: 一种“语言”强化的新范式,它将策略参数化为代理的记忆编码,并配对参数选择LLM。
  • Toolformer: 一种学习以新颖方式使用工具的模型,它通过自监督的方式学习如何使用不同的工具,如搜索引擎、计算器和翻译系统。
  • Swiftsage: 用一个小模型直接输出决策,当小模型不行时改用大模型通过复杂planning输出决策。
  • Creator: 通过工具创造实现了大模型抽象与具象思维能力的解耦,面对有难度的问题能够保持更好的鲁棒性。

OpenAI 不可用?使用开源模型一键替换 OpenAI API
https://mp.weixin.qq.com/s?__biz=MzI2MjkxNjA2Mg==&mid=2247487114&idx=1&sn=0c443a88bafa49daec18f8a16d0c6284

docker run --rm -p 8080:8080 --name api-server secondstate/llama-3-8b-nomic-1.5:latest

curl -X POST http://localhost:8080/v1/chat/completions \
    -H 'accept:application/json' \
    -H 'Content-Type: application/json' \
    -d '{"messages":[{"role":"system", "content": "You are a helpful assistant."}, {"role":"user", "content": "What is the capital of France?"}], "model": "Meta-Llama-3-8B-Instruct-Q5_K_M.gguf"}'

curl -X POST http://localhost:8080/v1/embeddings \
    -H 'accept:application/json' \
    -H 'Content-Type: application/json' \
    -d '{"model": "nomic-embed-text-v1.5.f16", "input":["LlamaEdge is the easiest & fastest way to run customized and fine-tuned LLMs locally or on the edge."]}'

https://www.secondstate.io/articles/wasm-runtime-agi/

长时间以来,来自开源生态的朋友们一致支持着Qwen的发展,包括

  • 微调(Axolotl、Llama-Factory、Firefly、Swift、XTuner)、
  • 量化(AutoGPTQ、AutoAWQ、Neural Compressor)、
  • 部署(vLLM、SGL、SkyPilot、TensorRT-LLM、OpenVino、TGI)、
  • 本地运行(MLX、Llama.cpp、Ollama、LM Studio)、
  • Agent及RAG(检索增强生成)框架(LlamaIndex, CrewAI, OpenDevin)、
  • 评测(LMSys, OpenCompass, Open LLM Leaderboard)、
  • 模型二次开发(Dolphin, Openbuddy)。

https://zhuanlan.zhihu.com/p/703883561

https://llamaedge.com/

Q: Why can’t I use Python to run the LLM inference?
A: You can certainly use Python to run LLMs and even start an API server using Python. But keep mind that PyTorch has over 5GB of complex dependencies. These dependencies often conflict with Python toolchains such as LangChain. It is often a nightmare to set up Python dependencies across dev and deployment machines, especially with GPUs and containers.

In contrast, the entire LlamaEdge runtime is less than 30MB. It is has no external dependencies. Just install LlamaEdge and copy over your compiled application file!

Q: Why can’t I just use native (C/C++ compiled) inference engines?
A: The biggest issue with native compiled apps is that they are not portable. You must rebuild and retest for each computer you deploy the application. It is a very tedious and error prone progress. LlamaEdge programs are written in Rust (soon JS) and compiled to Wasm. The Wasm app runs as fast as native apps, and is entirely portable.

wasm 使用案例
https://wasmedge.org/docs/zh/start/usage/use-cases/

阿里千问
https://qwen.readthedocs.io/en/latest/framework/LlamaIndex.html

  1. 本地安装,测试,部署很方便,支持多种方式,满足不同需求
  2. 量化,fine tune(有监督训练), embedding(RAG)都支持本地实现
  3. function call,Agent, LangChain相关功能需要使用阿里的dashscope服务

跨设备运行小小阿里云通义千问大模型 Qwen1.5-0.5B-Chat
https://zhuanlan.zhihu.com/p/684034037

mac如何安装git-lfs,以及modelscope的使用示例
https://zhuanlan.zhihu.com/p/692680970

ModelScope+transformers调用llama模型
https://zhuanlan.zhihu.com/p/698481268

https://zhuanlan.zhihu.com/p/681690385

https://wasmedge.org/docs/develop/rust/wasinn/llm_inference/

-m, --model-alias <ALIAS>
      Model alias [default: default]
-c, --ctx-size <CTX_SIZE>
      Size of the prompt context [default: 4096]
-n, --n-predict <N_PRDICT>
      Number of tokens to predict [default: 1024]
-g, --n-gpu-layers <N_GPU_LAYERS>
      Number of layers to run on the GPU [default: 100]
-b, --batch-size <BATCH_SIZE>
      Batch size for prompt processing [default: 4096]

苹果AppleMacOs系统Sonoma本地部署无内容审查(NSFW)大语言量化模型Causallm
https://zhuanlan.zhihu.com/p/686099177
https://hf-mirror.com/tastypear/CausalLM-7B-DPO-alpha-GGUF

LLaMA-Factory QuickStart
https://zhuanlan.zhihu.com/p/695287607

使用 Python库DEAP的多目标优化示例
https://blog.csdn.net/gongdiwudu/article/details/138033230

Pygmo multi-objective optimization with constraints
https://stackoverflow.com/questions/77411477/pygmo-multi-objective-optimization-with-constraints

命令行听歌

for %%i in (D:\mp3\*.mp3) do D:\haohu\soft\ffmpeg\bin\ffplay "%%i" -autoexit

基于STM32+VS1053B的MP3设计
https://zhuanlan.zhihu.com/p/690699207

这里我们使用的是stm32F103VET6,内部Flash有512K,100pin的外部引脚,属于大容量芯片,足够我们diy。对于本设计,stm32这一块用到的知识点有:SDIO驱动SD卡,SPI驱动VS1053B芯片,IIC驱动OLED;对于程序,用的是stm32标准库

功能范围:

  • CPU 专注于通用计算任务。
  • SoC 集成了多个功能模块,满足复杂的计算和通信需求。
  • MCU 专注于特定的嵌入式应用,如控制系统、传感器等。

应用领域:

  • CPU 广泛用于个人电脑、服务器等通用计算设备。
  • SoC 常见于智能手机、平板电脑等便携设备。
  • MCU 主要应用于嵌入式系统,如家电、汽车电子等。

集成程度:

  • CPU 通常作为计算机系统的核心,但需要其他芯片的支持。
  • SoC 在一个芯片上集成了多个功能模块。
  • MCU 是一种完整的嵌入式系统,集成了所有必要的组件。

https://blog.csdn.net/github_35631540/article/details/139122039

  • ESP8266
    • 应用场景:主要用于 WiFi 联网项目,如智能家居设备、IoT 传感器和无线控制。
    • 优势:低成本、内置 Wi-Fi 功能、低功耗模式,易于接入互联网。
    • 代表产品:NodeMCU 开发板、ESP-01模块。
  • 51单片机
    • 应用场景:广泛应用于教育和基础电子学习、简单的控制系统如家电控制、工业仪器等。
    • 优势:成本极低、指令简单、资源占用小,适合初学者和低成本项目。
    • 代表产品:Intel 的 MCS-51 系列。
  • ESP32
    • 应用场景:IoT设备,智能家居,低功耗传感器网络,音频应用等。
    • 优势:比 ESP8266 更强大的 CPU,支持蓝牙和 Wi-Fi,更多的 I/O 端口,更佳的安全性能。
    • 代表产品:ESP32 开发板。
  • Arduino
    • 应用场景:广泛用于教育、原型开发、艺术作品、简单的机器人。
    • 优势:易于学习的编程环境,丰富的社区和库支持,适合快速原型开发。
    • 代表产品:Arduino Uno, Arduino Mega。
  • STM32系列
    • 应用场景:汽车应用、工业控制、医疗设备、高性能嵌入式应用。
    • 优势:基于 ARM Cortex-M 核心,性能强大,低功耗,丰富的外设,支持多种开发环境。
    • 代表产品:STM32F103 系列、STM32F4 系列。
  • Raspberry Pi
    • 应用场景:作为学习计算机编程的工具、家庭媒体中心、高级DIY项目如自制服务器或游戏机。
    • 优势:具备完整的计算机功能,支持多种操作系统,拥有丰富的I/O接口和社区支持。
    • 代表产品:Raspberry Pi 4 Model B。

[嵌入式系统-72]:ARM芯片选型基础
https://blog.csdn.net/HiWangWenBing/article/details/138421375

  • 经典 ARM 处理器 ARMx
    • ARM7 系列:这是 ARM 处理器家族中较早的一代产品,采用 32 位 RISC 架构。
      • 广泛应用于嵌入式系统、移动设备等领域。
    • ARM9系列处理器是在ARM7基础上发展而来的,性能有明显提升。
      • 无线设备、仪器仪表、安全系统、机顶盒、高端打印机、数字照相机
    • ARM11 系列处理器是 ARM9 的升级
  • 嵌入式 Cortex-Mx系列:微控制器
    • 低成本、低功耗、高性能
    • 物联网(IoT)、工业自动化、智能家居和汽车电子等
    • 智能灯光控制、智能门锁、智能家电等设备中,实现远程控制和自动化管理。
  • 嵌入式 Cortex-R 系列:实时处理器
    • 实时处理器,专为需要高可靠性、高可用性、容错功能、可维护性和实时响应的嵌入式系统而设计。
    • 广泛应用于车载控制系统中,如发动机控制、车身控制、底盘控制等。在工业控制领域。
  • 高性能应用 Corex-A 系列:应用处理器
    • 高性能应用处理器,专为需要强大计算能力和高性能指令集的应用而设计
    • 广泛应用于智能手机、平板电脑、笔记本电脑等移动设备以及网络设备、存储设备等领域。

《龙之家族》血龙狂舞战争,黑党与绿党各有哪些势力?
https://zhuanlan.zhihu.com/p/569141727

ck 中按字符串列平均分成 10份

select count(*) from tbl
where CRC32(name)>= 0*((pow(2, 32) - 1) / 10)
and  CRC32(name) < 1*((pow(2, 32) - 1) / 10);
┌──count()─┐
│ 65588724 │ -- 65.59 million
└──────────┘
select count(*) from tbl
where CRC32(name)>= 1*((pow(2, 32) - 1) / 10)
and  CRC32(name) < 2*((pow(2, 32) - 1) / 10);
┌──count()─┐
│ 65424285 │ -- 65.42 million
└──────────┘

函数平移和伸缩变换的知识汇总
https://mp.weixin.qq.com/s?__biz=MzU0Mjg4ODc2OQ==&mid=2247488669&idx=1&sn=d7eafbfe91f41ed555e81e92ed9643d8

LLM101n: Let’s build a Storyteller
https://github.com/karpathy/LLM101n

thought through though

【tcp】关于tcp状态的Recv-Q 和 Send-Q
https://www.jianshu.com/p/4676ea4d03e1

TCP 半连接队列和全连接队列满了会发生什么?又该如何应对?
https://www.cnblogs.com/xiaolincoding/p/12995358.html

几种防御 SYN 攻击的方法:

  • 增大半连接队列;
    • 增大 tcp_max_syn_backlog 和 somaxconn
    • 增大 backlog
  • 开启 tcp_syncookies 功能
  • 减少 SYN+ACK 重传次数

开启 syncookies 功能就可以在不使用 SYN 半连接队列的情况下成功建立连接,在前面我们源码分析也可以看到这点,当开启了 syncookies 功能就不会丢弃连接。

syncookies 是这么做的:服务器根据当前状态计算出一个值,放在己方发出的 SYN+ACK 报文中发出,当客户端返回 ACK 报文时,取出该值验证,如果合法,就认为连接建立成功

https://www.languagereactor.com/ 这个学英语插件不错,可以每一句反复听,会自动断句。

所谓「不可能三角」,是指一款No Code工具无法同时兼顾「灵活」、「易用」与「效率」。

比如,如果工具:

支持各种场景(灵活),同时能显著提高网页产出效率,那他的配置一定很复杂(需要应对各种场景,不易用)
支持各种场景(灵活),同时很好用,那他的开发效率就不会高(无法无脑生成页面,需要修改产物代码)
配置简单(易用),同时开发效率高,那他的应用场景就窄(不灵活)
framer选择了第三条道路,即 牺牲灵活性,保持易用与效率。

具体来说,framer的应用场景局限在生成落地页、产品介绍页、官网这样的静态页。
https://framer.com/

C++11新特性
https://blog.csdn.net/qq_56044032/article/details/125230984

perl 菜鸟教程
https://www.runoob.com/perl/perl-tutorial.html
Perl 基本语法
https://www.cnblogs.com/cosiray/archive/2012/03/18/2404371.html
Modern Perl, 4e
http://modernperlbooks.com/books/modern_perl_2016/index.html

Google on Monday said the search company is reversing its plan to phase out the use of third-party cookies in its Chrome browser in favor of a new strategy that will allow people to “make an informed choice that applies across their web browsing.”

https://en.wikipedia.org/wiki/Denavit–Hartenberg_parameters

坐标系与矩阵(5): Denavit-Hartenberg算法
https://cloud.tencent.com/developer/article/1849681

在动力学中,比如人的胳膊就有好几个关节,且不同的关节有不同的旋转轴,如果是路飞的话,关节之间的长度还是不固定的。这里,每一个关节都存在一个自身坐标系,其中旋转可以是绕三个轴,平移则是沿着三个轴,每个坐标系存在6个自由度。问题就有点复杂了,每个人对每个关节可能会定义不同的坐标系方向,这会直接决定求解该问题的难度。DH算法则提供了一个一般性理论,且每一个关节只需要4个自由度。

https://cloud.tencent.com/developer/article/1969850
栅格化的对象是网格,网格表面可以通过三角形无限细分,而三角形是最简单的平面。接下来就是栅格化核心内容:如何绘制一个三角形。

栅格化的流水线主要有两个阶段:顶点(vertex)和片元(fragment),前者将三维空间下三角形的每一个点投射到二维平面上,后者则将投影后的三角形填充颜色,最终完成一个三角形的渲染。当多个三角形存在遮盖问题时,则通过深度检测(Z-buffer机制)来判断几何对象间的远近。

Whitted-Style Ray Tracing算法(1979)采用射线模拟相机到光源间的光路传输,并考虑了射线和光源之间的遮盖,射线和物体间的反射,以及和半透明物体间的折射等光学现象。该算法模拟了光线传播中的基本物理规律,比如Fresnel, Beer law,折射率以及传输过程中的衰减等,非常健壮的实现了阴影、折射、反射效果。

通过栅格化和光线追踪的发展来看,人们对真实感的定义随着时间而变化,最初希望有基本的阴影、折射、反射效果,随着技术和硬件能力的提升,人们的标准也不断的提高,正应了那句歌词,得不到的永远在骚动。这也反映了Moore‘s Law和Blinn’s Law之间的相互制约:当计算能力不断提升时,人们也会提高渲染真实感的标准,从而保证渲染时间不变。

在概念上,无论栅格化还是光线追踪,真实感的标准主有三点:照片级别(photo realistic)和物理正确(physically based rendering)以及性能(high performance),只是两者给出了不同的优先级。光线追踪优先前两点,往往需要极大的计算量,因此在离线渲染领域成为主角。而Rasterization技术主要应用于实时渲染领域,为了性能而有条件地牺牲前两点。

https://github.com/rqlite/rqlite

rqlite is a relational database which combines SQLite’s simplicity with the power of a robust, fault-tolerant, distributed system.

You can use rqlite to store your important data reliably, ensuring it’s always available. If you’re interested in understanding how distributed systems actually work, it’s a good example to study. A lot of thought has gone into its design, separating storage, consensus, and API clearly.

The fastest, most reliable, Redis-based distributed queue for Node.
Carefully written for rock solid stability and atomicity.
https://github.com/taskforcesh/bullmq

du -sh 排除挂载点,清理 /tmp

# 创建目录排除文件,排除掉非系统盘挂载点,NFS 挂载点 和 /proc
mount |awk '$1~/^\/dev/&&$3!="/" || $5~/nfs/ {print $3}' >> ~/.du_exclude
echo /proc >> ~/.du_exclude

# 查看文件大小分布
ncdu -X ~/.du_exclude /
du -sh -X ~/.du_exclude /*

# 清理 10 天未改动的临时文件
find /tmp -ctime +10 | xargs rm -rf

202405

关于投资建议
https://retire50blog.wang/wp-content/uploads/7038138252_博客图片/关于投资建_files_9bbe285294f3059a76a55f60ed91b249ea8a1d0b/1.png

https://retire50blog.wang/invest/imp/关于我-2.html

多少钱可以财务自由?
https://xueqiu.com/5819606767/60786196

举一个例子,如果你历史上的投资复利是15%,GDP是7%,CPI是3%,每年计划开销25万,则
1、实现基本的财务自由,可投资资产>25万/(15%-3%)=208万,未来的花销每年可以按照CPI=3%的速度增加
2、实现高级的财务自由,可投资资产>25万/(15%-3%-7%)=500万,未来的花销每年可以按照GDP+CPI=10%的速度增加

《微信公开课》读后感&做期权的思考
https://retire50blog.wang/invest/读《2018微信公开课》后感.html

投资体系演变和最新规划
https://retire50blog.wang/invest/投资体系演变历史和最新规划.html

https://retire50blog.wang/invest/关于赚钱.html
https://retire50blog.wang/invest/价投投资思路变化.html
https://retire50blog.wang/invest/躺.html

  • 我这里每年的开销不多,一般20万以下。
  • 10%,300万的现金,获取3-4%的存款理财收益,可以提供10万。另外我还有一些增收手段,一年能有个50万。
  • 长江电力,有个转债132018,在2024年4月9日转债到期之前,可以做到一些增收。今年下半年开始做,到目前增收约15万。
  • 沪深300,我用期货代替510310,每年可以增收3%左右,大约27万。今年7月底开始实施,到现在10月基本满了一个季度,增收7.5万。如果全年四个季度,会有25-30万。
  • 贵州茅台,分仓4个号,打新股有些额外收益。今年前十个月打新收益7万。长电由于经常和转债切换,且大量集中在了一个低佣金的账号里,所以没法稳定提供打新市值。
  • 一年合计有60万收益,足够覆盖不到20万的开销。如果有其他重要开支,可以从10%的现金里出。

https://retire50blog.wang/invest/这么想.html

mysql 修改认证插件
# 查看日志
tail -f /var/log/mysql/error.log
2024-05-09T00:57:25.534340Z 206919 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ‘‘mysql_native_password’ is deprecated and will be removed in a future release. Please use caching_sha2_password instead’

# 修改默认插件并重启
vi  vi /etc/mysql/mysql.conf.d/mysqld.cnf
    default_authentication_plugin=mysql_native_password
systemctl restart mysql
systemctl status mysql

# 确认插件修改成功
show plugins;
show variables like '%auth%';

# 以指定认证插件创建账号并分配权限
create user 'user'@'6.6.6.6' identified with mysql_native_password by '****';
select host, user, plugin from mysql.user;
grant all privileges on testdb.*  TO 'user'@'6.6.6.6';

视频音频比特率(码率)与采样率之间的联系
https://zhuanlan.zhihu.com/p/486101944

qbasic Beginner Tutorials
http://www.petesqbsite.com/sections/tutorials/beginners.shtml
http://www.petesqbsite.com/sections/tutorials/zines/qboa/4-beginner.txt

Is there a resource that teaches math through programming?
https://www.reddit.com/r/compsci/comments/y79zd/is_there_a_resource_that_teaches_math_through/

How and where can I learn programming and mathematics simultaneously?
https://www.quora.com/How-and-where-can-I-learn-programming-and-mathematics-simultaneously

How can someone combine programming and mathematics while learning both?

I will preface this by saying that it really depends on what area of mathematics you’re learning. For instance, when I was in set theory, fundamental logic and some of those strains of classes, I wasn’t really programming up a lot of the course materials. There are options but they are limited for these type of classes.

But lets assume first that you’re in an area like one of the Algebra classes before Modern / Abstract Algebra.

Here you will learn many ways to solve equations, about polynomials, trigonometry, and the likes.

One of the reasons that the law of sines stuck with me so much was because it was one of the first programs I wrote on my TI calculator.

The programming concepts were pretty simple: I/O (user input, display results), modes of calculations (degrees vs radians), and possibly loops (for doing multiple exercises).

excel 根据 email 获取域名

=RIGHT(A1, LEN(A1) - SEARCH("@", A1))

https://www.nytimes.com/2019/11/13/books/review/the-man-who-solved-the-market-gregory-zuckerman.html

https://makemoneyonlinetutorials.quora.com/
https://blogsked.com/make-money-online-2024/

How much time does it realistically take to start seeing results from online money-making methods like blogging or YouTube?

DOS game “F-15 Strike Eagle II” reverse engineering/reconstruction war stories
https://news.ycombinator.com/item?id=40347662

具备反脆弱特性的期权波动率多头,如何控制Theta消耗?
https://mp.weixin.qq.com/s?__biz=MzU5NDc0MTkyNw==&mid=2247492445&idx=1&sn=933c24a9555eeeffbe3a4412331615d5&chksm=fe7e3c95c909b583a9ceef9d7ade0e6f9d122dbae5e711e097b38806441c1f6a550173373287&scene=21#wechat_redirect

Write 8-bit code in your browser.
https://8bitworkshop.com/

mysql 查看回滚进度

mysql> select now(),trx_state,trx_rows_modified from INNODB_TRX where trx_id=5795845153 limit 10;
+---------------------+--------------+-------------------+
| now()               | trx_state    | trx_rows_modified |
+---------------------+--------------+-------------------+
| 2024-05-16 07:12:21 | ROLLING BACK |           7525492 |
+---------------------+--------------+-------------------+
1 row in set (0.00 sec)

https://aws.amazon.com/cn/tutorials/create-manage-nonrelational-database-dynamodb/
https://aws.amazon.com/cn/solutions/case-studies/dropbox-dynamodb-case-study/?pg=dynamodb&sec=cs#dropbox
https://docs.aws.amazon.com/zh_cn/amazondynamodb/latest/developerguide/SQLtoNoSQL.WhyDynamoDB.html

查询多个数据源
https://docs.aws.amazon.com/zh_cn/athena/latest/ug/running-federated-queries.html

The main purpose of this project is to power sco and neco, which are more general purpose coroutine libraries.
https://github.com/tidwall/llco

https://github.com/tidwall/hashmap.c
Hash map implementation in C.

用 python 写一个函数,把函数调用表达式 a(1, b(2, c(0))) 解析成 json 格式的抽象语法树,如下

{
  "type": "CallExpression",
  "callee": {
    "type": "Identifier",
    "name": "a"
  },
  "arguments": [
    {
      "type": "NumberLiteral",
      "value": 1
    },
    {
      "type": "CallExpression",
      "callee": {
        "type": "Identifier",
        "name": "b"
      },
      "arguments": [
        {
          "type": "NumberLiteral",
          "value": 2
        },
        {
          "type": "CallExpression",
          "callee": {
            "type": "Identifier",
            "name": "c"
          },
          "arguments": [
            {
              "type": "NumberLiteral",
              "value": 0
            }
          ]
        }
      ]
    }
  ]
}

一探究竟:深挖网关性能异常背后的秘密
https://mp.weixin.qq.com/s/zN9m4r-frwpkFN3tzsVXjQ

手撕红黑树!使用C语言带你实现一个平衡搜索树【正文】
https://mp.weixin.qq.com/s?__biz=Mzg3ODg3Mzg3Nw==&mid=2247483882&idx=2&sn=f1f8ed6baa834cf767bac33cf26765f4&chksm=cea3dbcdcfba1239a3b6c591675904b2af5b6e5669015aa4779e688198f3cc867930bf1dc628&scene=132&exptype=timeline_recommend_article_extendread_extendread_for_notrec&show_related_article=1&subscene=0&scene=132#wechat_redirect

红黑树可以称得上几乎平衡的二叉搜索树,能够在最坏的情况下把插入、检索和删除的时间复杂度都控制在$O(\lg(n))$,如果把一系列数据结构都当成是学生的话,把插入、随机检索和删除作为考核科目,那么红黑树可以比喻成每科都能拿90分的学霸,而二叉平衡树(AVL)在“检索”拿到95分,哈希表更是在“检索”科目拿到97分,不过后面两位学生在插入和删除方面拿到的分数就比90分低多了。

https://time.geekbang.org/column/article/312589
大力水手Jerry
一课一思:service mesh是软硬一体化,基础设施软件化,系统的模块被分割为业务代码和基础设施代码,团队既要负责业务的开发,也要负责基础设施代码的开发,实现开发和运维的一体化,这对团队提出了很高的要求。换句话说,云原生和网格统一了软件业务开发和生产运维,它将基础设施软件化,并为生产运维提供了工具和手段。类似于monolithic发展到micro-services,复杂性并不会消失,而是转换到另外一个维度,云原生的目的并不是消除复杂性,而是更加专业和灵活的管理软件的复杂性和基础设施的复杂性。云原生的主要矛盾可能就是面向业务的代码开发管理和面向基础设施的运维管理,后者会消耗资源,从某种角度说相当于侵占了前者的资源,因此下一次的软件架构,可能会屏蔽掉所有面向基础设施的管理内容,整体软件架构只呈现出业务的关联依赖。

不管是做单体应用还是微服务,在系统设计之初就要做好领域分析建模,在开发阶段要严格按照领域设计分层开发,将来即使要拆分也会很容易。

SpringFU、Spring Graal Native

awk 里用 FPAT 解析 csv

$ echo -e "1,2\n\"3\\\"a\",\"4,5\"" | awk  'BEGIN{FPAT="[^,]+|\"[^\"]+\""}{print NF,$1"|"$2}'
2 1|2
2 "3\"a"|"4,5"

pv data.csv |awk  'BEGIN{FPAT="[^,]+|\"[^\"]+\""}NF==13{print $0' | clickhouse-client --query 'insert into data FORMAT CSV'

为什么现在没人读Linux源码了?
https://www.sohu.com/a/731268212_121124376

https://mp.weixin.qq.com/s?__biz=MzIzOTU0NTQ0MA==&mid=2247538751&idx=1&sn=9382ab61af6648c2e4c099f70e1078cf&chksm=e8e519b4508b139afbfd4b75cf0c5189b807f31e87e235f6fd821804ee14e2b70c220e63c5ac&scene=132&exptype=timeline_recommend_article_extendread_samebiz&show_related_article=1&subscene=0&scene=132#wechat_redirect

  • 确认使用的对象(ToC:高并发,ToB:高可用)
  • 系统的服务场景(即时通信:低延迟,游戏:高性能,购物:秒杀-一致性)
  • 用户量级(万级:双机、百万:集群、亿级:弹性分布式、容器化编排架构)
  • 百万读:3主6从,每个节点的读写高峰QPS可能可以达到每秒5万,可以实现15万,30万读性能
  • 亿级读,通过CDN、静态缓存、JVM缓存等多级缓存来提高读并发
  • 百万写,通过消息队列削峰填谷,通过hash分拆,水平扩展分布式缓存
  • 亿级写,redis可以定制数据结构、SSD+内存LRU、冷数据异步多线程复制
  • 持久化,(Mysql)承受量约为 1K的QPS,读写分离提升读并发,分库分表提升写并发

https://mp.weixin.qq.com/s?__biz=MzIzOTU0NTQ0MA==&mid=2247538395&idx=1&sn=de3fd76a18d3d08806ff09a5ab59142f&chksm=e8e11d6334dac1a75aed9e4fc597b523eb96859350ffcb744ec30e21312d543643c0a4f2f67b&scene=132&exptype=timeline_recommend_article_extendread_samebiz&show_related_article=1&subscene=132&scene=132#wechat_redirect

https://blog.csdn.net/wuhuayangs/article/details/121830094

布隆过滤器中一个元素如果判断结果为存在的时候元素不一定存在,但是判断结果为不存在的时候则一定不存在。

布隆过滤器适合的场景

  • 区块链中使用布隆过滤器来加快钱包同步;以太坊使用布隆过滤器用于快速查询以太坊区块链的日志
  • 数据库防止穿库,Google Bigtable,HBase 和 Cassandra 以及 Postgresql 使用BloomFilter来减少不存在的行或列的磁盘查找。避免代价高昂的磁盘查找会大大提高数据库查询操作的性能
  • 判断用户是否阅读过某一个视频或者文章,类似抖音,刷过的视频往下滑动不再刷到,可能会导致一定的误判,但不会让用户看到重复的内容
  • 网页爬虫对URL去重,采用布隆过滤器来对已经爬取过的URL进行存储,这样在进行下一次爬取的时候就可以判断出这个URL是否爬取过了
  • 使用布隆过滤器来做黑名单过滤,针对不同的用户是否存入白名单或者黑名单,虽然有一定的误判,但是在一定程度上还是很好的解决问题
  • 缓存击穿场景,一般判断用户是否在缓存中,如果存在则直接返回结果,不存在则查询数据库,
    • 如果来一波冷数据,会导致缓存大量击穿,造成雪崩效应,
    • 这时候可以用布隆过滤器当缓存的索引,只有在布隆过滤器中,才去查询缓存,如果没查询到则穿透到数据库查询。
    • 如果不在布隆过滤器中,则直接返回,会造成一定程度的误判
  • WEB拦截器,如果相同请求则拦截,防止重复被攻击。用户第一次请求,将请求参数放入布隆过滤器中,当第二次请求时,先判断请求参数是否被布隆过滤器命中。
  • 可以提高缓存命中率。
  • Squid 网页代理缓存服务器在 cache digests 中就使用了布隆过滤器。
  • Google Chrome 浏览器使用了布隆过滤器加速安全浏览服务
  • Google 著名的分布式数据库 Bigtable 使用了布隆过滤器来查找不存在的行或列,以减少磁盘查找的IO次数
  • Squid 网页代理缓存服务器在 cache digests 中使用了也布隆过滤器
  • Venti 文档存储系统也采用布隆过滤器来检测先前存储的数据
  • SPIN 模型检测器也使用布隆过滤器在大规模验证问题时跟踪可达状态空间
  • Google Chrome浏览器使用了布隆过滤器加速安全浏览服务

如果允许误判率的话,可以使用布隆过滤器,只有你想不到的,没有你做不到的。

判断用户是否阅读过某一个视频或者文章,类似抖音,刷过的视频往下滑动不再刷到,可能会导致一定的误判,但不会让用户看到重复的内容

布隆过滤器在这个场景用的对吗?

  • 如果布隆过滤器说这个视频不存在,那肯定不存在,用户就会刷到它,他肯定没看过这个视频,符合预期
  • 如果布隆过滤器说这个视频存在,但不一定存在,用户就刷不到了这个视频了,那这不就错过一个视频了吗,类似用户丢消息了,这能接受吗?

SpringBoot+Docker:高效容器化的最佳实践
https://mp.weixin.qq.com/s/AkX53sMwx3wiCGufAAFN9w

https://mp.weixin.qq.com/s/BbV43_T6UzHvG8GnqESEUg

Best Microsoft Office alternative of 2024
https://www.techradar.com/news/best-microsoft-office-alternative

office2003蜻蜓特派员3in1 官方版
https://pan.baidu.com/s/1cCNaCu?at=1717033722095

编译原理(七)——自顶向下语法分析概述
https://blog.csdn.net/weixin_43633784/article/details/108620459

First集、Follow集、Predict集的简单求法 三个重要集合
https://blog.csdn.net/qnsEmma/article/details/107943236

https://blog.csdn.net/m0_61819793/article/details/134274982

202404

Embeddings
https://platform.openai.com/docs/guides/embeddings

OpenAI’s text embeddings measure the relatedness of text strings.

An embedding is a vector (list) of floating point numbers. The distance between two vectors measures their relatedness. Small distances suggest high relatedness and large distances suggest low relatedness.

OpenResty 开发速览
https://www.ogura.io/posts/2019/01/openresty_quickview/

eBPF专题一 | 手把手教你用eBPF诊断MySQL(含源码)
https://mp.weixin.qq.com/s/3S2t-Nfip-2--aOgov4qtw

蚂蚁专家介绍RDMA技术砖题(一):技术概述
https://mp.weixin.qq.com/s/WlQlN3qR9DxXvvI_PQnr3A

http://news.sohu.com/a/716725440_411876

AI Agent的深度思考 | 附十一个行业的应用场景
https://mp.weixin.qq.com/s/5hh-HLUmgI_ODzbqA0d_ag

Lor 是什么#
Lor是一个运行在OpenResty上的使用Lua编写的Web框架。 它兼顾开发效率和运行时性能, 可用于快速开发API Server和传统Web页面应用。
http://lor.sumory.com/docs/getting-started-cn

被cloudflare 代理后 nginx 如何获取客户真实ip
https://zhuanlan.zhihu.com/p/668005446
https://nocache.org/p/restore-real-ip-address-from-cloudflare-cdn-in-nginx

Configuring Your Nginx Server for Mutual TLS mtls
https://smallstep.com/hello-mtls/doc/server/nginx
https://developers.cloudflare.com/ssl/client-certificates/

Everything You Need To Know About IRON CONDORS
https://optionstradingiq.com/wp-content/uploads/Iron-Condor.pdf

https://github.com/DeliberateEngineer

「十一充电」腾讯魔方技术总监:作为游戏程序员是如何自我提升的?
https://baijiahao.baidu.com/s?id=1646675636195344957&wfr=spider&for=pc

Yes, taking a contrarian view can be profitable when markets panic,
but we also need to be aware that some of the worst market declines in history have come AFTER the VIX Futures market moved into Backwardation.

SHRINK an Amazon AWS EBS root volume (2020 Update)
https://medium.com/@ztobscieng/shrink-an-amazon-aws-ebs-root-volume-2020-update-8db834265c3e

Cilium:基于eBPF的高效云原生网络和ServiceMesh方案
https://www.51cto.com/article/759002.html

【网络】eBPF、Cilium、Calico
https://zhuanlan.zhihu.com/p/500174411

司徒捷
http://finance.sina.com.cn/zl/usstock/20141028/173120665258.shtml
https://baijiahao.baidu.com/s?id=1738975229150699274&wfr=spider&for=pc

OpenResty使用Lua大全(十)实战: Lua + Redis 实现动态封禁 IP
https://feixiang.blog.csdn.net/article/details/136658128

OpenResty使用Lua大全(十二)实战: 动手实现一个网关框架
https://blog.csdn.net/A_art_xiang/article/details/136658438

计算机中我们常常会混淆指令周期、CPU周期和时钟周期,要区分这些并不难,但要想彻底弄懂这些,就得要求我们对CPU底层有一定了解。
https://zhuanlan.zhihu.com/p/90829922

  • 指令周期(Instruction Cycle):取出并执行一条指令的时间。
  • CPU 周期:一条指令执行过程被划分为若干阶段,每一阶段完成所需时间。
  • 时钟周期(Clock Cycle):又称震荡周期,是处理操作的最基本单位。

所以,我们说一个指令周期,包含多个 CPU 周期,而一个 CPU 周期包含多个时钟周期。

【浅析】x86模式变迁下Linux的启动过程
https://zhuanlan.zhihu.com/p/86058611

Linux启动具体过程:

  • 电脑刚加电时,会把 CS 重置为0xFFFF,IP重置为0x0000 ,所以第一条指令就会指向0xFFFF0,属于ROM范围。
  • 进入BIOS时期;BIOS首先会检查硬件,如果硬件没问题,会开始建立中断向量表和中断服务(BIOS中基本输入输出要基于中断服务),最后BIOS会将启动盘的第一个扇区MBR 512字节加载到内存中的 0x7c00 来运行。(MBR存放的为boot.img,由 boot.S 编译而成,再由grub2安装至启动盘)
  • 进入BootLoader时期;bot.img做的唯一事情就是加载core.img(core.img由一系列的模块组成)。boot.img将控制权交给disk.img,disk.img的任务就是加载core.img其他部分,先是lzma_decompress.img,再是kenel.img,最后是各个模块对应的映像。
  • lzma_decompress.img调用real_to_prot切换到保护模;切换过程主要做两部分工作:
    • 一是启用分段,在内存中建立段描述符表,将段寄存器变成选择子,指向某个段描述符
    • 二是启用分页
  • 解压缩kernel.img;kenel.img会调用grub_main函数,在这个函数里边,grub_load_config()会开始解析grub.conf文件里的配置信息,然后grub_show_menu()会显示让你选择的操作系统列表,然后grub_menu_execute_entry()开始加载操作系统。
  • 启动内核

Go中的组合
https://zhuanlan.zhihu.com/p/619881005

eBPF实用技巧 | 函数参数超过5个怎么办?
https://mp.weixin.qq.com/s/tZR4YW2cD4Goe9lUPSuOhA

起 eBPF 大家都不陌生,就内核而言,hook 会尽可能选在 tracepoint,如果没有 tracepoint,会考虑使用 kprobe。

tracepoint 的范围有限,而内核函数又太多,基于各种需求场景,kprobe 的出场机会较多;但需要注意的,并不是所有的内核函数都可以选作 hook 点,inline 函数无法被 hook,static 函数也有可能被优化掉;如果想知道究竟有哪些函数可以选做 hook 点,在 Linux 机器上,可以通过less /proc/kallsyms查看。

windows 内存溢出

printf '\xcc%.0s' {1..1000}|iconv -f gbk -t utf-8 - -o -
烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫

关于“烫烫烫烫烫烫烫”的程序员笑话
https://blog.csdn.net/duke_ding2/article/details/130907027

https://www.futunn.com/learn/detail-how-to-trade-options-on-a-computer-86188-230557322?global_content={"promote_id"%3A13766%2C"sub_promote_id"%3A38}

【期权分析工具】波动率分析:如何判断期权的估值水平?
https://www.futunn.com/learn/detail-options-analysis-tool-volatility-analysis-how-to-determine-the-valuation-level-of-options-86188-230550334
【期权分析工具】价格计算器:如何计算期权的未来价格?
https://www.futunn.com/learn/detail-option-analysis-tool-price-calculator-how-to-calculate-the-future-price-of-options-86188-230569331
【期权分析工具】异动分析:如何跟踪大资金的动向?
https://www.futunn.com/learn/detail-options-analysis-tool-transaction-analysis-how-to-track-the-movement-of-large-funds-86188-230551335

https://www.investingdaily.com/45022/option-delta-calculation-explained/

Know Your Greek Letters for Better Trading Results
https://www.investingdaily.com/71403/know-your-greek-letters-for-better-trading-results/

【可转债知识】04可转债四大要素-回售条款
https://xueqiu.com/8132666925/257544240

Practical Linux tracing ( Part 1/5) : symbols, debug symbols and stack unwinding
https://tungdam.medium.com/things-you-should-know-to-begin-playing-with-linux-tracing-tools-part-i-x-225aae1aaf13

投資美股最核心的20張圖表
https://x.com/TheInvestorLEI/status/1781064276658282788

AI Agent的深度思考 | 附十一个行业的应用场景
https://mp.weixin.qq.com/s/5hh-HLUmgI_ODzbqA0d_ag

好用投資工具網站App分享:選股、基本面、估值、回測(2024.2)
https://vocus.cc/article/65d83f7ffd89780001d4f385

https://www.gurufocus.com/pricing

As the founder of GuruFocus.com, many people naturally assume that I have a degree in finance or some other closely related field. However, I actually possess a Ph.D. in physics.

https://www.cnn.com/markets/fear-and-greed

A few big stocks can skew returns for the market.
It’s important to also know how many stocks are doing well versus those that are struggling.
This shows the number of stocks on the NYSE at 52-week highs compared to those at 52-week lows.
When there are many more highs than lows, that’s a bullish sign and signals Greed.

The market is made up of thousands of stocks.
And on any given day, investors are actively buying and selling them.
This measure looks at the amount, or volume, of shares on the NYSE that are rising compared to the number of shares that are falling.
A low (or even negative) number is a bearish sign.
The Fear & Greed Index uses decreasing trading volume as a signal for Fear.

可转债知识】06快速看懂一只可转债!
链接:https://xueqiu.com/8132666925/259443693
要看懂一只可转债,应该先在募集说明说里找到转股价、下修条款、强赎条款、回售条款四大要素,募集说明书在各家券商APP可转债页面下的公告里都能找到

Miller is like awk, sed, cut, join, and sort for data formats such as CSV, TSV, JSON, JSON Lines, and positionally-indexed.
https://github.com/johnkerl/miller?tab=readme-ov-file

Is there a robust command line tool for processing csv files?
https://unix.stackexchange.com/questions/7425/is-there-a-robust-command-line-tool-for-processing-csv-files

I’m sure there are more criticisms, but the impetus for this project was a 40GB CSV file that was handed to me. I was tasked with figuring out the shape of the data inside of it and coming up with a way to integrate it into our existing system. It was then that I realized that every single CSV tool I knew about was woefully inadequate. They were just too slow or didn’t provide enough flexibility. (Another project I had comprised of a few dozen CSV files. They were smaller than 40GB, but they were each supposed to represent the same kind of data. But they all had different column and unintuitive column names. Useful CSV inspection tools were critical here—and they had to be reasonably fast.)

A fast CSV command line toolkit written in Rust.
https://github.com/BurntSushi/xsv?tab=readme-ov-file

$ pv test.csv|csvcut -c 9 | grep -Ev '^""$' | wc -l
13.0GiB 0:05:55 [37.5MiB/s] [==============================================================================================>] 100%
9316774
$ pv test.csv| xsv fixlengths -l 10 |xsv search  -s 9 -v '^$'| wc -l
13.0GiB 0:02:00 [ 110MiB/s] [==============================================================================================>] 100%
9316799

Open Source realtime backend in 1 file
pocketbase.io

https://twitter.com/WealthCoachMak/status/1784255938427240786
If you had $250,000 cash and sold options with it…
It might be enough to retire early
You can generate $3k to $10k per month and if that covers your monthly expenses…
You never have to work again
Option Selling is very powerful

words

  • instruments
  • security
  • stock
  • equities
  • share
  • holders
  • portfolio
  • positions
  • net worth

WHAT IS IV RANK AND HOW TO USE IT. 2023 GUIDE
https://optionstradingiq.com/what-is-iv-rank-and-how-to-use-it/

https://caifuhao.eastmoney.com/news/20231109093356353014470
“历史总是惊人的相似。”股市的行情总会在绝望中产生,在犹豫中上涨,在疯狂中灭亡。这是一个不断循环的过程,也是市场的一种规律。投资者们需要学会在绝望中寻找希望,抓住犹豫中的机会,避免在疯狂中迷失自我。只有这样,他们才能够在股市的大潮中游刃有余,成为真正的赢家。

电子取证之PC版微信数据库解密
https://cn-sec.com/archives/440791.html

Function graph tracer for C/C++/Rust/Python
https://github.com/namhyung/uftrace

202402

Clickhouse 纯手工迁移表
https://www.cnblogs.com/hdpdriver/p/16088755.html

ClickHouse 建表create table时primary by与order by
https://blog.csdn.net/qq_36951116/article/details/106260189

  • ORDER BY的作用, 负责分区内数据排序;
  • PRIMARY KEY的作用, 负责一级索引生成;
  • Merge 的逻辑, 分区内数据排序后,找到相邻的数据,做特殊处理。
    • 只有在触发合并之后,才能触发特殊逻辑。以去重为例,在没有合并的时候,还是会出现重复数据。
    • 只对同一分区内的数据有效。以去重为例,只有属于相同分区的数据才能去重,跨越不同分区的重复数据不能去重。
  • 通常只有在使用 SummingMergeTree 或 AggregatingMergeTree 的时候,才需要同时设置ORDER BY与PRIMARY KEY。
    • 显式的设置 PRIMARY KEY,是为了将主键和排序键设置成不同的值,是进一步优化的体现。
    • 如果 ORDER BY 与 PRIMARY KEY 不同,PRIMARY KEY 必须是 ORDER BY 的前缀(为了保证分区内数据和主键的有序性)。

ClickHouse 查询优化详细介绍
https://mp.weixin.qq.com/s/38RMVbw25P3iuE4IIuxdog

https://clickhouse.com/docs/zh/engines/table-engines/mergetree-family/mergetree

日志分析下ES/ClickHouse/Loki比较与思考
https://mp.weixin.qq.com/s/n2I94X6tz2jOABzl1djxYg

  • 方案A:Local Storage + Pssh扫描派(代表作:跳板机上各种脚本)
  • 方案B:Central Storage + Inverted Index派(代表作:ES)
  • 方案C:Central Storage + Column Storage + MR派(代表作:Hive)
  • 方案D:Central Storage + Column Storage + MPP派(代表作:ClickHouse)
  • 方案E:Central Storage + 扫描类(代表作:Grafana-Loki)

可观测性数据收集集大成者 Vector 介绍
https://blog.csdn.net/n9ecommunity/article/details/133810461

核心就是 pipeline 的处理,有 Source 端做采集,有中间的 Transform 环节做数据加工处理,有 Sink 端做数据转发。

  • 超级快速可靠:Vector采用Rust构建,速度极快,内存效率高,旨在处理最苛刻的工作负载
  • 端到端:Vector 致力于成为从 A 到 B 获取可观测性数据所需的唯一工具,并作为守护程序、边车或聚合器进行部署
  • 统一:Vector 支持日志和指标,使您可以轻松收集和处理所有可观测性数据
  • 供应商中立:Vector 不偏向任何特定的供应商平台,并以您的最佳利益为出发点,培育公平、开放的生态系统。免锁定且面向未来
  • 可编程转换:Vector 的高度可配置转换为您提供可编程运行时的全部功能。无限制地处理复杂的用例

快手、携程等公司转战到 ClickHouse,ES 难道不行了?
https://mp.weixin.qq.com/s/hP0ocT-cBCeIl9n1wL_HBg

https://zhuanlan.zhihu.com/p/547100507
ClickHouse现在是云原生的,支持分层存储。如果你关注它,会看到它的一条演进轨迹。最开始是单机的,单机即可实现很多高性能查询;然后演进到分布式,利用了比如复制表、分布式表,巧妙地变成了一个分布式架构;再往后,大家在讲云原生,也是可以分层存储、存算分离,有一些存储可以放到S3上,也可以放到HDFS上面去;后来也支持了OSS,目前也是通过原生的分层存储方式向云原生再迈进了一步。在此之前,虽然ClickHouse支持把一些冷数据,或者是部分的数据放到像S3这样的对象存储上面去,但是它的实现比较粗暴。

mysql 加密

mysql> select hex('给我狗子');
+--------------------------+
| hex('给我狗子')          |
+--------------------------+
| E7BB99E68891E78B97E5AD90 |
+--------------------------+
1 row in set (0.00 sec)

mysql> select unhex(hex('给我狗子'));
+----------------------------+
| unhex(hex('给我狗子'))     |
+----------------------------+
| 给我狗子                   |
+----------------------------+
1 row in set (0.00 sec)


mysql> select hex(AES_ENCRYPT('13884331246','abc123')) encrypt_text;
+----------------------------------+
| encrypt_text                     |
+----------------------------------+
| 61F56849292176EAD44B26FCDB52C791 |
+----------------------------------+
1 row in set (0.00 sec)

mysql> select AES_DECRYPT(unhex('7EDEB1877EE7AD6BD30BE668ECF924A4'),'password') plain_text;
+-------------+
| plain_text  |
+-------------+
| 13884331246 |
+-------------+
1 row in set (0.00 sec)

ClickHouse自定义函数实例教程
https://blog.csdn.net/neweastsun/article/details/130235194

ck 随机取 30% 的数据

where rand32()<pow(2,32)*0.3

ClickHouse性能调优之排序和数据类型
https://www.yii666.com/blog/499218.html

  • 通过排序键可以让内存使用大幅减少,尤其是select查询中按排序键排序。
  • 对于已存在的表,排序表达式仅可以使用新增列
  • 正确使用排序键可以提升压缩因子20多倍,重复值相较于随机值更有利于压缩。
  • 在处理大型表并寻找最佳性能查询时,需要仔细选择数据类型。
    • 不要把整形设置为float型
    • 对数值设置合适的精度,精度越低越好
    • 对于文本类型尽可能使用LowCardinality(String) 或FixedString

clickhouse里的数组数据类型与相关使用介绍
https://blog.csdn.net/u010882234/article/details/130464938

从 ClickHouse 到 Apache Doris,腾讯音乐内容库数据平台架构演进实践
https://www.infoq.cn/article/nybtjqs07zcrqqnc0xwt

浅谈ClickHouse聚合和窗口函数
https://blog.csdn.net/weixin_59801183/article/details/134186433

Uber 如何使用MySQL + Redis提供4000 万/秒的读取请求
https://mp.weixin.qq.com/s/cneQcz_uEwChMFuWtoVolw

ClickHouse 到底有多神? - leiysky的回答 - 知乎
https://www.zhihu.com/question/505958148/answer/3341039818

mysql 提高写入性能,写入完毕后要注释掉

skip-log-bin
innodb_doublewrite = 0
innodb_log_buffer_size = 32M

SPL 实践:单节点实现每日百亿时序数据实时写入和秒级统计
https://c.raqsoft.com.cn/article/1705410891469

doris-10亿数据和100万表join高并发测试
https://www.cnblogs.com/lilei2blog/p/15524029.html

How to merge large tables in ClickHouse using join
https://datachild.net/data/clickhouse-join-large-tables-on-column

Optimizing ClickHouse Joins for Performance: A Deep Dive into Nested-Loop and Merge-Scan Joins with Practical Examples
https://chistadata.com/optimizing-clickhouse-joins-for-performance-a-deep-dive-into-nested-loop-and-merge-scan-joins-with-practical-examples/

MergeJoin是一种基于排序的连接算法,它要求参与连接的表在连接字段上进行排序。Merge Join 的原理如下:

  • 对参与连接的表按照连接字段进行排序,确保两个表的连接字段是有序的。
  • 使用两个指针分别指向两个表的第一个记录。
  • 比较两个指针所指向的记录的连接字段的值,如果相等,则将这两条记录合并为一条,并输出。
  • 如果两个指针所指向的记录的连接字段的值不相等,则将连接字段较小的记录的指针向后移动一位,然后继续比较。
  • 重复步骤 3 和步骤 4,直到其中一个表的记录全部被处理完

Merge Join 的优势在于它只需要对参与连接的表进行一次排序,并且可以并行处理多个连接操作,从而提高查询的效率

  • 数据排序 为了使用 Merge Join,参与连接的表必须在连接字段上进行排序。如果表没有按照连接字段排序,可以使用ClickHouse 提供的ORDER BY 语句对表进行排序。
  • 数据类型 Merge Join 要求连接字段的数据类型必须相同,否则无法进行连接。在进行连接操作之前,需要确保连接字段的数据类型一致。
  • 内存限制 Merge Join 使用了一定的内存来存储连接字段的值,如果连接字段的值较大或者连接的表的数据量很大,可能会导致内存不足。在使用 Merge Join 时,需要根据实际情况调整 ClickHouse 的内存配置,确保有足够的内存来执行连接操作。
  • 多表连接 Merge Join 可以连接两个或多个表。当连接多个表时,需要保证每个表的连接字段都进行了排序,并且连接字段的数据类型相同。

原文链接:https://blog.csdn.net/weixin_42754420/article/details/132794340

ClickHouse Joins Under the Hood - Full Sorting Merge Join, Partial Merge Join - MergingSortedTransform
https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3

查看 raid 信息

$ sudo mdadm --detail /dev/md5
/dev/md5:
           Version : 1.2
     Creation Time : Thu Dec 22 23:42:37 2022
        Raid Level : raid10
        Array Size : 7394613248 (6.89 TiB 7.57 TB)
     Used Dev Size : 3697306624 (3.44 TiB 3.79 TB)
      Raid Devices : 4
     Total Devices : 4
       Persistence : Superblock is persistent

Redis数据结构:Stream类型全面解析
https://blog.csdn.net/weixin_45187434/article/details/132593271

group_concat 和 over partition

mysql> select * from a;
+------+-------+
| a_id | a_age |
+------+-------+
|    1 |     2 |
|    2 |     3 |
|    3 |     4 |
+------+-------+
3 rows in set (0.00 sec)

mysql> select * from b;
+------+-------+
| b_id | b_age |
+------+-------+
|    1 |     5 |
|    1 |     6 |
|    3 |     6 |
+------+-------+
3 rows in set (0.00 sec)

mysql> select a_id,a_age,group_concat(b_age,',') from a left join b on a_id = b_id group by a_id,a_age;
+------+-------+-------------------------+
| a_id | a_age | group_concat(b_age,',') |
+------+-------+-------------------------+
|    1 |     2 | 6,,5,                   |
|    2 |     3 | NULL                    |
|    3 |     4 | 6,                      |
+------+-------+-------------------------+
3 rows in set (0.04 sec)

mysql> select b_age,a.*, count(*) over(partition by b_age) match_count,row_number() over(partition by b_age) match_number from b left join a on b_id = a_id;
+-------+------+-------+-------------+--------------+
| b_age | a_id | a_age | match_count | match_number |
+-------+------+-------+-------------+--------------+
|     5 |    1 |     2 |           1 |            1 |
|     6 |    1 |     2 |           2 |            1 |
|     6 |    3 |     4 |           2 |            2 |
+-------+------+-------+-------------+--------------+
3 rows in set (0.00 sec)

Appending to a File from Multiple Processes
https://nullprogram.com/blog/2016/08/03/

MONGODB 内存使用分析与判断内存是否缺少
https://cloud.tencent.com/developer/article/2047328

ilickhouse has everything to be one of the most used databases in the future. But today it is not yet possible to be used, only for data already processed and only use simple select and simple queries.

It really is an incredibly fast database, but it lacks features much used in other banks, such as subselect. With subselect we can use almost everything without relying on its own functions (UDF). Without both functions its use is complicated.

I will try to work Clickhouse together as MonetDB and post here if the result was good.

csv文件中每隔 100 行取一行,保留第一行的 headers

awk '(NR%100==0 || NR==1){print $0}' result.csv

How to Do IP Address Geolocation Lookups on Linux
https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/

sudo apt-get install geoip-bin
geoiplookup 8.8.4.4
https://dev.maxmind.com/geoip/geolite2-free-geolocation-data
sudo apt install mmdb-bin

企业运维实践-Nginx使用geoip2模块并利用MaxMind的GeoIP2数据库实现处理不同国家或城市的访问最佳实践指南
https://www.zhihu.com/tardis/bd/art/547045377

JAVASCRIPT & CSS WORLD MAP
https://www.cssscript.com/tag/world-map/

https://www.cssscript.com/interactive-vector-map/

只需提供一个视频 主题 或 关键词 ,就可以全自动生成视频文案、视频素材、视频字幕、视频背景音乐,然后合成一个高清的短视频
https://github.com/harry0703/MoneyPrinterTurbo

nginx-geoip2

nginx 集成 IP 地理位置

$ nginx -v
nginx version: nginx/1.24.0
$ cd ~/download/
$ wget http://nginx.org/download/nginx-1.24.0.tar.gz
$ tar xf nginx-1.24.0.tar.gz
$ wget -c https://github.com/leev/ngx_http_geoip2_module/archive/refs/tags/3.4.tar.gz -O ngx_http_geoip2_module-3.4.tar.gz
$ tar xf ngx_http_geoip2_module-3.4.tar.gz
$ cd nginx-1.24.0/
$ which nginx
/usr/sbin/nginx
$ nginx -V
nginx version: nginx/1.24.0
built by gcc 9.3.0 (Ubuntu 9.3.0-10ubuntu2)
built with OpenSSL 1.1.1f  31 Mar 2020
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.24.0/debian/debuild-base/nginx-1.24.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
$ ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.24.0/debian/debuild-base/nginx-1.24.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --add-dynamic-module=../ngx_http_geoip2_module-3.4
$ ls objs/*.so
objs/ngx_http_geoip2_module.so  objs/ngx_stream_geoip2_module.so
$ sudo cp -a objs/*.so /etc/nginx/modules
$ ls /etc/nginx/modules
ngx_http_geoip2_module.so  ngx_http_js_module-debug.so  ngx_http_js_module.so  ngx_stream_geoip2_module.so  ngx_stream_js_module-debug.so  ngx_stream_js_module.so
$ sudo nginx -s stop
$ sudo cp -a objs/nginx /usr/sbin/nginx
$ sudo nginx
$ sudo vi /etc/nginx/nginx.conf

    load_module modules/ngx_http_geoip2_module.so;
    http {
        log_format  main  '$remote_addr $geoip2_data_country_code [$time_local] $request_time $request '
            '$status $host $http_accept_encoding $body_bytes_sent "$http_referer" '
            '"$http_user_agent" "$http_x_forwarded_for" ';

        geoip2 /usr/local/GeoIP2/GeoLite2-City.mmdb {
            $geoip2_data_country_name country names en;
            $geoip2_data_country_code default=CN source=$remote_addr country iso_code;
        }

        map $geoip2_data_country_code $lang_ch {
            CN yes;
            TW yes;
            HK yes;
            MO yes;
            default no;
        }

        access_log  /var/log/nginx/access.log main;

        server {
            location /geotest {
                default_type text/html;
                if ($lang_ch = no) {
                    return 403 "Access denied!IP [ $remote_addr ] $geoip2_data_country_code";
                }
                return 200 "Welcome to you! IP [ $remote_addr ] $geoip2_data_country_code";
            }
        }
    }

$ tail -f /var/log/nginx/access.log

202401

How to install and use ZSTD compression tool on Linux
https://linuxconfig.org/how-to-install-and-use-zstd-compression-tool-on-linux

zstd example1.txt
zstd -d example1.txt.zst
tar --zstd -cf example.tar.zst example/

mysql: slow import
https://dba.stackexchange.com/questions/271097/mysql-slow-import

SET GLOBAL innodb_flush_log_at_trx_commit = 2;

[mysqld]
skip-log-bin
innodb_doublewrite = 0
innodb_log_buffer_size = 32M

SHOW VARIABLES LIKE 'log_bin';

InnoDB关键特性之double write
https://www.cnblogs.com/wangqianqiannb/p/9754450.html

关于IO的最小单位:

  • 数据库 IO 的最小单位是 16K(MySQL默认,oracle是8K)

  • 文件系统 IO 的最小单位是 4K(也有 1K 的)

  • 磁盘 IO 的最小单位是 512B

    show variables like ‘%double%’;
    show global status like ‘%dblwr%’;

python 数据类型 复数
https://zhuanlan.zhihu.com/p/617689935?utm_id=0

  • 在电路分析中,复数可以用来表示电路中的电压、电流等物理量,例如电压可以表示为实部加上虚部的复数,而阻抗可以表示为复数形式的电阻和电抗。
  • 在信号处理中,复数可以用来表示信号的幅度和相位,例如正弦信号可以表示为实部为幅度,虚部为相位的复数形式。
  • 在图像处理中,复数可以用来表示图像的频域信息,例如图像可以通过傅里叶变换转换为频域信息,而频域信息可以表示为实部和虚部的复数形式。
  • 除此之外,复数还可以用于解决一些数学问题,例如求解方程、计算积分等。

从 CoT 到 Agent,最全综述来了!上交出品
https://baijiahao.baidu.com/s?id=1783669439007774940&wfr=spider&for=pc

tmate 的意思是 teammates,它是 tmux 的一个分支,并且使用相同的配置信息(例如快捷键配置,配色方案等)。它是一个终端多路复用器,同时具有即时分享终端的能力。它允许在单个屏幕中创建并操控多个终端,同时这些终端还能与其他同事分享。

你可以分离会话,让作业在后台运行,然后在想要查看状态时重新连接会话。tmate 提供了一个即时配对的方案,让你可以与一个或多个队友共享一个终端。
https://www.linuxprobe.com/quickly-share-tmate.html

  • 运行 tmate 时,会通过 libssh 在后台创建一个连接到 tmate.io (由 tmate 开发者维护的后台服务器)的 ssh 连接。
    tmate.io 服务器的 ssh 密钥通过 DH 交换进行校验。
  • 客户端通过本地 ssh 密钥进行认证。
  • 连接创建后,本地 tmux 服务器会生成一个 150 位(不可猜测的随机字符)会话令牌。
  • 队友能通过用户提供的 SSH 会话 ID 连接到 tmate.io

How to close terminal without killing running processes on Linux
https://tecadmin.net/close-terminal-without-killing-running-processes-on-linux/

CTRL + Z 
bg
disown -h %1

jobs -l
sudo tail -f /proc/609120/fd/1

eBPF 实践教程:使用 uprobe 捕获多种库的 SSL/TLS 明文数据
https://eunomia.dev/zh/tutorials/30-sslsniff/

查看进程重定向
https://unix.stackexchange.com/questions/15693/see-the-stdout-redirect-of-a-running-process

$ cat test.sh
while true;do date;sleep 1;done
$ bash test.sh >> test.log
^Z
[1]+  Stopped                 bash test.sh >> test.log
$ bg
[1]+ bash test.sh >> test.log &
$ jobs -l
[1]+ 2168892 Running                 bash test.sh >> test.log &
[02:01:07 ubuntu@scripts-server ~/haohu]$ disown -h %1
$ readlink -f /proc/2168892/fd/1
test.log
$ lsof test.log
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
bash    2168892 ubuntu    1w   REG  259,1     7250 768788 test.log

终端迁移

$ ps -ef | grep test.sh
ubuntu   2185765 2185718  0 02:35 pts/16   00:00:00 bash test.sh
$ screen -S test
$ sudo reptry -t 2185718
  • 分享一个实用的小工具 https://github.com/nelhage/reptyr Reparent a running program to a new terminal。

  • 比如你在远程终端下运行一个需要执行很久的脚本,没有在 screen 或 tmux 下,也没有用nohup 执行,一旦终端关掉,所有子进程就会自动被关闭,脚本还要重新运行。

  • 以前需要 ctrl+z, bg, disown 一梭子,虽然能保住进程不挂掉,但 stdout 和 stderr 都无法查看了,除非之前做了重定向可以用readlink -f /proc/$pid/fd/1 继续查看脚本输出。

  • 现在这个小工具可以直接把当前终端会话连带子进程一锅端迁移到另一个screen会话里,输入输出都会自动迁移。

Redis module功能介绍
https://blog.51cto.com/u_15127532/2659222

  • 布隆过滤器 RedisBloom
    • 当尝试通过网络或磁盘搜索查询时,可以先查询BloomFilter,它肯定地告诉我们要查找的元素是否可能存在(然后可以继续进行查找)还是不存在(此时可以放弃查询直接回复不存在,节省查询资源)。
    • 布隆过滤器在网页去重,数据查询和广告投放中经常被使用;新业务上线前,增加布隆过滤器也是一个很有效解决缓存击穿的有效手段。
    • 实际上是一个很长的二进制向量和一系列随机映射函数,可以用于检索一个元素是否在一个集合中。它的优点是空间效率和查询时间都比一般的算法要好的多,但是有一定的误识别率且无法删除元素。
    • 只要有一次哈希计算的结果对应为 0,则该元素一定不存在;反之则可能存在。
  • 布谷鸟过滤器 CuckooFilter
    • 布谷鸟过滤器在做防缓存击穿时具有很好的表现,与布隆过滤器不同的是,它可以删除元素
  • 支持json的模块 Redisjson
    • 它允许从 Redis 存储、更新和获取 JSON 值。
    • redisjson 可以通过在 redis 服务器本地直接操作部分数据
  • 咆哮位图 Redis-roaring
    • 咆哮位图(RoaringBitmap)将整个大位图进行了分块,如果整个块都是零,那么这整个块就不用存了。
    • 但是如果位图中的元素比较少且分散,每个块里面都有 1,只存储所有位 1 的块内偏移量(整数),这就是单个块位图的稀疏存储形式 —— 存储偏移量整数列表。
  • 可用于检索的模块 RediSearch
    • 它使用户能够以极快的方式对其 Redis 数据集执行复杂的搜索查询,例如精确的词组匹配和文本查询的数字过滤,
    • 还有使用 Reids 自带的 GEO 命令进行地理过滤
  • 支持机器学习的redis RedisML/RedisAI
  • 支持事物处理的模块 RedisGears

物联网边缘计算中的全能数据库RedisEdge:实时数据、时间序列、AI、消息流、MapReduce
https://zhuanlan.zhihu.com/p/81505287

在物联网边缘计算的复杂环境中,应用程序不可避免地需要多个数据模型:

  • 内存数据库存储采集的实时设备数据。
  • 现场会断网,所以需要把待发送到云端的数据存储到时间序列数据库中。同时边缘侧需要对历史数据进行聚合分析,例如计算温度一段时间内平均值。
  • 现场采集的数据需要转发给一个或多个消费者进行处理。
  • 边缘侧需要人工智能学习能力,来支持视频流分析,图像识别,故障诊断等低延迟响应业务。
  • 边缘侧进行类似 MapReduce 的计算。
  • 运行占用空间小,以能在性能受限的边缘计算计算节点上运行。

RedisEdge将开源版本Redis(带有Redis Streams的5.0版本)与RedisAI和RedisTimeSeries、RedisGears这三个模块一起打包,就可以提供边缘计算所需的数据模型了:

  • Redis 5.0版本,内置的Set、List、Hash等数据结构可用作实时内存数据库,用来存储边缘网关采集到的设备实时数据。
  • Redis 5.0版本的Redis Streams数据结构,可用做消息中间件,把采集到的设备实时数据转发给其他边缘计算软件组件。
  • RedisTimeSeries是Redis的一个模块,可用作时间序列数据库,在边缘计算网关断网的情况下,能够离线保存需要上传到云端的设备历史数据。同时也有历史数据降采样、压缩、聚合的功能。
  • RedisGears也是Redis的一个模块,类似MapReduce的分布式动态执行框架,可以用来在分布式的边缘计算节点或者雾计算节点上运行Serverless无服务程序代码。
  • RedisAI也是Redis的一个模块,用于执行深度学习模型,在边缘侧调用PyTorch、Tensorflow和ONNXRuntime等深度学习工具。

一个方案是用开源多模型数据库Postgresql + 扩展插件(连接第三方数据库postgres-fdw + PG时间序列数据库扩展timescale + REST接口暴露PostgREST + 实时流分析pipelinedb) + PL/Python函数或SPI接口。

eBPF 实践教程:使用 uprobe 捕获多种库的 SSL/TLS 明文数据
https://eunomia.dev/zh/tutorials/30-sslsniff/

wget 使用代理
https://zhuanlan.zhihu.com/p/528378176

wget -e use_proxy=yes -e https_proxy=127.0.0.1:8080 https://aka.pw/bpf-ecli -O ecli && chmod +x ./ecli

nettrace - 网络诊断工具
https://github.com/OpenCloudOS/nettrace

  • 在一些场景下(特别是云原生场景),Linux系统中的网络部署变得越来越复杂。
  • 一个TCP连接,从客户端到服务端,中间可能要经过复杂的NAT、GRE、IPVS等过程,网络报文在节点(主机)上的处理路径也变得越来越长。
  • 在发生网络故障(比如网络丢包)时,如何快速、有效地定位出网络问题成为了一个难题。
  • 目前常规的网络故障定位手段,如tcpdump、dropwatch、ftrace、kprobe等存在一定的短板:
  • tcpdump:只能在链路层抓包,无法定位内核协议栈中的问题,比如常规的内核丢包问题
  • ftrace:只能跟踪内核函数,无法进行报文过滤,且入手较难,需要对内核协议栈有一定了解
  • kprobe:临时编写内核模块,效率和安全性低
  • BCC:功能单一,临时编写BCC程序跟踪效率低,需要对内核有一定了解,入手难
  • dropwatch:功能单一,只能查看网络丢包问题,且无法得到丢包原因和解决方案

BTF
# grep BTF /boot/config-$(uname -r)
CONFIG_VIDEO_SONY_BTF_MPX=m
# CONFIG_DEBUG_INFO_BTF is not set

eBPF Hello, World!
https://bowers.github.io/eBPF-Hello-World/

How To Add eBPF Observability To Your Product
https://www.brendangregg.com/blog/2021-07-03/how-to-add-bpf-observability.html

Meet Gain— the New Fastest Go TCP Framework
https://betterprogramming.pub/gain-the-new-fastest-go-tcp-framework-40ec111d40e6

Extreme HTTP Performance Tuning: 1.2M API req/s on a 4 vCPU EC2 Instance
https://talawah.io/blog/extreme-http-performance-tuning-one-point-two-million/

周刊(第9期):Mozilla rr使用简介
https://www.codedump.info/post/20220313-weekly-9/

rr是由Mozilla出品的一款调试工具,用官网的话来说:

  • rr这个名字里的两个r,意指record and replay,即“记录及回放”,它的使用也很简单,就是这两步:
  • record:rr record /your/application --args 记录下来程序的执行环境。
  • replay:rr replay,默认将使用最近保存的记录文件进行回放,回放时可以进入类似gdb那样的调试环境。

Awk CSV parser
https://github.com/geoffroy-aubry/awk-csv-parser

csv 导入 mysql

假如 csv 有 a,b,c 三列,我们只需要 a,c 列,并且要加入 id 自增列

# 重命名 csv 文件
mv data.csv origin_data.csv
# 创建管道队列文件,文件名要和后面在 db 里创建的表名严格一致
mkfifo data.csv

# 在 db 里建表,用压缩格式以节省空间,增加自增列方便后续按范围分块并发处理
CREATE TABLE `data` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `a` varchar(128),
  `c` varchar(128),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;

# 开一个 screen 准备用 mysqlimport 导入,分隔符用 |,用 --columns 指定列
mysqlimport --fields-terminated-by='|' --fields-optionally-enclosed-by='"' --local \
    --columns='a,c' -uuser -p mydb data.csv

# 再开一个 screen 往队列文件中动态输入只包含 a,c 列的数据
# awk-csv-parser 是基于 awk 的 csv 解析器,性能非常高,默认输出字段以 | 分割
# pv 是一个处理大文件的进度查看器,tail -n+2 用来跳过首行
# cut 命令用来只输出 1,3 列,就是 a,c 列
pv origin_data.csv | awk-csv-parser|tail -n+2 | cut -d'|' -f1,3 > data.csv

# 查看 io
sudo iotop -oPa 
  Total DISK READ:   38.13 M   ⣿⣿⣷⣶⣶⣶⣦⣤⣤⣄⣀⣀⣀⣀⠀⠀⠀⠀⠀ |   Total DISK WRITE:  361.06 M   ⣿⣿⣿⣿⣶⣶⣶⣤⣤⣤⣄⣀⣀⣀⠀⠀⠀⠀⠀
Current DISK READ: 2201.20 K/s ⣿⣇⣧⣼⣀⣰⣶⣆⣴⣦⡀⣦⣠⣤⠀⠀⠀⠀⠀ | Current DISK WRITE:   13.30 M/s ⣿⣀⣄⣤⣤⣼⣧⣶⣾⣄⣸⣿⣄⣰⠀⠀⠀⠀⠀
TID      PRIO USER      DISK READ   DISK WRITE  GRAPH[R+W]▽         COMMAND
373072   be/4 mysql     1044.48 K    180.39 M   ⣿⠀⣤⣰⣰⣸⣷⣆⣿⣀⣼⣶⣀⣰⠀⠀⠀⠀⠀ ►mysqld
601812   be/4 ubuntu      35.52 M      0.00 B   ⣀⣀⣀⣀⡀⣀⣀⣀⣀⣀⠀⣀⣀⣀⠀⠀⠀⠀⠀  pv

iostat -m -x 1 sda
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          11.56    0.00    0.38   26.13    0.00   61.93

Device            r/s     rMB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wMB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dMB/s   drqm/s  %drqm d_await dareq-sz     f/s f_await  aqu-sz  %util
sda             12.00      1.16     2.00  14.29  108.25    98.67  126.00      2.38    20.00  13.70  132.95    19.37    0.00      0.00     0.00   0.00    0.00     0.00    7.00  111.71   18.83  80.80

优点

  • 不需要真正在磁盘上生成原始 csv 的副本,节省磁盘空间,降低 io
  • 解析转换 csv 和导入数据可以同时进行,降低数据处理时间
  • 最终只导入需要的列,不需要导入后再删除列,使用 ROW_FORMAT=COMPRESSED 后改表会非常慢

Using AWK with CSV Files
https://earthly.dev/blog/awk-csv/

echo one,two,three | awk -F "," '{ print $2}'
echo one,\"two\",three | awk -F "," '{ print $2}'
echo 1,\"2a,2b\", 3 | awk -F "," '{ print $3}'

> git clone https://github.com/adamgordonbell/csvquote
> cd csvquote
> go build -o csvquote cmd/cvsquote/main.go
> cp ./csvquote /usr/local/bin

echo 1,\"2a,\"\"2b\", 3 | csvquote
echo 1,\"2a,\"\"2b\", 3 | csvquote | csvquote -u
echo 1,\"2a,2b\", 3 | csvquote | awk -F "," '{ print $2 }' | csvquote -u
  • The gawk version 4 manual says to use FPAT = “([^,]*)|(”[^“]+”)"
  • When FPAT is defined, it disables FS and specifies fields by content instead of by separator.
  • The short answer is “I wouldn’t use gawk to parse CSV if the CSV contains awkward data”, where ‘awkward’ means things like commas in the CSV field data.
  • I’d probably use Perl and the Text::CSV or Text::CSV_XS modules to read and process the data.
  • Remember, Perl was originally written in part as an awk and sed killer - hence the a2p and s2p programs still distributed with Perl which convert awk and sed scripts (respectively) into Perl.

jsonl 处理
https://github.com/jqlang/jq
jq is a lightweight and flexible command-line JSON processor akin to sed,awk,grep, and friends for JSON data. It’s written in portable C and has zero runtime dependencies, allowing you to easily slice, filter, map, and transform structured data.

https://www.baeldung.com/linux/jq-command-json

Capturing the Network Traffic of a Process
https://www.baeldung.com/linux/capture-process-network-traffic

Capturing the network traffic of a process is an important task for system administrators and developers who need to monitor and analyze the information to identify security vulnerabilities or diagnose performance issues.

Airflow概览
https://zhuanlan.zhihu.com/p/352989254

irflow是将多个任务按照其依赖关系组织起来进行管理调度的工具。Airflow基于python编写,通过python脚本可以配置和使用其作为data pipeline。除了命令行之外,Airflow提供了web可视化界面,用来管理和监控任务的执行,并且可以查看任务依赖关系图。Airflow可以方便同Hive、Presto、MySQL、HDFS、Postgres 等数据库交互,另外,提供了hook便于扩展。

DAG(有向无环图)是Airflow工作流的基本概念。DAG的每个节点表示一个任务,有向边是任务之间的依赖。每个任务具有原子性,保证在任务失败的时候可以自动或手动重试该任务,而不必重启整个DAG。这些任务和依赖构成的DAG就是一个工作流。

仿百度网盘的一款轻量级微服务架构网盘系统,云盘系统,文件管理系统
https://gitee.com/college996/zwz-netdisk/tree/master

How do I find out which process is eating up my bandwidth?
https://askubuntu.com/questions/2411/how-do-i-find-out-which-process-is-eating-up-my-bandwidth

  • Use iftop to locate the TCP port on your machine that is receiving the most traffic. Then use sudo netstat -tup to locate the process “owning” that port.
  • sudo apt-get install nethogs
    • sudo nethogs -v 3
  • dstat --net --top-io-adv

Practical Linux tracing ( Part 1/5) : symbols, debug symbols and stack unwinding
https://tungdam.medium.com/things-you-should-know-to-begin-playing-with-linux-tracing-tools-part-i-x-225aae1aaf13

使用strip, eu-strip, objcopy等剥离与导回符号表及调试信息
https://blog.csdn.net/nirendao/article/details/104107608

gcc -g -o test test.c

# test.debug 将包含调试信息和符号表; 而test将只包含调试信息
objcopy --only-keep-debug test test.debug

# 从test文件里剥离debug段
objcopy --strip-debug test

# 更彻底地,上面这句可以换成下面这句以移除所有的debug信息和符号表
strip -s test

# 在二进制文件 test 中添加 .gnu_debuglink 段以指向符号表和调试信息文件
objcopy --add-gnu-debuglink=test.debug test

# objdump 命令可以查看指定的section
objdump -s -j .gnu_debuglink test

https://openanolis.cn/sig/ebpfresearch/doc/633529753894377555

BPF是一个新的动态跟踪技术,目前这项技术正在深刻的影响着我们的生产和生活。

BPF在四大应用场景发挥着巨大作用:系统故障诊断,它可以动态插桩透视内核;网络性能优化,它可以对接收和发送的网络包做修改和转发;系统安全,它可以监控文件打开和关闭从而做出安全决策等;性能监控,它可以查看函数耗费时间从而知道性能瓶颈点。

BPF技术也是随着Linux内核的发展而发展的,Linux内核版本经历了3.x向4.x到5.x演进,eBPF技术的支持也是从4.x开始更加完善起来,特别是5.x内核也增加了非常多的高级特性。但是云上服务器有大量的3.10内核版本是不支持eBPF的,为了让我们现有的eBPF工具在这些存量机器得以运行,我们移植了BPF到低版本内核,同时基于libbpf的CO-RE能力,保证一个工具可运行在3.x/4.x/5.x的低、中、高内核版本。

另外,当前比较热门的BPF开发方式有:

1)纯libbpf应用开发:借助libbpf库加载BPF程序到内核的方式:这种开发方式不仅效率低,没有基础库封装,所有必备步骤和基础函数都需要自己摸索;
2)借助BCC:开发效率高、可移植性好,并且支持动态修改内核部分代码,非常灵活。但存在部署依赖Clang/LLVM等库;每次运行都要执行Clang/LLVM编译,严重消耗CPU、内存等资源,容易与其它服务争抢。

学会Pointer指针事件 ,一套拖拽事件两端(PC端、移动端)跑
https://segmentfault.com/a/1190000043955743

C语言深度理解结构体(内存对齐、位段、偏移量、柔性数组)
https://blog.csdn.net/SPMAX/article/details/122774979

escapture
抓包
./ecapture tls -m pcap -i eth0 --pcapfile=ecapture.pcapng --port=443
sudo ./ecapture mysqld -m /usr/sbin/mysqld

浏览器指纹检测

DWARF
https://www.wenmi.com/article/px5ev6038m8o.html

OhMyZsh,简直是我用来伪装资深程序员的神器!
https://zhuanlan.zhihu.com/p/505591537

brew install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 查看当前在使用的shell
echo $SHELL
# 也可以使用下面命令自行修改默认shell
chsh -s $(which zsh)

macos 安装 Docker

brew install docker docker-compose colima

Docker部署clickhouse(超详细图文教程)
https://blog.csdn.net/fy512/article/details/123482700

docker pull yandex/clickhouse-server
docker pull yandex/clickhouse-client

docker run -d -p 8123:8123 -p 9000:9000 --name clickhouse yandex/clickhouse-server
docker run -it --rm --link clickhouse:clickhouse-server yandex/clickhouse-client --host clickhouse

# 如果想指定目录启动,这里以clickhouse-test-server命令为例,可以随意写
mkdir /work/clickhouse/clickhouse-test-db       ## 创建数据文件目录
# 使用以下路径启动,在外只能访问clickhouse提供的默认9000端口,只能通过clickhouse-client连接server
docker run -d --name clickhouse-test-server --ulimit nofile=262144:262144 --volume=/work/clickhouse/clickhouse_test_db:/var/lib/clickhouse yandex/clickhouse-server


CREATE TABLE t_stock
(
    `id` UInt32,
    `sku_id` String,
    `total_amount` Decimal(16, 2),
    `create_time` Datetime
)
ENGINE = MergeTree()
PARTITION BY toYYYYMMDD(create_time)
PRIMARY KEY id
ORDER BY (id, sku_id)

insert into t_stock values
(101,'sku_002',2000.00,'2020-06-01 11:00:00'),
(102,'sku_004',2500.00,'2020-06-01 11:00:00'),
(103,'sku_002',2000.00,'2020-06-02 11:00:00'),
(104,'sku_002',12000.00,'2020-06-03 11:00:00'),
(105,'sku_002',600.00,'2020-06-04 11:00:00');
select * from t_stock;

docker exec -it clickhouse bash
cd /var/lib/clickhouse/data/

insert into t_stock values
(101,'sku_002',2000.00,'2020-06-01 14:00:00'),
(102,'sku_004',2500.00,'2020-06-01 15:00:00'),
(103,'sku_002',2000.00,'2020-06-01 16:00:00'),
(104,'sku_002',12000.00,'2020-06-01 17:00:00');

OPTIMIZE TABLE t_stock FINAL;

CREATE TABLE t_stock_2
(
    `id` UInt32,
    `sku_id` String,
    `total_amount` Decimal(16, 2),
    `create_time` Datetime,
    INDEX secondIndex total_amount TYPE minmax GRANULARITY 5
)
ENGINE = MergeTree
PARTITION BY toYYYYMMDD(create_time)
PRIMARY KEY id
ORDER BY (id, sku_id)

深入浅出 ClickHouse 物化视图
https://mp.weixin.qq.com/s/7RxBg1mxdpffcpWp02TJ7w

clickHouse-MergeTree家族引擎
https://blog.csdn.net/bwf317/article/details/110785858

  • AggregatingMergeTree 也是预先聚合引擎的一种,用于提升聚合计算的性能
  • 与 SummingMergeTree 的区别在于:
    • SummingMergeTree 对非主键列进行 sum 聚合
    • 而 AggregatingMergeTree 则可以指定各种聚合函数。
  • AggregatingMergeTree 的语法比较复杂,需要结合物化视图或 ClickHouse 的特殊数据类型 AggregateFunction 一起使用
    • AggregateFunction(arg1 , arg2) ;参数一 聚合函数 参数二 数据类型
  • 在 insert 和 select 时,也有独特的写法和要求:写入时需要使用 -State 语法,查询时使用 -Merge 语法。

Working with CSV and TSV data in ClickHouse
https://clickhouse.com/docs/en/integrations/data-formats/csv-tsv

mysql 锁

show status like 'table%';
show status like 'InnoDB_row_lock%';
show engine innodb status\G
show OPEN TABLES where In_use > 0;
select * from performance_schema.data_locks\G
select * from performance_schema.data_lock_waits\G

随着数字技术的发展,数据呈爆炸式增长,数据类型越来越丰富,对数据价值挖掘的实时性要求不断提升,业务场景也越来越复杂度。在过去几年里,数据分析的需求通常采用多套系统组合的方式来完成,比如采用 Kylin 在支持 BI 报表场景,采用 Trino、Impala 支撑交互式分析场景,采用 ClickHouse、Druid 来支撑实时分析场景,StarRocks 希望通过技术创新简化数据技术栈,用户可以借助 StarRocks 一个引擎实现全场景的数据分析。

链接:https://www.zhihu.com/question/415561162/answer/3364773974

当前业界构建数据分析的技术栈,有两条典型的路线,一个是数仓路线,一个是数据湖的路线。数据仓库的路线,数据先通过 ETL 统一写入到数仓进行管理,然后构建数据集市来满足 BI 分析的各种需求,优势是数据质量高、查询性能高、具备实时分析的能力、数据治理功能完善等;而数据湖的路线,通常是未经加工的数据先统一存储在数据湖,作为企业数据的 Single source of truth,然后按需的使用数据,构建数据应用,优势是通开放生态、扩展性强,性价比高。

现在什么数据库或大数据技术比较适合做数据仓库? - StarRocks的回答 - 知乎
https://www.zhihu.com/question/415561162/answer/3364773974

202312

在visudo时更改默认编辑器
https://blog.csdn.net/ethnicitybeta/article/details/122554415

export VISUAL=vim
sudo -E visudo

VISUAL="vim" ; export VISUAL
EDITOR="$VISUAL" ; export EDITOR

sudo usermod -aG root ubuntu
%root   ALL=(ALL:ALL) NOPASSWD:ALL

P就是能在多项式时间内解决的问题,NP就是能在多项式时间验证答案正确与否的问题。用大白话讲大概就是这样。所以P是否等于NP实质上就是在问,如果对于一个问题我能在多项式时间内验证其答案的正确性,那么我是否能在多项式时间内解决它?

SET time_zone = ‘UTC’;
ERROR 1298 (HY000): Unknown or incorrect time zone: ‘UTC’

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p -Dmysql

hysteria2
https://v2.hysteria.network/zh/docs/getting-started/Client/

Retrieve response headers from PHP cURL
https://blog.cpming.top/p/get-response-header-from-php-curl

$headers = [];
$url = "https://www.google.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADERFUNCTION,
    function ($curl, $header) use (&$headers) {
        $len = strlen($header);
        $header = explode(':', $header, 2);
        if (count($header) < 2) // ignore invalid headers
            return $len;

        $headers[strtolower(trim($header[0]))][] = trim($header[1]);

        return $len;
    }
);
$response = curl_exec($ch);
print_r($headers);

https://aws.amazon.com/codewhisperer/

speex是近年来开发出的一套功能强大的语音引擎,能够实现高质量和低比特率的编码。它不仅提供了基于码激励线性预测(CELP)算法的编/解码模块,而且在其最新发布的版本中还提供了声音预处理和声学回声消除模块,为保障IP网络中的语音通信质量提供了技术手段。此外,Speex还具有压缩后的比特率低(2.15~44.2kbps)的特点,并支持多种比特率。这些特点使得Speex特别适合VoIP, 音视频系统
https://blog.csdn.net/liuxunfei15/article/details/120353056

如何使用 Server-Sent Events 和 Flask 构建实时 Web 应用程序
http://www.javascriptcn.com/post/651ccd0795b1f8cacd44d0c6

Split Python Flask app into multiple files in File-Organization
https://pyquestions.com/split-python-flask-app-into-multiple-files

Python 解方程的三种方法
https://zhuanlan.zhihu.com/p/24893371

x + 2y = 3
4x + 5y = 6

In [1]: import numpy as np
   ...: A = np.mat('1,2; 4,5')    # 构造系数矩阵 A
   ...: b = np.mat('3,6').T       # 构造转置矩阵 b (这里必须为列向量)
   ...: r = np.linalg.solve(A,b)  # 调用 solve 函数求解
   ...: print r
   ...:
Out[1]: [[-1.]
         [ 2.]]