Skip to main content

· One min read
wen

背景

刚加入新公司,接手了一个项目,什么资料也没有。 🥲

想要了解这个项目,一个比较直接的办法就是先看看数据库的 ER 图,手动画图太麻烦,

Google 了下, 发现可以用 JetBrainsDataGrip 来导出 ER 图。

步骤

1. Connect to database

1️⃣. Click + button in the left panel

2️⃣. Select Data Source -> MySQL(or other database)

3️⃣. Fill in the your database information

img

2. Show diagram

1️⃣. Right click the database you want to show

2️⃣ 3️⃣. Select Diagram -> Show Diagram

4️⃣. Then you will see the ER diagram

img

扩展

DataGrip 还有很多功能,比如可以直接在里面写 SQL,还可以直接导出 SQL Script,等等。

点击这里查看更多功能。

· One min read
wen

背景

Diffuses Apphuggingface 推出的一个 App。

结论

以下基于 Version 1.1 (20230222.140932) 进行介绍.

先说结论,让它画猫画狗可能还行,画人就惨不忍睹了。😄

而且除了默认提供的 5 个模型(选择后会自动下载),不能加载其他模型。

一些生成结果

画狗

  • Prompt: Labrador in the style of Vermeer
  • Model: stabilityai/stable-diffusion-2-base

img

画人

danger

下面的图片有点恐怖哦。。。 😨 而且我都是我重复多次,选相对好的结果。

  • Prompt: Japanese beauty
  • Model: stabilityai/stable-diffusion-2-base

img

  • Prompt: Chinese beauty
  • Model: stabilityai/stable-diffusion-2-base

img

  • Prompt: Korean beauty
  • Model: stabilityai/stable-diffusion-2-base

img

  • Prompt: American beauty
  • Model: stabilityai/stable-diffusion-2-base

img

· 2 min read
wen

Update Docusaurus to v3

Docuaurus v3 has been released, here is the migration guide provided by the official.

I record the upgrade process here that may help you save some time. 😄

Upgrade dependencies

  • docusaurus.config.js
docusaurus.config.js

-const lightCodeTheme = require('prism-react-renderer/themes/github');
-const darkCodeTheme = require('prism-react-renderer/themes/dracula');
+const { themes } = require('prism-react-renderer');
+const lightTheme = themes.github;
+const darkTheme = themes.dracula;

prism: {
- theme: lightCodeTheme,
- darkTheme: darkCodeTheme,
+ theme: lightTheme,
+ darkTheme: darkTheme,
},

  • package.json
package.json
   "dependencies": {
- "@docusaurus/core": "2.4.3",
- "@docusaurus/preset-classic": "2.4.3",
- "@docusaurus/theme-mermaid": "^2.4.3",
- "@mdx-js/react": "^1.6.22",
+ "@docusaurus/core": "3.0.0",
+ "@docusaurus/preset-classic": "3.0.0",
+ "@docusaurus/theme-mermaid": "^3.0.0",
+ "@mdx-js/react": "^3.0.0",
"clsx": "^1.2.1",
- "prism-react-renderer": "^1.3.5",
- "react": "^17.0.2",
- "react-dom": "^17.0.2"
+ "prism-react-renderer": "^2.1.0",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0"
},
"devDependencies": {
- "@docusaurus/module-type-aliases": "2.4.3"
+ "@docusaurus/module-type-aliases": "3.0.0",
+ "@docusaurus/types": "3.0.0"
},


"engines": {
- "node": ">=16.14"
+ "node": ">=18.0"
}

Reinstall dependencies

Remove the node_modules directory and package-lock.json file, then reinstall the dependencies.

npm install

Check if mx/mdx files compiles under MDX v3

Use the following command to check if mx/mdx files compiles under MDX v3.

npx docusaurus-mdx-checker

For example, I got a check error after upgrated to v3:

  • Before Modified
<details><summary>xxx</summary>
...
</details>
  • After Modified
<details>
<summary>xxx</summary>
...
</details>

· One min read
wen

git commit --amend --no-edit

When you think you have fixed an issue, but you were not able to fix it completely in one go (perhaps there were just some typos);

OR

When you really have fixed an issue, but you forgot to add some files,

You can use this:

git add .
git commit --amend --no-edit # --no-edit 选项表示不修改 commit message。
git push -f # 如果你已经 push 过了,需要添加 -f 来强制 push。
note

Maybe I just wrote this article to experience the gitGraph feature of mermaidjs 😄.

And BTW the commit message of gitGraph is rotated by default.

If you want to change it to horizontal, you need to add the following configuration in docusaurus.config.js:

+      mermaid: {
+ options: {
+ gitGraph: { rotateCommitLabel: false },
+ },
+ },

· 5 min read
wen

刚过了不惑之年,有点感伤,碰巧听到这首歌,很有感触。

是不是该写封信给 10 年后的自己呢?😀

LRC 歌词:

曲名 : letter song (10年後の私へ)
作词 : doriko
作曲 : doriko
好きな人と歩いた場所も (曾和喜欢的人一起走过的地方)
その時見た景色も (那时曾看到的景色)
振り返らず 今を駆け抜け (统统抛掉 不再回头 向前飞奔)
私は何と出会うの (我将会遇见些什么呢)
立ち止まるほど (驻足不前)
意味を問うほど (探索意义)
きっとまだ大人ではなくて (一定是我还不够成熟)
今見てるもの (现在看到的事物)
今出会う人 (现在遇见的人)
その中でただ前だけを見てる (在这片纷繁喧嚣之中 我只会看向前方)
10年後の私へ (致十年以后的我)
今は幸せでしょうか (现在的你感到幸福么?)
それとも悲しみで (还是正沉浸在悲伤中)
泣いているのでしょうか (默默地流着泪?)
けどあなたの傍に (不过在你的身旁)
変わらないものがあり (依然会有不变的存在)
気付いていないだけで (未能察觉的你)
守られていませんか (依然在被守护着吧)
過ぎし日々に 想いを預け (把思念寄托于流逝的日子里)
時間だけ ただ追いかけてく (只有时间在不停的追赶)
背に寄り添った 誰かの夢に (托付在我肩上的 是谁的梦想)
振り向ける日がいつか来るのかな (总有一天必须要面对的吧)
10年後の私へ (致十年以后的我)
今は誰を好きですか (现在的你喜欢着谁呢?)
それとも変わらずに (还是和以前一样)
あの人が好きですか (继续喜欢着那个人呢?)
けどいつか (不过 现在的你)
知らない誰かを愛する前に (在爱上某个人之前)
自分のことを好きと (“喜欢自己”这句话)
言えるようになりましたか (能否先说出来呢)
大切な人たちは (我所珍爱的朋友们)
今も変わらずいますか (依然在反复平凡地生活吗?)
それとも遠く離れ (还是已经远去)
それぞれ歩んでますか (踏上了各自的旅途)
けど そんな出会いを (但是在重复了无数次的相遇)
别れを 缲り返して (和离别之后)
今の私よりも (是否比现在的我)
すてきになっていますか (更有魅力呢?)
10年後の私へ (致十年后的我)
今がもし幸せなら (如果现在的你是幸福的)
あの日の私のこと (从前的我)
思い出してくれますか (能否请你想起来呢)
そこにはつらいことに (回忆中的我)
泣いた私がいるけど (一定在伤心的哭泣吧)
その涙を優しく (请将这眼泪温柔地)
思い出に変えてください (融入记忆的海洋)

· 3 min read
wen

0. Background

When changing computers, you need to migrate some configuration files from the old computer to the new one, such as .zshrc, .vimrc, .gitconfig, and so on.

Some files may not necessarily be located in the home directory, such as .ssh/config, .config/.starship.yaml. It's a bit of a hassle to migrate these files manually.

Therefore, you need a tool to manage these configuration files.

1. Requirements

  • Support multiple platforms, such as macOS, Linux, Windows.
  • Support version management, such as git.
  • Support templates.

I did a little research and found that there are several tools that can manage dotfiles:

  • chezmoi
    • Golang written
    • Github Star 10.2k
  • dotbot
    • Python written
    • Github Star 6.5k

chezmoi meets my requirements, and it's written in Golang without any dependencies, so I decided to use chezmoi.

2. Install

sh -c "$(curl -fsLS get.chezmoi.io)"

You could find more installation methods here

3. Usage

3.1 Initialize

tip

After initialization, a ~/.local/share/chezmoi directory (local repository) will be generated in the home directory to store chezmoi configuration files. You can enter the directory with the chezmoi cd command.

3.2 Add files

3.3 Update files

tip

After updating the file, remember to commit to the remote repository. You can refer to the previous section.

3.4 Fetch files from remote repository

Fetch files from remote repository and apply them.

chezmoi update

It's equivalent to

chezmoi git pull origin main
chezmoi apply

3.5 Extend usage

3.5.1 Templating

chezmoi supports templates,which can generate different configuration files for different hosts and so on.

For example, I want to configure different account names for different computers, I can do this:

  • Create ~/.account.json file, the content is as follows:
~/.account.json
{
"name": "thewang"
}
  • Configure the data field in ~/.config/chezmoi/chezmoi.toml.
~/.config/chezmoi/chezmoi.toml
[data]
name = "thewang"
  • Add file with --autotemplate flag.
chezmoi add --autotemplate ~/.account.json

{
"name": "{{ .name }}"
}

· 3 min read
wen

0. Background

I have been using the snippet feature of Alfred 3, but the Alfred snippet feature is paid.

Recently, I discovered Raycast, where the Raycast snippet feature is free and open-source, allowing for personal customization.

Therefore, I plan to migrate my Alfred snippets to Raycast.

1. Migrate Alfred Snippets to Raycast

The format of Alfred's snippet files differs from that of Raycast's snippet files. Hence, it is necessary to first convert Alfred's snippet files to Raycast's snippet files.

1.1 Get Alfred Snippets Files

Open the Snippets feature in Alfred, click the Export button to export the Alfred snippets. Since collections in Alfred 3 do not support bulk export, they need to be exported one by one. 🐶

img

1.2 Convert Alfred Snippets to Raycast Snippets

Create a new folder and place the exported Alfred snippet files in it.

Then, create a file named convert-alfred-snippets-to-raycast-snippets.sh in this folder, with the following content:

convert-alfred-snippets-to-raycast-snippets.sh
#!/bin/sh -e
# Script for converting Alfred snippets to Raycast snippets
# Usage: chmod +x convert-alfred-snippets-to-raycast-snippets.sh; ./convert-alfred-snippets-to-raycast-snippets.sh
# NOTE: Install jq before running this script

# List up all *.alfredsnippets files and rename them to *.zip
for file in *.alfredsnippets; do
mv "$file" "${file%.alfredsnippets}.zip"
done

# Unzip all *.zip files and get the folders name
for file in *.zip; do
unzip -o "$file" # -o: overwrite existing files without prompting
done


# Merge all *.json files to one file for Raycast snippets
jq -s 'map(.alfredsnippet | {name, keyword, text: .snippet})' *.json > ./output.json

# Clean up all files except output.json
for file in *.json; do
if [ "$file" = "output.json" ]; then
continue
fi
rm "$file"
done

for file in *.zip; do
rm "$file"
done

for file in *.plist; do
rm "$file"
done

# You can now import the output.json file to Raycast

echo "Done! 🎉 You can now import the output.json file to Raycast -> Import Snippets"

OR download from Github gist: convert-alfred-snippets-to-raycast-snippets.sh

note

To execute this script, you need to install jq, which is a command-line JSON processor tool.

For Mac, you can install jq using Homebrew with the command: brew install jq. You can also refer to the official website for more installation options.

Run the following command:

chmod +x convert-alfred-snippets-to-raycast-snippets.sh
./convert-alfred-snippets-to-raycast-snippets.sh

An output.json file will be generated in the current directory.

1.3 Import Raycast Snippets

Open Raycast, then click on Import Snippets. Choose the output.json file generated in the previous step to import the snippets into Raycast.

Reference

Migrating Alfred Snippets to Raycast