惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
V
Visual Studio Blog
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
L
LangChain Blog
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
P
Proofpoint News Feed
博客园_首页
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Check Point Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog

Hunsh's Blog

如何选择合适的加密手段 Nginx SNI Proxy 如何优雅导入 k8s.io/kubernetes Make Go mod and Git to use specify .netrc 多架构镜像的体积优化 使用 buildkit 进行多架构构建并提取产物 如何修改镜像 layer(以 sourcemap-less grafana 为例) acme.sh 自动化 Google CA 申请证书 微信小程序嵌入任意公众号文章 k8s && bazel 项目从 go1.20 升级 go1.21 go serve http and https on same port typecho 迁移到 hexo 实现 hexo 文章和资源在同一目录下 golang mitm 遇到的问题 流式数据专用的 mine-type Golang 正向代理对于 Host 的处理 (RFC 7230) 分享 MacOS 的一些系统fix脚本(dns、sleep) prometheus rate/increase/delta/sum等函数不符合预期或出现小数的原理 [油猴脚本] USTB Everywhere 为校外访问添加访问任意网站的能力
生成个人的 Github PR List
2025-05-18 · via Hunsh's Blog

写了一个小脚本,可以生成任意用户的 pr list

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
58
59
60
from collections import defaultdict

import requests

USERNAME = 'hunshcn'
TARGET = 'source/about/index.md'

def generate_contributing_table(username, target):
url = f'https://api.github.com/search/issues?per_page=100&q=is%3Apr+author%3A{username}+archived%3Afalse+is%3Aclosed+is%3Amerged+is%3Apublic+type%3Apr&page='
data = []
page = 1
while True:
r = requests.get(url + str(page)).json()
total = r['total_count']
data.extend(r['items'])
if total <= page * 100:
break
page += 1

repos = defaultdict(list)

for item in data:
repo = item['repository_url'].removeprefix('https://api.github.com/repos/')
number = item['number']
repos[repo].append(number)

items = sorted(repos.items(), key=lambda x: len(x[1]), reverse=True)

# Generate markdown table
table_lines = [
"| # | 仓库 | PR |",
"|:---|:---|:---|"
]

for index, (repo, numbers) in enumerate(items, 1):
pr_links = [f"[#{n}](https://github.com/{repo}/pull/{n})" for n in numbers]
pr_list = " ".join(pr_links)
table_lines.append(f"| {index} | [{repo}](https://github.com/{repo}) | {pr_list} |")

# Read the index.md file
with open(target, 'r', encoding='utf-8') as f:
content = f.read()

# Replace the table block
start_marker = "<!-- Contributing block start -->\n"
end_marker = "\n<!-- Contributing block end -->"
table_content = "\n".join(table_lines)
start_index = content.find(start_marker)
end_index = content.find(end_marker)
assert start_index != -1 and end_index != -1, "Contributing block not found"
new_content = content[:start_index+len(start_marker)] + table_content + content[end_index:]

# Write back to the file
with open(target, 'w', encoding='utf-8') as f:
f.write(new_content)

print("done")

if __name__ == "__main__":
generate_contributing_table(USERNAME, TARGET)

这个主要是为了我的 about 页面而写的,会将 pr list 作为 table 写入指定的 markdown 中,只需要在 markdown 中准备一个 Contributing block

1
2
<!-- Contributing block start -->
<!-- Contributing block end -->

脚本就会自动填充,效果可以见 我的 aboout