自留地

瞎哔哔.....

背景

  1. 我的 MBP 只有 500GB, 多年用下来多余空间已经不足, 时不时就只有几 GB
  2. 我买了个 2 TB 的 SSD 做外置硬盘(尿袋), 每天插着用

发现微信占用了将近 50 GB

今天用 DaisyDisk 分析磁盘使用时, 发现微信占用了快 50 GB.

决定把迁移到 SSD 上, 因为动了沙盒环境, 微信迁移稍微麻烦一点, 上代码

注意: 先停止微信

1
2
3
4
5
6
7
8
9
10
11
# 将整个文件夹复制走
cp /Users/apple/Library/Containers/com.tencent.xinWeChat/Data/Documents /Volumes/Store/local/wechat/Documents

# 备份一下
mv /Users/apple/Library/Containers/com.tencent.xinWeChat/Data/Documents /Users/apple/Library/Containers/com.tencent.xinWeChat/Data/Documents_backup

# 创建软链接
ln -s /Volumes/Store/local/wechat/Documents $HOME/Library/Containers/com.tencent.xinWeChat/Data

# 重新签名一下
sudo codesign --sign - --force --deep /Applications/WeChat.app

这时候就可以启动 wechat 了, 无痛迁移, 无影响就可以把 Users/apple/Library/Containers/com.tencent.xinWeChat/Data/Documents_backup 删除了.

对了, 需要允许一下微信反问外置硬盘

我的微信版本

最后的最后

附上我目前使用的一个脚本, 将目前 macOS 常用缓存等文件夹搬家到 SSD 里

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash

# 设置目标目录
TARGET_DIR="/Volumes/Store/local"

# 预设要移动的文件夹列表
# 格式为: FOLDERS_TO_MOVE["<source_path>"]="<destination_name>"
# 如果 <destination_name> 为空, 则使用 source_path 的 basename
declare -A FOLDERS_TO_MOVE
FOLDERS_TO_MOVE=(
["$HOME/.pyenv"]=""
["$HOME/.ollama"]=""
["$HOME/.npm"]=""
["$HOME/.m2"]=""
["$HOME/.gradle"]=""
["$HOME/.cargo"]=""
["$HOME/Downloads/images"]=""
["$HOME/Downloads/lark"]=""
["$HOME/Library/Containers/com.tencent.xinWeChat/Data/Documents"]="wechat/Documents"
# ["$HOME/.go"]=""
# 在此添加更多文件夹
)

# 创建目标目录(如果不存在)
mkdir -p "$TARGET_DIR"

# 日志函数
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
}

# 为每个文件夹创建软链接
for folder in "${!FOLDERS_TO_MOVE[@]}"; do
dest_name="${FOLDERS_TO_MOVE[$folder]}"

# 如果 dest_name 为空, 使用默认行为
if [ -z "$dest_name" ]; then
dest_name=$(basename "$folder")
fi

# 目标路径
target_path="$TARGET_DIR/$dest_name"

# 检查原始文件夹是否存在
if [ ! -d "$folder" ]; then
log "警告: 文件夹 $folder 不存在,跳过"
continue
fi

# 检查目标位置是否已存在
if [ -e "$target_path" ]; then
log "警告: 目标位置 $target_path 已存在,跳过"
continue
fi

# 检查原始位置是否已经是软链接
if [ -L "$folder" ]; then
log "警告: $folder 已经是软链接,跳过"
continue
fi

# 创建目标路径的父目录 (如果需要)
mkdir -p "$(dirname "$target_path")"

# 移动文件夹到目标位置
log "移动 $folder$target_path"
mv "$folder" "$target_path"

# 检查移动是否成功
if [ $? -ne 0 ]; then
log "错误: 无法移动 $folder$target_path"
continue
fi

# 创建软链接
log "创建从 $target_path$folder 的软链接"
ln -s "$target_path" "$folder"

# 检查链接是否创建成功
if [ $? -ne 0 ]; then
log "错误: 无法创建从 $target_path$folder 的软链接"
# 尝试恢复原始文件夹
mv "$target_path" "$folder"
log "已尝试恢复原始文件夹"
else
log "成功: $folder 已移动并创建软链接"
fi
done

log "操作完成"

背景

  1. 我想运行一个镜像,发现他没有对应 arm 架构镜像,只有 linux/amd64, 案例
  2. 群晖上的 docker 无法拉取镜像,需要在本地拉取镜像,然后上传到群晖里

正文

如何运行和拉取非 ARM 架构镜像

直接运行 AMD 的镜像

报错如下

1
2
docker run vitess/lite:mysql84
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

通过 Rosetta 运行 AMD 镜像

我们需要使用 OrbStack (优势 -> 远比 Docker for Mac 资源占用低)

  1. 开启使用 Rosetta 运行 intel OrbStack 配置
  2. 运行时指定架构 -> docker run --platform linux/amd64 vitess/lite:mysql84

在本地拉取镜像,然后上传到群晖里

直接放脚本

1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash
set -e
set -x

image_name=$1
nas_ip="192.168.100.123"

docker pull --platform linux/amd64 $image_name
mkdir -p ~/Downloads/temp_images
docker save $image_name | gzip > ~/Downloads/temp_images/temp_image.tgz
scp ~/Downloads/temp_images/temp_image.tgz $nas_ip:~/temp_image.tgz
ssh $nas_ip "ls -l ~/temp_image.tgz; gunzip -c ~/temp_image.tgz | /usr/bin/docker load"

一、如何使用 tcpdump 抓取数据

我们使用 tcpdump 来进行抓取数据。
下面是一个命令案例:

1
tcpdump -i <net_name> host <ip> -w <ip>.pcap
阅读全文 »

背景

我在开发时候遇到一个问题,关于图片上传接口, 默认情况下,Python 代码是不会自动创建文件的,如果想要把图片保存到某个目录下面,需要事先检查是否有这个目录结构,否则就会报错。
但是纠结的那颗心,我😭拒绝写检查文件夹是否存在的代码。

所以有了这篇文章。

阅读全文 »

翻译自: https://wiredcraft.com/blog/how-to-post-on-hacker-news/

hacker-news

当我们为 devo.psWiredcraft 的部分产品工作时, 我创建了一份内部的市场营销指南(我们现在公开了)。指南里面的某一条建议被我们发布到 Hacker News 上。有几个朋友让我把整篇指南分享出来,所以我决定要把它发布在博客里。

阅读全文 »

背景描述:适用于自建https证书,GitLab Runner 在注册基于自建 https 证书的 GitLab server 时会遇到一些证书问题,这里提供了一种解决方案。

阅读全文 »
0%