星期三, 6月 15, 2016

修正 GitLab 發系統通知信需要密碼的錯誤

不論是前任管理員或網路上都有此誤解,澄清相關設定如下即可:
  • 寄件伺服器接受網域內互寄不需密碼驗證
  • gitlab_email_from 必須是真正的郵件位址,不能是 noreply@nodomain
  • 不設定 smtp_user_name
  • 不設定 smtp_password
  • 不設定 smtp_authentication
  • 其他 smtp 相關設定依官網範例

星期六, 6月 04, 2016

利用 PowerShell 處理多文字檔內的字串替換

假設待處理文字檔的完整路徑都一行一行地收集在 list.txt,每個檔案內的 old 都要換成 new,PowerShell 的命令檔 *.ps1 內容如下:

$fileList = Get-Content list.txt
foreach ($targetFile in $fileList) {
    (Get-Content $targetFile) |
Foreach-Object {$_ -replace "old", "new"} |
Set-Content $targetFile
}

若更單純些,只要處理一個文字檔,只要保留迴圈內的部份,$targetFile 直接換成檔名即可。

星期四, 6月 02, 2016

到不了的中斷點

在 Visual Studio 的某個專案,其他許多中斷點都正常,唯獨這一個停不下來:
  • string s = AppDomain.CurrentDomain.BaseDirectory;
它有什麼特別?原來這是編譯器最佳化的對象。有個設定可以讓它恢復平民身分:
  • Project Properties -> Build -> Optimize code -> uncheck