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

推荐订阅源

V
V2EX
C
Check Point Blog
博客园 - Franky
月光博客
月光博客
T
Tenable Blog
博客园 - 聂微东
Cyberwarzone
Cyberwarzone
The GitHub Blog
The GitHub Blog
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
IT之家
IT之家
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
CXSECURITY Database RSS Feed - CXSecurity.com
F
Full Disclosure
博客园 - 司徒正美
Project Zero
Project Zero
Y
Y Combinator Blog
A
Arctic Wolf
美团技术团队
博客园 - 叶小钗
S
Securelist
F
Fortinet All Blogs
T
Threatpost
T
Threat Research - Cisco Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
酷 壳 – CoolShell
酷 壳 – CoolShell
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Recorded Future
Recorded Future
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Schneier on Security
Apple Machine Learning Research
Apple Machine Learning Research
L
LangChain Blog
P
Privacy International News Feed
博客园_首页
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
P
Proofpoint News Feed
Cisco Talos Blog
Cisco Talos Blog
AWS News Blog
AWS News Blog
阮一峰的网络日志
阮一峰的网络日志
G
Google Developers Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
雷峰网
雷峰网
P
Proofpoint News Feed
Latest news
Latest news
G
GRAHAM CLULEY

RSS feed of yihong0618's gitblog

12 月,姥姥,以及大模型 · Issue #344 · yihong0618/gitblog 不要自动化你的情感链接 · Issue #343 · yihong0618/gitblog 那些幸福的瞬间 · Issue #342 · yihong0618/gitblog 12 年过去了,你过得还好么? · Issue #341 · yihong0618/gitblog Be a human, not a claw. · Issue #339 · yihong0618/gitblog 新年快乐以及一些近况 · Issue #338 · yihong0618/gitblog 偶得的佳句与 AI · Issue #337 · yihong0618/gitblog 确定性的丧失 · Issue #336 · yihong0618/gitblog Something Boring or Interesting · Issue #335 · yihong0618/gitblog 2025 年我提了 500 个 Pull Requests · Issue #334 · yihong0618/gitblog 网友 · Issue #333 · yihong0618/gitblog 如何判断一个项目是个好的开源项目并且想贡献? · Issue #331 · yihong0618/gitblog Things I don’t like · Issue #329 · yihong0618/gitblog Notes on Pycon2025 · Issue #327 · yihong0618/gitblog 从错误中学习 · Issue #326 · yihong0618/gitblog 一次艰难的 cpython issue 排查过程,以及我学到了什么 · Issue #325 · yihong0618/gitblog 八月 · Issue #324 · yihong0618/gitblog 从给 Greptime 贡献代码的过程中,我都学到了什么 · Issue #320 · yihong0618/gitblog Notes on May · Issue #318 · yihong0618/gitblog Things I like · Issue #311 · yihong0618/gitblog 我的 35 岁 · Issue #309 · yihong0618/gitblog 连续跑了 365 天 · Issue #306 · yihong0618/gitblog 最近给开源项目贡献的记录 · Issue #304 · yihong0618/gitblog 2020-2025 最喜欢的 12 篇文章和一张图 · Issue #302 · yihong0618/gitblog 断章 · Issue #301 · yihong0618/gitblog 这两个月 · Issue #299 · yihong0618/gitblog 从给 RisingWave 提 PR 说起,聊聊怎么快速切入一个复杂的开源项目 · Issue #296 · yihong0618/gitblog 能几日,又中秋 · Issue #294 · yihong0618/gitblog 第一次 AI 尝试,完全用 AI(MarsCode) 做个需求 · Issue #293 · yihong0618/gitblog 一件趣事儿 · Issue #292 · yihong0618/gitblog 这玩意不是就__ · Issue #291 · yihong0618/gitblog 六月 · Issue #290 · yihong0618/gitblog 跑了 10000km 花了 13 年 · Issue #289 · yihong0618/gitblog 抉择 · Issue #287 · yihong0618/gitblog 三月 · Issue #283 · yihong0618/gitblog About Me · Issue #282 · yihong0618/gitblog 用小爱加手指机器人实现传统开关语音关灯 · Issue #281 · yihong0618/gitblog 记忆碎片 · Issue #280 · yihong0618/gitblog 开源值得么? · Issue #279 · yihong0618/gitblog 聊聊读书 · Issue #275 · yihong0618/gitblog 旧文,移动端最好的游戏,《Dream Quest》以及其它 · Issue #274 · yihong0618/gitblog 微信好友 · Issue #272 · yihong0618/gitblog 如何写一个 PostgreSQL Extension · Issue #270 · yihong0618/gitblog 五月病 · Issue #268 · yihong0618/gitblog 杂感 · Issue #262 · yihong0618/gitblog vm.overcommit_memory 学习笔记 · Issue #261 · yihong0618/gitblog 开源四年的一些记录 · Issue #259 · yihong0618/gitblog 不用 root 使用小爱同学和 ChatGPT 交互折腾记 · Issue #258 · yihong0618/gitblog 用 eBPF trace PostgreSQL 的几种姿势 · Issue #257 · yihong0618/gitblog 2022 失落的一年 · Issue #255 · yihong0618/gitblog 写诗吧 · Issue #254 · yihong0618/gitblog 利用 GitHubPoster 和 GitHub Actions 备份任意用户推特 · Issue #252 · yihong0618/gitblog 一杯敬月光 · Issue #251 · yihong0618/gitblog 如何判断一个数字帐号来自中国大陆 · Issue #248 · yihong0618/gitblog Random Thoughts · Issue #242 · yihong0618/gitblog 反思 · Issue #241 · yihong0618/gitblog 今天的跑步电台 · Issue #239 · yihong0618/gitblog LeetCode 是如何运行的--测试篇 · Issue #237 · yihong0618/gitblog 新冠纪元 · Issue #235 · yihong0618/gitblog Postgres 需要学的东西 · Issue #234 · yihong0618/gitblog Postgres 中 GUC 的一些记录 · Issue #233 · yihong0618/gitblog 运交华盖欲何求 · Issue #231 · yihong0618/gitblog 年终岁尾 · Issue #230 · yihong0618/gitblog 二零二二的三个小目标 · Issue #229 · yihong0618/gitblog 经历了人生体验最棒的一次面试 · Issue #228 · yihong0618/gitblog 参加了《开源面对面》《ByteTalk》《枫言枫语》播客的一些记录 · Issue #223 · yihong0618/gitblog 有趣与无趣 · Issue #221 · yihong0618/gitblog running_page 开源一周年的总结 · Issue #220 · yihong0618/gitblog 接下来要写的东西 · Issue #219 · yihong0618/gitblog 一点思考 · Issue #218 · yihong0618/gitblog 友情链接 · Issue #217 · yihong0618/gitblog 朋友圈 · Issue #216 · yihong0618/gitblog 张小龙的饭否 · Issue #215 · yihong0618/gitblog 一件小事 · Issue #214 · yihong0618/gitblog 从 Rich 作者的一个问题说起 · Issue #212 · yihong0618/gitblog 逃离 · Issue #208 · yihong0618/gitblog 近况 · Issue #207 · yihong0618/gitblog 年过完了 · Issue #206 · yihong0618/gitblog 力扣的程序是如何运行的 · Issue #205 · yihong0618/gitblog 生存守则 · Issue #204 · yihong0618/gitblog 沮丧 · Issue #203 · yihong0618/gitblog 今年的三个小目标 · Issue #202 · yihong0618/gitblog 新年碎碎念 · Issue #201 · yihong0618/gitblog 二零二一开始 · Issue #200 · yihong0618/gitblog 记住这一刻 · Issue #199 · yihong0618/gitblog 巧妙利用 iOS 的快捷指令配合 GitHub Actions 实现自动化 · Issue #198 · yihong0618/gitblog 如何获取悦跑圈数据 · Issue #197 · yihong0618/gitblog 生的对立面 · Issue #196 · yihong0618/gitblog 推荐一些我一直关注的觉得不错的和 Python 相关的独立博客 · Issue #195 · yihong0618/gitblog 2020 年 10 月总结 11 月计划 · Issue #194 · yihong0618/gitblog 写在 0x20 岁之前 · Issue #193 · yihong0618/gitblog 如何获取 keep 跑步数据 · Issue #191 · yihong0618/gitblog 2020 年 9 月总结 10 月计划 · Issue #190 · yihong0618/gitblog 决定把gitblog和kb结合起来 · Issue #189 · yihong0618/gitblog 感冒了,真是难受 · Issue #188 · yihong0618/gitblog 把running page 变得通用必须提上日程了 · Issue #187 · yihong0618/gitblog 我转行程序员的经历 · Issue #186 · yihong0618/gitblog 普通人和天才之间的巨大鸿沟 · Issue #185 · yihong0618/gitblog 月跑 250 km计划 · Issue #184 · yihong0618/gitblog 2020年八月总结九月月展望 · Issue #182 · yihong0618/gitblog
如何用一个仓库记录自己的一年 · Issue #209 · yihong0618/gitblog
yihong0618 · 2021-05-28 · via RSS feed of yihong0618's gitblog

写在前面

从最开始的用 GitHub 的 Issues 写博客,到尝试用 GitHub 记录的年度数据已经二年有余了,从最开始有想法 2020, 到 2021 加了很多功能,把大部分的记录自动化,一点一点记录也算是有些心得了,这篇文章就介绍一下我是怎么做的,能帮助到同样感兴趣的大家就更好了。也算是践行这 2 年对我影响最大的文章之一

People Die, but Long Live GitHub

GitHub 的一个 repo 能做什么?

  1. 能记录 Issues
  2. Issues 可以评论
  3. 能给 Issue 打标签
  4. 能有一张展示的 README
  5. README 能引入 svg
  6. 有 Actions 可以辅助自动化
  7. Actions 可以放 secrets
  8. 可以用 cron 和各种事件触发 Actions
  9. API 公开,可以自己 DIY
  10. 有手机应用,不用开电脑能随时随地记录
  11. 有评论区
  12. 私有仓库这些以上的都有

好,我们把这些结合起来,记录自己的一年~

数字区

image
上图这些数字区是怎么实现方式分为两部分:

  • API 获取 -- 扇贝,开心词场,多邻国
  • Issues 配合 labels 获取,俯卧撑,花费。。。

每天早 8 点和晚 9 点,定时跑一次,计算数据进行整合,并配合 telegram 的 bot 提醒自己。
入口大家可以参考 Actions 的这个 workflow

Issues 的代码思路为获取 label -> 通过 label 找 issues -> issues 的评论特定格式 -> 通过函数解析 -> 整合 -> 通过正则替换 README 中的原有数据(文字) (README 可以写注释,而注释是不显示的,利用这个完成显示和替换)

def main(
    login_dict,
    github_token,
    repo_name,
):
    my_num_stat_str = MY_NUMBER_STAT_HEAD
    # API STAT STR
    for name, value_dict in MY_STATUS_DICT_FROM_API.items():
        try:
            url = value_dict.get("url")
            md_name = f"[{name}]({url})"
            # maybe a better way?
            total_data, streak, today_check = value_dict.get("daily_func")(
                *login_dict.get(name, tuple())
            )
            total_data_str = str(total_data) + value_dict.get("unit_str", "")
            my_num_stat_str += make_stat_str(
                md_name, total_data_str, streak, today_check
            )
        # just a tricky code for others for use
        except Exception as e:
            print(e)
            continue

    u = Github(github_token)
    # COMMENTS STAT STR
    for name, value_dict in MY_STATUS_DICT_FROM_COMMENTS.items():
        try:
            labels, map_func, reduce_func = LABEL_DAILY_DICT.get(name)
        except:
            # tricky for mine
            continue
        func = value_dict.get("daily_func")
        if not func:
            break

        issues = u.get_repo(repo_name).get_issues(labels=labels)
        total_data, streak, today_check, url, month_summary_dict = func(
            issues, map_func, reduce_func
        )
        # change the issue body for month summary
        unit = value_dict.get("unit_str", "")
        for i in issues:
            body = ""
            for b in i.body.splitlines():
                # from the summary table
                if b.startswith("|"):
                    break
                body += b + "\r\n"
            body = body + "\r\n" + make_month_summary_str(month_summary_dict, unit)
            # edit this issue body
            i.edit(body=body)
        name = f"[{name}]({url})"
        total_data_str = str(total_data) + unit
        my_num_stat_str += make_stat_str(name, total_data_str, streak, today_check)

    replace_readme_comments("README.md", my_num_stat_str, "my_number")

多说几句早起

关于早起这个数据和 issue 因为自己喜欢诗歌,我找了一个获取一句诗的 API, 然后自动评论,评论是带时间戳的,正好记录自己的起床时间。
那么是怎么触发的呢?
我用的是 iOS 系统,而 iOS 有个重要的功能是“捷径“。利用捷径可以触发 Actions workflow 的 api, 触发 api 就有时间戳了,再判断是不是早起,给自己发送就好了。
捷径的触发条件是闹钟关闭,为了保险起见,我可能比闹钟起的早,再加一条关闭背单词软件,解决了用 GitHub 记录早起的问题。

def make_get_up_message():
    sentence = get_one_sentence()
    now = pendulum.now(TIMEZONE)
    # 3 - 6 means early for me
    is_get_up_early = 3 <= now.hour <= 6
    get_up_time = now.to_datetime_string()
    body = GET_UP_MESSAGE_TEMPLATE.format(get_up_time=get_up_time, sentence=sentence)
    return body, is_get_up_early

关于如何利用捷径配合 Actions 我写过一篇文章 -- 巧妙利用 iOS 的快捷指令配合 GitHub Actions 实现自动化
image
而早起这句诗,我期待好久的 -- 苟利国家生死以,岂因福祸避趋之。还没随机到,随到这一天我决定跑 19.26 km.

GitHubPost 区

利用了我写的 GitHubPoster 项目,自动生成 svg 引入,而自动跑的脚本也在那个项目上。
image

GitHub Repos 区

利用我写的 github-readme-stats 自动替换生成。
image
image

娱乐区

全部利用 Issues 评论 -> 触发 Actions -> 自动替换 README 的注释区域生成
image

def replace_readme_comments(file_name, comment_str, comments_name):
    with open(file_name, "r+") as f:
        text = f.read()
        # regrex sub from github readme comments
        text = re.sub(
            GITHUB_README_COMMENTS.format(name=comments_name),
            r"\1{}\n\3".format(comment_str),
            text,
            flags=re.DOTALL,
        )
        f.seek(0)
        f.write(text)
        f.truncate()

做饭区

和上面类似,因为做的太多,我生成了个表格
image

def parse_cook_issue_table(me, issues):
    comments_str = MY_FOOD_STAT_HEAD
    food_dict = defaultdict(lambda: ["", "", 0])
    for issue in issues:
        comments = issue.get_comments()
        for c in comments:
            if not isMe(c, me):
                continue
            date_str = format_time(c.created_at)
            food_list_str = c.body.splitlines()[0]
            food_list = food_list_str.split(" ")
            for food in food_list:
                if food not in food_dict:
                    food_dict[food][0] = f"[{date_str}]({c.html_url})"
                    food_dict[food][1] = f"[{date_str}]({c.html_url})"
                else:
                    food_dict[food][1] = f"[{date_str}]({c.html_url})"
                food_dict[food][2] += 1
    for k, v in food_dict.items():
        comments_str += MY_FOOD_STAT_TEMPLATE.format(
            name=k, first_date=v[0], last_date=v[1], times=v[2]
        )
    return comments_str

月度数据

每次自动生成还会 edit issue 的内容生成月度数据整合
image

博客区

在 blog 的 repo 写 issue ->curl 2021 的 Actions workflow api -> 自动生成
image
image

收藏文章博客区

这个完全手动添加,我想保留一些仪式感
image

我也想做一个

如果大家想同样做一个这样的年度数据可以 follow 以下步骤:

  1. fork or clone 这个项目
  2. 增加 issues 打 label
  3. 修改 config
  4. 修改一些 api 的 config 数据换成自己的
  5. 如果有问题可以邮件或私信我
COOK_LABEL_LIST = [
    "Cook",
]
MOVIE_LABEL_LIST = [
    "Movie",
]
READ_LABEL_LIST = [
    "Read",
]
DRAMA_LABEL_LIST = [
    "Drama",
]
PUSHUP_LABEL_LIST = [
    "PushUps",
]
BANGUMI_LABEL_LIST = [
    "Bangumi",
]
GAME_LABEL_LIST = [
    "Game",
]
MONEY_LABEL_LIST = [
    "Money",
]
MEDITATION_LABEL_LIST = [
    "Meditation",
]
MORNING_LABEL_LIST = [
    "Morning",
]
GTD_LABEL_LIST = [
    "GTD",
]
MY_BLOG_REPO = "yihong0618/gitblog"
GITHUB_README_COMMENTS = (
    "(<!--START_SECTION:{name}-->\n)(.*)(<!--END_SECTION:{name}-->\n)"
)

# add new label here
LABEL_DICT = {
    "Cook": {"label_list": COOK_LABEL_LIST, "comment_name": "my_cook"},
    "Movie": {"label_list": MOVIE_LABEL_LIST, "comment_name": "my_movie"},
    "Read": {"label_list": READ_LABEL_LIST, "comment_name": "my_read"},
    "Drama": {"label_list": DRAMA_LABEL_LIST, "comment_name": "my_drama"},
    "Bangumi": {"label_list": BANGUMI_LABEL_LIST, "comment_name": "my_bangumi"},
    "Game": {"label_list": GAME_LABEL_LIST, "comment_name": "my_game"},
}


##### SHANBAY ######
MY_SHANBAY_USER_NAME = "ufewz"
SHANBAY_CALENDAR_API = "https://apiv3.shanbay.com/uc/checkin/calendar/dates/?user_id={user_name}&start_date={start_date}&end_date={end_date}"
MY_SHANBAY_URL = f"https://web.shanbay.com/web/users/{MY_SHANBAY_USER_NAME}/zone"

##### DUO ######
MY_DUOLINGO_URL = "https://www.duolingo.com/profile/yihong0618"

##### CICHANG ######
MY_CICHANG_URL = "https://twitter.com/yihong06181/status/1359040099107897344?s=20"


##### FOOD ######
MY_FOOD_STAT_HEAD = (
    "| Name | First_date | Last_date | Times | \n | ---- | ---- | ---- | ---- |\n"
)
MY_FOOD_STAT_TEMPLATE = "| {name} | {first_date} | {last_date} | {times} |\n"

##### Month Summary ######
MONTH_SUMMARY_HEAD = "| Month | Number | \n | ---- | ---- | \n"

MONTH_SUMMARY_STAT_TEMPLATE = "| {month} | {number} |\n"