202301

java

SpringCloud之Eureka详细的配置
https://www.cnblogs.com/BlogNetSpace/p/11264235.html
ubuntu 安装 rabbitmq
https://blog.csdn.net/sepnineth/article/details/126235964
搭建Eureka - 分区
https://blog.csdn.net/wxy540843763/article/details/100046858
Spring boot config 配置及刷新
https://blog.csdn.net/backonway/article/details/85094571
实体映射最强工具类:MapStruct 真香!
https://cloud.tencent.com/developer/article/1996748

mapstruct坑:Internal error in the mapping processor: java.lang.NullPointerException at org.mapstruct.
https://blog.csdn.net/qq_37132495/article/details/122010257

Setting -->Build,Execution,Deployment -->Compiler -->User-local build process VM options (overrides Shared options):
-Djps.track.ap.dependencies=false

解决 HikariPool-1 - Exception during pool initialization.问题
https://blog.csdn.net/qq_40369243/article/details/115818732

Spring Security 实战干货:用户信息UserDetails相关入门
https://segmentfault.com/a/1190000020628228?utm_source=tag-newest
spring-cloud-gateway之GlobalFilter
https://www.jianshu.com/p/55de48fc484b
SpringCloud:学习Gateway网关拦截器的ServerWebExchange
https://www.cnblogs.com/fdzang/p/11812348.html
统一认证中心 Oauth2 认证坑
https://blog.csdn.net/wangsofa/article/details/121155006
Spring Security OAuth2 单点登录
https://www.cnblogs.com/cjsblog/p/15512596.html
GateWay 中StripPrefix的作用
https://blog.csdn.net/pichcar1982/article/details/120427469
Spring Security Oauth2 ResourceServerConfigurerAdapter (资源服务器配置)
https://blog.csdn.net/wangooo/article/details/113924394
Spring Security OAuth2 Opaque 令牌的简单使用指南
https://blog.csdn.net/new_ord/article/details/127834421
springcloud — 微服务鉴权管理Spring Security OAuth2原理解析(五)
https://blog.csdn.net/qq_38658567/article/details/113249583
springboot以jar包运行
https://www.cnblogs.com/xiaohang123/p/14945194.html
如何在spring security手动自定义用户认证SecurityContextHolder设置Authentication?
https://blog.51cto.com/u_12004792/5786751

http://localhost:8611/auth-dev.yml
http://localhost:8611/auth/dev
http://localhost:8612/actuator/gateway/routes

前端

浏览器原生支持ES6 export和import模块
http://www.hlwen.com/2022/09/22/757.html

Node.js 如何处理 ES6 模块
http://www.ruanyifeng.com/blog/2020/08/how-nodejs-use-es6-module.html

vue项目多环境配置(.env)的实现
https://www.jb51.net/article/217747.htm

PWA超简单入门
https://juejin.cn/post/6844903584899792903
https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps
https://web.dev/progressive-web-apps/

尤雨溪:Turbopack真的比Vite快10倍吗?
https://blog.csdn.net/gtLBTNq9mr3/article/details/127680877

谈谈JS二进制:File、Blob、FileReader、ArrayBuffer、Base64
https://blog.csdn.net/qiwoo_weekly/article/details/127255281

webpack打包之sourcemap
https://blog.csdn.net/formylovetm/article/details/126095387

redis

一篇文章搞定Redis Stream
https://blog.csdn.net/lt_xiaodou/article/details/126525965

不管是list还是订阅/发布模式,都有其弊端,比如list不能友好的重复消费,需要重复消费的话,需要程序代码去控制;而订阅/发布模式是一种转发消息的模式,只有订阅者在线的时候才能接收到消息,订阅者不在线期间产生的消息,就丢掉了。而Stream,有借鉴Kafka一些市面上成熟的消息队列的思想,可以消费失败重复消费,消息是持久化的。

postgre

默认配置

$ cat ~/.psqlrc
\timing
\pset border 2

PostgreSQL中文文档
https://www.yiibai.com/manual/postgresql/index.html

linux

clear all iptables rules
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X

stress-ng: Simulate specific cpu percentages
https://serverfault.com/questions/796225/stress-ng-simulate-specific-cpu-percentages

I designed stress-ng so that one can specify 0 for the number of stressor processes to match the number of on-line CPUs, so to load each cpu at say 40%, use

stress-ng -c 0 -l 40

ssh 超时
https://www.bbsmax.com/A/MyJxnVG1dn/

服务端
vi /etc/ssh/sshd_config

    # server每隔60秒给客户端发送一次保活信息包给客户端
    ClientAliveInterval 60
    # server端发出的请求客户端没有回应的次数达到86400次的时候就断开连接,正常情况下客户端都会相应
    ClientAliveCountMax 86400

客户端
vi /etc/ssh/ssh_config

    # client 每隔60秒给客户端发送一次保活信息包给客户端
    ServerAliveInterval 60
    # client 端发出的请求服务端没有回应的次数达到86400次的时候就断开连接,正常情况下服务端都会相应
    ServerAliveCountMax 86400

How can I tail a zipped file without reading its entire contents?
https://stackoverflow.com/questions/1183001/how-can-i-tail-a-zipped-file-without-reading-its-entire-contents

No, you can’t. The zipping algorithm works on streams and adapts its internal codings to what the stream contains to achieve its high compression ratio.

Without knowing what the contents of the stream are before a certain point, it’s impossible to know how to go about de-compressing from that point on.

If it’s an option, then bzip2 might be a better compression algorithm to use for this purpose.

Bzip2 uses a block compression scheme. As such, if you take a chunk of the end of your file which you are sure is large enough to contain all of the last chunk, then you can recover it with bzip2recover.

How to get few lines from a .gz compressed file without uncompressing
https://stackoverflow.com/questions/8151380/how-to-get-few-lines-from-a-gz-compressed-file-without-uncompressing

gzip -cd CONN.20111109.0057.gz | head

zip, gzip, bzip2

  • gzip 只能压缩文件, 不能压缩目录, 后缀名为 .gz, 而且不保留原文件,还可以和 tar 命令一起构成 Linux 操作系统中比较流行的压缩文件格式。
  • bzip2 是gzip的升级版本,-压缩比比较高,- k 产生压缩文件后保留原文件

[译] 理解 zip 和 gzip 压缩格式背后的压缩算法
https://zhuanlan.zhihu.com/p/143459234

  • 虽然各种压缩算法适用于不同场景,但是它们的底层都是基于 DEFLATE。
  • DEFLATE 是同时使用了 LZ77 算法与哈夫曼编码(Huffman Coding)的一种无损数据压缩算法。
  • DEFLATE 最初是作为 LZW 以及其它受专利保护的数据压缩算法的替代版本而设计的。
  • 从技术上来说,zip 压缩格式是支持使用其他的压缩算法的,但是 DEFLATE 是其中最常用的一种。
  • zip 是一种相当简单的分别压缩每个文件的存档格式,分别压缩文件允许不必读取另外的数据而检索独立的文件。
  • zip 和 gzip(gz)不兼容,虽然它们都是使用相同的 deflate 压缩算法
  • zip 更像一个打包器,能把多个多件放到一个zip中;gzip 一次只对一个文件压缩,通常与 tar 命令一起用。
  • gz 的压缩速度更快,而 bz 的压缩比更好
  • GZIP 最早由 Jean-loup Gailly 和 Mark Adler 创建,用于 unix 系统的文件压缩,ZIP 文件格式是一种数据压缩和文档储存的文件格式。

Extract only a specific file from a zipped archive to a given directory
https://unix.stackexchange.com/questions/14120/extract-only-a-specific-file-from-a-zipped-archive-to-a-given-directory

unzip -l myarchive.zip
unzip -p myarchive.zip path/to/zipped/file.txt >file.txt
unzip -p myarchive.zip path/to/zipped/file.txt | head 
unzip -j "myarchive.zip" "in/archive/file.txt" -d "/path/to/unzip/to"
unzip -j myarchive.zip in/archive/file.txt another/file.ext -d /path/to/unzip/to
unzip -j archive.zip "sub/dir/*" -d "dest/dir"

I changed my hostname, why is my bash PS1 prompt unchanged?
https://unix.stackexchange.com/questions/15643/i-changed-my-hostname-why-is-my-bash-ps1-prompt-unchanged

echo 'mynewhostname' | sudo tee /etc/hostname
sudo hostname -F /etc/hostname
vi /etc/hosts
    127.0.0.1    mynewhostname.mydomainname.com    mynewhostname

SSH server gives “userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]” when connecting with Putty
https://unix.stackexchange.com/questions/721606/ssh-server-gives-userauth-pubkey-key-type-ssh-rsa-not-in-pubkeyacceptedalgorit

There are several types of keys and signature algorithms in the SSH protocol.
RSA keys, which have the key type ssh-rsa, can be used to sign with

  • SHA-1 (in which case, the signature type is ssh-rsa),
  • SHA-256 (which has signature type rsa-sha2-256),
  • or SHA-512 (which has signature type rsa-sha2-512).

backend

理解OAuth 2.0
http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html

Parquet 就是一种基于列式存储的文件格式,它有两个主要优点 [4]:

高度可压缩性:.json 或 .csv 文件通常默认未压缩,而 Parquet 会压缩数据,因此可以节省大量磁盘空间。表 通常包含具有大量唯一值的列(high cardinality(这里理解为出现次数多且值不同);例如用户 ID)和只有少数唯一值的列(low cardinality(虽然出现次数很多,但值都相同);例如国家)。频率越低,压缩效果越好(可能)——下一节将详细介绍。

文件查询/过滤下推:在读入之前修剪不必要的数据。这可以缩短加载时间并优化资源消耗。如果需要从一千个表中获取两列,你不需要扫描所有行来获取这两个属性——你直接获取整个这两列。

Arrow 序列化设计提供了一个“数据头”,它描述了表中所有列的所有内存缓冲区的确切位置和大小。这意味着你可以内存映射巨大的、大于 RAM 的数据集,并在它们上就地评估 pandas 风格的算法,而无需像现在使用 pandas 那样将它们加载到内存中。你可以从 1 TB 表的中间读取 1 兆字节,而只需支付执行这些总计 1 兆字节的随机读取的成本

下面这两个方式中需要进行权衡:

  • 优化磁盘空间/磁盘上的长期存储 → Parquet
  • 优化数据交换和快速检索 → Arrow

简单理解parquet文件格式——按列存储和元数据存储
https://blog.csdn.net/zhang35/article/details/122284903

Apache Arrow :零内存读取DataFrame
https://blog.csdn.net/qq_43232373/article/details/123995262

AWS 数据清洗技术栈

  • AWS S3 是一种对象存储服务,提供行业领先的可扩展性、数据可用性、安全性和性能。
  • Parquet 仅仅是一种列式存储格式,它是语言、平台无关的,并且不需要和任何一种数据处理框架绑定。
  • Apache Arrow 为平面和层次数据定义了一种与语言无关的柱状内存格式,这种格式的组织用于在现代硬件(如cpu和gpu)上进行高效的分析操作。pyarrow 是用于 Arrow 的 Python 库。
  • AWS Glue 是一项无服务器数据集成服务,它简化了发现、准备、移动和集成来自多个来源的数据以进行分析、机器学习(ML)和应用程序开发的工作。
  • Amazon Athena 是一种交互式查询服务,让您能够轻松使用标准 SQL 直接分析 Amazon S3 中的数据。

athena 的价格,扫描 1T 数据是5美元, 可以省钱的考虑点:

  • parquet 本身是压缩的,另外 athena 应该也支持压缩后的csv.gz格式。
  • parquet 是列数据库文件格式,如果查询语句里用不到所有列的话,一次查询可能不需要扫描整个文件,扫描量会少一些,这点比csv好。
  • parquet 支持分区,如果提前能知道以后可能的查询,可以设计好分区key,每次扫描可以继续减少扫描量。

mysql

mysql 排序,利用变量实现 显示排序序号
https://blog.csdn.net/weixin_55806809/article/details/122931550

  • “ := ” 赋值的意思 。 set 和 update 时, 但是一般都用 “ = ” 。 select 时 只能使用“ := ”方式
  • “ = ” set 和 update时 ,表示赋值。select 时 , 表示是判断。

code

set @i = 0;
set @sco = null;
select
student_id,
score,
case when @sco = score then @i else @i := @i + 1 end as 排名序号,
@sco := score
from tb_score where course_id = 1 ORDER BY score desc

SELECT sid,sname,gender,age,(@i:=@i+1) AS '序号'
FROM student,(SELECT @i:=0) AS itable;

MySQL 性能监控4大指标——第一部分
https://www.jianshu.com/p/36f385935ebd

Mysql Performance_schema简介, 表和常用性能查询
https://blog.csdn.net/solinger/article/details/122300008

哪类的SQL执行最多?

SELECT DIGEST_TEXT,COUNT_STAR,FIRST_SEEN,LAST_SEEN
FROM performance_schema.events_statements_summary_by_digest
ORDER BY COUNT_STAR DESC limit 10\G

哪类SQL的平均响应时间最多?
SELECT DIGEST_TEXT,COUNT_STAR,AVG_TIMER_WAIT,FIRST_SEEN,LAST_SEEN
FROM performance_schema.events_statements_summary_by_digest
ORDER BY AVG_TIMER_WAIT DESC limit 10\G

哪类SQL扫描记录数最多?
SELECT DIGEST_TEXT,SUM_ROWS_EXAMINED ,FIRST_SEEN,LAST_SEEN
FROM performance_schema.events_statements_summary_by_digest
ORDER BY SUM_ROWS_EXAMINED DESC limit 10\G

SELECT DIGEST_TEXT,ROUND((SUM(sum_timer_wait) / SUM(count_star)) avg_time,FIRST_SEEN,LAST_SEEN
FROM performance_schema.events_statements_summary_by_digest
ORDER BY ROUND((SUM(sum_timer_wait) / SUM(count_star))  DESC limit 10\G

SELECT * FROM sys.statements_with_runtimes_in_95th_percentile limit 10\G

SHOW GLOBAL STATUS LIKE "Questions";

SELECT schema_name
     , SUM(count_star) count
     , ROUND(   (SUM(sum_timer_wait) / SUM(count_star))
     / 1000000) AS avg_microsec

     FROM performance_schema.events_statements_summary_by_digest

 WHERE schema_name IS NOT NULL
 GROUP BY schema_name;

Find last query executed by specific session on MySQL server
https://dataedo.com/kb/query/mysql/find-last-query-executed-by-session

set global log_output = 'table';
set global general_log = 'on';
select *,CONVERT((argument) USING utf8) t  from mysql.general_log limit 10\G
set global general_log = 'off';

table operator

  • check table: 检查 InnoDB 和 MyIsam 是否有错误。检查表或者视图是否存在错误
  • optimize table: 恢复被删除的块和重组表,清理碎片
  • analyze table: 检测和重组表的关键字分布情况。用来分析和存储表的关键字的分布,使得系统获得准确的统计信息,影响 SQL 的执行计划的生成。
  • repair table : 修复表

MySQL中analyze table的作用是?生产上操作会有什么风险?
https://www.modb.pro/db/168442

一、analyze table的作用
1、analyze table 会统计索引分布信息。
2、对于 MyISAM 表,相当于执行了一次 myisamchk --analyze
3、支持 InnoDB、NDB、MyISAM 等存储引擎,但不支持视图(view)
4、执行 analyze table 时,会对表加上读锁(read lock)
5、该操作会记录binlog

二、生产上操作的风险
1、analyze table的需要扫描的page代价粗略估算公式:sample_pages * 索引数 * 表分区数。
2、因此,索引数量较多,或者表分区数量较多时,执行analyze table可能会比较费时,要自己评估代价,并默认只在负载低谷时执行。
3、特别提醒,如果某个表上当前有慢SQL,此时该表又执行analyze table,则该表后续的查询均会处于waiting for table flush的状态,严重的话会影响业务,因此执行前必须先检查有无慢查询。

算法

  • KMP:用于字符串的匹配问题,对于普通的做法需要O(n*m)的复杂度暴力匹配,一旦失配需要从这一次原串匹配的开头字符的下一个字符开始匹配,也就是意味着原串所正在匹配的位置 i 可能会一直回退。KMP复杂度O(m+n),KMP的做法就是保证了指向原串正在匹配的位置的i不会回退。

  • Trie树:(字典树,多模式串匹配算法)一种树形结构,它是一种专门处理字符串匹配的数据结构,用来解决在一组字符串集合中快速查找某个字符串的问题(本质是利用字符串之间的公共前缀,将重复的前缀合并在一起)。

  • AC自动机:Trie树跟AC自动机之间的关系,就像单串匹配中朴素的串匹配算法与KMP算法一样,只不过前者针对的是多模式串。所以AC自动机实际上就是在Trie树之上,加了类似KMP的next数组,只不过此处的next数组是构建在树上。