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

2022/04/14

[Python] flask restx 如何增加Email欄位驗證

https://flask-restx.readthedocs.io/en/latest/swagger.html#the-api-expect-decorator

 看了這段是這麼寫的


import re
EMAIL_REGEX = re.compile(r'\S+@\S+\.\S+')


user = api.model('User', {
    'id': fields.Integer(readonly=True, description='The user unique identifier'),
    'name': fields.String(required=True, description='The user name'),
    'email': fields.String(required=True, description='The user name', pattern='\S+@\S+.\S+')
})

在你要做這個額外檢查的API加入expect這個裝飾器

@ns_users.expect(user, validate=True)



2022/02/09

[Davinci Resolve]如何將影片檔和音檔同步

 終於在大學畢業前分開錄了個影片檔和用錄音筆額外收音的音檔

好幾天想著感覺要對上去是個大工程

後來搜尋一下,才發現這在達芬奇上滿簡單的

就記錄一下

【达芬奇教程】同步音频视频 - YouTube

10达芬奇媒体页面-视音频自动同步 - YouTube

不過如果原本聲音就炸掉,用波形或音頻同步就會失敗......


[Davinci Resolve]改善效能的設定

 不知道網友都用什麼設備在剪輯的,很少看到網友提及效能不夠的問題

但我用目前R7-4800U八核心十六執行緒的筆電,開了四分之一的代理才沒那麼卡

開了還是有卡卡的感覺

總之覺得各種不對勁,雖然以後應該會直接找礦渣來買了(或是真的去組整台桌機)

現在還是紀錄一下網路上找到的優化方式

[譯] 改善 DaVinci Resolve 效能的 5 個祕訣

如何讓 DaVinci Resolve 在任何電腦都能流暢播放? | 杰客森林 (jacksonlin.net)

2022/01/28

[Python] Mac環境 URLError CERTIFICATE_VERIFY_FAILED

 比起寫教學文章,我發現我都是遇到這種莫名其妙的Bug才會出來發文

目前是覺得自己有能力寫k6的教學了,之後來動工吧

最近想學Pytest這個測試框架

用的工具當然是熟悉的Selenium

但明明之前也用過unittest + selenium,開新的.py檔後爆出以下的問題

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py:1349: URLError

Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org

Stack overflow的解答是

Once upon a time I stumbled with this issue. If you're using macOS go to Macintosh HD > Applications > Python3.6 folder (or whatever version of python you're using) > double click on "Install Certificates.command" file. :D


如果你是用Mac開發

你要打開來 "應用程式" -> "用來開發Python的版本" -> "Install Certificates.command"

這樣就可以了