2023/03/24

[laravel] Windows 10 環境使用Laravel Sail建置遇到Port占用問題

Laravel Sail預設會裝Redis,而Redis的預設Port為6379,就會遇到這行

0.0.0:0: listen tcp 0.0.0.0:6378: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

而以Mac OS寫的文章沒有提到

我找到的原因是這個

【茶包射手日記】ASP.NET Core Kestrel 網站無權繫結錯誤與 Windows 10 Port 限制-黑暗執行緒 (darkthread.net)


將Port改成這以外的Port(例如6396就可以了)

延伸閱讀:

2023/02/10

[laravel][Windows env]composer 安裝套件時失敗

 "The zip extension and unzip/7z commands are both missing, skipping" in Windows during composer install laravel - Stack Overflow

我在看網路上的教學文章提及laravel sail是個好東西,所以我嘗試安裝好laravel之後在專案中下載

結果看到一堆錯誤

打了這個指令

composer require laravel/sail --dev

出現很多


- Syncing sebastian/complexity (2.0.2) into cache

    Failed to download sebastian/code-unit-reverse-lookup from dist: The zip extension and 

unzip/7z commands are both missing, skipping.

The php.ini used by your command-line PHP is: C:\php-8.2.2-Win32-vs16-x64\php.ini

    Now trying to download from source

其他的解法清一色是linux的解法,windows就沒有apt-get


stackoverflow裏頭提及解法是將php.ini的一行

extension=zip

將註解給取消即可









2022/12/17

[Google Cloud] gcloud builds submit 忽略了我的金鑰檔案

 Google Cloud Build 教學 (一) — 透過本地端完成 GCP Cloud Build 服務 | by 楊承翰 | Medium

gcloud builds submit  |  Google Cloud CLI Documentation

選擇本地打包放上去CONTAINER REGISTRY才丟到Cloud Run的原因就是因為我沒搞定金鑰如何放在環境變數裡,

問題來了,為什麼我需要使用這個金鑰呢?好像是因為我需要在imager裡用到google cloud?

好問題,我還是先去背誦義務役都要背的單戰好了

解決方式:

多寫一個 .gcloudignore 讓我的金鑰檔案不被忽略而沒有打包進build裡

找到的問題點:

打包部署時遇到下列說明(奇怪為什麼之前沒這個問題)

Creating temporary tarball archive of 7 file(s) totalling 24.0 KiB before compression.

Some files were not included in the source upload.

文檔中有寫清楚,如果打包時檔案沒有 .gcloudignore,就會使用 .gitignore 作為打包時處理要忽略的檔案

[SOURCE]
The location of the source to build. The location can be a directory on a local disk or a gzipped archive file (.tar.gz) in Google Cloud Storage. If the source is a local directory, this command skips the files specified in the --ignore-file. If --ignore-file is not specified, use.gcloudignore file. If a .gcloudignore file is absent and a .gitignore file is present in the local source directory, gcloud will use a generated Git-compatible .gcloudignore file that respects your .gitignored files. The global .gitignore is not respected. For more information on .gcloudignore, see gcloud topic gcloudignore.

2022/11/09

[Python]踩坑Pitfall configparser.NoSectionError: No section:

python 读取配置文件总是报错 configparser.NoSectionError: No section:

存環境變數的時候,就照著這篇文章的建議

使用.txt作為副檔名,使用.ini作為副檔名會讀取不到

Using .txt as filename extension because using .ini could not read configuration file

花了三小時才找到的坑QQ

jiamingla/LINE-Notify-youtube-video-notify (github.com)

後來想想造成這個問題可能的原因:

本地未打包、打包後都能讀取到 config.ini,部署上 Cloud Run 就讀取不到,我想是 Cloud Run 有保留 config.ini 作為其他用途吧

2022/06/21

[JavaScript] JSON.stringify()的坑

console.log(JSON.stringify('dd'));

console.log('dd');

> '"dd"' > "dd"

JSON.stringify()會貼心地幫你保留下來""或是''

好的


2022/04/16

[Python] 下載最新版本後不能檢查密碼 safe_str_cmp 這個方法被棄用該怎麼辦

 我看好到幾篇教學文章都會用到

from werkzeug.security import safe_str_cmp

用來檢查使用者登入時輸入的密碼是否和db內的密碼解密後一樣?

搜尋一下stackoverflow的結果通常是給你就把werkzeug的版本固定在2.0.0就好了

我在想有沒有這個函式的替代方案

於是找到了這篇

DeprecationWarning: 'safe_str_cmp' is deprecated and will be removed in Werkzeug 2.1. Use 'hmac.compare_digest' instead. return safe_str_cmp(bcrypt.hashpw(password, pw_hash), pw_hash) - githubhot

用hmac的這個來替換就可以了?

hmac --- 基於金鑰雜湊的訊息驗證 — Python 3.10.4 說明文件

hmac.compare_digest(ab)

不過我還沒試過,之後再回來補這部分XD