Coder Social home page Coder Social logo

2021's Introduction

yihong0618

😄 你好~ 我是 yihong0618,生活工作在大连。 喜爱游戏跑步读书,编程和有趣的东西。 项目大多和这些相关。

你可以到我的网站来玩, 📫 如果你想聊聊,可以给我发邮件, 也可以来到我的 tg 频道

也欢迎赞助我杯可乐 Sponsor Me

爱发电:s

Yesterday you said tomorrow.

记录下的跑步 13 年。

2021's People

Contributors

yihong0618 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

2021's Issues

消费记录

这个 issue 记录自己的花费。试试记账吧。。。今天是2021-01-20,从今天开始记注:~~分类写在后面,用英文逗号分隔。~~分类写在下面

Month Number
1月 673 (元)
2月 1592 (元)
3月 2378 (元)
4月 1888 (元)
5月 2741 (元)
6月 2040 (元)
7月 195 (元)
8月 34 (元)

家庭记录

这个 issue 记录我的生活。碎碎念,不如意,开心,懊悔。

珍惜眼前

体重记录

156
不如从今天开始。
我应该是搞定了小米的 api, 想办法自动记录。

只是现在不太知道怎么表现才好。

今天膝盖有些疼,连续称体重 10 天左右了,好像是瘦了 4 斤 之前没太称。
现在是 152 左右。理论上这个月过完能到 150

目标呢?

这次的目标很远大,想瘦到 126 并保持。

所以还有 26 斤。倒是还好,50斤我也瘦过。

大概呢,用 4 个月完成。

周记记录

这个 issue 开始记周记,今天是周日,不如从今天开始之前看到一篇文章,说是写公开周记。嗯,我觉得周记是不错的选择,周的单位也正好,不长不短。

Month Number
4月 1 (周)
5月 4 (周)
6月 4 (周)
7月 4 (周)
8月 5 (周)
9月 4 (周)
10月 4 (周)
11月 5 (周)
12月 4 (周)

新番记录

这个 issue 记录自己刷的新番,今年要多看一点儿哈哈哈哈哈哈。

做饭记录

这个 issue 记录自己 2021 的美食旅程。


2021.02.05 准备重构这个变成表格了。
2021.02.08 重构完成


格式: 菜在第一行,用空格分隔。

早起记录

看了“黑影儿”的早起跑步记录。决定把自己的跑步也改成早上,还能给媳妇儿子做早餐,背单词。不如从明早开始

Month Number
2月 10 (天)
3月 31 (天)
4月 30 (天)
5月 30 (天)
6月 27 (天)
7月 27 (天)
8月 12 (天)
9月 6 (天)
10月 2 (天)
11月 15 (天)
12月 16 (天)

问题记录

有些困扰自己的问题,一些是有答案的,一些是没有的。
但记录在这里的,大约是公开场合无法问出来的,如果你看到了,希望讨论的话,非常感谢。

记录在这里吧。

如何用一个仓库记录自己的一年

写在前面

从最开始的用 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 记录早起的问题。
关于如何利用捷径配合 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

书签记录

这个 Issue 记录自己今年收藏的书签。或者有意思的东西。

游戏记录

还是要打游戏的吧。

这个 issue 记录下自己 2021 的游戏记录。

观影记录

这个 issue 记录自己 2021 年看的电影

冥想记录

不如从今天开始,这个 issue 记录自己冥想。不知道有啥用,那就试验一下吧。

Month Number
1月 11 (分钟)
2月 9 (分钟)
3月 35 (分钟)
4月 28 (分钟)
5月 13 (分钟)
6月 8 (分钟)
7月 11 (分钟)
8月 18 (分钟)
9月 7 (分钟)
10月 15 (分钟)
11月 27 (分钟)
12月 8 (分钟)

教训记录

这个 issue 记录自己的教训。今年快过完了,明年把这个主题的放前面。

俯卧撑记录

这个 issue 记录自己今年的俯卧撑

Month Number
1月 443 (个)
2月 1333 (个)
3月 1745 (个)
4月 1933 (个)
5月 1140 (个)
6月 881 (个)
7月 605 (个)
8月 581 (个)
9月 415 (个)
10月 450 (个)
11月 500 (个)
12月 550 (个)

GTD

这个 issue 记录自己的每日 todo list, 不如从今天开始- [ ] 激励自己- [ ] 记录自己

Month Number
4月 46 (个)
5月 21 (个)
6月 22 (个)
7月 4 (个)
8月 10 (个)
9月 10 (个)
10月 10 (个)

日语记录

从第一次背 50 音,已经过去好多年了。最多学到初级下册的第五课。
每次都没坚持下来。

嗯,
我又开始了,2021 年争取慢慢进入日语世界

目标呢?不敢说,争取 7 月能过个 N3,不行就12月再看吧,如果能坚持下来,今年争取 N2.

今天已经开始学了。

初级下的单词已经背一周了。
开始认真起来吧。


具体如何学还没想好,
但开始很重要。


2021.07.16 补充

12 月试试吧。
目前的策略是把 N3 的单词全部背完。一天学习一个小时到两个小时。

报名 N3

大概这样,不如从今天开始?

思路 - 每天

  • 三课 n3 的开心词场
  • 5 个语法
  • 1-2 集动漫或日剧
  • 1 个新闻
  • 1 课多邻国

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.