Skip to content

Instantly share code, notes, and snippets.

@jasper-lai
jasper-lai / IHubContext.txt
Created March 1, 2024 03:09
SignalR IHubContext<THub, T> 的使用
// IHubContext<THub, T> 的使用.
// javascript
connection.on("ReceiveMessage", function (user, message) {
var li = document.createElement("li");
document.getElementById("messagesList").appendChild(li);
li.textContent = `${user} says ${message}`;
});
// C# 建立一個與 client 的合約, 作為強型別使用.
@jasper-lai
jasper-lai / Cannot connect ubuntu asp.net core webapi.md
Last active November 4, 2022 05:50
issues on ubuntu asp.net core web api

Cannot connect ubuntu asp.net core webapi

問題描述

最近在試 ubuntu 20.04 (執行於 oracle virtualbox) 上的 asp.net core 6 webapi / mvc 程式.
在 ubuntu 上的 edge 可以開啟 webapi 的 swagger 測試頁面; 但無法由 windows 上的 edge 連入, 會出現 ERR_CONNECTION_RESET 的錯誤訊息.

大致步驟如下:

1.. ubuntu 20.04 預設為 firefox, 會出現 SEC_ERROR_UNKNOW_ISSUER, MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT 的錯誤, 有查了一下 在 Linux 上使用 Chrome, Edge, Firefox 信任憑證, 但無法解決 firefox 的問題; 故改用 edge.

@jasper-lai
jasper-lai / End_of_Line_Issue_2_Vs_Code.md
Last active October 25, 2022 08:01
End of Line 相關議題 PART 2 : Vs Code

行尾結束字元探討(End of Line) PART 2 : Vs Code

前言

在前一篇 行尾結束字元探討 PART 1 : Git, 針對 行尾結束字元(End of Line) 在 Git 上的一些議題, 作了一些討論.

本篇再針對 End of Line 在 Vs Code 上的一些議題, 作一些討論.

經過實測發現, 雖然前一篇提到出現 "warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it" 的訊息, 其實對整個版控並無影響, 只是一個提醒而已; 但這整個過程, 將以前沒有注意到的細節, 作了一次探討; 也第一次在 Ubuntu 上安裝 ASP.NET Core 6.0 SDK 及 Visual Studio Code, 並在 Ubuntu 上進行程式修及版控, 也算是有收穫了.

@jasper-lai
jasper-lai / End_of_Line_Issue_1_Git.md
Last active October 25, 2022 07:55
行尾結束字元探討 PART 1 : Git

行尾結束字元探討(End of Line) PART 1 : Git

前言

最近在 study vs code + dotne CLI 的開發方式, 當然也括 git 的部份. 當手工下達 git add . 指令時, 會出現 LF will be replaced by CRLF the next time Git touches it 的警告訊息.

PS D:\22-Projects.Git\52-ASP.NET Core\MvcFriends> git add .
warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '.vscode/launch.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css', LF will be replaced by CRLF the next time Git touches it
@jasper-lai
jasper-lai / docker_bind_mount_for_file_issue.md
Last active September 12, 2022 02:31
issues on bind mount file to container

問題:

小弟剛學習 docker, 如果以下的描述有誤, 請幫忙指點, 謝謝.

在 Windows 10 WSL 2 的環境下, 想要利用 docker run 的 -v 參數, 由外部 bind mount 一個檔案到 container. 經實測發現:
(1) 如果那個檔案預先不存在 host, 會被建成資料夾;
(2) 如果存在 host, 則不會被建成資料夾.

不知這個實測結果, 是否是正常的?

環境:

Windows 10 Home 21H1 (host) + WSL 2 (with Ubuntu 20.04 distro)

@jasper-lai
jasper-lai / sql2019_ubuntu_problem.md
Last active August 3, 2022 05:58
SQL Server 2019 for Ubuntu 20.04 安裝問題

問題:

安裝 SQL Server 2019 on Ubuntu 20.04, 發現只要關機再開機, 就會發生 mssql-server 無法啟動的問題; 錯誤訊息如 [附錄1] 及 [附錄2].

環境:

Windows 10 Home (host) + Virtual Box 6.1.22 + Ubuntu 20.04 (guest) + SQL Server 2019 for Ubuntu

微軟官網安裝文件:

說明:

小弟最近在嚐試安裝 SQL Server 2019 on Ubuntu 20.04, 發現只要關機再開機, 就會發生失敗, 如 [附錄1] 及 [附錄2].

查了一下 Google: 有人提到是 sqlservr.sfp 損壞 (https://dba.stackexchange.com/questions/223911/sql-server-2019-ctp-2-1-on-ubuntu-fails-after-powering-off), 必須要 reinstall 才能解決. 但總不能每次關機再開, 就要 reinstall, 這樣很麻煩.

@jasper-lai
jasper-lai / IBF
Last active April 27, 2022 07:50
IBF
IBF Project
@jasper-lai
jasper-lai / .net6_ef_core_from_db.html
Last active March 10, 2022 06:11
.net6_ef_core_from_db.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<title>.NET 6 Console Program with EF Core From Existing Database</title>
</head>
<body>
@jasper-lai
jasper-lai / link_main_template.cshtml
Last active December 20, 2021 09:38
link_main template