Compare commits
10 Commits
36397ff348
...
d0e6e30c8b
| Author | SHA1 | Date | |
|---|---|---|---|
| d0e6e30c8b | |||
| 70d2505dc5 | |||
| 6145012653 | |||
| f555f04b92 | |||
| ad4e75712f | |||
| bfdfeee8ae | |||
| e2665a4b17 | |||
| a40d08b39c | |||
| dd474b5177 | |||
| 2753c60fca |
130
content/posts/2019/[C++ 筆記] 好用的 optional/index.md
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
---
|
||||||
|
slug: "[C++ 筆記] 好用的 std::optional"
|
||||||
|
title: "[C++ 筆記] 好用的 std::optional"
|
||||||
|
description:
|
||||||
|
toc: true
|
||||||
|
authors:
|
||||||
|
- awin
|
||||||
|
tags:
|
||||||
|
- c++
|
||||||
|
categories:
|
||||||
|
- Programming
|
||||||
|
series:
|
||||||
|
- C++ 筆記
|
||||||
|
date: 2019-12-22T00:00:00
|
||||||
|
lastmod: 2019-12-22T00:00:00
|
||||||
|
featuredVideo:
|
||||||
|
featuredImage:
|
||||||
|
draft: false
|
||||||
|
enableComment: true
|
||||||
|
---
|
||||||
|
|
||||||
|
> since C++17
|
||||||
|
|
||||||
|
[`std::optional`](https://en.cppreference.com/w/cpp/utility/optional) 讓 function 的回傳值多了一個選擇:**有值**或是 `nullopt`。
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
例如我們有一個 function 要從某個檔案讀值出來(或是去 DB 查一個東西之類的需求),就假設我們要讀一個 int,我們也許會這樣寫:
|
||||||
|
```cpp
|
||||||
|
int readData(std::string filePath) {
|
||||||
|
...
|
||||||
|
int data = readFromFile(...);
|
||||||
|
...
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
但如果要讀的檔案不存在呢?這時候要 return 什麼呢?所以這時候我們會改成這樣寫:
|
||||||
|
```cpp
|
||||||
|
bool readData(std::string filePath, int& readData) {
|
||||||
|
FILE* file = fopen(...)
|
||||||
|
if (!file) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
readData = readFromFile(...);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
我們用一個回傳值代表檔案讀取失敗與否,要是檔案存在且開啟成功,那麼 `readData` 這個回傳值就代表我們讀到的值。要是回傳值是 `false`,那 `readData` 就沒有意義。
|
||||||
|
但是這樣會讓傳入跟傳出的參數混在一起,第一時間也不容易直覺的分辨出來,像這種情況 Python 就清楚很多:
|
||||||
|
```python
|
||||||
|
def readData(filePath):
|
||||||
|
data = None
|
||||||
|
try:
|
||||||
|
with open(filePath, "rb") as f:
|
||||||
|
data = f.read(...)
|
||||||
|
return data
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
return None
|
||||||
|
|
||||||
|
value = readData("123.txt")
|
||||||
|
if value:
|
||||||
|
pass # Do something...
|
||||||
|
```
|
||||||
|
可以像 Python 那樣都從回傳值來判斷嗎? `std::optional` 可以達到這個目的:
|
||||||
|
```cpp
|
||||||
|
std::optional<int> readData(std::string filePath) {
|
||||||
|
FILE* file = nullptr;
|
||||||
|
fopen_s(&file, filePath.c_str(), "rb");
|
||||||
|
if (!file) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
int readData;
|
||||||
|
fread(&readData, 1, sizeof(readData), file);
|
||||||
|
fclose(file)
|
||||||
|
|
||||||
|
return readData;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = readData("123.txt");
|
||||||
|
if (result) {
|
||||||
|
auto value = result.value();
|
||||||
|
// Use value here...
|
||||||
|
}
|
||||||
|
|
||||||
|
// 或是這樣寫也可以
|
||||||
|
if (result == std::nullopt) {
|
||||||
|
// Error handle here
|
||||||
|
} else {
|
||||||
|
auto value = result.value();
|
||||||
|
// Use value here...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
雖然用起來沒辦法讓 C++ 像 Python 那麼簡單,但是 `std::optional` 確實讓整段 code 看起來更清楚了。
|
||||||
|
除了 [`std::optional<T>::value()`](https://en.cppreference.com/w/cpp/utility/optional/value) 以外,還有其他的取值方法:
|
||||||
|
```cpp
|
||||||
|
std::optional<std::string> name;
|
||||||
|
|
||||||
|
// Some process...
|
||||||
|
|
||||||
|
if (name)
|
||||||
|
{
|
||||||
|
printf("name = %s\n", (*name).c_str());
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
如果 `std::optional` 包含的是 struct 或是 class,也可以用 `->` 來直接存取 member(或 member function):
|
||||||
|
```cpp
|
||||||
|
struct User {
|
||||||
|
uint32_t id;
|
||||||
|
std::string name;
|
||||||
|
int32_t age;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::optional<User> user;
|
||||||
|
|
||||||
|
// Some process...
|
||||||
|
|
||||||
|
if (user) {
|
||||||
|
printf("id = %d\n", user->id);
|
||||||
|
printf("name = %s\n", user->name.c_str());
|
||||||
|
printf("age = %d\n", user->age);
|
||||||
|
}
|
||||||
|
```
|
||||||
68
content/posts/2021/Windows 11 重灌/index.md
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
---
|
||||||
|
slug: Windows 11 重灌
|
||||||
|
title: Windows 11 重灌
|
||||||
|
description:
|
||||||
|
toc: true
|
||||||
|
authors: [awin]
|
||||||
|
tags: [windows]
|
||||||
|
categories: [System]
|
||||||
|
series: [Windows]
|
||||||
|
date: 2021-11-01T00:00:00
|
||||||
|
lastmod: 2021-11-01T00:00:00
|
||||||
|
featuredVideo:
|
||||||
|
featuredImage:
|
||||||
|
draft: false
|
||||||
|
enableComment: true
|
||||||
|
---
|
||||||
|
|
||||||
|
## 恢復備份
|
||||||
|
- `%userprofile%/.config`
|
||||||
|
- `%userprofile%/.ssh`
|
||||||
|
- `%userprofile%/.bash_profile`
|
||||||
|
- `%userprofile%/.bashrc`
|
||||||
|
- `%userprofile%/.gitconfig`
|
||||||
|
- `%userprofile%/.vimrc`
|
||||||
|
|
||||||
|
## 安裝 Chocolatey
|
||||||
|
先安裝 [Chocolatey](https://chocolatey.org/) ,根據 [https://chocolatey.org/install](https://chocolatey.org/install) ,用 Administrator 權限打開 Terminal ,輸入以下指令安裝:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
||||||
|
```
|
||||||
|
|
||||||
|
## 安裝需要的軟體
|
||||||
|
接著就可以安裝需要的工具了。
|
||||||
|
```shell
|
||||||
|
choco install powertoys 7zip vscode hxd sublimetext4 androidstudio intellijidea-community git winmerge freefilesync freedownloadmanager gsudo firacode cascadiacode sourcecodepro delta googlechrome googledrive enpass.install sharex win32diskimager k-litecodecpackmega --yes
|
||||||
|
```
|
||||||
|
|
||||||
|
可以在 [https://community.chocolatey.org/packages](https://community.chocolatey.org/packages) 找到其他工具,再加到清單後面即可。
|
||||||
|
|
||||||
|
上面的指令安裝了下列的軟體,可以依自己需求增刪:
|
||||||
|
- [powertoys](https://community.chocolatey.org/packages/powertoys)
|
||||||
|
- [7zip](https://community.chocolatey.org/packages/7zip)
|
||||||
|
- [vscode](https://community.chocolatey.org/packages/vscode)
|
||||||
|
- [hxd](https://community.chocolatey.org/packages/hxd)
|
||||||
|
- [sublimetext4](https://community.chocolatey.org/packages/sublimetext4)
|
||||||
|
- [androidstudio](https://community.chocolatey.org/packages/androidstudio)
|
||||||
|
- [intellijidea-community](https://community.chocolatey.org/packages/intellijidea-community)
|
||||||
|
- [git](https://community.chocolatey.org/packages/git)
|
||||||
|
- [winmerge](https://community.chocolatey.org/packages/winmerge)
|
||||||
|
- [freefilesync](https://community.chocolatey.org/packages/freefilesync)
|
||||||
|
- [freedownloadmanager](https://community.chocolatey.org/packages/freedownloadmanager)
|
||||||
|
- [gsudo](https://community.chocolatey.org/packages/gsudo)
|
||||||
|
- [firacode](https://community.chocolatey.org/packages/firacode)
|
||||||
|
- [cascadiacode](https://community.chocolatey.org/packages/cascadiacode)
|
||||||
|
- [sourcecodepro](https://community.chocolatey.org/packages/sourcecodepro)
|
||||||
|
- [delta](https://community.chocolatey.org/packages/delta)
|
||||||
|
- [googlechrome](https://community.chocolatey.org/packages/googlechrome)
|
||||||
|
- [googledrive](https://community.chocolatey.org/packages/googledrive)
|
||||||
|
- [enpass.install](https://community.chocolatey.org/packages/enpass.install)
|
||||||
|
- [sharex](https://community.chocolatey.org/packages/sharex)
|
||||||
|
- [win32diskimager](https://community.chocolatey.org/packages/win32diskimager)
|
||||||
|
- [k-litecodecpackmega](https://community.chocolatey.org/packages/k-litecodecpackmega)
|
||||||
|
|
||||||
|
## 升級軟體
|
||||||
|
```shell
|
||||||
|
choco upgrade all -y
|
||||||
|
```
|
||||||
BIN
content/posts/2022/用 oh-my-posh 美化 Git bash/featured.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 26 KiB |
47
content/posts/2022/用 oh-my-posh 美化 Git bash/index.md
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
slug: 用 oh-my-posh 美化 Git bash
|
||||||
|
title: 用 oh-my-posh 美化 Git bash
|
||||||
|
description:
|
||||||
|
toc: true
|
||||||
|
authors:
|
||||||
|
- awin
|
||||||
|
tags:
|
||||||
|
- terminal
|
||||||
|
categories:
|
||||||
|
- Tool setup
|
||||||
|
series:
|
||||||
|
- Windows
|
||||||
|
date: 2022-06-14T00:00:00
|
||||||
|
lastmod: 2022-06-14T00:00:00
|
||||||
|
featuredVideo:
|
||||||
|
featuredImage:
|
||||||
|
draft: false
|
||||||
|
enableComment: true
|
||||||
|
---
|
||||||
|
|
||||||
|
讓 [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701) 中的 Git bash 也可以美美的。
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
## 步驟
|
||||||
|
以下步驟都是在 [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701) 中的 Git bash[^1] 執行。
|
||||||
|
1. 先下載一個你喜歡的theme: [https://ohmyposh.dev/docs/themes](https://ohmyposh.dev/docs/themes)
|
||||||
|
2. 下載並安裝字型:[Caskaydia Cove Nerd Font](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/CascadiaCode.zip?WT.mc_id=-blog-scottha)
|
||||||
|
3. Install OhMyPosh: `winget install JanDeDobbeleer.OhMyPosh`
|
||||||
|
4. 建立並修改 `~/.profile`,然後加入
|
||||||
|
`eval "$(oh-my-posh --init --shell bash --config ~/montys.omp.json)"`
|
||||||
|
注意最後的 `montys.omp.json` 就是第一步下載的theme,這邊要改成你自己的路徑。
|
||||||
|
5. 修改 Windows Terminal 的 `setting.json`,將字型改為 `CaskaydiaCove NF`
|
||||||
|

|
||||||
|
6. 重開 Windows Terminal
|
||||||
|
|
||||||
|
[^1]: 在 [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701) 中設定 Git bash 可以參考:[Windows Terminal's 設定 Git Bash 和 SSH @ 傑克! 真是太神奇了! :: 痞客邦 ::](https://magicjackting.pixnet.net/blog/post/225162505-windows-terminal's-%E8%A8%AD%E5%AE%9A-git-bash-%E5%92%8C-ssh)
|
||||||
|
|
||||||
|
## 成果
|
||||||
|

|
||||||
|
|
||||||
|
## 參考
|
||||||
|
- [Oh My Posh](https://ohmyposh.dev/)
|
||||||
|
- [How to make the ultimate Terminal Prompt on Windows 11 - This video is LONG and WORDY and DETAILED - YouTube](https://www.youtube.com/watch?v=VT2L1SXFq9U)
|
||||||
|
- [My Ultimate PowerShell prompt with Oh My Posh and the Windows Terminal - Scott Hanselman's Blog](https://www.hanselman.com/blog/my-ultimate-powershell-prompt-with-oh-my-posh-and-the-windows-terminal)
|
||||||
|
- [Windows-Terminal配置OhMyPosh来美化GitBash_偕臧x的博客-CSDN博客](https://blog.csdn.net/qq_33154343/article/details/120661945)
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
---
|
||||||
|
slug: Dokcer Compose 遇到 Python 3.6 不再支援問題
|
||||||
|
title: Dokcer Compose 遇到 Python 3.6 不再支援問題
|
||||||
|
description:
|
||||||
|
toc: true
|
||||||
|
authors:
|
||||||
|
- awin
|
||||||
|
tags: []
|
||||||
|
categories: []
|
||||||
|
series: []
|
||||||
|
date: 2023-05-09T00:00:00
|
||||||
|
lastmod: 2023-05-09T00:00:00
|
||||||
|
featuredVideo:
|
||||||
|
featuredImage:
|
||||||
|
draft: false
|
||||||
|
enableComment: true
|
||||||
|
---
|
||||||
|
|
||||||
|
解決 `docker-compose` 警告 Python 3.6 不再支援問題。
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
可能已經發生一時間了,但是最近才注意到 XD。
|
||||||
|
|
||||||
|
在使用 `docker-compose down` 或是 `docker-compose up`,都會出現下面這個訊息:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/snap/docker/2746/lib/python3.6/site-packages/paramiko/transport.py:32: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography (40.0) will be the last to support Python 3.6.
|
||||||
|
from cryptography.hazmat.backends import default_backend
|
||||||
|
```
|
||||||
|
|
||||||
|
雖然已經確定使用 Python 3.10,查看 docker-compose 版本也確實發現它還是使用 Python 3.6:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
xxxx@xxxx:~/oooo/ooxx$ sudo docker-compose version
|
||||||
|
/snap/docker/2746/lib/python3.6/site-packages/paramiko/transport.py:32: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography (40.0) will be the last to support Python 3.6.
|
||||||
|
from cryptography.hazmat.backends import default_backend
|
||||||
|
docker-compose version 1.29.2, build unknown
|
||||||
|
docker-py version: 5.0.3
|
||||||
|
CPython version: 3.6.9
|
||||||
|
```
|
||||||
|
|
||||||
|
這是因為 `docker-compose` 這個命令已經過時了,請改用 `docker compose` 就可以了。<br>
|
||||||
|
要是習慣改不過來,不妨就加個alias吧:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
alias docker-compose='docker compose'
|
||||||
|
```
|
||||||
BIN
content/posts/2023/Fujifilm X-T5 入手感想/featured.jpg
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
content/posts/2023/Fujifilm X-T5 入手感想/images/IMG_6330.mp4
Normal file
BIN
content/posts/2023/Fujifilm X-T5 入手感想/images/IMG_6332.jpg
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
BIN
content/posts/2023/Fujifilm X-T5 入手感想/images/IMG_6333.jpg
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
BIN
content/posts/2023/Fujifilm X-T5 入手感想/images/IMG_6334.jpg
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
62
content/posts/2023/Fujifilm X-T5 入手感想/index.md
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
slug: Fujifilm X-T5 入手感想
|
||||||
|
title: Fujifilm X-T5 入手感想
|
||||||
|
description:
|
||||||
|
toc: true
|
||||||
|
authors:
|
||||||
|
- awin
|
||||||
|
tags:
|
||||||
|
- photography
|
||||||
|
- fujifilm
|
||||||
|
- x-t5
|
||||||
|
categories:
|
||||||
|
- Hobby
|
||||||
|
series: []
|
||||||
|
date: 2023-04-08T00:00:00
|
||||||
|
lastmod: 2023-04-08T00:00:00
|
||||||
|
featuredVideo:
|
||||||
|
featuredImage:
|
||||||
|
draft: false
|
||||||
|
enableComment: true
|
||||||
|
---
|
||||||
|
|
||||||
|
買了 X-T5 也一陣子了,機器功能什麼的是很OK的,尤其跟前一台比起來,性能、感光度什麼的都是大幅度的進步,滿滿的升級感。
|
||||||
|
|
||||||
|
只是使用上還是不習慣,這一篇來講一下不習慣的點,還有解決方法。
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
雖然 X-T5 的轉盤很漂亮很有型,但是要一直轉來轉去也是有點煩人,像是你將設定快門之後(快門先決),要改成A模式(光圈先決),先得把快門轉回A,然後再把光圈轉到你要的位置,如果這時候要回到P模式,對,快門轉盤跟光圈環都要調回A才行。也不是不好,就是有點煩人。
|
||||||
|
|
||||||
|
第二個不習慣的點是我還是習慣用觀景窗來取景,要調整轉盤的話,變成要將相機放下來,轉動轉盤,再把相機拿起來取景,尤其是ISO轉盤,它在左手邊,要由本來扶著鏡頭的左手來調整,一整個就很不順手。我還是希望可以在取景的時候,用右手就可以改變設定,不用把相機拿上拿下的。
|
||||||
|
|
||||||
|
另外一個問題是X-T5的握把實在太淺了,有夠難握,這時候就很懷念前一台那厚實的握把,可以牢牢握住的那種踏實感。
|
||||||
|
|
||||||
|
這邊紀錄一下這幾個問題的解決方法。
|
||||||
|
|
||||||
|
## 握把
|
||||||
|
關於握把,是買[Smallrig 3870](https://www.smallrig.com/SmallRig-Retro-Cage-for-FUJIFILM-X-T5-3870.html),這個兔籠可以加深握把,而且也把快門鈕的位置往前移,但是它往前移的機構並沒有做的很好,必須按連桿中間部份才可以有效的對焦。看下面的影片,一開始按連桿的前面(也就是它原本預計要把快門前移的位置),你會發現按下去之後,連桿沒辦法順利的拉動原本的快門鈕,必須按中間一點的位置才行。
|
||||||
|
|
||||||
|
{{< video src="images/IMG_6330.mp4" type="video/mp4" preload="auto" >}}
|
||||||
|
|
||||||
|
雖然不完美,但是握把真的舒服太多了,所以這點瑕不掩瑜,是一個可以適應的小問題。
|
||||||
|
|
||||||
|
## 滾輪控制
|
||||||
|
第二個問題是希望可以把光圈、快門、ISO的調整都改為用右手的前後滾輪來控制,這樣就可以在取景的時候直接調整了。要達到這目標有幾個地方要調整:
|
||||||
|
1. 光圈環調成 "A"
|
||||||
|
2. ISO 轉盤調成 "C"
|
||||||
|
3. EV 轉盤調成 "C"
|
||||||
|
4. 設定選單,進入「設定」頁面的「按鈕/轉盤設定」,將前轉盤的3個功能改為「F」、「EV」、「ISO」
|
||||||
|
5. 同樣的選單位置,將後轉盤改為「S.S」
|
||||||
|
|
||||||
|
| | | |
|
||||||
|
|:-------------------------:|:-------------------------:|:-------------------------:|
|
||||||
|
|  |  |  |
|
||||||
|
|
||||||
|
這樣設定之後,後轉盤可以用來控制快門,前轉盤可以控制光圈、EV、ISO這3樣。
|
||||||
|
現在相機會變為「P模式」,將快門轉盤轉到 "T" 之後就會變成「S模式」,這時候可以用後轉盤來調整快門。
|
||||||
|
將快門轉盤調回 A,將前轉盤「向左轉」,這時候會出現藍色的光圈數值,這時候就是「A模式」了。
|
||||||
|
按下前轉盤可以在光圈、EV、ISO之中切換。如果快門轉盤沒有調回 A,那麼就是「M模式」,總之一切都可以在這2個轉盤中搞定了。
|
||||||
|
唯一還是需要用到轉盤的就是快門轉盤了,不過從A調到T只要2格,這不容易弄錯,很快就可以熟悉了。
|
||||||
|
|
||||||
|
後來我發現X-H2就是我想要的這種操作模式,如果這樣的設定還是用不習慣,看來只能......🤣。
|
||||||
BIN
content/posts/2023/福岡 Nu Gundam/featured.jpg
Normal file
|
After Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 638 KiB |
|
After Width: | Height: | Size: 634 KiB |
|
After Width: | Height: | Size: 592 KiB |
25
content/posts/2023/福岡 Nu Gundam/index.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
slug: 福岡 Nu Gundam
|
||||||
|
title: 福岡 Nu Gundam
|
||||||
|
description:
|
||||||
|
toc: true
|
||||||
|
authors:
|
||||||
|
- awin
|
||||||
|
tags:
|
||||||
|
- Gunpla
|
||||||
|
categories:
|
||||||
|
- Hobby
|
||||||
|
series:
|
||||||
|
- Scale Model
|
||||||
|
date: 2023-02-15T00:00:00
|
||||||
|
lastmod: 2023-02-15T00:00:00
|
||||||
|
featuredVideo:
|
||||||
|
featuredImage:
|
||||||
|
draft: false
|
||||||
|
enableComment: true
|
||||||
|
---
|
||||||
|
|
||||||
|
繼台場 RX-78 與 Unicorn 之後,很開心終於收集到了 LaLaport 的 Nu Gundam,下一個目標,當然就是橫濱的 RX-78 F00 啦!
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
5
layouts/shortcodes/video.html
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<video class="video-shortcode" preload="{{ .Get "preload" }}" controls>
|
||||||
|
<source src="{{ .Get "src" }}" type="{{ .Get "type" }}">
|
||||||
|
There should have been a video here but your browser does not seem
|
||||||
|
to support it.
|
||||||
|
</video>
|
||||||
@@ -35,7 +35,7 @@ def get_year(time_str):
|
|||||||
|
|
||||||
|
|
||||||
def create_post(filepath, args):
|
def create_post(filepath, args):
|
||||||
with open(filepath, 'w') as f:
|
with open(filepath, 'w', encoding="utf-8") as f:
|
||||||
f.write('---\n')
|
f.write('---\n')
|
||||||
|
|
||||||
for key in DEFAULT_FRONT_MATTER.keys():
|
for key in DEFAULT_FRONT_MATTER.keys():
|
||||||
@@ -70,6 +70,8 @@ def main(args):
|
|||||||
print("Need a title!")
|
print("Need a title!")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
print(f'\n--------------------------------------------------------------------------------\nargs.posttitle = {args.posttitle}')
|
||||||
|
|
||||||
os.chdir('content/posts')
|
os.chdir('content/posts')
|
||||||
dir_name = os.path.join(str(get_year(args.postdate)), args.posttitle)
|
dir_name = os.path.join(str(get_year(args.postdate)), args.posttitle)
|
||||||
try:
|
try:
|
||||||
@@ -85,7 +87,7 @@ def main(args):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-t", "--posttitle", default=None, help="The title of post.")
|
parser.add_argument("-t", "--posttitle", default=None, type=str, help="The title of post.")
|
||||||
parser.add_argument("-d", "--postdate", default=datetime.datetime.now().strftime('%Y-%m-%d'), help="The date of post.")
|
parser.add_argument("-d", "--postdate", default=datetime.datetime.now().strftime('%Y-%m-%d'), help="The date of post.")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|||||||