郭安安的筆記碎片

因為是碎片所以看不懂很正常

簡介

  • 基於 AI / LLM 技術的開發助手,用於改善開發者體驗 (DX)
  • 核心技術來自於 OpenAI 的 GPT-3.5 Turbo 模型
    • 該模型基於海量的自然語言文本資料集進行訓練,並具備一定的推理能力
  • 明年初有機會到 GPT 4 (32K)
  • 幾乎支援「任何」程式語言
  • 官方宣稱不會用客戶資料作為訓練模型
    閱讀全文 »

#!/bin/sh

# 遍歷資料夾下的所有子資料夾
for dir in */; do
# 進入子資料夾
cd "$dir" || continue

# 檢查是否為 git 專案
if [ -d ".git" ]; then
# 獲取當前分支名稱
current_branch=$(git symbolic-ref --short HEAD)

# 設置 upstream 至 origin 下
git branch --set-upstream-to="origin/$current_branch" "$current_branch"
fi

# 返回上一級資料夾
cd ..
done

  • 透過 Js 發送 OpenAI 官方提供的 API (https://api.openai.com/v1/chat/completions),需至 官方網站 申請 API Key 才能使用
  • API 規格參考:

    https://platform.openai.com/docs/api-reference/making-requests

    閱讀全文 »

/// <summary>
/// 自動適應列寬
/// </summary>
/// <param name="sheet">需要自適應列寬的sheet表</param>
/// <param name="columnCount">起始列數</param>
public static void AutoFitColumnWidth(ISheet sheet, int columnCount, int startRowIndex = 0)
{
//列寬自適應,只對英文和數字有效
for (int ci = 0; ci < columnCount; ci++)
{
sheet.AutoSizeColumn(ci);
}
//獲取當前列的寬度,然後對比本列的長度,取最大值
for (int colIndex = 0; colIndex < columnCount; colIndex++)
{
int columnWidth = sheet.GetColumnWidth(colIndex) / 256;
for (int rowNum = startRowIndex; rowNum < sheet.LastRowNum; rowNum++)
{
IRow currentRow;

//當前行未被使用過
if (sheet.GetRow(rowNum) == null)
{
currentRow = sheet.CreateRow(rowNum);
}
else
{
currentRow = sheet.GetRow(rowNum);
}

if (currentRow.GetCell(colIndex) != null)
{
ICell currentCell = currentRow.GetCell(colIndex);
int length = Encoding.Default.GetBytes(currentCell.ToString()).Length;
if (columnWidth < length)
{
columnWidth = length;
}
}

if (columnWidth > 255)
{
columnWidth = 255;
break;
}
}

sheet.SetColumnWidth(colIndex, columnWidth * 256);
}
}

以下 Bash 腳本會自動 Pull 當前目錄下所有儲存庫的程式碼:

#!/bin/bash

for dir in */; do
if [ -d "$dir/.git" ]; then
echo "Updating $dir"
cd "$dir"
git pull
cd ..
fi
done

使用 cli 實現主機端自動更新 git 並發布 dotnet 站台的腳本

cd "D:\\Workspace\\FutureVision"
git pull
iisreset /stop
dotnet publish "D:\\Workspace\\FutureVision\\FutureVision" -c Release -o "D:\\wwwroot\\FutureVision"
iisreset /start

Chrome 自 59 版起內建了 Headless 模式,允許透過命令列啟動 Chrome 以無 GUI 方式執行,藉此可透過 C# 套件快速實作開啟網頁並擷圖等功能

閱讀全文 »

以前寫的 Vue2 都忘得差不多了,藉著最近接到 Vue3 專案的機會,重新學習一下

Vue3 推薦結合以下套件使用,透過官方推薦的初始化指令 npm init vue@latest 可自動建立一個基礎的 Vue 專案

  • Vite: 建置工具
  • Pinia: 狀態管理

Import

CDN:

<script src="https://unpkg.com/vue@next"></script>
閱讀全文 »
0%