最近,解决了一些已知问题:
1. 如何多运动
最近几个月稍许没控制饮食 + 偷懒不运动,体重随即增加好几斤。
痛定思痛,把体重秤和瑜伽垫放到书桌边,时常称重一下,不断提醒自己体重已超标。
闲暇时就站到瑜伽垫上做几组 HIIT。
睡前准备好跑步衣服、水壶、袜子和鞋,早上起来洗漱后简单热身一下就出门;不想跑就先走一公里。
2. 配置文件历史记录的问题
以前只是用文件备份的方式,总是感觉很不优雅,但一直拖着不去解决。
jinhuaiyao@jinhuaiyao-macbook-pro Mac_Script % ls -ltr *[0-9][0-9]* |head -4
-rw-r--r-- 1 jinhuaiyao staff 10700 Aug 22 2018 rsa.scpt.20180822
-rw-r--r-- 1 jinhuaiyao staff 91 Aug 22 2018 lvspmgt1.20180822
-rw-r--r-- 1 jinhuaiyao staff 241 Aug 14 2021 lvspmgt.20210814
-rw-r--r-- 1 jinhuaiyao staff 241 Sep 15 2021 lvspmgt.20210915
这几个月频繁使用 gitea 管理脚本,于是想到配置文件也可以通过 git 去管理,不同的配置文件放在不同的 repo 即可,只是初始化费点事而已。
jinhuaiyao@jinhuaiyao-t7820:~/glance/config$ ls -ltr
total 16
-rw-rw-r-- 1 jinhuaiyao jinhuaiyao 1514 Apr 3 13:24 startpage.yml
-rw-rw-r-- 1 jinhuaiyao jinhuaiyao 436 Apr 3 13:31 glance.yml
-rw-rw-r-- 1 jinhuaiyao jinhuaiyao 2256 Apr 3 16:49 home.yml.bad
-rw-rw-r-- 1 jinhuaiyao jinhuaiyao 2525 Apr 14 19:17 home.yml
jinhuaiyao@jinhuaiyao-t7820:~/glance/config$ git init
jinhuaiyao@jinhuaiyao-t7820:~/glance/config$ git remote add origin http://10.0.3.200:3000/jinhuaiyao/glance-config.git
jinhuaiyao@jinhuaiyao-t7820:~/glance/config$ git add .
jinhuaiyao@jinhuaiyao-t7820:~/glance/config$ git config --global user.name "jinhuaiyao"
jinhuaiyao@jinhuaiyao-t7820:~/glance/config$ git config --global user.email "[email protected]"
jinhuaiyao@jinhuaiyao-t7820:~/glance/config$ git commit -m "init: glance config"
[master (root-commit) 5fedbce] init: glance config
4 files changed, 216 insertions (+)
create mode 100644 glance.yml
create mode 100644 home.yml
create mode 100644 home.yml.bad
create mode 100644 startpage.yml
jinhuaiyao@jinhuaiyao-t7820:~/glance/config$ git config --global credential.helper store
jinhuaiyao@jinhuaiyao-t7820:~/glance/config$ git push -u origin master
3. PDF 转 markdown 文件的问题
断断续续收集了许多 PDF 格式的文章,需要一款工具能够方便地将值得反思读的文章转成 markdown 格式,存于 Notion,阅读 + 批注。
最近找到了微软开源的工具 markitdown,试用了一下,符合预期。
# 安装 Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)
# 安装 python
brew install python
jinhuaiyao@jinhuaiyaos-macbook-air markitdown % which python3
/opt/homebrew/bin/python3
jinhuaiyao@jinhuaiyaos-macbook-air markitdown % python3 --version
Python 3.13.5
# 安装 markitdown
cd ~/Documents
git clone https://github.com/microsoft/markitdown.git
cd markitdown
jinhuaiyao@jinhuaiyaos-macbook-air markitdown % /opt/homebrew/bin/python3 -m venv .venv
jinhuaiyao@jinhuaiyaos-macbook-air markitdown % source .venv/bin/activate
(.venv) jinhuaiyao@jinhuaiyaos-macbook-air markitdown % pip install -e 'packages/markitdown [all]'
Obtaining file:///Users/jinhuaiyao/Documents/markitdown/packages/markitdown
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
...
...
Successfully built markitdown
...
...
# 试用一下
(.venv) jinhuaiyao@jinhuaiyaos-macbook-air markitdown % which markitdown
/Users/jinhuaiyao/Documents/markitdown/.venv/bin/markitdown
(.venv) jinhuaiyao@jinhuaiyaos-macbook-air Documents % markitdown a.pdf > a.md
命令行的方式还是不方便,需要一个可以用图形化的方式。
打开 Automator,新建一个 Quick Action,命名为 ToMarkDown。
设置调用 shell 脚本去执行 python 脚本。
cd ~/Documents/markitdown
file_path="$(realpath"$1")"
./.venv/bin/python3 /Users/jinhuaiyao/Nextcloud/Config/Mac_Script/convert_pdf.py "$file_path"
jinhuaiyao@jinhuaiyao-macbook-pro Mac_Script % cat convert_pdf.py
import sys
import os
from markitdown import MarkItDown
file_path = sys.argv [1]
output_dir = os.path.dirname (file_path)
md = MarkItDown ()
result = md.convert (file_path)
output_file = os.path.join (output_dir, os.path.basename (file_path).replace (".pdf", ".md"))
with open (output_file, 'w') as f:
f.write (result.text_content)
print (f"Saved to: {output_file}")
右击一个 PDF 文件,Quick Actions → ToMarkdown,就可以在当前目录得到同名的 markdown 文件了。
也可以通过 System Settings → Keyboard → Keyboard Shortcuts → Services → Files and Folders,给 ToMarkDown 设置一个快捷键,这样就不需要鼠标操作了。
效果图: