Skip to content

Instantly share code, notes, and snippets.

@hunandy14
hunandy14 / context-reader.md
Created June 23, 2026 04:59
讀取最近與 OpanClaw 的對話紀錄
name context-reader
description 讀取主人最近的對話紀錄,供 cron 獨立 session 載入對話 context 使用。

Context Reader — 載入主人最近對話

提醒類 cron 的共用前置步驟。讓獨立 session 載入主人最近的對話紀錄。

參數

@hunandy14
hunandy14 / README.md
Last active June 21, 2026 12:18
Migrations - OpenClaw 設定變更管理

Migrations — OpenClaw 設定變更管理

用時間戳排序的 patch 檔,逐筆記錄並套用 OpenClaw 的設定變更(格式仿 Supabase migration)。


🚦 三條鐵則(動手前先確認)

  1. 路徑只用相對路徑 migrations/ 開頭 — 新版本擋掉 ~/.openclaw 目錄,絕對路徑會執行失敗。
  2. 一定先 --dry-run — 驗證過才能真的 apply。
@hunandy14
hunandy14 / cli.py
Last active May 22, 2026 03:00
claw-voice
#!/usr/bin/env python3
"""
cli.py — OpenClaw TTS adapter
提供兩種執行模式:
1. 語音合成(OpenClaw 會自動以下列形式呼叫):
cli.py <text> <output_path>
2. 產生 OpenClaw 設定檔並輸出後續套用指令:
@hunandy14
hunandy14 / Register-DuckDNS.ps1
Last active March 24, 2026 06:00
Windows 開機自動同步 duck dns
function Register-DuckDNS {
param(
[Parameter(Mandatory)][string]$Domain,
[Parameter(Mandatory)][string]$Token,
[int]$Interval
)
Get-ScheduledTask -TaskName "DuckDNS_9615e983" -ErrorAction SilentlyContinue |
Unregister-ScheduledTask -Confirm:$false
$url = "https://www.duckdns.org/update?domains=$Domain&token=$Token"
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -Command `"Invoke-RestMethod '$url'`""
@hunandy14
hunandy14 / Set-WSLPortForward.ps1
Last active September 29, 2025 14:03
建立 Windows 到 WSL 的端口轉發
<#
.SYNOPSIS
建立 Windows 到 WSL 的端口轉發
.DESCRIPTION
此函數會建立從 Windows IP 到 WSL IP 的端口轉發規則,
允許外部連線透過 Windows 主機連接到 WSL 內的服務。
.PARAMETER ListenPort
Windows 端監聽的端口號
@hunandy14
hunandy14 / run_nginx_site
Last active August 14, 2025 13:54
快速部署 nginx 容器網站
#!/usr/bin/env bash
# =======================================
# 🐳 run_nginx_site 函式
# =======================================
# 用途:快速部署 nginx 容器網站
#
# 🔧 支援參數(具名與位置皆可):
# --domain <名稱> ✅ 必填(位置參數1),預設為 mysite.com
# --port <數字> ➕ 可選(位置參數2),預設為 8080
@hunandy14
hunandy14 / X509Certificate2.psm1
Created July 15, 2025 15:36 — forked from heaths/X509Certificate2.psm1
X509Certificate2 PowerShell module
#Requires -Version 6.0
using namespace System.Security.Cryptography
using namespace System.Security.Cryptography.X509Certificates
using namespace System.Text
<#
.Synopsis
Generate an X509 v3 certificate.
@hunandy14
hunandy14 / sarchdb.sql
Created January 23, 2025 15:24
SQLServer反向搜索字串在哪個表中或視圖中
-- 宣告搜尋的字串和結果表格
DECLARE @TargetString nvarchar(255) = '<要檢索的字串>';
DECLARE @SearchResults TABLE (
TableType nvarchar(10),
FullTableName nvarchar(500),
ColumnName nvarchar(370),
ColumnValue nvarchar(3630)
);
-- 設定交易隔離等級為 READ UNCOMMITTED
@hunandy14
hunandy14 / tree.sh
Created May 29, 2024 10:11
This script shows the directory tree, color-codes files and folders, and optionally displays file sizes and hidden files.
#!/bin/bash
# This script displays the directory tree structure, color-codes files and folders,
# and optionally shows file sizes and hidden files.
# Usage:
# tree.sh [-a] [-s] <directory>
# -a Show all files including hidden files
# -s Show file sizes
@hunandy14
hunandy14 / Install-OpenSSH.ps1
Last active October 16, 2024 04:52
自動爬蟲抓取最新版本OpenSSH並安裝
# 獲取最新版本OpenSSHUrl
function Get-OpenSSHAsset {
param (
[Parameter(Position = 0, ParameterSetName = "")]
[ValidateSet(
'OpenSSH-Win32.zip',
'OpenSSH-Win64.zip',
'OpenSSH-Win32.msi',
'OpenSSH-Win64.msi'
)]