發表文章

go 掃雷:time.Format 與 time.Parse

地雷 1: time.Format dt := time.Now() fmt.Println(dt.String()) 輸出為: 2023-01-13 19:21:12.4065311 +0800 CST m=+0.000709101 想要自訂輸出格式 strWrong := dt.Format("2023-01-13 15:01:05") fmt.Println(strWrong) 結果輸出很奇怪的東西: 13137-01-17 19:01:41 本來認為 go 可以依照指定的格式輸出,結果查了資料才發現必須用指定的時間才會乖乖聽話 正確: strRight := dt.Format(" 2006-01-02 15:04:05 ") fmt.Println(strRight) 輸出: 2023-01-13 19:24:41 地雷 2: time.Parse 想要從字串解析為日期時間,格式字串仍然須為指定時間  2006-01-02 15:04:05 // 沒用到秒,所以格式字串省略秒的部分 d3, _ := time.Parse("2006-01-02 15:04", "2023-01-13 12:25") fmt.Println(d3.String()) 預期輸出: 2023-01-13 12:25:00 +0800 CST 錯誤輸出, 時區錯誤 : 2023-01-13 12:25:00 +0000 UTC 改用: fmt.Println(d3.Local()) 錯誤輸出,時區對了,但 多了 8 小時 : 2023-01-13 20 :25:00 +0800 CST 查資料發現改用另一個函數即可得到正確結果 // 第三個參數用 time.Local d3, _ := time.ParseInLocation("2006-01-02 15:04", "2023-01-13 12:25", time.Local) fmt.Println(d3.String()) fmt.Println(d3.Local()) 輸出均為正確結果: 2023-01-13 12:25:00 +0800 CST 2023-01-13 12:25:00 +0800 CST

[工具] TranslucentTB,讓工作列實現透明毛玻璃

TranslucentTB,讓工作列實現透明毛玻璃 - GDaily Releases · TranslucentTB/TranslucentTB

Docker 跑 MacOS

MacOS Docker - YouTube Docker Macos sickcodes/Docker-OSX: Run macOS VM in a Docker! Run near native OSX-KVM in Docker! X11 Forwarding! CI/CD for OS X Security Research! Docker mac Containers.

go 背景執行 cmd / powershell 不顯示視窗

 https://stackoverflow.com/questions/42500570/how-to-hide-command-prompt-window-when-using-exec-in-golang 執行 powershell 時雖然加入 -WindowStyle Hidden 可以不顯示視窗,但實際上還是會看到視窗打開又關閉的狀況,會造成畫面閃動。 上面的討論提供的解法解決了這個問題。

ventoy + windows to go + vhdx = 快捷建構可攜帶的 Windows 系統

 快捷無痛安裝與體驗Windows 11 (一):利用Windows 11 To Go跨越安裝限制 (二):準備VHD虛擬硬碟與安裝Ventoy (三):將Windows 11 To Go部署至VHD虛擬硬碟 (四):排除Windows 11 To Go啟動錯誤問題 (五):拿到不同電腦也能啟動Windows 11 To Go 依照系列文章即可實作出成果,但過程仍有優化空間。 以下是我個人實作的調整: 1. vhdx 可以透過 Simple VHD manager 快速產生,bootice 或 diskpart 產生也行,採用動態大小為佳,效能雖較差但體感基本上不明顯,檔案大小較小部署上較快,需搭配登錄檔使用,不然會突然長大喔。vhdx 虛擬大小不可超過所在磁碟之剩餘可用空間,否則後續會無法使用該 vhdx 開機。 https://www.sordum.org/8705/simple-vhd-manager-v1-4/ VHD系统启动时, 阻止动态扩展VHD扩展到完整大小 2. regedit 部份可以先準備好 reg 檔,連同其他 reg 檔一併透過指令匯入。相關 reg 檔在 rufus 複製完檔案重開機之前先複製到 windows\system32 下方便匯入,匯入後可刪除 關閉 UAC 移除浮水印 reg import xxx.reg del /f xxx.reg del /f *.reg 3. 帳號可以直接以指令新增並加入管理員群組,預設42天後會強制變更密碼,雖然一樣可以空密碼跳過,但總是有點煩人,可以用 powershell 指令直接設成密碼永不過期。 net user 帳號 /add net localgroup administrators 帳號 /add powershell Set-LocalUser -Name "帳號" -PasswordNeverExpires 1 4. 若需要有『分鐘級』還原功能,可安裝完成後產生2個差異磁碟,日常使用+還原用各一,diskpart 或 bootice 均可處理。 diskpart Create vdisk file=”c:\test\test.vhdx” parent=”c:\test\parent.vhdx” 5. ventoy.json 要設定好比較方便使用,ventoy 官方有

Laravel 9 學習資源

  Laravel 9 Tutorial for Beginners | How to Learn Laravel 9 | Complete Laravel 9 Tutorial in 2022 Laravel 9 API Crash Course With Sanctum | Laravel Sanctum Full Tutorial | How to Build Laravel API

benphelps/homepage

https://github.com/benphelps/homepage A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations.