2023年11月29日 星期三

【Windows】在右鍵選單中新增「在此處開啟命令列」

 將以下內容以ANSI編碼格式存成.reg,點兩下執行即可修改註冊表

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_here]
@="在此處開啟命令列"
"Icon"="cmd.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_here\command]
@="\"C:\\Windows\\System32\\cmd.exe\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmdPrompt]
@="在此處開啟命令列"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmdPrompt\command]
@="\"C:\\Windows\\System32\\cmd.exe\" \"cd %1\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_here]
@="在此處開啟命令列"
"Icon"="cmd.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_here\command]
@="\"C:\\Windows\\System32\\cmd.exe\""

效果如下:




【Python】多版本管理 ─ Python Launcher (Windows)

Python Launcher 是 Python for Windows 才有的功能




列出可用版本: py -0



列出可用版本及執行檔路徑: py -0p



指定使用特定版本:
py -2 test.py 即是使用 python 2 版 (若有多個2版,預設使用最新的2版) 執行 test.py
py -3 test.py 則是使用 python 3 版 (若有多個3版,預設使用最新的3版) 執行 test.py
py -3.5 test.py 則是指定用 3.5 版執行


注意:不同版本套件要分別安裝,例如 py -2 -m pip install <套件名稱>

2023年11月22日 星期三

【Nmap】測試網站是否啟用HTTP/2


 nmap -p <port> --script=tls-nextprotoneg <host>





【gRPC】使用Go語言快速架設gRPC Server

安裝環境 Win10 64bit

電腦要先裝有GO


1. 建立專案資料夾 (結構如下) (helloworld資料夾)
專案目錄
- helloworld
- helloworld.proto
- server
- main.go


2. 建立proto文件 (專案目錄/helloworld/helloworld.proto)


3. 安裝編譯 Protocol Buffer 所需的套件
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest


4. 將proto文件編譯成binary
在專案目錄執行
$ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative helloworld/helloworld.proto


5. 撰寫gRPC Server code (專案目錄/server/main.go)

如果要啟用Server Reflection功能,需import
"google.golang.org/grpc/reflection"
並於main加入reflection.Register
s := grpc.NewServer()
pb.RegisterGreeterServer(s, &server{})
log.Printf("server listening at %v", lis.Addr())
// Register reflection service on gRPC server.
reflection.Register(s)


6. 啟動Server
go run server/main.go


7. 使用gRPC Client軟體(如gRPCurl、Evans、Postman Workspaces)來測試
grpc://host ip:port