2025年4月29日 星期二

VS CODE離線安裝套件方式

VS CODE可攜式安裝下載 https://code.visualstudio.com/download,點選windows 下.zip x64下載VSCode-win32-x64-1.99.3.zip,解壓縮到某目錄。

安裝離線版套件,例如安裝powershell套件,

先安裝最新版 powershell ,進入https://github.com/PowerShell/PowerShell

在右方Releases 會顯示最新版本號,點選進入去下載 PowerShell-7.5.1-win-arm64.msi


再到 https://marketplace.visualstudio.com/ 找需要的安裝檔vsix。


導引到https://github.com/PowerShell/vscode-powershell 一樣在右方Releases 會顯示最新版本號,點進去下載powershell-2025.0.0.vsix


開啟code.exe ,點選左方sidebar 的Extensions, 在視窗右上方 ... 選取 install from VSIX ...,就可以離線安裝所需的套件了。

心得:powershell 7功能較多,雖無像powershell 5 自帶ISE,但使用VS CODE套件也足以滿足所需,重點是還可以debug,十分方便。



2025年4月16日 星期三

tsql 不用unpivot 將columns轉rows

有個需求需要將多一筆資料的多欄位值轉成多列資料

之前都使用unpivot,試了一下直接用outer apply就可達成,十分好用。

其中concat 會自動處理null 為空值再串聯文字,所以也不用判斷isnull(col1,'')了。

declare @tab table (col1 nvarchar(10),col2 nvarchar(10),col3 nvarchar(10),col4 nvarchar(10))

insert into @tab values

('A','X','Y','Z'),

('B','X','Y',null),

('A','1','2','')

select distinct  col1,y.value

from @tab outer apply   (select * from string_split(concat(col2,',',col3,',',col4),',') where value > '') y

pdf.js 無法顯示部份字

有個檔案在pdf viewer套件中無法顯示內容,但下載檔案後使用工具又可以正常顯示。 本來以為是套件版本太舊的原因,於是去下載pdf viewer套件 https://github.com/mozilla/pdf.js 更新後還是一樣。 覺得應是字型缺漏的問題,於是用PDF-X...