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.]]

202311

整会promise这8个高级用法
https://blog.51cto.com/u_14627797/6989643

promise数组串行执行

const requestAry = [() => api.request1(), () => api.request2(), () => api.request3()];
for (const requestItem of requestAry) {
  await promiseItem();
}

const requestAry = [() => api.request1(), () => api.request2(), () => api.request3()];
const finallyPromise = requestAry.reduce(
    (currentPromise, nextRequest) => currentPromise.then(() => nextRequest()),
    Promise.resolve(); // 创建一个初始promise,用于链接数组内的promise
);

sleep

function sleep(time) {
    return new Promise((resolve) => setTimeout(resolve, time));
}

await sleep(100) // 防止请求发送太快

https://blog.csdn.net/qq_57057576/article/details/125856993

  • 微信小程序中,图片的完全居中显示,line-height并不能发挥效果, line-height可以时内部文字垂直居中显示,但是对于图片并未发挥效果

  • 水平居中显示,可以使用 text-align:center

  • 解决方法:使用flew布局

    display: flex;
    align-items: center;
    justify-content: center;

微信小程序高度height设置百分比无效,只需一步搞定

page{height:100%}

使用 Certbot 为 Nginx 自动配置 SSL 证书
https://blog.csdn.net/qq_34010538/article/details/133825978

sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx

sudo certbot --nginx -d your_domain
sudo certbot renew --dry-run

清理临时文件
https://askubuntu.com/questions/380238/how-to-clean-tmp

sudo find /tmp -type f -atime +10 -delete

https://platform.openai.com/docs/assistants/overview

期货交易生涯中,您遇到哪些契机让你的交易水平发生质的蜕变? - 藏巧守拙的回答 - 知乎
https://www.zhihu.com/question/445059936/answer/2661994653

https://github.com/microsoft/inshellisense
inshellisense provides IDE style autocomplete for shells. It’s a terminal native runtime for autocomplete which has support for 600+ command line tools. inshellisense supports Windows, Linux, & MacOS.

EventSource / Server-Sent Events through Nginx
https://stackoverflow.com/questions/13672743/eventsource-server-sent-events-through-nginx

proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;

How to handle streaming in OpenAI GPT chat completions
https://blog.georgeck.me/how-to-handle-streaming-in-openai-gpt-chat-completions

Here are the main differences:

  • Standard SSE expects GET resources. As you can see, OpenAI expects POST with custom payload.
  • The same API endpoint will respond with content-type: application/json if there are any errors in the API request itself. So, the client will have to handle both types of responses.

english

  • Not only can you make your own GPT for fun or productivity, but you’ll soon be able to publish it on a marketplace they call the GPT Store — and maybe even make a little cash in the process.
  • The new features, announced with many others today at OpenAI’s first developer day in San Francisco, indicate a more hands-off approach to the AI marketplace, which has hitherto been defined by a handful of dedicated general-purpose systems.
  • Indeed, said systems are becoming even more general-purpose with new capabilities, but the AI giant has clearly taken a page from Apple’s book in seeing that being the go-to platform for the ingenuity of others is at least as valuable as having ingenuity oneself.
  • Use Assistant API once it’s released for automatic context retrieval. The Assistant API will create a thread that we can add messages too, to keep the history of actions, but it doesn’t support the Vision API yet.

curl请求IPv6服务(地址)
https://blog.csdn.net/a145127/article/details/127408971

-6 表示使用IPv6的地址
-g 或 --globoff 表示url中允许使用[]
 
curl -6 -g "http://[726c:4666:637f:f130:c92f:5330:6b10:7165]:8080"    

MySQL REGEXP word boundaries [[:<:]] [[:>:]] and double quotes
https://stackoverflow.com/questions/18901704/mysql-regexp-word-boundaries-and-double-quotes

In MySQL up from 8.0.4 use: \\bword\\b

How to declare a variable in MySQL?
https://stackoverflow.com/questions/11754781/how-to-declare-a-variable-in-mysql

MySQL: Selecting multiple fields into multiple variables in a stored procedure
https://stackoverflow.com/questions/2450529/mysql-selecting-multiple-fields-into-multiple-variables-in-a-stored-procedure

SELECT Id, dateCreated
INTO iId, dCreate
FROM products
WHERE pName = iName

Flink的DAG可视化开发实践
链接:https://www.jianshu.com/p/9662f6a65cd8

离线分析之所以适合用DAG进行开发,是因为它的主要逻辑表达语言工具是SQL,再辅以循环、分支、归并等结构,更复杂的情况可以用MR和Python节点解决,这样几乎能完全适应所有离线分析的场景。而Flink虽然支持FlinkQL,但是它在实际工作场景下的适用性太弱了,关键的原因就在于离线分析是属于统计,而流式计算式是计算。SQL擅长统计,但并不适合计算(离线分析中复杂点的计算也基本用UDF来做)。

Flink之所以难以用DAG可视化开发,关键的问题就是它的算子只定义了基本特性,内部的逻辑完全自由。这种自由定义,对纯代码开发来说是可以的且强大的,但却对可视化开发不友好。如果可视化仅仅是拖出一个节点来,然后在里面用Java/Scala实现特定的方法,那这就不是可视化开发了,而是另一种Flink专用IDE了。

https://www.yuque.com/boyan-avfmj/aviatorscript/guhmrc
Aviator 起源于 2010 年左右,当时我还在淘宝中间件,读了龙书,了解了 ASM ,开始读 clojure 编译器的源码。刚好同时在做 Notify 这个内部消息中间件的一个重要版本实现,其中有一个需求是实现 AMQP 规范里的 header 订阅,允许用户指定一个布尔表达式来决定是否订阅某种类型的消息,需要对布尔表达式字符串进行求值。当时正处于造轮子的兴奋期,因此就写了第一个版本出来,第一个版本花了一两天的功夫,整个代码结构其实到现在也没有特别大的改变,还是那么乱 :)

数据仓库 ,由数据仓库之父比尔·恩门(Bill Inmon)于1990年提出的。 1991年,他写了一本书,叫《Building the Data Warehouse》(建立数据仓库),书中提出的:
数据仓库(Data Warehouse)是一个

  • 面向主题的(Subject Oriented)、
  • 集成的(Integrated)、
  • 不可修改的(Non-Volatile)、
  • 与时间相关的(Time Variant)的数据集合,
  • 专门用于支持管理决策(Decision Making Support)。

ClickHouse is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).

场景特征:

大多数是读请求
数据总是以相当大的批(> 1000 rows)进行写入
不修改已添加的数据
每次查询都从数据库中读取大量的行,但是同时又仅需要少量的列
宽表,即每个表包含着大量的列
较少的查询(通常每台服务器每秒数百个查询或更少)
对于简单查询,允许延迟大约50毫秒
列中的数据相对较小:数字和短字符串(例如,每个URL 60个字节)
处理单个查询时需要高吞吐量(每个服务器每秒高达数十亿行)
事务不是必须的
对数据一致性要求低
每一个查询除了一个大表外都很小
查询结果明显小于源数据,换句话说,数据被过滤或聚合后能够被盛放在单台服务器的内存中
clickhouse自身限制:

不支持真正的删除/更新支持 不支持事务
不支持二级索引
有限的SQL支持,join实现与众不同
不支持窗口功能
元数据管理需要人工干预维护

链接:https://www.jianshu.com/p/7ec2cc9a4069

实时数仓方案如何选型和构建
原文链接:https://blog.csdn.net/weixin_43597208/article/details/126355132

这种方案的好处有二,方案简单;数据实时。不过有两个缺点:

一个是用户每产生一个新的报表需求,都需要开发一个Flink流式计算任务,数据开发的人力成本和时间成本都较高。

第二个是对于每天需要接入近百亿的数据平台,如果要分析近一个月的数据,则需要的Flink集群规模要求很大,且需要将很多计算的中间数据存储在内存中以便多流Join。

大数据分析使用哪些工具? - Smartbi的回答 - 知乎
https://www.zhihu.com/question/415610563/answer/3255681655

28、实时用户画像之任务调度DS之Flink任务实战讲解
https://edu.51cto.com/lesson/781871.html

markmap 这个名字是 Markdown 和 Mindmap 的组合
https://markmap.js.org/repl

python3网络编程
https://0xbharath.github.io/python-network-programming/protocols/dns/index.html

Setting Up V2Ray with NGINX + WebSocket + TLS
https://tofu.icu/archives/13

bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
apt update
apt install nginx certbot python3-certbot-nginx
vi /usr/local/etc/v2ray/config.json

{
  "inbounds": [
    {
      "port": 10000,
      "listen":"127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "your-uuid",
            "alterId": 0
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
        "path": "/yourpath/"
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

certbot certonly --nginx -d example.com

server {
  listen 443 ssl;
  listen [::]:443 ssl;

  ssl_certificate       /path/to/your/certificate;
  ssl_certificate_key   /path/to/your/certificate_key;
  ssl_session_timeout 1d;
  ssl_session_cache shared:MozSSL:10m;
  ssl_session_tickets off;

  ssl_protocols         TLSv1.2 TLSv1.3;
  ssl_ciphers           ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
  ssl_prefer_server_ciphers off;

  server_name           example.com;
  location /yourpath/ {
    if ($http_upgrade != "websocket") {
        return 404;
    }
    proxy_redirect off;
    proxy_pass http://127.0.0.1:10000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    # Show real IP in v2ray access.log
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

service nginx restart

Disable Python’s output buffering with sys.stdout.flush() or -u command line option.
https://python-code.dev/articles/3750

import os
import sys

if not os.environ.get("PYTHONUNBUFFERED"):
    os.environ["PYTHONUNBUFFERED"] = "1"
    os.execv(sys.executable, [sys.executable] + sys.argv)

print("This message will be printed without buffering")

What Is Python Output Buffering and How to Disable It?
https://blog.finxter.com/what-is-python-output-buffering-and-how-to-disable-it/

import io
import os
import sys
import time

try:
    # open stdout in binary mode, then wrap it in a TextIOWrapper and enable write_through
    sys.stdout = io.TextIOWrapper(open(sys.stdout.fileno(), 'wb', 0), write_through=True)
    # for flushing on newlines only use :
    # sys.stdout.reconfigure(line_buffering=True)
except TypeError:
    # In case you are on Python 2
    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

How to Check if Python’s Output Buffering Is Enabled
https://adamj.eu/tech/2020/06/26/how-to-check-if-pythons-output-buffering-is-enabled/

import io
import sys

def output_buffering_enabled():
    return isinstance(sys.__stdout__.buffer, io.BufferedWriter)

Resume Matcher is an open source, free tool to improve your resume. It works by using language models to compare and rank resumes with job descriptions.

www.resumematcher.fyi/

有哪些命令行的软件堪称神器? - HelloGitHub的回答 - 知乎
https://www.zhihu.com/question/59227720/answer/2644274078

滴滴弹性云基于 K8S 的调度实践
https://mp.weixin.qq.com/s/nMSIsS72fSXGqJO9Vy_Pfw

https://sendgrid.com/en-us/marketing/sendgrid-vs-amazon-ses

Nginx 中运行 JavaScript
https://zhuanlan.zhihu.com/p/393788937

https://github.com/nginx/njs/issues/179

While OpenResty is mature and a great tool to use, we decided to implement our own scripting for nginx for several reason.

njs is tailored to be executed inside nginx (fast VM creation/destroying), lua may have GC issues under heavy load.
lua adds a lot of ad-hoc features (directives, lua methods), njs strives for simplicity using powerful native nginx primitives (variables, subrequests).
njs is a pure nginx module, OpenResty is a set of patches which sometime abuses original nginx design.
we need our own scripting for nginx-plus (paid version) features.
While we already use njs for production it is still in early phase and lacks many features which OpenResty has. BTW we do not plan to implement everything lua/openresty has because the design philosophy is different.

Modern C++ Programming Course (C++11/14/17/20)
https://github.com/federico-busato/Modern-CPP-Programming

12 Lessons, Get Started Building with Generative AI
https://microsoft.github.io/generative-ai-for-beginners/

Longhorn is a distributed block storage system for Kubernetes. Longhorn is cloud-native storage built using Kubernetes and container primitives.
https://github.com/longhorn/longhorn

Go 语言 | 1.16 新增的embed在各流行Web框架中的应用
https://zhuanlan.zhihu.com/p/372800639

解决:

go get -u "github.com/gin-gonic/gin"

报错:

go: module github.com/gin-gonic/gin: Get "https://proxy.golang.org/github.com/gin-gonic/gin/@v/list": dial tcp 142.251.43.17:443: i/o timeout

解决:可以使用国内代理

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

go get -u "github.com/gin-gonic/gin"

Golang gin框架
https://blog.csdn.net/book_longker/article/details/123760632

golang微框架Gin
https://blog.csdn.net/qq_46079238/article/details/130780276

gin 打包静态文件·
https://www.jianshu.com/p/448c6ef02bc8

Golang微服务框架居然可以开发单体应用?—— Kratos单体架构实践
https://www.jianshu.com/p/c541e7b73c3d

从微信后端仓库发展史谈谈单仓和多仓
https://mp.weixin.qq.com/s/S2vcMTpLJpMREC6UoAGJmQ

Java快速创建http/https服务器
https://blog.csdn.net/qq_18497293/article/details/128019269

PyQt5-无边框窗体的移动实现
https://www.sumver.cn/archives/955/

Python搭建悬浮窗口
https://www.python100.com/html/EKRD86544Y9L.html

https://zhuanlan.zhihu.com/p/659744471?utm_id=0

20个堪比 Everything 的 Windows 实用小工具推荐

  • 文档名搜索神器:Everything
  • 文件管理和快速启动器:Listary
  • 全文搜索利器:AnyTXT Searcher
  • 格式最全的阅读器:SumatraPDF
  • 剪贴板历史:Ditto
  • 快速看图:Honeyview
  • 系统优化利器:Dism++
  • 软件卸载:GeekUninstaller
  • 窗口置顶显示:Window TopMost Control
  • 网络下载神器:IDM
  • 新一代效率利器:Quicker
  • 批量重命名:Advanced Renamer
  • 截图贴图神器:Snipaste
  • 速度最快的文本编辑器:EmEditor
  • 电脑上的瑞士军刀:DesktopOK
  • 电脑分区&数据恢复:DiskGenius
  • 护眼神器:f.lux
  • 镜像制作:Rufus
  • 快速预览文件:QuickLook
  • Windows 官方外挂:PowerToys

AI绘画软件Fooocus教程
https://zhuanlan.zhihu.com/p/656708919https://zhuanlan.zhihu.com/p/656708919

202310

invalid magic number: latest release of llama.cpp cannot import 13B GGML q4.0 model
https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/discussions/14

rolling back llama.cpp to commit hash a113689 works.

Yeah, latest llama.cpp is no longer compatible with GGML models. The new model format, GGUF, was merged recently. As far as llama.cpp is concerned, GGML is now dead - though of course many third-party clients/libraries are likely to continue to support it for a lot longer. I need to update my GGML READMEs to mention this and will be doing this shortly.

https://www.zhihu.com/tardis/bd/art/647329639?source_id=1001

参数高效的模型微调

  • 这一类方法的代表是LORA(https://arxiv.org/pdf/2106.09685.pdf)、LLaMA Adapter、Prefix-tuning,微调时对整个模型进行冻结,在模型上加入少量可学习的参数或者网络层,训练时只对这部分进行微调。
  • 这种方法其实就是将大模型作为提取特征的工具,因为模型本身巨大的参数量无需调整所以计算代价不高,甚至可以在单个消费级显卡上进行微调。
  • 如果你对大模型的使用场景距离已经训练的大模型的已有能力不远,应该首先尝试这种方法。

英语老师必备10条超好用的ChatGPT提示词
https://zhuanlan.zhihu.com/p/642571375

  • 请解释"touch base"的意思
  • 请提供关于"环保"的英语作文范例
  • 请提供一个关于"现在进行时"的练习题
  • 请纠正以下句子的语法错误: “She don’t like to swim in the pool.”
  • 请提供一个关于"在餐厅点餐"的英语口语对话练习
  • 如何向学生解释"虚拟语气"?
  • 请提供一个关于"动物"的英语课堂活动
  • 请提供一个关于"时间"的英语谚语
  • 如何提高学生的听力能力?
  • 请提供一个关于"友谊"的英语小故事

帮我写一篇“英语老师必备10条超好用的ChatGPT提示词”文章,要求2000字左右

https://huggingface.co/Unbabel/gec-t5_small

This model is an implementation of the paper A Simple Recipe for Multilingual Grammatical Error Correction from Google where they report the State of the art score in the task of Grammatical Error Correction (GEC). We implement the version with the T5-small with the reported F_0.5 score in the paper (60.70).

链接:https://www.zhihu.com/question/24113539/answer/2565029397

表示程度的优雅形容词,你认识哪几个?

  1. marvellous 好的非凡的
  2. splendid 极佳的;非常好的
  3. sensational 轰动的;引起渲然的;哗众取宠的;耸人听闻的;极好的;绝妙的
  4. spiffing 极好的;很棒的
  5. stupendous 极大的;令人惊叹的;了不起的
  6. ravishing 极其的;迷人的
  7. dashing 风度翩翩的;自信的;潇洒的
  8. joyous 高兴的;快乐的;令人愉快的
  9. glorious 值得称道的;光荣的;荣耀的
  10. eclectic 不拘一格的;兼收并蓄的
  11. chuffed 很愉快;很高兴;很满意
  12. thrilled 非常兴奋;极为激动

你有什么相见恨晚的英语学习方法? - 李献计的回答 - 知乎
https://www.zhihu.com/question/26677313/answer/2611743445

炒单赚的是几跳的钱,一天要做上百次,但是有很严格的止损止盈的标准,很多时候都是进去之后马上止损出来了。

这种赚钱模式,赚的其实是频率的钱,不会有太高的胜率。正常来说胜率一般也就是在60%到70%之间,不会有更高的胜率了。如果胜率再高一些,那么盈亏比就是连1比1都做不到了,可能盈利两次才会抵消一次亏损,这样来说就没有意义了。

以螺纹为例子,三跳止盈止损,胜率70%,一天操作100次的话(操作一手)。盈利2100,亏损900,手续费700,这样来算盈利就是500元。再加上手续费返还的话可能盈利是800或者更多。

链接:https://www.zhihu.com/question/522538926/answer/2589354781

【llm大语言模型】一文看懂llama2(原理,模型,训练) - yeyan的文章 - 知乎
https://zhuanlan.zhihu.com/p/651248009

炒期货的人最后都变成什么样了? - 藏巧守拙的回答 - 知乎
https://www.zhihu.com/question/279198518/answer/2316292946

How have top CDOs used their data to drive customer acquisition, revenue and profit goals? How can analytics create consensus across functional silos and competing c-suite priorities? In this event, top CDOs explore these questions and share the strategies they are using to keep dispersed employees informed, agile and productive.

https://www.forbes.com/sites/insights-teradata/2020/10/01/forbes-virtual-series-the-data-leaders-building-the-future-of-innovation/?sh=df7e0593e1d8
Watch the full event below for actionable insights from dynamic CDOs who have prioritized data and analytics to drive digital transformation and navigate our new reality.

PostgreSQL怎么查看数据库用户系统权限、对象权限
https://blog.csdn.net/weixin_41287260/article/details/127438227

SELECT * FROM  pg_roles WHERE rolname='postgres';
select * from information_schema.table_privileges where grantee='postgres';
select * from information_schema.usage_privileges where grantee='postgres';
select * from information_schema.routine_privileges where grantee='postgres';
select * from information_schema.column_privileges where grantee='postgres';
select * from information_schema.data_type_privileges ;
select * from information_schema.udt_privileges where grantee='postgres';

Postgres : 创建schema、创建表空间与指定用户权限
https://blog.csdn.net/weixin_42405670/article/details/130569729

CREATE SCHEMA my_schema;
CREATE USER my_user WITH PASSWORD 'password';
GRANT ALL ON SCHEMA my_schema TO my_user;
\dn
\du
grant USAGE on SCHEMA public to test ;
REVOKE ALL ON COMPANY FROM test;
REVOKE ALL ON SCHEMA public FROM test;

https://github.com/grafana/loki

Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. It is designed to be very cost effective and easy to operate. It does not index the contents of the logs, but rather a set of labels for each log stream.

Compared to other log aggregation systems, Loki:

  • does not do full text indexing on logs. By storing compressed, unstructured logs and only indexing metadata, Loki is simpler to operate and cheaper to run.
  • indexes and groups log streams using the same labels you’re already using with Prometheus, enabling you to seamlessly switch between metrics and logs using the same labels that you’re already using with Prometheus.
  • is an especially good fit for storing Kubernetes Pod logs. Metadata such as Pod labels is automatically scraped and indexed.
  • has native support in Grafana (needs Grafana v6.0).

jquery + PHP 上传图片

php

public function upload_photo() {
    $fileInfo = $_FILES['file'];

    $uploadPath = 'assets/uploads/files/' . date('Y') . '/' . date('m') . '/' . date('d');
    if (!file_exists($uploadPath)) {
        mkdir($uploadPath, 0777, true);
        chmod($uploadPath, 0777);
    }
    $ext = pathinfo($fileInfo['name'], PATHINFO_EXTENSION);
    $ext = strtolower($ext);
    $allowExt = array('jpeg', 'jpg', 'png');
    if (!in_array($ext, $allowExt)) {
        echo 'error';
        return;
    }

    $maxSize = 2097152;
    if ($fileInfo['size'] > $maxSize) {
        echo 'error';
        return;
    }
    if (!getimagesize($fileInfo['tmp_name'])) {
        echo 'error';
        return;
    }

    $uniName = md5(uniqid(microtime(true), true)) . '.' . $ext;
    $destination = $uploadPath . '/' . $uniName;
    if (!move_uploaded_file($fileInfo['tmp_name'], $destination)) {
        echo 'error';
        return;
    }
    echo $destination;
}

js

<input class="imgInput" id="img-upload" type="file" name="photo_img" accept="image/jpeg,image/jpg,image/png">

var file = $("#img-upload")[0].files[0];
if (file){
   var formData = new FormData();
   formData.append('file', file);
   $.ajax({
       url: "upload_photo",
       type: "post",
       data: formData,
       contentType: false,
       processData: false,
       success: function (res) {
           console.log(JSON.stringify(res));
       }
   })
}

精选英文作文21篇
https://www.ruiwen.com/yingyuzuowen/5118720.html

独立开发者靠什么赚钱? - 李牧云的回答 - 知乎
https://www.zhihu.com/question/591944056/answer/3247553182

高中语文将《国风·卫风·氓》编入教材有什么意义? - 沧浪停云的回答 - 知乎
https://www.zhihu.com/question/52756329/answer/963323829

Apache Calcite系列
https://zhuanlan.zhihu.com/p/614668529

Apache Calcite 是一种提供了标准的 SQL 语言、多种查询优化和连接各种数据源基础框架,可以让用户轻松的接入各种数据,并实现使用SQL查询。此外,Calcite 还提供了 OLAP 和流处理的查询引擎。

大家对Apache Calcite可能不熟悉,但是大家肯定对Hive、Flink、Kylin以及Durid这些框架很熟悉吧,他们内部其实就是用的Apache Calcite。

pydash https://pydash.readthedocs.io/en/latest/devguide.html

Tool Description Configuration

  • black Code formatter pyproject.toml
  • isort Import statement formatter setup.cfg
  • docformatter Docstring formatter setup.cfg
  • flake8 Code linter setup.cfg
  • pylint Code linter pylintrc
  • mypy Type checker setup.cfg
  • pytest Test framework setup.cfg
  • tox Test environment manager tox.ini
  • invoke CLI task execution library tasks.py

json 判断为空

mysql> select JSON_EXTRACT('{"a":1,"b":null,"c":[]}','$.a');
+-----------------------------------------------+
| JSON_EXTRACT('{"a":1,"b":null,"c":[]}','$.a') |
+-----------------------------------------------+
| 1                                             |
+-----------------------------------------------+
1 row in set (0.00 sec)

mysql> select JSON_EXTRACT('{"a":1,"b":null,"c":[]}','$.b');
+-----------------------------------------------+
| JSON_EXTRACT('{"a":1,"b":null,"c":[]}','$.b') |
+-----------------------------------------------+
| null                                          |
+-----------------------------------------------+
1 row in set (0.00 sec)

mysql> select JSON_EXTRACT('{"a":1,"b":null,"c":[]}','$.c');
+-----------------------------------------------+
| JSON_EXTRACT('{"a":1,"b":null,"c":[]}','$.c') |
+-----------------------------------------------+
| []                                            |
+-----------------------------------------------+
1 row in set (0.00 sec)

mysql> select JSON_EXTRACT('{"a":1,"b":null,"c":[]}','$.d');
+-----------------------------------------------+
| JSON_EXTRACT('{"a":1,"b":null,"c":[]}','$.d') |
+-----------------------------------------------+
| NULL                                          |
+-----------------------------------------------+
1 row in set (0.00 sec)

实现一个四则运算语法解析器 - Gloria的文章 - 知乎
https://zhuanlan.zhihu.com/p/112460676

python 解析时间加时区

>>> datetime.strptime('2023-10-26T16:19:44+08:00','%Y-%m-%dT%H:%M:%S%z')
datetime.datetime(2023, 10, 26, 16, 19, 44, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800)))
>>> print(datetime.strptime('2023-10-26T16:19:44+08:00','%Y-%m-%dT%H:%M:%S%z'))
2023-10-26 16:19:44+08:00

拆分字符串: 写代码或正则把字符串 ‘a(1,2,3),b(1),c,e(f(3,4))’ 拆分成 a(1,2,3), b(1), c, e(f(3,4))4个子串。

循序渐进掌握递归正则表达式
https://www.cnblogs.com/f-ck-need-u/p/11344531.html

Pyparsing实战
https://zhuanlan.zhihu.com/p/259638397

如何看待 Rust 这门语言? - lencil的回答 - 知乎
https://www.zhihu.com/question/432640008/answer/2322776585

如何使用原生 vim 覆盖90%的插件功能 - 鹅厂架构师的文章 - 知乎
https://zhuanlan.zhihu.com/p/599417117

HubSpot picks up B2B data provider Clearbit to enhance its AI platform
https://techcrunch.com/2023/11/01/hubspot-picks-up-b2b-data-provider-clearbit-to-enhance-its-ai-platform/?guccounter=1

使用Antlr4实现计算器[Python]
http://www.opstool.com/article/336

2.19 实现一个简单的递归下降分析器
https://python3-cookbook.readthedocs.io/zh-cn/latest/c02/p19_writing_recursive_descent_parser.html

小试牛刀-递归下降算法(3)
https://zhuanlan.zhihu.com/p/30314216

消除左递归和回溯
https://www.bilibili.com/video/BV1BS4y1M7a9

消除左递归
A -> Aα|β

A -> βA'
A' -> αA'|ε

消除回溯
A -> δβ1 | δβ2 | ... | δβi | βi+1| ... | βj

A  -> δA'|βi+1|βj
A' -> β1|...|βj

公式解析

expr        -> expr + term
             | expr - term 
             | term

term        -> term * factor
             | term / factor
             | factor

factor      -> ( expr )
             | var
             | func
             | NUM
var         -> ALPHA
func_call   -> ALPHA ( args )
args        -> expr , expr
             | expr

去掉左递归

expr        -> term expr_tail 
expr_tail   -> + term expr_tail
             | - term expr_tail
             | e

term        -> factor term_tail
term_tail   -> * factor term_tail
             | / factor term_tail
             | e

factor      -> ( expr )
             | NUM
             | ALPHA alpha_tail
alpha_tail  -> ( args ) # func call
             | e        # var
args        -> expr args_tail 
args_tail   -> , expr
             | e

使用Micronuat + RxJava + KotlinTest
https://zhuanlan.zhihu.com/p/113983792

整会promise这8个高级用法,
https://blog.51cto.com/u_14627797/6989643

202309

高手是怎样做日内交易的?(货有点干) - 近我者富的文章 - 知乎
https://zhuanlan.zhihu.com/p/137631599

交易周期的确定:

  • 1 分钟交易周期:以小博大,快进快出。
  • 3 分钟交易周期:小波段交易。
  • 15 分钟交易周期:日内趋势交易。
  • 补充:日内短线交易不等于频繁交易。

什么是交易系统?

最通俗的理解:进场、出场、止损以及仓位管理的规则或规矩就是交易系统。

进场

  • 开盘价高于昨日收盘价,15 分钟不破,我择机进场做多,反之做空
  • 进场周期为1分钟,价格站在所有均线之上做多,反之做空。
  • 价格跳空高开不做多,价格跳空低开不做空;
  • 价格跳空高开跌破昨日最高价放空;价格低开突破昨日最低价做多

出场

  • 重要压力位置或者阻力位置
  • 或者盈利目标实现(盈亏比不低于 2:1)
  • 感觉行情不流畅或者有潜在风险,也会离场
  • 利必须达到止损的2倍,这是一个离场原则,其次趋势一有停顿的苗头就平仓。

止损

  • 每日亏损不允许超过总资金的 1.5%,如果一日我交易 3 次,则每次亏损就是 0.5%。
  • 每次下单必须立即止损跟上,如果你没有想好,就不要交易。
  • 止损点位的严格要求,

仓位

  • 以损定量。允许亏损的钱除以点数,就是开仓的手数。
  • 这次开仓我允许亏损500元,亏损点数是20点,每个点是10元钱,则开仓手数=500/200=2.5手。

研判

  • 研判今天的市场是单边还是震荡,以此制定交易计划;
  • 价格在30分钟最高价和最低价之间的区域内上下波动为震荡,突破有可能出现趋势。
  • 震荡行情——高空,低多。
  • 趋势行情——追随趋势。

期货日内交易如何做到一年3-10倍? - 傲娇元宝的回答 - 知乎
https://www.zhihu.com/question/304573577/answer/2511392700

  • 开盘几分钟内、尾盘2、3分钟内不要开仓
  • 以目标为终点线而不是时间:实现目标后坚决走人(每天的目标是多少,预先设定好,而不是做到交易所休盘时间)
  • 如果那天处于亏损状态,在亏损到设定的警戒线后也一定要坚决走他人。这里的目标既有盈利也有亏损警戒线。
  • 在正式开盘后,不要预测走势,要善于发现价格趋势,跟随价格趋势,然后根据自己的技术指标进场,这一点很难。
  • 上个交易时段尾盘最后趋势,上午10点15分休盘和11点30分休盘前的最后趋势,这个规律几乎百分之95都是可靠的。
  • 所有的技术指标和参数都是后发的,只有市场心理是唯一的先发指标。这一点对日内交易非常重要。
    • 还有整数点尤其是50和100多次上攻或下破都失败,预示着什么;
    • 开盘20分钟左右开盘价即最高价或最低价意味着什么。
  • 单边趋势明显,就尽可能做单边,这个时候做双向交易极容易陷入陷井里。
  • 每个品种一旦行情启动,正常都不会低于多少个点,基本有规律的
  • 最后,做日内交易,尽量做一个品种,不要分散。
  • 至于多少资金合适,60万之内都可以随便做,一次下单30%到50%资金没有问题的,不要尝试什么金字塔形加仓。一次性到位。
  • 什么品种合适呢,按照交易量大、波动幅度大、交易活跃度高来选。资金在10万以上,尽量选金属和贵金属,10万以下选农产品。
  • 最后建议,每天坚持锻炼身体,保持良好的精神状态和身体状态是成功的外在条件,它们直接影响你的专注力、判断力和行动力。

Elasticsearch自定义评分的N种方法
https://cloud.tencent.com/developer/article/1600163

布尔查询中的每个must,should和must_not元素称为查询子句。

  • 文档满足must或 should条款的标准的程度有助于文档的相关性得分。分数越高,文档就越符合您的搜索条件。
  • must_not子句中的条件被视为过滤器。它会影响文档是否包含在结果中,但不会影响文档的评分方式。在must_not里还可以显式指定任意过滤器,以基于结构化数据包括或排除文档。
  • filter:必须 匹配,但它以不评分、过滤模式来进行。filter内部语句对评分没有贡献,只是根据过滤标准来排除或包含文档。
  • 一句话概括:filter、must_not不影响评分,其他影响评分。

独立开发者犯法吗? - 第五面壁者的回答 - 知乎
https://www.zhihu.com/question/617917921/answer/3173907554

89年,手里1269万现金,怎么稳健理财? - CPA CFA 盐究所的回答 - 知乎
https://www.zhihu.com/question/596318158/answer/3083468070

装上了4个兆瓦户用光伏电站,花掉1000多万,每年可以从国家电网收到200万以上的电费,除去各种费用,实际净收入不低于170万。

然后,如果还能剩下点钱再按照文中方式做做理财

mapreduce为什么被淘汰了? - 雷鹏的回答 - 知乎
https://www.zhihu.com/question/303101438/answer/2925341473

十多年前在人人网(当时还叫校内网)第一次接触 MapReduce。当时刚入职,团队用 Cascading 做广告数据的分析,整个分析 Pipeline 牵涉到好多个 job,在数十个结点的 hadoop 集群上跑一遍要好几个小时,还经常就把整个集群跑挂了,一直没法上线。

当时我花了大概一周时间理清了广告分析的业务逻辑,然后写了一个等效的多线程 C++ 单机程序,一共也就 300 多行代码,单机跑一遍数据只要十几分钟。

职场最重要的能力是什么? - 策北的回答 - 知乎
https://www.zhihu.com/question/508168208/answer/2936070092

仔细观察你的老板在做什么事,尤其是在季末、年末这种关键时间节点,你就知道职场中什么能力最重要了。

作为一个在互联网行业打滚摸爬5年的职场人,我可以负责任地说:职场中最重要的一定是向上汇报的能力,其次是链接资源的能力,最后才是执行力。

How to remove all event listeners from a DOM element in Javascript
https://techoverflow.net/2019/12/26/how-to-remove-all-event-listeners-from-a-dom-element-in-javascript/

var elem = document.getElementById(‘root’);elem.replaceWith(elem.cloneNode(true));

唐奇安通道–日内策略的鼻祖 - 币圈牛哥的文章 - 知乎
https://zhuanlan.zhihu.com/p/551573373

1970年,唐奇安通道规则在一个对当时最流行的机械交易系统进行模拟测试和比较研究中取得了最优结果,随后声名远扬。唐奇安通道的理论基础是人类最起码需要21日来使得新事物代替旧事物。当绝大多数交易者都在认为趋势可能已经变化时,也就是经过了“21”日的适应期时,主要趋势却已做好了继续运行的准备。

交易系统可以有多简单? - 股玄明的回答 - 知乎
https://www.zhihu.com/question/418378495/answer/3134141491

这就是交易致胜的核心原则,只要符合这些原则,可以用的方法和指标多的是,没有最好,只要最适合自己。需要在实践中去寻找。

只要掌握并能在实践中遵循这些原则,哪怕用一个很简单的指标,能用纪律保持一致性,你会发现赚钱是一件很简单很无聊的事

炒股就是要简单的事情重复做,长时间坚持使用一个方法,把它用得炉火纯青,炒股也能像其他行业和一样,熟能生巧,手起刀落,不假思索做出每一个决定。

那些编程水平很高的程序员是怎么训练出来的? - 郭忠明的回答 - 知乎
https://www.zhihu.com/question/351504112/answer/2128951951

为什么国内的独立开发者做不起来? - The Alpha的回答 - 知乎
https://www.zhihu.com/question/598811656/answer/3157920350

国内所谓独立开发者基本就那几样: 记账, 天气, todo list, 背单词, 笔记(基本已经被notion干没了), 现在还有各种gpt套壳.

什么备案, gitee代码审查根本算不上障碍. 一个人是独立开发者, 首先他是个程序员. 除了 Apple store 要交钱(这个全世界统一), 其他问题有一堆绕过的方法.

请问真正的交易高手,能否把你们最舍不得分享的交易秘诀,用简单的一两句话暗示一下?谢谢!? - 老李闯江湖的回答 - 知乎
https://www.zhihu.com/question/425638863/answer/2957795098

期货品种详解之玉米期货 - 投资银河汇的文章 - 知乎
https://zhuanlan.zhihu.com/p/221958261

作为中国的高产粮食作物,玉米是畜牧业、养殖业、水产养殖业等的重要饲料来源,也是食品、医疗卫生、轻工业、化工业等的不可或缺的原料之一。

1 玉米供应

在国际玉米市场上,美国产量占40%以上,中国产量占近20%,南美产量约占10%。可见美国是世界玉米的主产区,其生产和供应对国际市场的影响很大。特别是美国的玉米生产已成为影响国际供应的最重要因素,其他国家和地区的产量比例较低,对国际市场的影响较小。

2 对玉米的需求

美国和中国都是玉米的主要生产国和消费国,玉米消费量较大的国家包括欧盟,日本,巴西,墨西哥等。这些国家的消费需求变化对玉米价格的影响更大。特别是近年来,主要消费国的玉米加工业发展迅速,极大地推动了玉米消费需求。

铁秃鹰:一个适合散户稳赢的期权策略 - 期权酱的文章 - 知乎
https://zhuanlan.zhihu.com/p/647737099

How to fetch an email body using imaplib in python?
https://stackoverflow.com/questions/2230037/how-to-fetch-an-email-body-using-imaplib-in-python

一位期货日内短线交易高手的交易技法(附详细方法) - 于渊的文章 - 知乎
https://zhuanlan.zhihu.com/p/438891011

举例,哪怕先浮盈30点没平,但是行情掉头,哪怕赚2个点都得平!或者先赚了十来个点就平了等下一单机会,不追单,就等符合信号的机会。

分时图15分钟以后均线向下,只做空,kd超80,直接空,止损线为楼梯上一个N字顶部,就是上一个压力位,止盈跟随止盈就好,距离一个N保本。因为是跟随止盈,所以符合利润奔跑起来,因为反向压力位止损,所以,止损小。符合盈亏比,并且顺势

链接:https://zhuanlan.zhihu.com/p/607446554

  • 第一、知道什么时候不交易,才是交易的绝招。
  • 第二、只交易成交量排名前20的品种。
  • 第三、利用趋势、形态、成交量抓住行情的爆发点。还要判断行情是否走完,及时止盈。
  • 第四、顺大势,逆小势;
  • 第五、日内看分时,不研究基本面。中长线看k线,需要关注基本面;
  • 第六、趋势反转,快到慢,慢到快。成交量极度缩小,可能也是行情反转的时候。
  • 第七、看图的时候,重点关注分时图的角度和幅度。

期货日内交易中,还是有很多大神的 - 2927913627的文章 - 知乎
https://zhuanlan.zhihu.com/p/141439996

  • 日内只是一个容纳资金相对较小需要素质更高的一条路,你可以走,可以不走,但它从来都不是死胡同。
  • 日内交易就是重仓,半仓全仓是常态,而且日内只观察市场情绪,不看重什么趋势。
  • 这个特性排除了大部分强调价值,轻仓,顺势及看指标的这部分人。
  • 日内做的好的人,中长线也不会差到哪去,但是能做中长线的未必能做日内。
  • 大部分人做日内死的很快,如果不合适很快就能看出来,长线如果反向波动了还能说是回撤,就算不合适也不是短期能看出来的。
  • 日内做三个月,你的技术、心态都要比没训练过的人强大很多!
  • 很多时候日内容易落入频繁交易,盈亏比做不大的怪圈,
    • 盈亏比的问题好解决无非拿久一些,
    • 频繁交易更好解决,以前每天做10单现在我就做2单加严格止损,
    • 但核心的问题来了,怎么让每天的两单能捕捉到大行情?也就是日内系统其实特别依赖开仓。

期货日内交易的4个方法 - 我要慢慢的变富的文章 - 知乎
https://zhuanlan.zhihu.com/p/445493285

一、开仓的两个基本策略。一是做量价齐升的健康行情,这是程序化喜欢的行情,这种小的单边行情量价同步,只要多巡逻发现,每天有3至5次机会。但是比的是速度,对反应能力要求高。二是做多空行情的转折点、分界点,这种临界点的操作,属于回马枪,抢反弹,顺应小周期的v型,但要符合主趋势方向,不然很容易被秒杀。

日内交易的时间和空间有限,不专注盯盘是不行的。现在,程序化交易或者称量化交易盛行,不专注盯盘,更干不赢计算机。

严格止损,树立微利观,降低盈利预期。期货日内交易时,我们有些单子进场后发现不是流畅的行情,没有入场见红,应当迅速的止损。如果出现浮盈后,量价不同步了,要果断止盈。

现在,许多交易高手都是重仓吃小波动,吃一小段。这也导致日内走势一波三折,盘面不稳定。

事实上,期货行情震荡的时间远比单边上涨趋势的时间要长得多,日内不要奢求大的单边行情。日内交易坚持小止赢,慢慢变富才是硬道理。

降低交易频率,控制日内交易的次数。我们需要选择那些连续小阳线或连续小阴线的强势行情,这种流畅的行情稳定性强,才会入场见红。当然这种期货行情不会很多,当没有出现连续流畅的行情,市场方向不明确,持仓量不配合,量行不同步,就应当放弃大部分的垃圾时间和垃圾行。

日内交易:1.选择大于等待,要找强势品种,联动共振品种。2.固定3分钟周期。3.做多选底部增仓向上,做空选顶部增仓向下。4.主动止损和止盈。5.不要隔夜。

https://memo.ac/releases.html

logrotate

#logrotate -d /etc/logrotate.d/testlog
#logrotate -f /etc/logrotate.d/testlog

compress                     通过gzip压缩转储以后的日志
nocompress                   不做gzip压缩处理
copytruncate                 用于还在打开中的日志文件,把当前日志备份并截断;是先拷贝再清空的方式,拷贝和清空之间有一个时间差,可能会丢失部分日志数据。
nocopytruncate               备份日志文件不过不截断
create mode owner group      轮转时指定创建新文件的属性,如create 0777 nobody nobody
nocreate                     不建立新的日志文件
delaycompress                和compress 一起使用时,转储的日志文件到下一次转储时才压缩
nodelaycompress              覆盖 delaycompress 选项,转储同时压缩。
missingok                    如果日志丢失,不报错继续滚动下一个日志
errors address               专储时的错误信息发送到指定的Email 地址
ifempty                      即使日志文件为空文件也做轮转,这个是logrotate的缺省选项。
notifempty                   当日志文件为空时,不进行轮转
mail address                 把转储的日志文件发送到指定的E-mail 地址
nomail                       转储时不发送日志文件
olddir directory             转储后的日志文件放入指定的目录,必须和当前日志文件在同一个文件系统
noolddir                     转储后的日志文件和当前日志文件放在同一个目录下
sharedscripts                运行postrotate脚本,作用是在所有日志都轮转后统一执行一次脚本。如果没有配置这个,那么每个日志轮转后都会执行一次脚本
prerotate                    在logrotate转储之前需要执行的指令,例如修改文件的属性等动作;必须独立成行
postrotate                   在logrotate转储之后需要执行的指令,例如重新启动 (kill -HUP) 某个服务!必须独立成行
daily                        指定转储周期为每天
weekly                       指定转储周期为每周
monthly                      指定转储周期为每月
rotate count                 指定日志文件删除之前转储的次数,0 指没有备份,5 指保留5 个备份
dateext                      使用当期日期作为命名格式
dateformat .%s               配合dateext使用,紧跟在下一行出现,定义文件切割后的文件名,必须配合dateext使用,只支持 %Y %m %d %s 这四个参数
size(或minsize) log-size     当日志文件到达指定的大小时才转储,log-size能指定bytes(缺省)及KB (sizek)或MB(sizem).当日志文件 >= log-size 的时候就转储。 

Where is the cron / crontab log?
https://askubuntu.com/questions/56683/where-is-the-cron-crontab-log

tail -f /var/log/syslog | grep CRON
journalctl -u cron.service

Open the file
/etc/rsyslog.d/50-default.conf
Find the line that starts with:
#cron.* 
uncomment that line, save the file, and restart rsyslog:

sudo service rsyslog restart
You should now see a cron log file here:

/var/log/cron.log

However, you will not see more information about what scripts were actually ran inside /etc/cron.daily or /etc/cron.hourly, unless those scripts direct output to the cron.log (or perhaps to some other log file).

Scripteable GPT partitions using parted
https://unix.stackexchange.com/questions/200582/scripteable-gpt-partitions-using-parted

parted --script /device \
    mklabel gpt \
    mkpart primary 1MiB 100MiB \
    mkpart primary 100MiB 200MiB \
    ...

sudo 出现unable to resolve host 解决方法 Ubuntu环境, 假设这台机器名字叫abc(机器的hostname), 每次执行sudo 就出现这个警告讯息: sudo: unable to resolve host abc 虽然sudo 还是可以正常执行, 但是警告讯息每次都出来,而这只是机器在反解上的问题, 所以就直接从/etc/hosts 设定, 让abc(hostname) 可以解回127.0.0.1 的IP 即可

我认为做期货必须对均价线极为重视,均价线就是盘中分时图上一根黄色线,别小看这根线,在期货短线操作中,我大部分时间是以这根黄线进行短线操作。简单的方法是如果当日期价跳空高开,期价回落至均价下方,等到第二低点不低于第一低点时,买入!等到拉升至均价上方,特别是当天出现较大的涨幅时,短线抛出!这样,可以轻松获取至少500元以上的收益。反之也是这样,当期价跳空低开,期价在多方逢低买盘介入下,会出现反弹,第一波反弹不必着急沽空,等第二波反弹时,发现不能突破盘中的最高点,沽空!等下跌至均价下方,可当日平仓。

链接:https://zhuanlan.zhihu.com/p/343907175

链接:https://www.zhihu.com/question/304573577/answer/2511392700

  • 日内短线交易入市之后如果不能马上获利,就准备迅速离场,不加仓,不补仓,不逆势死扛,不持仓过夜。
  • 开盘几分钟内、尾盘 2、3 分钟内不要开仓
    • 当然这个期间开仓也是输赢效率最大的时候,很多时候一笔交易可以快速在 1,2 分钟实现 5-10% 的盈利,没有5年以上的的经验不要尝试,
    • 因为这个时段的行情基本上和技术指标、价格趋势没有多大关系,更多的交易心理导致的价格走势
  • 以目标为终点线而不是时间:实现目标后坚决走人
    • 每天的目标是多少,预先设定好,而不是做到交易所休盘时间
    • 因为一个人在多次操作后,判断力控制力专注力都会下降,很难一直保持高水平。
    • 这里强调一下,如果那天处于亏损状态,在亏损到设定的警戒线后也一定要坚决走他人。这里的目标既有盈利也有亏损警戒线。
  • 在正式开盘后,不要预测走势,要善于发现价格趋势,跟随价格趋势,然后根据自己的技术指标进场,这一点很难。
  • 上个交易时段尾盘最后趋势,上午 10 点 15 分休盘和 11 点 30 分休盘前的最后趋势,这个规律几乎百分之 95 都是可靠的。
  • 所有的技术指标和参数都是后发的,只有市场心理是唯一的先发指标。
  • 整数点尤其是 50 和 100 多次上攻或下破都失败,预示着什么;开盘20分钟左右开盘价即最高价或最低价意味着什么。
  • 单边趋势明显,就尽可能做单边,这个时候做双向交易极容易陷入陷井里。
    • 开盘就是最高或次高、最低或次低价,基本上就是单边强趋势。
    • 震荡行情就做双向交易。
  • 最后,做日内交易,尽量做一个品种,不要分散。
  • 至于多少资金合适,60 万之内都可以随便做
    • 一次下单 30% 到 50% 资金没有问题的,不要尝试什么金字塔形加仓。
    • 一次性到位。
  • 什么品种合适呢,按照交易量大、波动幅度大、交易活跃度高来选。
    • 资金在10万以上,尽量选金属和贵金属
    • 10万以下选农产品。
    • 不建议选白糖、镍这类“妖”风盛行的品种。

做短线你必须认识到,从你介入行情的那一秒开始,行情在未来的走势就必须符合你的心理预期。如果行情出现不确定,或者波动加剧,此时市场虽然还未证明你错了,但是如果你还不进行减仓或平仓来抑制风险,那么真正等市场证明你错了的时候,你已经无力承担这种止损规模了。

  • Scala主要解决 Java 在灵活性和可扩展性方面的缺陷,它提供了更加强大的函数式编程和面向对象编程模式,以及更高效的内存管理机制。
  • Groovy主要解决 Java 在语法简洁性和可读性方面的缺陷,它提供了更加灵活的语法,使得 Java 的代码变得更加简洁易读。
  • Clojure主要解决 Java 在函数式编程方面的缺陷,它提供了更加灵活的函数式编程模型,使得代码更加简洁、可读性更高、测试更容易。
  • Kotlin是想干掉Java。众所周知Scala用户里有Better Java派和Pure-FP派。Kotlin在很多地方就是学习了Scala的语法,比如说data class和类构造器的设计,在Scala中都可以找到类似的东西。

编程三大信息学赛事CSP、NOIP、NOI,一文搞清!
这三个比赛都是由中国计算机学会(CCF)举办的。从报名资格上看,参加CSP-S复赛非零分者,将自动入围NOIP。所以大致同学们的竞赛之路如下:

1、CSP-J/S初赛
2、CSP-J/S复赛
3、NOIP
4、省内选拔(省选)
5、NOI(国赛)

信奥赛CSP、NOIP、NOI 一文搞清关系
https://baijiahao.baidu.com/s?id=1744364952219454792&wfr=spider&for=pc

Llama 2 本地运行全攻略
https://mp.weixin.qq.com/s/vMNGwf5F_nJ-Q0h6LA0cyw

easy_english_every_day

Easy English Every Day

01 打招呼

  • Great to see you!
  • Good to see you!
  • How are you doing?
  • How have you been?
  • What are you doing here?
  • Oh I’m meeing my friend.
  • I’m superised to see you here.
  • You look excited.
  • What’s going on?
  • Joe and I are getting married next month.
    And we’re having our honeymoon in Europe.

02 对不起

  • I heard Juliet divorced her husband.
  • Oh! I’m sorry to hear that.
  • You know, they fell in love at first sight and quickly jumped into marriage.
  • Really? I never heard.
  • She looks quite depressed.
  • It’s so sad. I hope she’ll get through this.

03 请再说一遍

  • Excuse me?
  • Sorry! I didn’t get you.
  • I could use some water.
  • I didn’t get the joke.
  • Could you say that again?
  • Could you slow down please?
  • Could you speak up a bit?

04 再见

  • I have some errands to run. I’v got to go.
  • OKay. I’ll catch you later.
  • run some errands.
  • I called, but I did’t catch you.
  • Oh!It’s getting late. I’d better go.
  • Bye!See you!
  • You’d better sit and have a rest.
  • I have another appointment. I probably should get going.
  • Nice talking to you.Bye!
  • have an appointment.
  • make an appointment.
  • keep an appointment.
  • I had an appointment with doctor.

05 求助

  • Hello! Could you help me a little bit?
  • No problem!
  • He always help me with the housework.
  • Could you give me a hand?
  • OKay!
  • Let me give you a hand with those bags.
  • Could you do me a favour?
  • Sure.I’d love do.

06 借东西

  • Could you lend me a book?
  • Sure, there you go.
  • Can I borrow you pen?
  • Yes, here you are.
  • Can I borrow you pen for a few days?
  • Do you have a pen?
  • I don’t have one with me.

07 谢谢

  • The coat looks great for you!
  • Tha’s very nice to you to say.
  • I was just noticing your boots, what a great color.
  • Your lasagna is delicious!
  • Oh, I’m glad you like it.
  • You’re the best teacher ever.
  • Thanks for saying so.

08 你知道吗

  • Do you know Andy?
  • Yes. We went to school together. What’s up?
  • Do you know where he is?
  • Do you happen to know his number?
  • Yes, I have his number.
  • Do you happen to know the nearest bookstore?
  • Do you have any idea how to contact him?
  • We locked our keys in the car! Do you have any idea how we can get in?

09 受够了

  • I’m fed up with the music.
  • Yeah! This place is really dull.
  • I’m fed up with you complaint.
  • Do you get along with your husband?
  • He’s driving me crazy!
  • That noise is driving mad.
  • This computer is annoying me!
  • Uh-oh! It broken down again. Your need to buy a new one.
  • It annoys me …
  • It really annoys me when people forget to say thank you.

10 婉拒邀请

  • Joe and I are having a party this Saturday. Would you like to come?
  • I’d love to, but I don’t think I can make it!
  • Will you come to my party weekend?
  • I’m so sorry! I have another commitment.
  • Drop by if you can.
  • Thanks for inviting me. May be another time.
  • Thank you for coming.

11 小长假

  • How was your weekend?
  • I went hiking with my family.
  • a long weekend
  • How was your day?
  • How was your trip?
  • Terrific! How was that?
  • We have a log of fun together. We also had a picnic by the lake.
  • no picnic
  • Bringing up kids is no picni.
  • How did you spend your weekend?
  • Oh, nothing special. I hung out with my friend.
  • I barely hang out with my frends.

12 接受邀请

  • Would you like to come over for dinner tonight?
  • Sure, want me to bring anything?
  • Thank you for dinner, it was sa tasty!
  • You’re welcome.
  • Thank you for such wonderful gift.
  • Thank you for having us. We had a good time.
  • Any time.
  • I had some friends over last night.

13 压力大,工作忙

  • How’s it going?
  • I’m very busy with work these days.
  • Then why don’t you take a few days off?
  • be in the middle of (doing) sth.
  • I’m in middle of a big project.
  • I’m in middle of my new business.
  • How is school?
  • I can never finish my homework.
  • Oh, relax! Everything will be ok.
  • be working on (doing) sth.
  • I’m woking on my homework/speech/essay.
  • I’m working on making new firends.
  • I’m under a lot of pressure right now.
  • Don’t let it get top of you.

14 失恋了,不开心

  • What’s the matter, Joanna? Why the long face?
  • It’s difficult to explain. I just feel so sad.
  • Try me. It’s not as sad as you think.
  • You know, my boyfirend broke up with me. I can’t get over him.
  • America is not as good as you think.
  • break up with sb.
  • divorce sb.
  • Move on! You need get over your ex!
  • Maybe tomorrow will be different.
  • Yes, maybe I should try starting to date someone new.
  • I’m dating my frend’s brother.

15 你俩很熟吗

  • Do you know that girl?
    • Are you familiar with someone? // 慎用,这样问可能是窥探人家的隐私
    • I thought hew was a bit familiar with my wife. // 我觉得他和我老婆有一点太随便了
    • Do you know someone well? // 应该这样问
  • The tall one?
  • No, not that one. The one in jacket, with long hair.
    • blond(blonde) 金黄色
    • brown 棕色的
    • chestnut 栗色的
    • the gril with brown hair
  • She’s Ann. She works with Max.
  • She’s cute.
  • And she’s smart. She graduated from Stanford.
    • She graduated from colleage tow years ago.

16 介绍朋友

  • Can I introduce you to my friend, Jane?
  • Hi, Jane! I’m Will. Haven’t we met before?
  • Will, meet my frend Jane.
  • Jane, this is Will, my work firend.
  • I’d like you to meet my friend, Jane.
  • Hi Jane, It’s pleasure to meet you!
  • I think you guys might hit it off.
    • We hit it off with each other as soon as we meet.
  • We sure did!

17 搭讪金句

  • You are a friend of Jenny’s right?
  • Yes, I am. Did I see you before?
  • I’m afraid you’ve got the wrong person.
  • I’m so sorry, my brain is not kicking into gear.
  • Please remind me about your name.
  • I feel like I know you from somewhere.
  • I know your face, but I can’t put a name to it.

18 和老外聊天

  • Where are you from? 你来自于哪里?
    • Where are you coming from? 你刚才从哪里来?
  • I’m from the States.
    • I’m originally from Oslo, Norway, but I live in Chicago.
  • Are you from Washington?
  • No. I’m from California.
  • I heard that California is known for its beaches, sunshine and year round great weather.
  • I’ve been to Los Angeles.
  • First time in Bejing?
  • Actually I first came here in 2012.
    • This is the first/second/third time I’ve been here.
  • What do you think is the most famous place in Beijing?

19 马上能用到的聊天技巧

  • Where did you grow up?
  • I was born in Beijing and brought up in Shanghai.
    • I was born and brought up in Beijing,
      but I moved to Shanghai with my parents 5 years ago.
  • How long have you been here?
    • How long have you worked here?
    • How long have you been single?
  • I’ve been here for 5 years.
  • How do you like it here so far?
    • How do you like the weather?
    • I wish it would stop raining.
    • I prefer it warmer.
  • I like the food and the secnic spots here.

20 聊职业

  • What do you do for a living?
  • I’m a marking manager for a tech company.
    • I’m a 职业 for 工作地.
    • I’m a music teacher for a private school.
  • What line of business are you in?
  • I’m a English teacher instructing people in English online.
    • instruct someone in something
    • He instructs me in use the gym enquiment.
  • What type of work do you do?
  • I’m a fitness trainer specializeing in creating easy and fun
    exercise programs for people who don’t enjoy going to the gym.
    • specialize in 专门从事,专攻
    • The hop specializes in handmade chocolates.
    • go to the gym 去健身房
    • I go go the gym twice a week.

21 聊运动健身

  • Do you do any sports?
    • do/play sports
    • What’s the favorite sport to play? 你最喜欢什么运动
    • What’s your favorite sport? 不一定是做运动
  • No, I don’t do sports, I’m not a big fan.
    • I’m not a fan. 我不热爱某事物
    • I’m not that into that. 我不太感兴趣。(这句语法很诡异)
  • Do you play any ball games?
    • play+球类
    • backetball, baseball, soccer, golf
  • Yes, I play backetball. It’s my thing.
  • Do you usually work out?
    • do lifting 做负重练习,举铁
    • do yoga 做瑜伽
    • do plank 做平板支撑
    • How often do you work out? 你多久锻炼一次啊?
    • How many hours do you usually spend on working out every day?
      你每天要锻炼多长时间啊?
  • I do the gym a lot, sometimes I do yoga.

22 最爱的书和电影

  • What kind of books do you read?
    • stick to 坚持,忠于做某事
    • science fiction 科幻小说/电影
  • I most like to sitck to science fiction.
    • tend to do 倾向于做某事
    • I tend to read books like ‘I’ll Give you the Sun’ by Jandy Nelson.
    • I read verfy little thrillers and fansasy.
    • I like all kinds of books.
  • What kind of movies do you like?
    • movie 电影
    • romantic comedy 浪漫喜剧
  • My favorite types of movies are romantic comedies.
    • I love … the most. 我最喜欢…
    • I never like horror movies.
    • action 动作片
    • thriller 惊险片
    • horror 恐怖片
    • comedy 喜剧片
  • Who’s your favorite actor?
    • actor 男演员
    • actress 女演员
    • ideal 完美的,理想的人或事物
  • I’m a fan of Matt Damon from the Martians. He is an ideal for me.
    • I’m a fan of 很喜欢某演员。
    • He’s a good family man. 他是个很有家庭观念的人。
    • He has a good sence of humor. 他是个很有幽默感的人。

23 你说怎么样?

  • How do you like your new job?
  • I like it. And I still have a lot to learn and improve
  • 词汇
    • learn 学习
    • improve 提高
  • 活用
    • How do you like …? 你觉得…怎么样?问客观评价
    • How did you like Paris?
    • How did you like it when you live in Paris?
    • How do you like these shoes?
  • How do you feel about your coworkers?
  • They are friendly and easy to get along with.
  • 词汇
    • coworker 同事
    • friendly 友善的
  • 活用
    • How do you feel about…? 你觉得…怎么样?问主管感受,真实想法
    • How do you feel about overtime?
    • I don’t mind working overtime at all,
      and I’m flexble with my hours,
      so I won’t have a problem.
  • What do you say we go to see a move?
  • OKay, Let’s go.
  • 词汇
    • tonight 今晚
  • 活用
    • What do you say? 征求别人的建议和想法
    • Let’s go to the movies tonight, wht do you say?
    • Let’s eat out tonight. What do you say?

24 学会夸人

  • That’s a lovely hat! It looks great on you!
  • Oh,!I’m glad you like it!
  • 词汇
    • lovely 好看的
    • hat 帽子
  • 活用
    • That’s a lovely … …真好看
    • something looks great on someone 更侧重于说东西漂亮。
    • I really like your… 夸别人的衣着,可以说,我很喜欢你的…
    • I really like your outfit. 我好喜欢你的衣服。
    • I really like the way you look. 我好喜欢你的打扮。
  • You look pretty in that dress!
  • Thank you. That’s very nice of you to say.
  • 词汇
    • pretty 漂亮的
    • dress 裙子
  • 活用
    • You look pretty in … 更侧重于说人(穿什么)漂亮
    • You are looking nice today! 你今天真漂亮!
    • 形容女人漂亮动人,还可以用 beautiful, stunning, gorgeous
  • Those errrings suit you well.
    这耳环真配你。
  • Thanks. My boyfirend send them to me as birthday gifts.
    谢谢,这耳环是我男朋友送我的生日礼物。
  • 词汇
    • earring 耳环
    • suit 相配,适合
  • 活用
    • Blue suits you well. 蓝色很适合你
    • It brings out your eyes. 它更显你漂亮(帅气)。
    • It really match your skin tone. 它很配你的肤色。

25 迟到了

  • You are 20 minutes late. What kept you?
    你迟到了20分钟,怎么回事?
  • I went the wrong way.
    我走错路了。
  • 词汇
    • minute 分钟
    • wrong 错误的
  • 活用
    • I wasn’t feeling well and overslept.
      我感觉不舒服,睡过头了。
    • I got stuck in the traffic.
      我遇到了交通堵塞。
    • I got stuck in the rain/snow.
      我被雨/雪困住了。
  • I’m sorry for being late. 对不起,我来晚了。
  • Never mind. 没关系的
  • 词汇
    • late 迟到的
    • mind 介意
  • 活用
    • My car broke down. 我的车坏了。
    • I missed the bus/train. 我没有赶上公共汽车/地铁。
  • Sorry for keep you waiting. 真抱歉让你久等了。
  • No bit deal. 没什么的。
  • 词汇
    • wait 等待
    • deal 交易
  • 活用
    • Sorry for taking up more or your time.
      真不好意思耽误了你那么久。
    • Thank you for your flexibility.
      感谢你抽出时间来见我。

26 征求同意

  • I was wondering if I could use your computer?
    不知道我能不能用一下你的电脑?
  • yes, feel free.
    可以,你用吧。
  • 词汇
    • wonder 想知道
    • computer 电脑
  • 活用场景
    • I was wondering if
      表示委婉征求同意,行吗?可以吗?
    • I was wondering if I could park here?
      请问这里能停车吗?
    • feel free
      请随意,回答别人的询问,表示你想怎么做都可以。
  • Do you mind me opening the window?
  • No, not at all. Please do so.
  • 词汇
    • mind 介意
    • window 窗户
  • 活用
    • Do you mind…?
      委婉征求同意,表示 你不介意…吗?
    • Do you mind if open the window?
    • I feel a little chilly, please don’t.
  • Is Mike cool with us using this house?
    Mike 不介意我们借用这房子吧?
  • Relax, he would be cool with that.
    放心,他不会介意的。
  • 词汇
    • cool 赞同的
    • use 使用
  • 活用
    • be cool with 同意,赞同某事
    • I’m cool with that 我没意见/我同意

27 社交网站头像

  • Excuse me!Could you take a picture of us?
    麻烦您能帮我们拍张照片吗?
  • OKay.
    可以的
  • 词汇
    • picture 照片
    • photo 照片
  • 活用
    • Could you please 可以表示 劳驾您,麻烦您
    • take a picture/photo of 给某人或景物照相
  • Could you take one more from this angle?
    能从这个角度再帮我拍一张吗?
  • Sure.
    好呀
  • 词汇
    • angle 角度
  • 活用
    • take one more (picture) 再拍一张(照片)
  • will you take a selfie with me?
    能跟我一起拍张照片吗?
  • No problem.
    没问题
  • 词汇
    • selfie 自拍照
    • profile picture (网站个人资料) 头像
  • 活用
    • Would you mind if we take a picture together?
      请问您能跟我合个影吗?
    • Hey, let’s take a quick picture.
      咱们拍张照片吧
    • Let’s document our firendship. CHEESE!
      我们来吧友谊记录下来吧。茄子!
    • Can we take a picture? I want a new profile pic.
      咱们拍张照片吧,我想换个新头像。

28 你有空吗?

  • Do you have a minite? 你有时间吗?
  • I would like to give you my full attention.
    我很想挺你把话说完,
    May I let you know when I can do that?
    不过我们可以下次有空再说吗?
  • 词汇
    • full 完全的
    • attention 注意力
  • 活用
    • Do you have a moment? 你有时间吗?
    • Can I talk you for a moment? 我能跟你说点事吗?
    • Could I have a word with you? 我能跟你说几句话吗?
  • Can you spare me a few seconds?
    能给我几分钟时间吗?
  • I’m sorry. I’m a little busy right now.
    不好意思,我现在很忙
  • 词汇
    • spare 空出,腾出
    • second 秒
  • 活用
    • I’m in such a rush. 我正在赶时间
    • I’m rushing a meeting. 我正赶着要开会
    • Can we make it another time?
      我们下次再约个时间吧
  • Can I have Lily for a second?
    我想找 Lily 说句话。
  • OKay. 好的
  • 词汇
    • interrupt 打断(谈话)
    • mean 有意,打算做某事
  • 活用
    • Ah…Sorry to interrupt. 呃。对不起,打扰一下。
    • Umm…I didn’t mean to interrupt.
      嗯,不好意思,打扰一下。
    • May I borrow Mike for a sec?
      我想找 Mike 一下,
      I need him to check on my computer.
      我想让他检查一下我的电脑。

29 道歉了,就一定会原谅?

  • I apologize for screwing up your plans.
    对不起把你的计划打乱了。
  • I hear you.
    我知道
  • 词汇
    • apologize 道歉
    • screw up 搅乱
  • 活用
    • apologize for 为…而道歉
    • I apologize for losing my temper
      对不起,我发脾气了。
  • I’t my fault. Will you forgive me?
    是我的错,你能原谅我吗?
  • I forgive you.
    我原谅你
  • 词汇
    • fault 错误
    • forgive 原谅
  • 活用
    • I accept your apology.
      我接受你的道歉。
    • I appreciate your apology.
      很感谢你能向我道歉。
  • I feel really bad about what I just said.
    我刚才那样说,真的很抱歉
  • It’s okay. 没事的。
  • 词汇
    • feel 感觉
  • 活用
    • feel bad about 为…感到愧疚,不好意思
    • I feel bad about leaving without saying goodbye.
      我连句再见都没说,心里感觉很过意不去。
    • I feel bad about not inviting hi.
      我没邀请他,觉得很过意不去。

30 听不清,没信号

  • Hello. Could I speak to Andrew Pryce, Please?
    你好,我想找一下 Andrew Pryce.
  • He’s not here. Would you lile to leave a message?
    他现在不在。我能帮你留言给他妈?
  • Oh, yes, could you ask him to call me back?
    好的,你能转告他给我回个电话吗?
  • May I ask who is calling?
    请问你是哪位呢?
  • 词汇
    • speak 说话
    • message 消息,留言
  • 活用
    • He’s not in the office.
      他没在办公室
    • Oh, thanks. I’ll call back later
      谢谢,我一会儿再打过来。
    • He’s on another call.
      他正在打电话
  • Hey, Dane, this is Joanna. Is Linda there?
    嗨,Dane,我是 Joanna。Linda 在吗?
  • Hang on a sec.
    你等一下
  • 词汇
    • hang on 等一下
  • 活用
    • This is … 我是…(打电话时)
    • Hold on. 等一下
    • Just a minute. 等一下
    • On moment please 请稍等
    • Please hold. 请稍等
    • I’ll get her/him. 我去叫他/她。
  • Your are breaking up. I can barely here you.
    你说话断断续续的,我几乎听不见你说什么。
  • We had a bad connection. Could you say that agaain
    我们的通话质量不好,你能再说一遍吗?

202308

shell

@a_b_c 的式样

  • a:基于索引(ind)还是值(val)来排序

  • b:按字符串(str)比较,按数值(num)比较和按类型(type)比较。如果是按照类型,在升序的情况下,数值>字符串>数组

  • c:指定升序(asc)或降序(desc)

    awk ‘BEGIN{a[“AAAA”]=“4”;a[“BBBB”]=“3”;a[“CCCC”]=“2”;a[“DDDD”]=“1”;PROCINFO[“sorted_in”]=“@ind_str_asc”;for(i in a)print i,a[i]}’

    AAAA 4
    BBBB 3
    CCCC 2
    DDDD 1

清理临时文件

sudo tmpreaper 3d /tmp

java

keycloak 是一个开源的进行身份认证和访问控制的软件。是由Red Hat基金会开发的,我们可以使用keycloak方便的向应用程序和安全服务添加身份认证,非常的方便。基于 Java 开发,支持多种数据库。

https://www.jianshu.com/p/2275ae26bcd1
https://www.keycloak.org/getting-started/getting-started-zip
https://keycloak.org.cn/docs/latest/securing_apps/index.htm

fellow是什么职位

  1. 定义

在职场中,“Fellow”这个词常常被提到,特别是在高科技领域或大型科技公司中。但是究竟什么是Fellow?

Fellow一般指一家公司内部地位非常高的职位,通常是该公司的高级工程师或研究员,以及在公司的业务领域内有卓越贡献的专家或者知名人士。

  1. 符号意义

Fellow是一种荣誉职位,通常并不属于资深的管理层,但是比其他技术职位更为高级。这样的职位通常拥有许多特权,例如能够拥有极高的薪水、股票期权、和决策权等等。此外,Fellow这一荣誉称号通常是有名有姓的,可以增加其个人名望影响力。

  1. 职责与作用

作为Fellow,他们不仅需要掌握自己所擅长的技术领域,更需要关注公司在其主要业务领域中所面临的各种挑战,对公司的业务发展提供战略上的支持和帮助。此外,Fellow还通常担任公司内部的技术指导角色,他森弊梁们需要指导和协助团队内的其他工程师或研此运究人员进行技术探讨和方案设计。

  1. 如何成为Fellow

通俗的讲,成为Fellow需要具备出色的技术能力,背景广泛,创新意识强,以及在业界享有广泛赞誉。但是正如各大高科技公司都非常注重的一点,除了技术能力外,想要成为Fellow还需要在公司的其他方面拥有贡献,例如文化影响力、创新推动、团队管卜坦理等等。因此,沉淀和积累多年的技术能力,加上个人的职业发展规划,透过事业上不断的提升,才能够拥有成为Fellow的机会。

  1. 不同公司的Fellow

尽管Fellow是一种荣誉职位,但是在不同的公司内,其意义和职责并不完全相同。在一些公司,Fellow与高级工程师等级相当,只是更为高端的称号,并没有其他明显的区别;而在一些公司中,Fellow则是公司内技术发展中不可或缺的重要人才。此外,在某些公司中,Fellow可以作为公司内部层级更高的一种董事会成员,直接参与公司战略设计和管理决策。

  1. 综合展望

Fellow的职位定位非常高,拥有丰富的工作经验、专业知识和独特的技能,是公司内部顶尖的科技人才。成为Fellow不仅需要掌握技术,更需要有广阔的视野和洞察力,能够全面了解公司的业务和发展规划。未来Fellows的标准可能会更高,要想成为科技领域的佼佼者,一定需要不断地完善自己的技能和知识储备,拥有更强的团队领导和规划战略的能力。

english

While building your web application, you may have some tasks, such as parsing and storing an uploaded CSV file, that take too long to perform during a typical web request. Thankfully, Laravel allows you to easily create queued jobs that may be processed in the background. By moving time intensive tasks to a queue, your application can respond to web requests with blazing speed and provide a better user experience to your customers.

For example, you may wish to allow users to backup their data once per hour while imposing no such limit on premium customers.

python

Building LLM applications for production
https://huyenchip.com/2023/04/11/llm-engineering.html

Python高性能编程六:multiprocessing模块
https://zhuanlan.zhihu.com/p/455171966

  • 多进程中运行了一定数量的Python进程,每个进程都有自己的内存空间等,所以没有GIL竞争。而对一个进程的多线程,会存在GIL竞争而造成额外开销,于是代码运行会变慢。
  • 每当一个线程被唤醒并设法获得GIL时,就使用了系统资源。如果一个线程忙碌,那么其他线程将重复不断地唤醒并设法获取GIL,这些重复造成开销越来越大。
  • 当然,这是多线程运行于多个CPU上的问题,多线程的单核CPU没有没有GIL竞争。
  • 同样比纯Python快了很多,并且线程越多,速度基本会越快。通过工作于GIL之外,numpy能够用多线程达到更快的速度。

是时候进行OAuth 2.1了
https://zhuanlan.zhihu.com/p/553934043?utm_id=0

如果您现在想要实施安全的OAuth解决方案,则需要阅读以下内容:RFC 6749(OAuth 2.0 Core),RFC 6750(持有者令牌),RFC 6819(威胁模型和安全注意事项),RFC 8252(本机应用程序的OAuth),RFC 8628(设备授予),基于浏览器的应用程序的OAuth,OAuth 2.0安全最佳实践,RFC 7009(令牌吊销),RFC 8414(授权服务器元数据), 如果您还要实现OAuth服务器,那么您需要阅读RFC 7519(JWT),JWT Best Current Practice,JWT Profile for Access Tokens,以及我忘记的其他一些内容。

OAuth 2.1中将包含的内容的细节仍在小组内进行讨论,并将在即将举行的IETF会议的议程中。这些讨论的起点大致如下。

从 OAuth 2.0 Core、RFC 6749 开始

  • 包括 OAuth 2.0 持有者令牌,RFC 6750
  • 采用安全 BCP,这将删除密码授予和隐式流
  • 要求所有客户端类型使用 PKCE,而不仅仅是公共客户端(在安全性 BCP 中定义)
  • 采用本机应用和基于浏览器的应用 BCP
  • 包括设备授予作为可用的顶级授权选项 (RFC 8626)
  • 包括令牌吊销 (RFC 7009)
  • 包括授权服务器元数据 (RFC 8414)

如果授权服务器打算与任意资源服务器(如 OAuth 服务和开源项目)进行互操作,则还有一组附加要求,其中包括:

  • 令牌自检 (RFC 7662)
  • JWT访问令牌(当前工作组草案)
  • 智威汤逊当前最佳实践(当前工作组草案)

我们都知道OAuth2.0的授权码模式是最安全的授权模式。但在非TLS链接发生时,该模式的部分授权流程可能被拦截导致“中间人攻击”。为了防止报文被修改,在授权码的基础上附加了一个PKCE流程RFC7636用于JavaScript单页应用,后面还出台了针对移动端的PKCE规范RFC8252。

登录鉴权理论知识串讲:OAuth2、JWT、session、refresh token、SSO、OIDC、IDP…
https://zhuanlan.zhihu.com/p/573697777

OAuth, OpenID Connect(OIDC), SAML, JWT, IDP, UMA, CAS,SSO,PKCE, LDAP, kerberos

OpenID Connect(简称 OIDC)1.0 是建立在 OAuth 2.0 上的身份验证机制,它允许客户端通过授权服务对用户进行认证,以及获取用户信息。其意义主要在于以安全的方式分发用户的唯一标识(访问凭证依然是 Access Token)。
http://timd.cn/openid-connect/

  • OP:OpenID Provider,即 OAuth 2.0 中的授权服务,用于对用户进行鉴权
  • RP:Relying Part,即 OAuth 2.0 中的客户端,它从 OP 获取对鉴权信息和用户信息
  • ID Token:是一个 JWT,包含本次授权的基本信息

金融

QuantLib是基于欧美成熟金融市场开发的大型金融产品定价分析框架,其涵盖的金融工具(Instruments)主要分为四类:固定收益(Fixed Income)、期权(Option)、信贷(Credit)和通胀(Inflation)。每一个大类又包含了多个金融工具或衍生品,比如固定收益产品包括远期(Forward)、债券(Bonds)和互换(Swaps)等。

高频交易的常见策略包括,

  • 做市策略(Market Making):这种策略中,做市商手中持有一定现货,在交易所挂限价单,同时和买卖双方进行交易,为市场提供流动性。这种策略的收入包括买卖价差和交易所返佣两个部分。
  • 趋势策略(Directional):简单说就是进行价格预测。高频使用了更深度、颗粒度更细的行情,会做相对中低频更精细的预测,并且会用报撤单速度的优势,先下单来人为制造趋势。
  • 套利策略(Arbitrage):简单说就是价格回归。流动性越好的市场,具有相关性的品种、合约价差会越快消失,速度最快的玩家才可以抓住这些转瞬即逝的机会。

在国内,证券交易所不允许日内交易,没有返佣;期货交易所流动性好的品种都限制日内报撤单数量,返佣非常不稳定。扣除高频在硬件和系统开发上的投入成本,(算算GPU,万兆网卡多少钱),纯粹的高频做市策略,收益绝对没有到“暴利”的程度。

而在套利策略和趋势策略中,其实高频交易主要提供的是运算速度和交易执行速度上的优势,但是一旦策略本身研发能力跟不上,速度也不会给策略带来明显的优势。而且套利和趋势策略追求的对价格和价格关系的准确计算,并不是说做到了高频就一定能赚钱,刻意提高频率,一味追求频繁交易只会增加交易费用,增加亏损的概率。

而且,高频的一大问题是,策略的资金容量非常有限。即使策略本身收益稳定且高,绝对收益的数量也是有上限的。

一般来说,国内的高频团队,能够赚钱的,都是在趋势策略、套利策略等其他策略上也很有实力的团队,都会逐渐往大资金容量的中长周期低频策略上发展,九坤、幻方、锐天、明泓、宽德都是如此。

卷因子更需要一些计算机和数学方面的能力,目前主流的利用机器学习遗传算法发现因子,需要强大的编程方面的能力,同时也需要数理统计方面的知识对数据进行处理,对超参数进行合理预估。

链接:https://www.zhihu.com/question/314495451/answer/1046204865

我一直很好奇,高中数学考试每次145+的人怎么做到的? - 川上老师的回答 - 知乎
https://www.zhihu.com/question/525449367/answer/2963025237

总结:
①计算能力★
②预习课本
③刷题
④广泛学习课外知识
⑤做题习惯好——心态好,稿纸、卷面工整
⑥考试合理分配时间
⑦检查考试卷——新法重做/逐步检验
⑧适当投机取巧
⑨不要懒惰,反复巩固

庄家能把散户看透到什么地步? - 酒馆的投资笔记的回答 - 知乎
https://www.zhihu.com/question/435574315/answer/2978606013

1、世人都有贪嗔痴,行情上涨总是想多赚点,行情一跌就开始装死,不愿意认输。好不容易解套,直接就成了放牛娃。在这个市场当中,如果你没有原则,你一定会被庄家左右,被自己的情绪左右,我的原则是每次亏损不超过本金5%,如果盈利则至少要10%,一旦10个点以上盈利开始回吐,至少要保证当笔交易不能亏损出局。这样即便你的胜率只有50%,100次,你的收益也将达到800%,难吗?难的是人的贪婪和恐惧,知行合一。

2、集中投资,学会空仓。散户的最大痛点:不会空仓,弱势亏损补仓,本金少股票多,亏损死扛,100万以下不宜超过3只股,把那些大级别均线系统向下的,股性不强,不在主流赛道的股票去掉,认错,可能对于你来说需要很大的勇气,但是承认自己的错误,是我们成功的开始。会买的是徒弟,会卖的是师父,会空仓的是祖师爷。当行情不好的时候,一定要能管住自己的手。而当你真正看好的时候,要敢于重仓,其实投资市场绝大部分盈利都是来自于几只好股票。我的持仓从来不超过3只,哪怕是在牛市。

3、我自始至终觉得成交量这个指标非常重要,学会这点你将碾压80%的交易选手。量比小于0.5,属于明显缩量,缩量能创新高,说明主力高度控盘,而且可以排除主力出货的可能,如果正好处于上升通道,则吃肉的概率极大。如果股票涨停,量比小于1,说明还有较大的上涨空间,次日再次涨停的概率极大,如果量比大于1.5,而且突破某个重要阻力位(比如20日均线)之后缩量回调的个股,是不可多得的买入对象。

4、暴跌是检验股票的试金石,牛市里行情暴跌意味着抄底的机会,也是选股的好时机,如果大盘暴跌,你的股票微跌甚至不跌,那明显是有资金抱团,拒绝下跌,所以这种票可以放心持有,必有回报。如果大盘暴跌,你的票大跌,第二天大盘涨它暴涨,这很可能是主力借大盘下跌洗盘,股性不错,这种票你可以在大盘暴跌时买入,大盘涨的时候出,短线反弹套利。

5、趋势为王,顺势而为。趋势一旦形成,不用多分析,必须跟随,跟着资金走,不猜,不预测,不假设,如果你不会判断趋势,你就看均线,所谓均线,就是把行情划分为多头和空头,多头就是向上,空头就是乡下,短线你就看5日均线,放量突破,你就跟进,中长线趋势你就看20日均线,放量突破你就进,破则出。

6、把握情绪冰点。大盘每天都有自己的情绪,大部分时候,盘中会出现一些情绪“冰点”,可能是在开盘,可能是开盘一段时间后的分歧点,也可能是下午,或者是尾盘,总之,每天的盘面几乎都有情绪冰点。这个时候往往会选择在冰点进行出手,因为冰点恰好可以考验出个股强弱,这样往往能够获得被情绪带下来的恐慌筹码,也能够有效避免追高。

7、懂得看题材:消息面、主线,资金,承接力度。消息是最能刺激行情的催化剂,这是短线选手必须要关注的点,主线就是市场最热门的方向,比如2021年的新能源、2022年的新冠药概念;资金主要看主力净流入,承接力度指的是板块的持续性,是否有资金愿意去抬轿形成合力。

8、做短期强势股要关注量能和换手率:大涨的时候,必须是放量的,说明有资金介入,看好未来的走势;另外,一般当天涨幅大于5个点以上,换手率不要低于5%,但最好不要超过30%,这些都是多年经验的总结,不信大家可以去观察最近的强势股走势,你会给我点赞的。

9、倍阳缩倍阴是非常靠谱的起涨形态,什么叫倍阳缩倍阴?就是大涨的当天是放倍量的,隔天的阴线量能缩一倍。但值得注意的是,回调没有破第一天大阳线的底部,随后出现小阴小阳的K线就是绝佳的进场机会,后市爆发力极高!

10、投资源于生活,从细节中寻找机会,看一个公告要从点推面。资金介入的逻辑是赚钱,赚钱的逻辑是价值,价值的逻辑是商业行为的落地。所以,思考的方向是消息面 - 逻辑面 - 资金面 - 技术面 – 分时盘口,从生活的案例中提炼出精华。

11、长线思维。看长做短,意思是你不一定要长期持有一个票,但是一定要有这种思维,所谓长线思维指的是你要有自己操作模式,不要人云亦云,坚持自己的思路,不断完善,你才能够稳定获利,精益求精。

12、大赚之后要学会空仓,散户大赚之后往往就会骄傲,然而骄兵必败,厉兵秣马再战,商品是有时间周期的,大赚以后会忘记时间的价值,当一个人成功一次后会增加自信心,连续成功便会自信心爆棚,对自己的判断是百分百认可,看好一个股就立马买了,如果买错了但小亏并不会让自己的信心减少多少,只有直到大亏时才会使信心大幅下降,当信心下降后,出手便会容易变形!不要妄想抓住每个版块的机会,同时追两只兔子的人,一直也会逮不到!

13、交易越是不顺的时候,越要沉住气,艰难的路不是谁都有资格走的,扛得住涅槃之痛,才配的上重生之美。股市就是这样,当赚钱效应出来的时候赚钱很容易。当亏钱效应出来的时候亏钱也很容易,关键点在于勇于出手和即时收手。

14、“一将功成万骨枯”,炒股其实是很血腥的,一赚二平七亏,是这个市场唯一不变的真理。我认识的很多股市高手,都会研究佛学,每一波大的行情,无论是上涨还是下跌,我们都会选择去放生,我知道这毫无意义,但求念头通畅。如果有一天大家都成功的时候,一定要记得做一些对社会有意义的事情!佛系点说这是因果,正经点说达则兼济天下!

以上都是我炒股16年实践经验和技术的总结,不一定适用每个人,需要每个人结合自己的实践去使用总结,作为交易者,最可怕的不是你技术上存在问题,而是你的认知不够,掉进了这些交易陷阱却不自知!没有无敌的交易系统,只有无敌地使用交易系统的人!这是真理,交易系统最终要回归到人身上!

个人维护一个20%收益的低频量化策略,难度有多大?现实吗? - quantkoala的回答 - 知乎
https://www.zhihu.com/question/270964258/answer/3138383627

前端

前端Web实战:从零打造一个类Visio的流程图拓扑图绘图工具
https://blog.csdn.net/Alsmile/article/details/131725305

其它

高中数学学那么多三角函数公式到底有什么用? - 吾欲揽六龙的回答 - 知乎
https://www.zhihu.com/question/62411548/answer/2572017203

Flink-Table API(概念、基础操作、流表转换)
https://www.cnblogs.com/EnzoDin/p/16743404.html

个人做量化交易靠谱吗? - 金融圈笛子的回答 - 知乎
https://www.zhihu.com/question/329206671/answer/2363335984

指数增强策略里最重要的一块是因子投资,也就是我们通过一定的标准,选出能够跑赢指数的股票组合。在海外几十年的历史中,人们总结了四大跑赢指数的因子:

  • 价值,也就是认为,低市盈率的公司可以跑赢高市盈率的公司。
  • 质量,也就是现金流好,负债率低的公司,可以跑赢现金流差,负债率高的公司。
  • 规模,也就是小盘股可以跑赢大盘股。
  • 动量,也就是过去强势的公司,在未来会跑赢过去弱势的公司。

量化交易都有哪些主要的策略模型? - 金融圈笛子的回答 - 知乎
https://www.zhihu.com/question/24179101/answer/2188611287

个人做量化交易靠谱吗? - 泛程序员的回答 - 知乎
https://www.zhihu.com/question/329206671/answer/2079148606

对于实时性不敏感的策略,再更一个散户白嫖AWS的信息。我有几个日内策略(1分钟蜡烛图)的策略是用AWS Lambda + DynamoDB + S3 + CloudWatch 实现的。因为aws每个月都有一定的免费额度,特别是lambda额度很大。。那几个策略就是白用的状态。因为是日内1分钟策略,每天的Lambda运算量只有几千秒,远远达不到aws收费限额。。。但是lambda省心,不用维护不用停机。。就这么省心。DynamoDB用来维护状态,因为lambda是无状态的,也是免费用。S3用来维护一些历史数据,定期清理,一个月0.2美金。。。就这样跑了大半年,没有出过任何问题。。日常交易、警报直接通过lambda发邮件过来。。。挺舒心的。。。

夏普率

  • 你实盘夏普超过1后,通常已经有比较好的框架了:包括资产配置和风险控制。
  • 且做到夏普过1,已经旱涝保收了,说实话,已经超过许多所谓“专家”了。
  • 夏普1的意思就是长期看,你每承担的1分风险,换得了1分回报,很公平。
  • 在这之前,没必要投资研究更好的回测系统和交易系统。
  • 如果你做了几年实盘,夏普低于0.7,请不要再做了。

交易中的高手高在哪里? - 道行天的回答 - 知乎
https://www.zhihu.com/question/322969695/answer/2945988471

要入行机器学习是不是非学数学不可?要学到什么程度,如何才能提高数学水平? - 生姜DrGinger的回答 - 知乎
https://www.zhihu.com/question/597884858/answer/3002690154

举个例子,仅仅满足调用Python机器学习、深度学习的包,比如SK-learn、PyTorch,是不够的。
为了调参,为了解释结果,也需要大家理解机器学习算法的底层数学知识。
这些数学基础大致可以分成如下几个板块:

  • 微积分(比如,向量微积分中的梯度、黑塞矩阵)
  • 线性代数(比如,向量空间、特征值分解、奇异值分解)
  • 概率统计(比如,最小二乘法、多元统计、多元高斯分布、最大似然估计MLE、贝叶斯推断、最大后验估计)
  • 数值与优化(比如,极值、数值微积分、拉格朗日乘子法、基于梯度的优化方法、遗传算法)

为了学习深度学习,大家当然可以进一步学习随机过程、自动微分、信息论、图论等内容。

对于国内理工科同学来说,虽然数学三件套(微积分、线性代数、概率统计)学了很多数学工具,但是想要入门机器学习,现有的数学三件套的知识体系已经很落后“时代需求”。

  • 微积分:过度一元,极少多元
  • 线性代数:为什么要那么强调行列式?
  • 线性代数:为什么不联系数据、几何、多元微积分、优化、统计?
  • 概率统计:太多一元,极少多元
  • 概率统计:太多频率派,极少贝叶斯派
  • 贝叶斯统计推断更靠近“人脑思维”模式

线性代数是现代计算的核心。最应该强调“多视角”,比如数据视角、几何视角、空间视角、优化视角、统计视角等等。“多重视角”把代数、线性代数、几何、解析几何、概率统计、微积分、优化方法等编织成一张绵密的网络。

为什么全世界都在加息,而中国却在减息,有金融大神科普一下吗? - 佐伊24的回答 - 知乎
https://www.zhihu.com/question/559951607/answer/3126681915

链接:https://zhuanlan.zhihu.com/p/439091470
分享的小白避免踩坑六大神句,分享给大家:

  • “长期持有”
  • “减少操作”
  • “大类配置”
  • “分散持仓”
  • “坚持定投”
  • “选基选人”
  • 用“选基选人”“分散持仓”规划自己的收入来源,让自己既有稳定的主业收入,也有爱好和投资收入,让自己接下来的人生选择更有底气。
  • 用“长期持有”“大类配置”去设定自己的人生目标,做长期主义者。
  • 用“减少操作”“坚持定投”去远离浮躁,一点点收获成长,实现自己的人生目标。
  • End~

在股市里怎么跑赢90%以上的股民? - 渔人日志的回答 - 知乎
https://www.zhihu.com/question/413391595/answer/2585672232

所有的指标都是事后诸葛,唯有成交量和换手率是一个例外,这两个指标都是真金白银堆出来的

3分钟”战胜“市场:一个简单的投资组合 - 泛程序员的文章 - 知乎
https://zhuanlan.zhihu.com/p/249909117

  • 如果你在开发新策略,至少需要检测两个参数,即 sharpe 和 相关性。
  • 即使新策略的sharpe超过了1.1,如果与市场相关性过高,那么并不一定是好的策略。
  • 相反的,即使新策略sharpe没有很好,但是相关性非常低,那么这个新策略就可以与市场形成一个新的投资组合,进而实现更高的sharpe。

看哪些纪录片可以提高认知? - 似舟的回答 - 知乎
https://www.zhihu.com/question/599621146/answer/3059427656

1《隐姓亿万富豪》

有自己的量化模型,可以提供两年实盘交易记录,如何找投资? - Spectre的回答 - 知乎
https://www.zhihu.com/question/561140482/answer/2958575664

其次是国内的公司quant思路,主流的就是高频交易、因子选股、日内交易,基本不会做低频CTA、统计套利和宏观对冲。

说说你的日内交易策略是什么? - 郑多多的回答 - 知乎
https://www.zhihu.com/question/42126058/answer/3046718478

  • 波动率突破,除了突破多空信号之外,还可以在波动线和加仓信号进场,日内交易机会很多。
  • 大部分行情都是震荡行情,利用成交量加权平均价通道来确定日内压力和支撑,如下图所示,能比较好的做好止盈和止损。
  • 主图粗线为vwap成交量加权平均价,上下沿分别为1和2单位的ATR标准差,视作支撑和压力

fin tune
https://mp.weixin.qq.com/s/4v45pshI8wwvMXPpBEPAQw

海龟交易策略使用了什么量化交易模型? - 李奇的回答 - 知乎
https://www.zhihu.com/question/495850466/answer/2207096515

深度学习做股票预测靠谱吗? - Spectator的回答 - 知乎
https://www.zhihu.com/question/54542998/answer/2867826714

线性代数到底是什么? - AK Fourier的回答 - 知乎
https://www.zhihu.com/question/489470968/answer/3117627141

「成考」和「自考」的区别是什么? - 自考上岸锦鲤的回答 - 知乎
https://www.zhihu.com/question/21912024/answer/2611884601

jstack命令详解 - 知乎用户BgiUTI的文章 - 知乎
https://zhuanlan.zhihu.com/p/475571849

终极找 bug 大法 - 二分
https://segmentfault.com/a/1190000041400805

https://www.51cto.com/article/677058.html
安全 | 零知识证明是零信任吗?

java 应用 cpu 过高故障排查
https://blog.csdn.net/qq_41538097/article/details/131842679

  • 查看进程下的线程详情 top -H -p 11748

  • 将线程 12240 的 pid 转为 16 进制 printf “0x%x\n” 12240

  • 使用 java jdk 下自带的 jstack 查看进程的快照 jstack 12227|grep -A 20 0x2fd0

  • GC问题:

    • top+top -Hp + jstack排查是"VM Thread"消耗过多资源,可以进一步使用jmap工具进行内存溢出排查。
  • 业务执行过慢问题:

    • top+top -Hp + jstack排查发现是普通业务线程,可看到具体是哪个接口。
  • 死锁:

    • jstack + Java进程打印堆栈信息中包含死锁信息deadlock
  • 线程处于waiting状态:

    • 多打印几次jstack信息,对比一直停留在waiting状态的线程。

原文链接:https://blog.csdn.net/wx17343624830/article/details/130946645

Java解决HTTP请求异常的方法
http://news.558idc.com/617235.html

  • 连接超时异常(ConnectTimeoutException):当HTTP请求连接超时时抛出此异常。通常是因为连接到外部系统花费的时间超过了预定的最大连接时间。
  • 请求超时异常(SocketTimeoutException):当HTTP请求发送后,在指定的时间内没有得到响应时,会抛出此异常。通常是由于外部系统处理请求的时间过长或者响应消息丢失造成。
  • 无法建立连接异常(ConnectionRefusedException):当向外部系统发起连接请求时,被拒绝连接时会抛出此异常。通常是由于外部系统关闭或者未启动。
  • 主机不可达异常(UnknownHostException):当通过域名解析得到的IP地址无法与目标主机建立连接时,会抛出此异常。通常是由于网络不可达或者域名解析错误引起。
  • SSL证书异常(SSLHandshakeException):当与外部系统进行HTTPS通信时,验证SSL证书失败时会抛出此异常。通常是由于证书过期、证书不受信任或者证书链不完整等原因引起。

Analysis of HTTP Performance problems
https://www.w3.org/Protocols/HTTP-NG/http-prob.html

Timing breakdown phases explained
https://developer.chrome.com/docs/devtools/network/reference/?utm_source=devtools#timing-explanation

有适合于2万元(人民币)以内小资金的股票量化策略吗? - 徐西摩的回答 - 知乎
https://www.zhihu.com/question/436291669/answer/3101205205

【105】因子择时到底行不行? - llanglli的文章 - 知乎
https://zhuanlan.zhihu.com/p/632461153

【量化课堂】多因子策略入门
https://www.joinquant.com/view/community/detail/fd9bf8d85320864d6718ed35e16d4c6a

二分查找 1000万数据和二分查找 500 万数据的速度变化

$ python3
Python 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import timeit
>>> timeit.timeit('bisect.bisect(a,3)', 'import bisect;a = list(range(10000000))')
0.40884770452976227
>>> timeit.timeit('bisect.bisect(a,3)', 'import bisect;a = list(range(10000000))')
0.4190584868192673
>>> timeit.timeit('bisect.bisect(a,3)', 'import bisect;a = list(range(10000000))')
0.3647211641073227
>>> timeit.timeit('bisect.bisect(a,3)', 'import bisect;a = list(range(5000000))')
0.3612236827611923
>>> timeit.timeit('bisect.bisect(a,3)', 'import bisect;a = list(range(5000000))')
0.354061558842659
>>> timeit.timeit('bisect.bisect(a,3)', 'import bisect;a = list(range(5000000))')
0.35363607108592987

分区问题

一个表,8000万数据,有三列 id, user_id, created_at,物理设备就一块磁盘。

常用查询(需保证速度): select count(*) from t where user_id = xxx;
不常用的查询(慢点无所谓): select count(*) from t where created_at > '2023-08-06';

A 方案是就存单表,在user_id和created_at上加索引。
B 方案是根据 user_id 分成 5 个 hash 分区,user_id 和 created_at上依旧有索引。

只说常用查询,问 B 方案比 A方案性能快很多吗?为什么?

原文链接:https://blog.csdn.net/Hmj050117/article/details/121349435

指针数如何计算?
假设主键ID为bigint类型,长度为8字节,而指针大小在InnoDB源码中设置为6字节,这样一共14字节。

那么一个页中能存放多少这样的组合,就代表有多少指针,即 16384 / 14 = 1170。那么可以算出一棵高度为2 的B+树,能存放 1170 * 16 = 18720 条这样的数据记录。

同理:
高度为3的B+树可以存放的行数 = 1170 * 1170 * 16 = 21902400

千万级的数据存储只需要约3层B+树,查询数据时,每加载一页(page)代表一次IO。所以说,根据主键id索引查询约3次IO便可以找到目标结果。

金融里的IR和IC是什么

  • IC即信息系数(Information Coefficient),表示所选股票的因子值与股票下期收益率的截面相关系数 ,通过IC值可以判断因子值对下期收益率的预测能力。
  • 当IC的绝对值大于0.05时,因子的选股能力较强,当IR大于0.5时因子稳定获取超额收益能力较强
  • IR即信息比率(Information Ratio),是超额收益的均值与标准谁差之比,IR=IC的多周期均值/IC的标准谁方差,代表因子获取稳定Alpha的能力。

指数列表
https://www.joinquant.com/data/dict/indexData

只要三步,就能让你找到买了就会涨的股票! - 笑看人生886的文章 - 知乎
https://zhuanlan.zhihu.com/p/532831538

SVM 讲解
机器学习在量化交易上有应用吗,效果怎么样? - quantkoala的回答 - 知乎
https://www.zhihu.com/question/534980414/answer/3089883071

求期权的卖方策略,让资金取得长期稳定的低风险高收益? - 東雲的回答 - 知乎
https://www.zhihu.com/question/581979454/answer/2877622828

快速了解 OpenAI 的 fine-tune 和 Embedding 能力 - 人类观察所主任的文章 - 知乎
https://zhuanlan.zhihu.com/p/609359047

https://blog.csdn.net/weixin_39199838/article/details/130810313
利用openai的Chat-3模型fine-tuning训练自己的模型

这四个模型的成本差异比较大,给个直观的示例:我自己准备的10条文本数据(csv文件大小18K)用davinci训练花费是$1.56。

ChatGPT背后的技术-基于人类反馈的强化学习(RLHF)
https://zhuanlan.zhihu.com/p/616708590

OpenAI API (三)Fine-tuning
https://zhuanlan.zhihu.com/p/648714349

一句话解释,Fine-tuning就是在基础模型上根据新的数据训练出自定义模型。

通过Fine tuning,您可以从API提供的模型中获得更多好处,包括:

  • 比提示设计更高质量的结果
  • 能够训练超过提示所容纳的更多示例
  • 由于较短的提示而节省tokens

训练样本越多,效果就越好。数据集大小每翻倍,模型质量线性增加。

数云融合|探究GPT家族的进化之路:GPT-3、GPT-3.5和GPT-4的比较分析
https://zhuanlan.zhihu.com/p/616691512

OpenAI的GPT1,GPT2,GPT3,GPT4系列的模型概览
https://zhuanlan.zhihu.com/p/650057910

AI Canon
https://a16z.com/2023/05/25/ai-canon/

AI Linkedin Post Generator
https://taplio.com/generate-linkedin-posts

为什么有人不愿意承认能上985/211的大多是智商高的? - 走心小哥的文章 - 知乎
https://zhuanlan.zhihu.com/p/561073604

你在国内亲眼见过自己一个人全职做 量化交易、并比同等相近能力的上班族赚得多很多的人吗? - 金融圈笛子的回答 - 知乎
https://www.zhihu.com/question/360042171/answer/2415198507

你在国内亲眼见过自己一个人全职做 量化交易、并比同等相近能力的上班族赚得多很多的人吗? - 知乎
https://www.zhihu.com/question/360042171/answer/1989559460

交易产生手续费一万块,交易所返7500到期货公司,期货公司拿到这个钱,首先要交掉大约6.7%左右的税,这个是没办法免的,这以后才给你返90%或95%,事实上你到手的返佣/你交出去的手续费,大概就是50~60%这样。上期所会高很多,INE会低很多。当然这个月INE90%了,综合返率本月会上到70%+

托管机房里机器到交易所的RTT也就350us左右,标准差没几个us。

高频看不看K线,就跟造房子看不看牛顿三定律一样。K线是基石,但过于基础了,现在的做法已经在K线、微观之上,叠了太多太多太多的东西了,绝不是“肉眼看K线形态”这种电视股票脱口秀的东西了。

请教您行情源您用的是哪个呢?我不太懂,难不成您是用的ctp,然后直接tcpdump抓包,分析协议以后再进fpga处理?
直接交易所进期货公司第一级交换机的镜像数据。如果你也是同行,详询期货公司,这个现在已经普及了。

Elasticsearch:普通检索和向量检索的异同?
https://ost.51cto.com/posts/11561

如果你在搜索时不知道确切的query 词元,或者你希望能对更广泛的同/近义词所指向的内容进行召回,可以考虑通过向量搜索来完成
他们大多会具有以下一些特点:

1.较慢的索引速度
2.较大的索引大小
3.较慢的查询速度(在大数据量的场景)
4.限的缩放比例
5.(对于精确匹配)具有较低的精度
6.较差的词元和词组的搜索能力
7.通过向量(某些解决方案中可以包含一部分标量字段)进行召回
8.对近似语义的捕获程度较高,可以很好的处理同/近义词

OpenAI的新功能:Function Calling - BitByBit的文章 - 知乎
https://zhuanlan.zhihu.com/p/637107426

202307

english

余光中:怎样改进英式中文?- 论中文的常态与变态
https://open.leancloud.cn/improve-chinese/

前谷歌工程师的英语频道
https://www.youtube.com/watch?v=pDehb5xQfWc

英语口语教程
https://www.youtube.com/@SpeakEnglishWithTiffani/videos

https://engineering.linkedin.com/blog/2021/leveraging-behavior-analytic-computation-for-anti-abuse-defenses

Behavior analytic computation, on the other hand, can provide high quality features for bot-driven attacks without collecting extra user data.

The idea of behavior analytic computation is to capture the key bot/automation signatures hidden among the existing feature values or numbers—these signatures can be preserved even if the features are constantly changed.

It intelligently utilizes simple arithmetic and logarithmic operations to transform existing features into more robust ones in constant time.
Two key operations of behavior analytic computation are ratio and logarithm.
Ratio can capture the relative change of numbers instead of absolute numbers;
logarithm can amplify particular ratio values that differentiate bot/automation traffic and human traffic patterns.

When two features are independent of each other, statistically we will see some kinds of natural distributions between them.
Assuming X and Y are two feature types, xi and yi are values of the feature, respectively.
When a particular value x1 is selected and the request numbers from top values of Y within a certain time period are sorted descendingly, the distribution of different yi count can be obtained.

Another example where behavior analytic computation can contribute is by improving the quality of counters.
Counters are commonly used against large-scale abuse,
as higher counter values typically reflect the likelihood of automation-driven abuse.

However, certain behavioral and structural information that is not captured by counters will also be missed by models if only typical counters are used as the features.

Fig. 2 shows two examples of the requests from a single user within one hour where the x-axis is time and y-axis is the request index.

The counter values for both cases are identical, but different behaviors are shown.

While there is no obvious automation evidence found on Fig a, the requests on Fig b contain certain regular patterns indicating automation behind the scenes.

Behavior analytic computation again captures such a plot signature into a single automation score where more human-like plots (Fig. 2(a)) have lower scores and automation-like plots (Fig. 2(b)) have higher scores.

The extracted score is able to capture the key automation pattern even if users constantly adjust different regularities within the same time period.

The same lightweight computation continues to provide speed and flexibility to the defense.

More importantly, the extracted automation score is able to fill the gap where typical counters fail to differentiate between human requests or bot-driven automation requests at low counting numbers.

Due to its capability to detect low-frequency automation, this extracted automation score has almost doubled our machine learning model recall on detecting automation-driven abuse at LinkedIn.

Overall, we are able to leverage behavior analytic computation for our anti-abuse defense from three different aspects:

Behavior analytic computation can capture automation signatures as robust features,
thus improving model and rule resilience against fast-changing attacks.
When defending against an actual dynamic attack,
the extracted feature can bring significant robustness improvements

  • greatly extending the time of protection by more than two orders of magnitude.

The other key merit of behavior analytic computation is the ability to expand abuse labels.
The typical anti-abuse defense is based on supervised models.
However, for many bot-driven abuse types, such as scraping or account takeover,
often only a small portion of all abusive requests/users are labeled,
which limits the effectiveness of the models.

Behavior analytic computation
provides an unsupervised approach
where each extracted automation signature
can perform as an automation detection classifier.
Those signatures have helped
expand the overall recall
when defending against bot-driven large-scale attacks
in many abuse verticals at LinkedIn.

Overall, we are able to
leverage behavior analytic computation
for our anti-abuse defense
from three different aspects:

As bad actors can
persistently adapt to penetrate existing defenses
and additional applications on the platform
can provide entry points
for new abuse scenarios,
anti-abuse defense
inevitably needs to continually handle
new abuse scenarios and behaviors.

Quick turnaround to the new abuse activities
becomes critical to properly contain the overall damage.
Unlike other robust features,
such as browser or device fingerprinting,
which often require longer engineering time and higher cost to onboard,
behavior analytic computation
can provide a prompt response
to evolving attack signals
to mitigate the threat.

When facing new abuse scenarios
where early assessment of existing features
is critical to define anti-abuse strategy,
behavior analytic computation’s lightweight extraction
can also offer fast offline analysis
and quick preliminary defense onboarding.

Bad actors will always continue to change
and evolve their behaviors,
so resilience of the defense and fast turnaround
are essential to ensure long lasting anti-abuse success.
Behavior analytic computation is a newer concept
that offers a lightweight and quick defense onboarding
based on existing features,
while preserving member privacy.

The extracted automation signatures
can not only enrich the feature set,
enhancing defense robustness,
but also provide expanded abuse labels
to significantly improve incident response time and coverage
for large-scale bot-driven attacks.

Fighting abuse at LinkedIn
is an ongoing effort
requiring extensive collaboration
between multiple teams.
I would like to acknowledge our partners from the following teams,
without whom this would not have been possible:

架构

技术架构评审需要考虑的问题-朱晔

  • 组件选型
    • A 不是开源的,出了问题怎么办?
    • B 虽然是开源的,但是是 Erlang 写的,公司没人能看懂怎么办?
    • C 我看待解决的 Issues 还有很多,有没有去了解过?
    • 这个组件在性能方面你是否了解过?
    • 开源的免费版本不支持集群怎么办?
    • 如果彻底要自己写这个组件有没有可能性?
  • 性能
    • 整体设计上会做到的 TPS、QPS 和 RT 是多少?
    • 随着数据量的增大系统性能会不会出现明显问题?
    • 系统哪个环节会是最大的瓶颈?
    • 是否打算做压力测试,压力测试方案是怎么样的?
    • 怎么提高前端用户的访问流畅性?
  • 可伸缩性
    • 每一个环节是否都是可以横向扩展的?
    • 扩容需要怎么做手动还是自动?
    • 数据库不能横向扩展怎么办?
    • 纵向扩展有多少效果?
    • 横向扩展是否是线性的?
    • 扩展后是否可以提高响应速度?
  • 灵活性
    • 是否有了解过产品层面以后会怎么发展?
    • 模块 A 是否能拆分出去独立为其它业务服务?
    • 模块 B 是否可以替换为另一种第三方数据源?
    • 如果流程有变,需要多大的工作量来适应?
    • 业务是否可以做到可配?
  • 可扩展性
    • 为什么 A 和 B 都有差不多的逻辑?
    • 是否考虑到了 A 业务的实现以后还有 B 的可能性?
    • 如果现在有两种策略以后扩展到了八种策略怎么做?
    • 以后是否可以把这个业务的 H5 前端适配到 PC?
  • 可靠性
    • 是否架构中有单点?
    • 故障转移是怎么实现的?
    • 集群内部故障转移需要多久?
    • MQ 或存储出现问题的时候系统会怎么样?
    • MQ 或存储出现问题又恢复了系统是否会自己恢复?
    • 是否考虑过异地故障转移的方案?
    • 是否考虑过多活的方案?
    • 是否有数据丢失的可能性?
    • 数据丢失后是否可以恢复?
    • 系统彻底挂了对其它业务的影响是什么?
    • 系统彻底挂了是否可以有线下的方式走业务?
  • 安全性
    • 是否彻底避免 SQL 注入和 XSS?
    • 是否做了风控策略?
    • 是否有防刷保护机制?
    • 数据库拖库了会怎么样?
    • 是否有数据泄露的可能性?
    • 数据的权限怎么控制的?
    • 功能的权限是怎么控制的?
    • 是否做了日志审计?
    • 受到了 DDOS 攻击怎么办?
    • 数据传输是否加密验签?
  • 兼容性
    • 老的系统打算怎么办?
    • 怎么进行新老系统替换?
    • 新老系统能否来回切换?
    • 别的系统怎么连接你这套新服务?
    • 上下游依赖是否梳理过,影响范围多大?
    • 上下游改造的难度怎么样?
    • 上下游改造有排期吗?
    • 上下游改造的计划和通知时间确定了吗?
    • 使用了新的数据源数据怎么迁移?
    • 使用了新的技术老项目开发能否适应?
  • 弹性处理
    • 这个数据重复消费会怎么样?
    • 这个接口重复调用会怎么样?
    • 是否考虑了服务降级?哪些业务支持降级?
    • 是否考虑了服务熔断?熔断后怎么处理?
    • 是否考虑了服务限流?限流后客户端表现怎么样?
    • 队列爆仓会怎么样?
    • 是否考虑了隔离性?
  • 事务性
    • 这段业务由谁保证事务性?
    • 数据库事务回滚后会怎么样?
    • 服务调用了失败怎么办?
    • 队列补偿怎么做的?
    • 服务调用补偿怎么做的?
    • 数据补偿实现最终一致需要多久?
    • 在数据不完整的时候用户会感知到吗?
  • 可测试性
    • 测试环境和线上的差异多大?
    • 是否支持部署多套隔离的测试环境?
    • 是否打算做单元测试,覆盖率目标是多少?
    • 测试黑盒白盒工作量的比例是怎么样的?
    • 是否支持接口层面的自动化测试?
    • 是否有可能做UI自动化测试?
    • 压测怎么造数据?
    • 是否可以在线上做压测?
    • 线上压测怎么隔离测试数据?
    • 是否有测试白名单功能?
  • 可运维性
    • 每一个组件对服务器哪方面的压力会最大?
    • 重新搭建整套系统最快需要多少时间?
    • 系统是否可以完全基于源代码构建?
    • 系统是否有初始化或预热的环节?
    • 系统里哪些环节需要人工参与?
    • 数据是否需要定期归档处理?
    • 会不会有突发的数据量业务量增大?
    • 随着时间的推移如果压力保持不变的话系统需要怎么来巡检和维护?
    • 怎么在容器里进行部署?
  • 监控
    • 业务层面哪些指标需要监控和报警?
    • 应用层面系统内部是否有暴露了一些指标作监控和报警?
    • 系统层面使用的中间件和存储是否有监控报警?
    • 是否所有环节都接入了全链路跟踪?
    • 出现报警的时候应该由谁来处理?
    • 每一个模块是否有固定的主要和次要负责人?
    • 有没有可能系统出了问题无法通过监控指标体现?
    • 哪些指标需要上大屏由监控进行7*24监控?

mysql

使用delete删除mysql数据的时候,mysql并没有把数据文件删除,而是将数据文件的标识位删除,没有整理文件,因此不会彻底释放空间。被删除的数据将会被保存在一个链接清单中,当有新数据写入的时候,mysql会利用这些已删除的空间再写入。即,删除操作会带来一些数据碎片,正是这些碎片在占用硬盘空间。 -

optimize table table_name
alter table table_name engine=engine_name

该方法通常用于切换表的引擎,例如MyISAM转为InnoDB,但是同样适用于释放表空间,只不过切换后的引擎和原来的engine相同罢了。

注意事项

  • 这两种方式都适用于我们常用的表,myisam和innodb。
  • 优化表的时候会锁表,数据表越大,耗时越长,因此不要在网站忙时进行表优化。

MySQL进阶三板斧(三)看清“触发器 (Trigger)”的真实面目
https://zhuanlan.zhihu.com/p/158670286

How to detect rows with chinese characters in MySQL?
https://stackoverflow.com/questions/9795137/how-to-detect-rows-with-chinese-characters-in-mysql

Notice the Chinese Character is from E4 to E9, hence we use the code

select number 
from Chinese_Test
where HEX(contents) REGEXP '^(..)*(E[4-9])';

python

如何使用Python画QQ图
https://blog.csdn.net/neweastsun/article/details/125859614

import numpy as np

np.random.seed(0)
data = np.random.normal(0,1, 1000)

import statsmodels.api as sm
import matplotlib.pyplot as plt

fig = sm.qqplot(data, line='45')
plt.show()

QQ 图的 X 轴是理论分位数,这意味着显示不是实际数据,而是实际数据在正态分布下的位置。
Y 轴显示实际数据。这意味着如果数据值沿45度角的大致直线下降,那么数据分布服从正态分布。

一文让你彻底搞懂最小二乘法(超详细推导)
https://blog.csdn.net/MoreAction_/article/details/106443383

用Python实现最小二乘算法
https://zhuanlan.zhihu.com/p/115648166
https://blog.csdn.net/weixin_43693650/article/details/120295362
https://blog.csdn.net/weixin_44231148/article/details/107149604
https://www.cnblogs.com/NanShan2016/p/5493429.html

from scipy.optimize import leastsq

def fun(p,x): #回归模型函数
    k,b = p
    return k*x+b

def error(p,x,y): #误差
    return fun(p,x)-y

p0 = np.array([1,3])
para = leastsq(error,p0,args=(Xi,Yi))

k,b = para[0]
  • 现实生活中我们可以利用最小二乘法解决更为复杂的问题。
  • 比方说有一个未知系数的二元二次函数 f(x,y)=w0x^2+w1y^2+w2xy+w3x+w4y+w5,这里 w0~w5 为未知的参数,为了确定下来这些参数,将会给定一些样本点 (xi,yi,f(xi,yi)),然后通过调整这些参数,找到这样一组 w0~w5,使得这些所有的样本点距离函数f(x,y)的距离平方之和最小。
  • 至于具体用何种方法来调整这些参数呢?有一种非常普遍的方法叫“梯度下降法”,它可以保证每一步调整参数,都使得f(x,y)朝比当前值更小的方向走,只要步长 α 选取合适,我们就可以达成这种目的。
  • 而这里不得不提的就是神经网络了。神经网络其实就是不断调整权值 w 和偏置 b,来使得cost函数最小,从这个意义上来讲它还是属于最小二乘法。
  • 更为可爱的一点是,神经网络的调参用到的仍是梯度下降法,其中最常用的当属随机梯度下降法。
  • 而后面伟大的 bp 算法,其实就是为了给梯度下降法做个铺垫而已,bp 算法的结果是 cost 函数对全部权值和全部偏置的偏导,而得知了这些偏导,对于各个权值 w 和偏置 b 该走向何方就指明了方向。
  • 因此,最小二乘法在某种程度上无异于机器学习中基础中的基础,且具有相当重要的地位。

线性回归是确定两种及两种以上变量的相互依赖关系。在数据分析中,线性回归是最简单且最有效的分析方法。
举个简单的例子,某商品的利润在售价为 2 元、5 元、10 元时分别为 4 元、10 元、20 元,我们很容易得出商品的利润与售价的关系符合直线:y=2x. 在上面这个简单的一元线性回归方程中,我们称 “2” 为回归系数,即斜率为其回归系数,回归系数表示商品的售价(x)每变动一个单位,其利润(y)与之对应的变动关系。

from numpy.linalg import inv  # 矩阵求逆
from numpy import dot  # 矩阵点乘
X = np.array([[1],[2],[3]])
Y = 2*X
#theta = (X.T*X)^-1X.T*Y
theta = dot(dot(inv(dot(X.T,X)),X.T),Y)
print(theta)

即X的转置与X点乘,再求逆, 再与X的转置点乘,再与Y点乘,一层层加括号即可。

python实现线性回归之最小二乘法,最小二乘法详解
https://blog.csdn.net/m0_38075425/article/details/90738415/

Thonny,更适合青少年学习编程的IDE工具。
https://zhuanlan.zhihu.com/p/464253266?utm_id=0

  • Python 编程工具比较多样,像比较入门的 Mu Editor,项目在用的 Pycharm、Pydev 等等
  • Thonny 由爱沙尼亚的 Tartu 大学开发,它的调试器是专为学习和教学编程而设计的,针对初学者学习 Python 语言优化了很多工具上的方式和方法

错误处理
Go

func main() {
   f, err := ioutil.ReadFile("test.xml")
   if err != nil {
      fmt.Println(err)
   } else {
      fmt.Println(f)
   }
}

Rust

fn main() {
    let f = File::open("hello.txt");
    match f {
        Ok(file) => {
            println!("File opened successfully.");
        },
        Err(err) => {
            println!("Failed to open the file.");
        }
    }
}

Java

try {
    File file = new File("test.txt");
    FileReader reader = new FileReader(file);
} catch (FileNotFoundException e) {
    System.out.println("文件不存在!");
} catch (IOException e) {
    System.out.println("文件读取失败!");
}

NodeJs

fs.readFile('file.txt', 'utf8', function (err, data) {
    if (err) rerurn console.log(err);
    console.log(data)
});

好的,对于普通可逆的矩阵,我们可以使用高斯-约当消元法来计算它的逆矩阵。这个算法包括三个步骤:

  1. 构造增广矩阵:将一个大小为 (N, 2N) 的增广矩阵创建为原始矩阵和单位矩阵的水平拼接。
  2. 对增广矩阵进行行变换:通过一系列行变换将增广矩阵变成上三角形矩阵。
  3. 反向代入:通过反向代入的方式,将上三角形矩阵转换成单位矩阵,同时右侧的部分即为原始矩阵的逆矩阵。

下面是一个用 Rust 实现这个函数的例子:

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
46
47
48
49
50
51
52
53
54
55
56
57
fn matrix_inverse(matrix: Vec<Vec<f64>>) -> Option<Vec<Vec<f64>>> {
let n = matrix.len();

// 构造增广矩阵
let mut augmented_matrix = vec![vec![0.0; 2 * n]; n];
for i in 0..n {
for j in 0..n {
augmented_matrix[i][j] = matrix[i][j];
}
augmented_matrix[i][i + n] = 1.0;
}

// 行变换,将增广矩阵变成上三角形矩阵
for i in 0..n {
if augmented_matrix[i][i] == 0.0 {
// 如果主对角线上的元素为零,则矩阵不可逆
return None;
}
for j in i + 1..n {
let ratio = augmented_matrix[j][i] / augmented_matrix[i][i];
for k in 0..2 * n {
augmented_matrix[j][k] -= ratio * augmented_matrix[i][k];
}
}
}

// 反向代入,将上三角形矩阵变成单位矩阵以及右侧的部分即为逆矩阵
for i in (0..n).rev() {
for j in 0..n {
let mut sum = 0.0;
for k in i + 1..n {
sum += augmented_matrix[i][k] * augmented_matrix[k][j + n];
}
augmented_matrix[i][j + n] = (augmented_matrix[i][j + n] - sum) / augmented_matrix[i][i];
}
augmented_matrix[i][i] = 1.0; // 对角线上的元素变成1
}

// 提取逆矩阵部分并返回
let mut inverse_matrix = vec![vec![0.0; n]; n];
for i in 0..n {
for j in 0..n {
inverse_matrix[i][j] = augmented_matrix[i][j + n];
}
}

Some(inverse_matrix)
}

fn main() {
let matrix = vec![
vec![1.0, 2.0],
vec![3.0, 4.0],
];
let inverse_matrix = matrix_inverse(matrix).unwrap();
println!("{:?}", inverse_matrix);
}

你可以将你的矩阵作为参数传递给 matrix_inverse 函数,并得到其逆矩阵作为返回值。请注意,这个函数假设矩阵是可逆的,并且不对输入进行验证。

OAuth2.0 原理流程及其单点登录和权限控制
https://kefeng.wang/2018/04/06/oauth2-sso/

游戏

Rpg maker 教程1:RM系列软件异同
https://zhuanlan.zhihu.com/p/59197226

java

https://blog.csdn.net/wdays83892469/article/details/126216765

Java AOT 在经过一波三折的发展后,目前最为成熟可行的方案就是 GraalVM Native Image,它所带来的优势是显著的:

  • 更快的启动速度、
  • 更小的内存消耗、
  • 脱离JVM独立运行 。

但对应的,它也存在着非常多的限制,尤其是在充满了反射等动态特性的 Java 工程生态圈,很难得到大规模的广泛应用。

总的来说,Java AOT目前是有着明确使用场景的一种技术,主要可以应用于:

  • 编写命令行 CLI 程序,希望程序可以完整独立运行而不是需要额外安装JVM。
  • 运行环境资源严重受限的场景,例如 IoT 设备、边缘计算等场景。
  • 希望追求极致的启动速度,并且应用逻辑相对足够轻量,如 FaaS。

Java 9 ~Java 17 主要更新了什么?
https://www.zhihu.com/question/513873484/answer/2328624634

Spring Boot 最新版3.x 集成 OAuth 2.0实现认证授权服务、第三方应用客户端以及资源服务
https://blog.csdn.net/friendlytkyj/article/details/128889875

https://blog.csdn.net/hxx688/article/details/127035172
https://blog.csdn.net/qq_50909707/article/details/127165284

Spring Security OAuth停更了?探索官方进化版Spring Authorization Server的革新之处!
https://blog.csdn.net/citywu123/article/details/131080947

OAuth2一些常见问题的QA
https://felord.cn/oauth2-qa.html

前端

Chrome 80.0中将SameSite的默认值设为Lax,对现有的Cookie使用有什么影响?
https://www.zhihu.com/question/373011996/answer/2442976854?utm_id=0

The Marketing Secrets Apple & Tesla Always Use: Rory Sutherland | E165
https://www.youtube.com/watch?v=Hz3RWxJck68

后台

Fast, secure data deduplication solutions
https://redis.com/solutions/use-cases/deduplication/

RedisBloom: Probabilistic Data Structures for Redis
https://github.com/RedisBloom/RedisBloom

bloom filter之所以能做到在时间和空间上的效率比较高,是因为牺牲了判断的准确率、删除的便利性

  • 存在误判,可能要查到的元素并没有在容器中,但是 hash 之后得到的k个位置上值都是 1。
    • 如果 bloom filter 中存储的是黑名单,那么可以通过建立一个白名单来存储可能会误判的元素。
  • 删除困难。一个放入容器的元素映射到 bit 数组的 k 个位置上是1,删除的时候不能简单的直接置为0,可能会影响其他元素的判断。
    • 可以采用Counting Bloom Filter

测试
235w url, 占内存才 14M

Redis:HyperLogLog使用与应用场景
https://zhuanlan.zhihu.com/p/445885116

布隆过滤器的误判率该如何计算? - 领创集团Advance Group的回答 - 知乎
https://www.zhihu.com/question/38573286/answer/2750794079

过滤器中有 1 亿个元素, k 取值为 14,那么需要空间约为 20 亿 bit ( 238MB )
误报率是2.019*10^9

期权

买近卖远,卖近买远——好难把握的日历价差
http://options.hexun.com/2020-11-06/202380118.html

买近卖远

  • 图形和买跨有些类似, 都是中间震荡会亏损,两边大幅突破会盈利。但是稍微带点曲度。
  • 认购日历来说,如果大涨,希望近月涨的多,远月涨得少,那就赚了;
  • 如果大跌,希望近月跌有限,远月跌的多点,那也还是赚的。
  • 如果一直震荡,平值期权到期归零,远月还有价值,则整体可能亏损。
  • 买近卖远的目的还有一个
    • 就是希望在远月波动率比较高的时候(希腊字母vega相关),能赚取远月降波的收益
    • 同时,近月的gamma比较高,希望波动大点。

卖近买远

  • 图形类似于卖跨的损益图。
  • 希望标的近期震荡,然后再涨或者跌,把近月时间价值损耗完。
  • 通常笔者用于卖方末日轮的对冲。
  • 还可以赚取远月升波的收益。

策略难点

  • 该组合的价差,在日内基本上横在一个数值附近,远月近月合约涨跌的金额基本对等~全天来看,收益极少。
  • 日历策略的影响因素比较多:
    • 近月远月合约的涨跌金额
    • 近月远月合约的波动率升降规律
    • 上涨时谁上涨的多,下跌时谁下跌的少。
    • 标的窄幅震荡时,这个因素更没有可控性。

期权卖方终极指南-第七章:如何正确交易日历价差
https://zhuanlan.zhihu.com/p/443166257

本章将主要讨论做多日历价差,也就是买入远期的认购合约 卖出近月认购合约。

日历价差的最大亏损就是建仓付出的权利金之差,比如上述苹果的例子,每组损失 = 340美元。

平值日历价差的希腊字母如下:

  • Delta 中性 - 建仓时我们对于股价运动方向不敏感
  • 空 Gamma - 快速的上涨或下跌将使我们亏损
  • 多 Theta - 其他条件不变时,随着时间的推移我们会挣钱
  • 多 vega - 隐波上升时我们会挣钱

本质

  • 认为日历价差实际上多 vega 实际上是大多数人犯的错误
  • 日历价差的真正意义 - 针对远期隐波(Forward Volatility)下注
  • 日历价差实际上是在交易 gamma 和 vega 的相对值。
  • 可以认为日历价差做空 gamma 的同时用 vega 对冲,或者说针对远期隐波下注。
  • 7 月合约的损益主要来自 gamma,而 9 月合约的损益主要来自 vega。
  • 实际上,在日历价差中,波动率的变化带来的盈亏,会被期限结构完全对冲。

假如你得到消息某个制药公司将要在 9 月 1 日公布一个新药,此时不同合约的隐波如下:

七月 = 30%
八月 = 30%
九月 = 30%
十月 = 30%

  • 现在我们知道 9 月份会有一个大新闻,其他人并不知道。因此 9 月合约的隐波应该比现在的更高才对,那么我们就卖出八月合约同时买入九月合约。
  • 这样,当新药公布后 9 月合约的隐波将会上涨,我们的日历价差组合也会盈利。
  • 究其原因,这种隐波的变化并非是跨期的,近月的隐波没有变化。我们建立组合时买入的远期隐波 = 30%,而八月结束后,隐波上升了,所以我们赚钱了。

波动率锥可以帮我们评估对于同一行权价的合约,哪个到期日的合约的隐波被高估或者低估。

  • 比如说如果我们看到一张合约 30 日到期的隐波 = 80, 120 日到期的隐波 = 80,
  • 由于期限结构的存在,我们可以认为 120 日的隐波被高估了,特别是当股票的实际波动 = 100时,30 日隐蔽显然被低估了。
  • 对于这种情况,我们应该做空日历价差,卖出 120 日合约 + 买入 30 日合约。
  • 这个组合表达的观点是,gamma 相对于 vega 更便宜,所以我们做多 gamma,做空 vega。

讲讲低风险套利——日历价差
https://zhuanlan.zhihu.com/p/375927451

什么是波动率?它代表市场上人心的看法,买的人多就会升波,卖的人多就会降波。

围绕做空波动率这个核心,我们开展开讲讲什么时候做正(卖近买远),什么时候做反(买近卖远)。

  1. 如果股市一直打横,那所有合约波动率将趋于统一。股市震荡才是常态,高位似尖峰,终将回落。
  2. 如果市场认为最近市场要跌(买沽多),沽合约近月合约波动率先行升波,远月合约波动率滞后后行,反之亦然
  3. 如果市场认为最近市场跌无可跌(卖沽多),那沽合约近月波动率会降得比远月更低
  4. 远月合约价值高,一旦升波增长幅度会更大,反之亦然
  5. 近月合约时间价值消减数倍于远月

由上述原因我根据观察推出几个心得:

  • 如果近月波高,远月波低,那我们做正日历(卖近买远)。正日历乃王道,它完美贴合第1、4、5点的理念。因此它收益是最高的。
  • 如果近月波低,远月波高,那我们做反日历(买近卖远)。反日历做为正日历的补充,因为第2、3点的关系,它更温和稳健,回撤也更小。
  • 市场不可能又看涨(购合约),又看跌(沽合约),所以它们购沽双方经常一个适合做正,一个适合做反。可互为补充来选择适合自己的组合。