从上游仓库中选取 commits 提交到另一个仓库 附加修改作者,消息,时间 前期准备 你要准备一个要同步的库 # 下载这个库 git clone git@github.com:coolbeevip/git-commits-replay.git # 查看这个库的所有 commits git --git-dir=./git-commits-replay/.git log --pretty=format:"%H,%an,%ae,%ad,%s" --date=format:'%Y-%m-%d %H:%M:%S' --reverse 52d099240f6da63193ba309106dad77d060836a7,Lei Zhang,zhanglei@apache.org,2023-02-18 10:49:43,Create A.md 516e406615c0020919939bafe59b35359a03c33b,Lei Zhang,zhanglei@apache.org,2023-02-18 10:50:09,Create B.md 551e5c88440396b73f3b1642bf765dcb9136fd1f,Lei Zhang,zhanglei@apache.org,2023-02-18 10:50:30,Create C.md 5dacf876b6f0b4a0d3ead7ec3daaac924b1b37f4,Lei Zhang,zhanglei@apache.org,2023-02-18 10:51:02,Create ALL.md 72a7a54c48286e9a7c92d1201108baa61cbd7db4,Lei Zhang,zhanglei@apache.org,2023-02-18 10:52:13,删除 A B C 新建一个仓库并关联要同步的库 # 新建一个本地仓库 mkdir git-commits-replay-local cd git-commits-replay-local git init git config --global init.defaultBranch master git branch -m master # 关联上游仓库 git remote add upstream git@github.com:coolbeevip/git-commits-replay.git 重放 commit 并修改提交信息 例如要将 52d099240f6da63193ba309106dad77d060836a7,Lei Zhang,zhanglei@apache.
Read more定时收集当前用户的CPU和内存利用率 创建如下 user_usage.sh #!/usr/bin/bash echo -e TIME\\tCPU%\\tMEM% while true do top -b -n 1 -u "$user" | awk -v user="$user" -v date="$(date '+%Y/%m/%d %H:%M:%S')" 'NR>7 { cpu_utilization_sum += $9; mem_utilization_sum += $10;} END { printf "%s\t%.2f\t%.2f\n",date,cpu_utilization_sum,mem_utilization_sum; }' sleep $1 done 每 3 秒采集一次 sh user_usage.sh 3 TIME CPU% MEM% 2023/01/06 17:26:56 64.80 82.10 2023/01/06 17:26:57 70.60 82.10 2023/01/06 17:26:58 393.60 82.10 2023/01/06 17:26:59 137.50 82.20 定时收集某个进程的CPU和内存利用率 创建如下 proc_usage.sh #!/usr/bin/bash echo proc $2 echo -e TIME\\tCPU%\\tMEM% while true do top -b -n 1 -p `ps -ef | grep $2 | grep -v grep | awk '{ print $2 }' | paste -s -d ','` | awk -v user="$user" -v date="$(date '+%Y/%m/%d %H:%M:%S')" 'NR>7 { cpu_utilization_sum += $9; mem_utilization_sum += $10;} END { printf "%s\t%.
Read moreLinux CPU 相关命令 查看 CPU 信息 $ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 4 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 85 Model name: Intel Xeon Processor (Skylake, IBRS) Stepping: 4 CPU MHz: 2299.996 BogoMIPS: 4599.99 Hypervisor vendor: KVM Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 4096K L3 cache: 16384K NUMA node0 CPU(s): 0-3 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat pku ospke spec_ctrl intel_stibp PI 值计算 $ time echo "scale=5000; 4*a(1)" | bc -l -q 7-Zip 基准测试 使用 7-Zip 自带的 LZMA 压缩基准测试测量 CPU 性能
Read more常用日志分析脚本,日志样例如下 2022-12-02 17:00:02,580 [reactor-http-epoll-7] O [com.my.gateway.filter.RequestGlobalFilter] RequestGlobalFilter.java:46 - request http://gateway/myapp/graphql remote address 110.242.12.19 统计文件中匹配规则的行数 统计 2022-12-02 日 17 点至 18 点包含 RequestGlobalFilter 关键字的行数 $ cat my-gateway_9999.log | grep '2022-12-02 17.*RequestGlobalFilter' | wc -l 24003 统计 2022-12-02 日 17 点至 18 点包含 RequestGlobalFilter 并且请求路径包含 myapp 关键字的行数 $ cat my-gateway_9999.log | grep '2022-12-02 17.*RequestGlobalFilter.*myapp.*' | wc -l 6369 分组统计 统计 2022-12-02 日 17 点至 18 点包含 RequestGlobalFilter 按照客户端 IP 地址统计每个客户端的请求行数 $ cat my-gateway_9999.
Read more本文记录了如何在 Maven 项目中使用 Apache Maven Checkstyle Plugin 检查代码风格质量 一个 Maven 项目 假设我有一个 Maven 项目,这个项目包含若干子模块。根目录的 pom.xml 看起来如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my</groupId> <artifactId>my-project</artifactId> <version>${revision}</version> <packaging>pom</packaging> <properties> <revision>0.1.0-SNAPSHOT</revision> </properties> <modules> <module>module-dependencies</module> <module>module-bar</module> <module>module-foo</module> </modules> </project> 在根项目 pom.xml 中增加 maven-checkstyle-plugin 插件 增加 maven-checkstyle-plugin 插件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my</groupId> <artifactId>my-project</artifactId> <version>${revision}</version> <packaging>pom</packaging> <properties> <maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version> <com.puppycrawl.tools.version>9.3</com.puppycrawl.tools.version> </properties> <modules> <module>module-dependencies</module> <module>module-bar</module> <module>module-foo</module> </modules> <build> <pluginManagement> <plugins> <plugin> <groupId>org.
Read more本文记录了如何在 Maven 项目中使用 Apache Maven PMD Plugin 检查代码(Java 代码)质量 一个 Maven 项目 假设我有一个 Maven 项目,这个项目包含若干子模块。根目录的 pom.xml 看起来如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my</groupId> <artifactId>my-project</artifactId> <version>${revision}</version> <packaging>pom</packaging> <properties> <revision>0.1.0-SNAPSHOT</revision> </properties> <modules> <module>module-dependencies</module> <module>module-bar</module> <module>module-foo</module> </modules> </project> 在根项目 pom.xml 中增加 maven-pmd-plugin 插件 增加 maven-pmd-plugin 插件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my</groupId> <artifactId>my-project</artifactId> <version>${revision}</version> <packaging>pom</packaging> <properties> <maven-pmd-plugin.version>3.19.0</maven-pmd-plugin.version> </properties> <modules> <module>module-dependencies</module> <module>module-bar</module> <module>module-foo</module> </modules> <build> <pluginManagement> <plugins> <plugin> <groupId>org.
Read more本文记录了如何在 Maven 项目中使用 SpotBugs Maven Plugin 检查代码(字节码)质量 一个 Maven 项目 假设我有一个 Maven 项目,这个项目包含若干子模块。根目录的 pom.xml 看起来如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my</groupId> <artifactId>my-project</artifactId> <version>${revision}</version> <packaging>pom</packaging> <properties> <revision>0.1.0-SNAPSHOT</revision> </properties> <modules> <module>module-dependencies</module> <module>module-bar</module> <module>module-foo</module> </modules> </project> 在根项目 pom.xml 中增加 spotbugs-maven-plugin 插件 增加 spotbugs-maven-plugin 插件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my</groupId> <artifactId>my-project</artifactId> <version>${revision}</version> <packaging>pom</packaging> <properties> <spotbugs-maven-plugin.version>4.7.1.1</spotbugs-maven-plugin.version> </properties> <modules> <module>module-dependencies</module> <module>module-bar</module> <module>module-foo</module> </modules> <build> <pluginManagement> <plugins> <plugin> <groupId>com.
Read more本文记录了如何在 Maven 多模块项目中使用 JaCoCo 生成覆盖率报告并推送到 Sonar 中 一个多模块项目 假设我有一个多模块项目,这个项目包含若干子模块,并且有若干测试用例。根目录的 pom.xml 看起来如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my</groupId> <artifactId>my-project</artifactId> <version>${revision}</version> <packaging>pom</packaging> <properties> <revision>0.1.0-SNAPSHOT</revision> </properties> <modules> <module>module-dependencies</module> <module>module-bar</module> <module>module-foo</module> </modules> </project> 关于 module-dependencies 模块的作用,可以查看我之前写的MAVEN PROJECTS BEST PRACTICES 在根项目 pom.xml 中增加 jacoco-maven-plugin 插件,并增加 module-coverage 模块 增加 jacoco-maven-plugin 插件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my</groupId> <artifactId>my-project</artifactId> <version>${revision}</version> <packaging>pom</packaging> <properties> <jacoco-maven-plugin.version>0.8.6</jacoco-maven-plugin.version> </properties> <modules> <module>module-dependencies</module> <module>module-bar</module> <module>module-foo</module> <module>module-coverage</module> </modules> <build> <pluginManagement> <plugins> <plugin> <groupId>org.
Read more将 ~/.ssh/下的所有文件迁移到新的机器上,然后在新的机器上执行 chmod 600 ~/.ssh/*
发布环境准备 生成签名密钥 安装 GPG 在GnuPG官网下载 2.X 安装包. 安装完毕后可以使用如下命令查看版本 $ gpg --version gpg (GnuPG/MacGPG2) 2.2.20 libgcrypt 1.8.5 Copyright (C) 2020 Free Software Foundation, Inc. 配置 GPG 安装完毕后你可以找到 $HOME/.gnupg/gpg.conf 文件,并增加如下推荐配置 personal-digest-preferences SHA512 cert-digest-algo SHA512 default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed 用 GPG 生成密钥 根据提示使用 ASF 邮箱生成 GPG 的密钥,更多详细说明请参考 Generate Key with GPG $ gpg --full-gen-key gpg (GnuPG/MacGPG2) 2.2.34; Copyright (C) 2022 g10 Code GmbH This is free software: you are free to change and redistribute it.
Read more