机械境

这里只是我的后花园,随性而写

之前在 通过 GitHub Actions 自动部署 Hexo,通过创建两个不同的分支,raw 分支存储原始的 Hexo 项目,master 分支存储 hexo generate 编译出来的静态页面,通过 hexo deploy 来部署。由于使用了 hexo deploy 需要设置部署用的 SSH 密钥。

下面的办法更简单,不需要做额外的设置,Hexo 项目在 main 分支,不需要再添加其他分支。

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
name: Hexo deploy

on:
push:
branches:
- raw
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js (.tool-versions)
uses: actions/setup-node@v4
with:
node-version-file: ".tool-versions"
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

---EOF---

在折腾过 antigenantidotesheldon 等 Zsh 的包管理器之后,我发现我主要使用的还是 oh-my-zsh。那就回归本源,再加上现在 oh-my-zsh 也可以自定义 Plugin。

1
2
3
4
5
6
7
8
9
# install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# install oh-my-zsh custom plugins
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone --depth=1 https://github.com/zsh-users/zsh-completions $ZSH_CUSTOM/plugins/zsh-completions
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
# install spaceship
git clone --depth=1 https://github.com/spaceship-prompt/spaceship-prompt.git $ZSH_CUSTOM/themes/spaceship-prompt
ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"

.zshrc 中 通过 plugins 配置需要启用的插件。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
export ZSH="$HOME/.oh-my-zsh"
DISABLE_MAGIC_FUNCTIONS=true
ZSH_THEME="spaceship"
plugins=(
command-not-found
common-aliases
docker
git
bun
npm
yarn
kubectl
asdf
thefuck
zsh-autosuggestions
zsh-syntax-highlighting
zsh-completions
)
source $ZSH/oh-my-zsh.sh

---EOF---

介绍

asdf 是一个版本管理器,用于在不同的项目中管理和切换软件版本。它支持多种编程语言、工具和框架,包括但不限于:

  • Python
  • Ruby
  • Node.js
  • Java
  • Rust
  • Docker

asdf 的主要优点包括:

  • 版本管理: 允许您轻松安装、切换和卸载不同版本的软件。
  • 项目隔离: 每个项目都可以使用自己的软件版本集,而不会影响其他项目。
  • 跨平台支持: 可在 macOS、Linux 和 Windows 上使用。
  • 易于使用: 具有简洁直观的命令行界面。
Read more »

介绍

Alacritty 简介

Alacritty 是一款开源、跨平台的终端仿真器,以其高性能、低延迟和可定制性而闻名。它使用 Rust 编程语言编写,并利用 GPU 渲染来实现流畅的滚动和快速的文本渲染。

优点

  • 高性能: GPU 渲染引擎使其成为市场上最快的终端仿真器之一,即使在处理大量文本或图形时也能提供流畅的体验。
  • 低延迟: 响应延迟极低。
  • 跨平台: 可在 Windows、macOS、Linux 和 FreeBSD 上运行。
  • 开源: 是开源的,这意味着用户可以自由查看、修改和分发其源代码。

缺点

  • 有限的扩展性: 与其他终端仿真器相比,不支持插件或扩展。
  • 缺少某些功能: 缺少某些高级功能,例如选项卡、分割窗格。

Zellij 介绍

Zellij 是一款开源、跨平台的终端复用器,它允许用户在单个窗口中管理多个终端会话。它使用 Rust 编程语言编写,并具有现代、可定制的界面。

特点

  • 终端复用: 核心功能是终端复用,它允许用户在单个窗口中打开和管理多个终端会话。
  • 可定制性: 提供了广泛的配置选项,允许用户根据自己的喜好定制布局、键盘快捷键和配色方案。
  • 插件支持: 支持插件,允许用户扩展其功能,例如添加对外部工具或服务的集成。
  • 跨平台: 可在 Windows、macOS、Linux 和 FreeBSD 上运行。
  • 开源: 是开源的,这意味着用户可以自由查看、修改和分发其源代码。

介绍部分为 Gemini 生成,手动做了部分调整。

Read more »

介绍

如果在内网中运行本地 Web 应用程序,可以使用 IP 地址和端口组合来访问服务,例如 http://192.168.1.32:8096 来访问 Jellyfin。但是如果发生 IP 变更的话,就需要修改 IP 地址,因此可以通过反向代理和本地域名的组合,例如 https://jellyfin.localhttps://homeassistant.local 来避免 IP 地址变更。这种由于是使用了自己生产的 CA 证书,浏览器会有告警提示。

准备

假定本地运行 Jellyfin 服务器的 HomeLab IP 为 192.168.1.32,容器名称为 jellyfin,端口为 8096,域名为 jellyfin.example.xyz

域名

自有域名

这里以 Cloudflare 为例

  1. My Profile/API Tokens 页面生成有 Zone.DNS 权限的 API token
  2. 在 DNS 记录中添加一条 A 记录,名称为 jellyfin, 内容为 192.168.1.32,代理状态为 仅 DNS - reserved IP

没有域名

通过 DuckDNS 注册账号,然后添加域名记录,比如 homelab001,IP 地址设为 192.168.1.32,最终的域名为 https://jellyfin.homelab001.duckdns.org

Read more »

前言

Wireguard 有两种模式,一直是内核态,一种是用户态。可以通过 modprobe wireguard 检查内核是否支持 Wireguard。如果该命令成功退出并且没有打印错误,则内核模块可用。如果 wireguard 内核模块不可用,可以切换到像 boringtun 这样的用户态实现。

这里以内核态为例。

准备工作

  1. 安装 Wireguard
    1
    2
    3
    4
    5
    6
    sudo yum install elrepo-release epel-release -y
    sudo yum update -y
    sudo yum install kmod-wireguard wireguard-tools -y
    sudo yum copr enable jdoss/wireguard
    sudo yum update -v
    sudo yum install wireguard-dkms -y
  2. 启用 Wireguard 内核模块
    1
    sudo modprobe wireguard
  3. 自动加载 iptable_raw
    1
    2
    sudo modprobe iptable_raw
    sudo echo "iptable_raw" | sudo tee /etc/modules-load.d/iptable_raw.conf
Read more »

准备工作

  • 注册 chatGPT 账户
  • 注册 Telegram Bot,通过 @BotFather 创建,并获取 token
  • 获取 Telegram Chat ID, 通过 @userinfobot 查询
  • 获取 Access Token
  • 准备反代服务,可以选择别人提供的,不是一定要自己部署

运行

  • 克隆 chatgpt-telegram-bot

  • 准备配置文件 local.json

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    {
    "debug": 1,
    "bot": {
    "token": "telegram bot token",
    "groupIds": [],
    "userIds": [],
    "chatCmd": "/chat"
    },
    "api": {
    "type": "unofficial",
    "unofficial": {
    "accessToken": "chatGPT access token",
    "apiReverseProxyUrl": "https://chat.duti.tech/api/conversation",
    "model": ""
    }
    }
    }
    • userIds 为数字,比如 114797892,可指定多个,如果不指定,就所有人都可用,groupIds 同理,建议配置上
    • accessToken 会有过期时间,暂时没特别好的自动更新的办法,主要是有 cloudflare 验证
  • 修改 docker-compose.yml,并构建镜像

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    version: '3'

    services:
    chatgpt:
    image: chatgpt-telegram-bot
    container_name: chatgpt
    build: .
    restart: unless-stopped
    volumes:
    - ./local.json:/app/config/local.json
    networks:
    - nginx-proxy

    networks:
    nginx-proxy:
    external: true

    docker-compose build 构建镜像

  • 运行
    docker-compose up -d 运行

  • 查看 log
    docker-compose logs -f --tail 100 chatgpt

    如无意外的话,应该会输出类似的日志

    1
    2
    3
    4
    5
    6
    > node --experimental-loader=extensionless dist/index.js

    (node:42) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
    (Use `node --trace-warnings ...` to show where the warning was created)
    2/23/2023, 3:06:13 AM 🔮 ChatGPT API has started...
    2/23/2023, 3:06:14 AM 🤖 Bot @xxx_bot has started...
  • 在 Telegram 中添加刚才创建的机器人,通过 /chat 聊天内容 开始,/help 会显示支持的指令

---EOF---

之前介绍了使用 antigensheldon 管理 Zsh 配置,由于 antigen 已经停止维护了,后面就有了 antibody,但是这个也停止维护了,最终就有了继任者 antidote,这几个使用上都大同小异。

  • 安装

    1
    2
    3
    4
    # macOS 使用 
    brew install antidote
    # 其他平台
    git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-$HOME}/.antidote
  • $HOME 目录添加 .zsh_plugins.txt 来定义需要使用的插件

    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
    # .zsh_plugins.txt

    # comments are supported like this
    https://github.com/peterhurford/up.zsh
    rummik/zsh-tailf
    mattmc3/zman
    agkozak/zsh-z

    # empty lines are skipped

    # annotations are also allowed:
    romkatv/zsh-bench kind:path
    olets/zsh-abbr kind:defer

    # frameworks like oh-my-zsh are supported
    ohmyzsh/ohmyzsh path:lib
    ohmyzsh/ohmyzsh path:plugins/command-not-found
    ohmyzsh/ohmyzsh path:plugins/common-aliases
    ohmyzsh/ohmyzsh path:plugins/gem
    ohmyzsh/ohmyzsh path:plugins/git
    ohmyzsh/ohmyzsh path:plugins/npm
    ohmyzsh/ohmyzsh path:plugins/tmux
    ohmyzsh/ohmyzsh path:plugins/yarn
    ohmyzsh/ohmyzsh path:plugins/fzf

    # prompts:
    # with prompt plugins, remember to add this to your .zshrc:
    # `autoload -Uz promptinit && promptinit && prompt pure`
    # sindresorhus/pure kind:fpath
    # romkatv/powerlevel10k kind:fpath

    # popular fish-like plugins
    zsh-users/zsh-autosuggestions
    zsh-users/zsh-completions path:src kind:fpath
    zdharma-continuum/fast-syntax-highlighting kind:defer
    # zsh-users/zsh-history-substring-search
  • .zshrc 中添加下面的内容,以后修改 .zsh_plugin.txt 中的内容后会自动更新

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    # .zshrc
    # Lazy-load antidote and generate the static load file only when needed
    zsh_plugins=${ZDOTDIR:-$HOME}/.zsh_plugins
    if [[ ! ${zsh_plugins}.zsh -nt ${zsh_plugins}.txt ]]; then
    (
    source ${ZDOTDIR:-$HOME}/.antidote/antidote.zsh
    antidote bundle <${zsh_plugins}.txt >${zsh_plugins}.zsh
    )
    fi
    source ${zsh_plugins}.zsh

    # starship
    # eval "$(starship init zsh)"

---EOF---

0%