vault backup: 2024-02-17 23:16:21

This commit is contained in:
2024-02-17 23:16:21 +08:00
parent d7f574153d
commit 2021ab7180
56 changed files with 3 additions and 16 deletions

View File

@@ -1 +0,0 @@
[AnthonyCalandra/modern-cpp-features: A cheatsheet of modern C++ language and library features.](https://github.com/AnthonyCalandra/modern-cpp-features)

View File

@@ -1 +0,0 @@
[C++20, How Hard Could It Be](https://docs.google.com/presentation/d/1HwLNSyHxy203eptO9cbTmr7CH23sBGtTrfOmJf9n0ug/edit?fbclid=IwAR2wToW9uFJuLtUR9nftfv9N9axXwPK7HmuJWqgVmCeXd1XJF7ySQIkNsJM&resourcekey=0-GH5F3wdP7D4dmxvLdBaMvw#slide=id.g1c5cc391dd_2_295)

View File

@@ -1,16 +0,0 @@
1. Use std::shared_ptr & std::unique_ptr & std::weak_ptr
2. Use std::array or std::vector
3. Use structured binding & std::tuple
4. Use for (auto& elem : collector)
5. Use std::format
6. Use std::optional
7. Use auto for return type
8. Use auto in variable declaration
9. Use `using` to replace `#define`
10. Use "Lambda expression" and std::function
11. `[[deprecated]]` attribute
12. Maybe...std::any?
13. And more, constexpr, concept,
## Reference
- [AnthonyCalandra/modern-cpp-features: A cheatsheet of modern C++ language and library features.](https://github.com/AnthonyCalandra/modern-cpp-features)

View File

@@ -1 +0,0 @@
[Modern C++ use in Chromium](https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++-features.md#Declaring-non_type-template-parameters-with-auto-tbd)

View File

@@ -1,172 +0,0 @@
## cut
Linux 的 `cut` 指令是一個實用的文字處理工具,可以將每一行文字的部份字元或欄位擷取出來,以下是使用方式與範例。
### 擷取字元
對於欄位寬度是固定的資料,可以使用擷取固定位置字元的方式,把指定的欄位抓出來,典型的例子就是從 `ls` 指令的輸出中擷取檔案權限。假設我們的 `ls` 指令與輸出資料如下:
```bash
# 僅輸出最後 5 筆檔案資訊
ls -l | tail -n 5
```
```
drwxr-xr-x 2 gtwang gtwang 4096 11月 7 22:29 影片
drwxr-xr-x 7 gtwang gtwang 4096 2月 6 21:01 文件
drwxr-xr-x 4 gtwang gtwang 4096 2月 22 21:09 桌面
drwxr-xr-x 2 gtwang gtwang 4096 1月 6 2017 模板
drwxrwxr-x 2 gtwang gtwang 4096 1月 6 2017 音樂
```
如果我們想要擷取第一欄中的檔案權限(也就是第 2 個字元到第 10 個字元),可以使用 `cut` 指令配合 `-c` 參數,將每一行的第 2 個字元至第 10 個字元抓出來:
```bash
# 擷取第 2 個字元至第 10 個字元
ls -l | tail -n 5 | cut -c 2-10
```
Output:
```
rwxr-xr-x
rwxr-xr-x
rwxr-xr-x
rwxr-xr-x
rwxrwxr-x
```
如果要擷取多個不連續的的區段,逗號分隔每個區段,例如:
```bash
# 擷取第 2-3 個、第 5-6 個與第 8-9 個字元
ls -l | tail -n 5 | cut -c 2-3,5-6,8-9
```
Output:
```
rwr-r-
rwr-r-
rwr-r-
rwr-r-
rwrwr-
```
### 排除字元
上面的範例中我們都是設定要擷取的部份,如果想要設定排除的部份,可以加上 `--complement` 這個補集參數,這樣 `cut` 就會將指定的部份刪除,留下剩餘的部份:
```bash
# 排除第 2 個字元至第 10 個字元
ls -l | tail -n 5 | cut -c 2-10 --complement
```
Output:
```
d 2 gtwang gtwang 4096 11月 7 22:29 影片
d 7 gtwang gtwang 4096 2月 6 21:01 文件
d 4 gtwang gtwang 4096 2月 22 21:09 桌面
d 2 gtwang gtwang 4096 1月 6 2017 模板
d 2 gtwang gtwang 4096 1月 6 2017 音樂
```
### 擷取欄位
若我們的資料欄位寬度不是固定的而是使用特定的字元分隔不同的欄位例如逗點分隔檔csv 檔):
```
5.1,3.5,1.4,0.2,"setosa"
4.9,3,1.4,0.2,"setosa"
7,3.2,4.7,1.4,"versicolor"
6.4,3.2,4.5,1.5,"versicolor"
5.9,3,5.1,1.8,"virginica"
```
若要擷取這個 csv 檔的特定欄位,可以使用 `cut` 指令加上 `-d` 參數指定欄位分隔字元,並以 `-f` 參數指定欲擷取的欄位,例如擷取出第 2 個欄位:
```bash
# 擷取 CSV 檔的第二個欄位
cut -d , -f 2 data.csv
```
Output:
```
3.5
3
3.2
3.2
3
```
若要擷取多個欄位,也是使用逗號分隔每個欄位:
```bash
# 擷取 CSV 檔的第 1-3 個與第 5 個欄位
cut -d , -f 1-3,5 data.csv
```
```
5.1,3.5,1.4,"setosa"
4.9,3,1.4,"setosa"
7,3.2,4.7,"versicolor"
6.4,3.2,4.5,"versicolor"
5.9,3,5.1,"virginica"
```
Linux 中的 `/etc/passwd` 檔案內容是以冒號分隔欄位的,若要從中擷取特定的欄位,可以指定以冒號為分隔字元:
```bash
# 擷取 /etc/passwd 的第 1 個與第 7 個欄位
head -n 5 /etc/passwd | cut -d : -f 1,7
```
```
root:/bin/bash
daemon:/usr/sbin/nologin
bin:/usr/sbin/nologin
sys:/usr/sbin/nologin
sync:/bin/sync
```
### 排除欄位
若要排除某些特定欄位,而留下其餘的欄位,同樣可以使用 `--complement` 參數:
```bash
# 排除 CSV 檔的第二個欄位
cut -d , -f 2 --complement data.csv
```
```
5.1,1.4,0.2,"setosa"
4.9,1.4,0.2,"setosa"
7,4.7,1.4,"versicolor"
6.4,4.5,1.5,"versicolor"
5.9,5.1,1.8,"virginica"
```
### 輸出分隔字元
`cut` 在輸出多欄位的資料時,預設會以輸入檔案所使用的分隔字元來分隔輸出的欄位,若要改變輸出欄位的分隔字元,可以使用 `--output-delimiter` 參數來指定:
```bash
# 指定輸出欄位分隔字元
head -n 5 /etc/passwd | cut -d : -f 1,7 --output-delimiter="^_^"
```
```
root^_^/bin/bash
daemon^_^/usr/sbin/nologin
bin^_^/usr/sbin/nologin
sys^_^/usr/sbin/nologin
sync^_^/bin/sync
```
### 實用範例
Linux 的系統管理者時常會需要使用 `ps` 指令查看各行程的狀態,但由於 `ps` 的輸出資訊很多,如果我們只想看程式的 PID 與指令內容,就可以用 `cut` 把要用的資訊擷取來:
```bash
# 找出所有 Python 程式的 PID 與指令內容
ps aux | grep python | sed 's/\s\+/ /g' | cut -d ' ' -f 2,11-
```
```
17100 grep --color=auto python
27904 /usr/bin/python -Es /usr/sbin/tuned -l -P
33890 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
```

View File

@@ -1,57 +0,0 @@
`scp` 指令的語法跟一般的 `cp` 類似,只不過 `scp` 可以在不同的 Linux 主機之間複製檔案,其語法為:
```
scp [帳號@來源主機]:來源檔案 [帳號@目的主機]:目的檔案
```
# 保留檔案時間與權限
若要讓檔案在複製之後,還可保留原本的修改時間、存取時間與權限,可以加上 `-p` 參數:
```
scp -p /path/file1 myuser@192.168.0.1:/path/file2
```
# 資料壓縮
若要將資料壓縮之後再傳送,減少網路頻寬的使用量,可以加上 `-C` 參數:
```
scp -C /path/file1 myuser@192.168.0.1:/path/file2
```
# 限制傳輸速度
若要限制網路的使用頻寬,可以用 `-l` 指定可用的網路頻寬上限值(單位為 Kbit/s
```
# 限制傳輸速度為 400 Kbit/s
scp -l 400 /path/file1 myuser@192.168.0.1:/path/file2
```
這樣就會限制 `scp` 只能使用 `400` Kbit/s也就是 `400 / 8 = 50` KB/s。
# 自訂連接埠
一般 SSH 伺服器的連接埠號為 22如果遇到使用非標準埠號的伺服器可以用 `-P` 來指定埠號。若遠端的 SSH 伺服器使用 `2222` 這個連接埠,我們就可以這樣複製檔案:
```
# 使用 2222 連接埠
scp -P 2222 /path/file1 myuser@192.168.0.1:/path/file2
```
# IPv4 與 IPv6
`-4``-6` 兩個參數分別可以讓 `scp` 使用 IPv4 與 IPv6 來傳輸資料:
```
# 使用 IPv4
scp -4 /path/file1 myuser@192.168.0.1:/path/file2
# 使用 IPv6
scp -6 /path/file1 myuser@192.168.0.1:/path/file2
```
# 更快的方法使用SSH+TAR
```
ssh 使用者@主機 "cd 目標目錄 ;tar -zcvf - 目標" | cat > 目標.tar.gz
```
例:
```
ssh 192.168.0.22 "cd /var ;tar -zcvf - log" | cat > 22_log.tar.gz
```
# 參考
- [SSH + TAR 取代 SCP @ Vexed's Blog :: 隨意窩 Xuite日誌](https://blog.xuite.net/vexed/tech/586811949)
- [Linux中互传文件ssh+tar 与Scp 比较 - 简书](https://www.jianshu.com/p/856a2dc883e0)
- [轉貼--ssh tar 命令把遠端檔拉回來或推過去 --- 山城風雲的點滴](http://jimsung168.blogspot.com/2014/01/ssh-tar.html)

View File

@@ -1,4 +0,0 @@
## 列出系統中的 systemd service
```bash
systemctl list-units --type=service
```

View File

@@ -1,14 +0,0 @@
`timedatectl`可以看現在的時間、時區等等。也可以改變時區。
![[Pasted image 20220516125616.png]]
`timedatectl list-timezones`列出所有時區我們已經知道我們的時區是Taipei所以可以用grep直接把它抓出來
```bash
timedatectl list-timezones | grep -i taipei
```
結果如下:
![[Pasted image 20220516125742.png]]
設定時區:
```
timedatectl set-timezone Asia/Taipei
```

View File

@@ -1,39 +0,0 @@
# 安裝
根據[Install Docker Engine on Debian](https://docs.docker.com/engine/install/debian/)來安裝Docker engine。
# 指令
## 列出可用的版本
```bash
# List the available versions:
apt-cache madison docker-ce | awk '{ print $3 }'
5:24.0.0-1~debian.11~bullseye
5:23.0.6-1~debian.11~bullseye
...
```
## Container 相關
### 列出 container
`docker ps`會列出執行中的container但是停止的不會
```bash
sudo docker ps
```
如果也要列出已停止的container
```bash
sudo docker ps -a
```
### 刪除 container
Container必須是停止狀態才可以刪除
```bash
sudo docker rm <CONTAINER_ID>
```
## Image 相關
### 列出 image
```bash
sudo docker image ls
or
sudo docker images
```

View File

@@ -1,29 +0,0 @@
{
"nodes":[
{"id":"2387a7bafd0d1fa1","type":"text","text":"Linux","x":-60,"y":-60,"width":112,"height":60},
{"id":"480671b59b65fbee","type":"text","text":"網路","x":-260,"y":-200,"width":123,"height":60},
{"id":"8b9a102062abf2ea","type":"text","text":"![[smb client]]","x":-660,"y":-231,"width":290,"height":123},
{"id":"0da49f9f13cb5ea0","type":"text","text":"虛擬化","x":140,"y":-200,"width":125,"height":60},
{"id":"67febece2a817d3a","type":"text","text":"系統管理","x":140,"y":80,"width":125,"height":60},
{"id":"c30ec48841c09729","type":"text","text":"# LOG 管理\n[[journalctl]]","x":341,"y":80,"width":186,"height":100},
{"id":"89e25cea38eee1c6","type":"text","text":"# 定時操作\n[[crontab]]","x":347,"y":220,"width":180,"height":100},
{"id":"631ba79f09378fa8","type":"text","text":"![[00. Inbox/Linux/Docker|Docker]]","x":341,"y":-238,"width":250,"height":137},
{"id":"d5901d4a7879a984","type":"text","text":"架站","x":-385,"y":-413,"width":125,"height":60},
{"id":"5396ff224cf2433d","type":"text","text":"- [[Apache]]\n- [[Gitea]]\n- [[Grafana]]\n- [[Nextcloud]]\n- [[Pelican blog]]\n- [[Proxmox VE]]\n- [[Storj]]\n- [[filebrowser]]\n- [[freshrss]]","x":-700,"y":-480,"width":242,"height":194},
{"id":"0211a8b636cb3542","type":"text","text":"指令操作","x":-262,"y":80,"width":125,"height":60},
{"id":"584c8fe580aa5c65","type":"text","text":"- [[cut]]\n- [[scp]]\n- [[timedatectl]]\n- [[systemd]]","x":-620,"y":55,"width":250,"height":110}
],
"edges":[
{"id":"2621855f17f1fce7","fromNode":"2387a7bafd0d1fa1","fromSide":"right","toNode":"0da49f9f13cb5ea0","toSide":"left"},
{"id":"63fe0dc1ef02bcf0","fromNode":"2387a7bafd0d1fa1","fromSide":"right","toNode":"67febece2a817d3a","toSide":"left"},
{"id":"8b1293fe476ce994","fromNode":"2387a7bafd0d1fa1","fromSide":"left","toNode":"480671b59b65fbee","toSide":"right"},
{"id":"7b14c2274a6a7dce","fromNode":"480671b59b65fbee","fromSide":"left","toNode":"8b9a102062abf2ea","toSide":"right"},
{"id":"3fb7bd17056728f2","fromNode":"0da49f9f13cb5ea0","fromSide":"right","toNode":"631ba79f09378fa8","toSide":"left"},
{"id":"47dcc8ff2aa219d2","fromNode":"67febece2a817d3a","fromSide":"right","toNode":"c30ec48841c09729","toSide":"left"},
{"id":"b9cbf23293526def","fromNode":"67febece2a817d3a","fromSide":"right","toNode":"89e25cea38eee1c6","toSide":"left"},
{"id":"305a94a3648fc58b","fromNode":"d5901d4a7879a984","fromSide":"left","toNode":"5396ff224cf2433d","toSide":"right"},
{"id":"1007d8512d956cdb","fromNode":"480671b59b65fbee","fromSide":"left","toNode":"d5901d4a7879a984","toSide":"right"},
{"id":"c6875871d1de0864","fromNode":"2387a7bafd0d1fa1","fromSide":"left","toNode":"0211a8b636cb3542","toSide":"right"},
{"id":"40f0ca450747f830","fromNode":"0211a8b636cb3542","fromSide":"left","toNode":"584c8fe580aa5c65","toSide":"right"}
]
}

View File

@@ -1,59 +0,0 @@
### 加入
使用`crontab -e`,然後加入這一行:
`*/1 * * * * /home/awin/script/ddns.sh`
### 說明
![[Pasted image 20240111231507.png]]
依序是 **分鐘,   小時,   日期,   月份,    星期,   command**
參數為 0-59,   0-23,   1-31,  1-21,   0-6,   需要執行的command
**※ 星期參數為 0 代表星期日**
- 【*】:星號,代表任何時刻都接受的意思
- 【,】逗號代表分隔時段。例如30 9,17 * * * command代表早上 9 點半和下午五點半都執行 command。
- 【-】減號代表一段時間範圍。例如15 9-12 * * * command代表從 9 點到 12 點的每個 15 分都執行 command。
- 【/n】斜線n 代表數字,表示每個 n 單位間隔。例如:*/5 * * * * command代表每隔 5 分鐘執行一次 command。
還有一些人性化的參數,一次取代全部五個數字參數
-@reboot】 :僅在開機的時候執行一次。
-@yearly 一年執行一次和0 0 1 1 * command效果一樣。
-@annually】:(和@yearly一樣
-@monthly一個月執行一次和0 0 1 * * command效果一樣。
-@weekly一個星期執行一次和0 0 * * 0 command效果一樣。
-@daily每天執行和0 0 * * * command效果一樣。
-@midnight】:(和@daily一樣
-@hourly 每小時執行和0 * * * * command效果一樣。
### 範例
- 每 5 分鐘執行一次:
- `*/5 * * * *  root    /usr/libexec/atrun`
- 每 5 小時執行一次
- `* */5 * * * root    /usr/libexec/atrun`
- 每天 AM 5:00 執行指令(星號與星號之間要有空隔)
- `00 05   * * *  username /bin/bash /路徑/command`
- 1 至 20 號每天執行一次
- `0 1 1-20  * * root    /usr/libexec/atrun`
- 當分針移到第 5 分時,執行此 cron
- `5 * * * * root    /usr/libexec/atrun`
- 當時針移到 1 點 1 分時,執行此 cron
- `1 1 * * * root    /usr/libexec/atrun`
- 每週一的 1 點 1 分,執行
- `1 1 * * 1 root    /usr/libexec/atrun`
- 2 月 29 日時針到 1 點 1 分,執行
- `1 1 29 2 * root    /usr/libexec/atrun`
- 8 點到 16 點每 5 分鐘執行一次 cron
- `/5 8-16 * * *   root    /usr/libexec/atrun`
### crontab 命令
#### 啟動
`sudo service cron start`
#### 重新啟動
`/etc/init.d/cron restart`
#### 查詢service狀態
`sudo /etc/init.d/cron status`
#### 編輯 crontab
`crontab -e`

View File

@@ -1,129 +0,0 @@
## 看log
Raspberry Pi 4沒有`/var/log/syslog`,要使用`journalctl`
```bash
journalctl
```
Or
```bash
journalctl | grep SOMETHING
```
### 看系統訊息
```bash
journalctl -p 0
```
#### Error code意思
```
0: 紧急情况
1: 警报
2: 危急
3: 错误
4: 警告
5: 通知
6: 信息
7调试
```
### 看開機log
```bash
journalctl --list-boots
```
- 第一個數字顯示的是journald 的唯一的啟動追蹤號碼,你可以在下一個命令中使用它來分析該特定的啟動。
- 第二個數字是啟動ID你也可以在指令中指定。
- 接下來的兩個日期、時間組合是儲存在對應文件中的日誌的時間。如果你想找出某個特定日期、時間的日誌或錯誤,這就非常方便了。
例如:
```bash
journalctl -b -45
```
Or
```bash
journalctl -b 8bab42c7e82440f886a3f041a7c95b98
```
也可以使用 `-x` 選項在顯示器上加入systemd 錯誤訊息的解釋。在某些情況下,這是個救命稻草。例:
```bash
journalctl -xb -p 3
```
### 看某一特定時間、日期的日誌記錄
使用 `--since` 選項與 `yesterday``today``tomorrow` 或 `now` 組合。
以下是一些不同指令的範例。你可以根據你的需求修改它們。它們是不言自明的。以下命令中的日期、時間格式為 `"YYYY-MM-DD HH:MM:SS"`
```bash
journalctl --since "2020-12-04 06:00:00"
journalctl --since "2020-12-03" --until "2020-12-05 03:00:00"
journalctl --since yesterday
journalctl --since 09:00 --until "1 hour ago"
```
### 看內核特定的記錄
```bash
journalctl -k
```
### 過濾出某個systemd 服務單元的特定日誌
例如,如果要查看 NetworkManager 服務的日誌
```bash
journalctl -u NetworkManager.service
```
如果不知道service name看[[systemd#列出系統中的 systemd service]]
### 查看使用者、群組的日誌
```bash
id -u debugpoint # 先找出使用者的uid
journalctl _UID=1000 --since today
```
### 查看可執行檔的日誌
```bash
journalctl /usr/bin/gnome-shell --since today
```
### 看log佔用的磁碟空間
```bash
journalctl --disk-usage
```
### 清除日誌
#### 手動清除
```bash
sudo journalctl --flush --rotate # 將所有日誌歸檔
sudo journalctl --vacuum-time=7d # 只保留最近7天的日誌
sudo journalctl --vacuum-time=1s # 只保留最近1秒的日誌
```
或者設定日誌的大小
```bash
sudo journalctl --vacuum-size=400M # 保留最後400M
```
#### 自動清除
修改`/etc/systemd/journald.conf`,裡面有下面幾個設定項:
- `SystemMaxUse`: 指定日志在持久性存储中可使用的最大磁盘空间。例:`SystemMaxUse=500M`
- `SystemKeepFree`: 指定在将日志条目添加到持久性存储时,日志应留出的空间量。例:`SystemKeepFree=100M`
- `SystemMaxFileSize`: 控制单个日志文件在被轮换之前在持久性存储中可以增长到多大。例:`SystemMaxFileSize=100M`
- `RuntimeMaxUse`: 指定在易失性存储中可以使用的最大磁盘空间(在 /run 文件系统内)。例:`RuntimeMaxUse=100M`
- `RuntimeKeepFree`: 指定将数据写入易失性存储(在 /run 文件系统内)时为其他用途预留的空间数量。例:`RuntimeMaxUse=100M`
- `RuntimeMaxFileSize`: 指定单个日志文件在被轮换之前在易失性存储(在 /run 文件系统内)所能占用的空间量。例:`RuntimeMaxFileSize=200M`
修改後記得重啟 `journalctl`
![[journalctl#重啟日誌]]
也請記得[[確認日誌的完整性]]
### 確認日誌的完整性
```bash
journalctl --verify
```
### 重啟日誌
若是有改變設定,記得重啟以讓變更生效:
```shell
sudo systemctl restart systemd-journald
```
### 參考
- [系統運作|如何使用journalctl 檢視和分析systemd 日誌(附實例)](https://linux.cn/article-15544-1.html)

View File

@@ -1,36 +0,0 @@
# Connect to SMB folder
## 安裝
```shell
sudo apt-get install cifs-utils
```
## 設定
### 建立 `~/.smbcredentials` ,用來存放帳號密碼
```shell
touch ~/.smbcredentials
vim ~/.smbcredentials
```
依下面格式填入
```
username=<your_username>
password=<your_password>
```
### 讓機器每次開機就自動掛載。
建立掛載點
```shell
sudo mkdir /mnt/sambashare
```
`/mnt/sambashare` 改成你自己喜歡的路徑
打開 `/etc/fstab`,填入下面這一行:
```
//samba_server_ip/share_name /mnt/sambashare cifs credentials=/home/pi/.smbcredentials,uid=pi,gid=pi 0 0
```
檢查
```shell
sudo systemctl daemon-reload
sudo mount -a
```

View File

@@ -1,108 +0,0 @@
## Install
```
sudo apt update && sudo apt install apache2
```
## 測試Apache
```
sudo service apache2 status
```
## 設置虛擬主機Virtual Hosts
假設要建立2個網站*test1.ui-code.com*與*test2.ui-code.com*
### 建立目錄並設置權限Permissions
```
sudo mkdir -p /var/www/test1.ui-code.com/public_html
sudo mkdir -p /var/www/test2.ui-code.com/public_html
sudo chmod -R 755 /var/www
```
### 建立測試頁面
#### 建立test1.ui-code.com的測試頁面
```
sudo nano /var/www/test1.ui-code.com/public_html/index.html
```
填入以下內容:
```html
<html>
<head>
<title>Welcome to test1.ui-code.com</title>
</head>
<body>
<h1>Welcome to test1.ui-code.com</h2>
</body>
</html>
```
#### 建立test2.ui-code.com的測試頁面
```
sudo nano /var/www/test2.ui-code.com/public_html/index.html
```
填入以下內容:
```html
<html>
<head>
<title>Welcome to test2.ui-code.com</title>
</head>
<body>
<h1>Welcome to test2.ui-code.com</h2>
</body>
</html>
```
### 建立虛擬主機文件Virtual Host Files
虛擬主機文件位於 /etc/apache2/sites-available/ 中,其用於告訴 Apache 網頁伺服器如何響應Respond 各種網域請求Request
讓我們為test1.ui-code.com 網域創建一個新的虛擬主機文件。
```
sudo nano /etc/apache2/sites-available/test1.ui-code.com.conf
```
將以下內容貼上:
```
<VirtualHost *:80>
ServerAdmin webmaster@test1.ui-code.com
ServerName test1.ui-code.com
ServerAlias www.test1.ui-code.com
DocumentRoot /var/www/test1.ui-code.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
```
再來為test2.ui-code.com 網域創建一個新的虛擬主機文件。
```
sudo nano /etc/apache2/sites-available/test2.ui-code.com.conf
```
將以下內容貼上:
```
<VirtualHost *:80>
ServerAdmin webmaster@test2.ui-code.com
ServerName test2.ui-code.com
ServerAlias www.test2.ui-code.com
DocumentRoot /var/www/test2.ui-code.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
```
### 啟用新的虛擬主機文件Virtual Host Files
現在我們有兩個虛擬主機文件,我們需要使用 a2ensite 工具來啟用它們。
```
sudo a2ensite test1.ui-code.com
sudo a2ensite test2.ui-code.com
```
測試配置語法是否有錯誤。
```
apachectl configtest
```
如果「Syntax OK」重啟 Apache。
```
sudo systemctl reload apache2
```
## 參考
- [[教學][Ubuntu 架站] 在 Ubuntu 20.04 安裝 Apache 網頁伺服器,並架設多個網站(多網域) | 優程式](https://ui-code.com/archives/271)

View File

@@ -1,30 +0,0 @@
## docker-compose.yml
```yaml
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
restart: always
networks:
- gitea
volumes:
- ./data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "8020:3000"
- "2244:22"
```
## 文件
- [Gitea Docs: Config Cheat Sheet](https://docs.gitea.io/zh-tw/config-cheat-sheet/)
- [How to Install Gitea on Ubuntu Using Docker](https://www.digitalocean.com/community/tutorials/how-to-install-gitea-on-ubuntu-using-docker)

View File

@@ -1,91 +0,0 @@
# 設定
`docker-compose.yml` 如下:
```yaml
version: "3"
services:
grafana:
image: grafana/grafana:latest
container_name: grafana
restart: always
user: "1000" # needs to be `id -u` // alternatively chown the grafana/data dir to 472:472
ports:
- "8081:3000" # expose for localhost
links:
- influxdb
volumes:
- ./data/grafana/data:/var/lib/grafana # data path
- ./data/grafana/provisioning:/etc/grafana/provisioning
- ./data/grafana/grafana.ini:/etc/grafana/grafana.ini
environment:
- GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource
influxdb:
image: influxdb
ports:
- "8082:8086"
volumes:
- ./data/influxdb/data:/var/lib/influxdb2
telegraf:
image: telegraf
user: telegraf:992 # Get 992 by `stat -c '%g' /var/run/docker.sock`, depend on system
depends_on:
- influxdb
links:
- influxdb
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
environment:
- HOST_PROC=/proc
- HOST_SYS=/sys
- HOST_ETC=/etc
```
檔案結構如下:
```
data\
grafana\
grafana.ini
telegraf\
telegraf.conf
docker-compose.yml
```
`data/grafana/grafana.ini``data/telegraf/telegraf.conf` 都是需要事先準備好的檔案。
## 設定 InfluxDB
先把 docker 建立起來,然後打開 influxdb[http://awinpi4:8082](http://awinpi4:8082/)),建立帳號、密碼、資料庫名稱。如下:
![[20240217_212138_chrome_setup_influxdb.png]]
之後會出現一串Token如下這個要記起來。
![[20240217_212319_chrome_1894x1254_influxdb_token.png]]
## 設定 telegraf
然後打開 `./data/telegraf/telegraf.conf` ,找到 `[[outputs.influxdb_v2]]` 這個區塊,把 `urls``organization``bucket``token` 的值改為剛剛建立與複製的那一串。如圖:
![[20240217_213900_Code_setup_telegraf_ini.png]]
然後重啟 docker compose。
# 設定 InfluxDB 的 dashboard
到 [https://github.com/influxdata/community-templates#templates](https://github.com/influxdata/community-templates#templates) 挑一個 template例如 [Raspberry Pi System Template](https://github.com/influxdata/community-templates/tree/master/raspberry-pi),找到他的網址,如下:
![[20240217_213108_chrome_1864x1044_raspberrypi_template_on_github.png]]
複製這一行,然後到 InfluxDB 的 template 去把它 import 進來。如下:
![[20240217_213237_chrome_2753x1254_setup_influxdb.png]]
![[20240217_213311_chrome_2753x1254_influxdb_install_template.png]]
接著 Dashboards 就會出現一個 Raspberry Pi System 的 dashboard 了。
![[20240217_213343_chrome_1624x1120_influxdb_dashboard.png]]
點下去之後大概是長這樣:
![[20240217_214001_chrome_2604x1716_influxdb_dashboard.png]]
# 參考
- [建構 Grafana + Influxdb v2.0 + Telegraf 監控系統(docker版) - DSA Learning](https://dsalearning.github.io/grafana/influxdb-telegraf-docker/)
- [Raspberry Pi, InfluxDB, Grafana, Docker | by Anton Karazeev | Medium](https://medium.com/@antonkarazeev/raspberry-pi-influxdb-grafana-docker-a526575d6e6f#id_token=eyJhbGciOiJSUzI1NiIsImtpZCI6ImVkODA2ZjE4NDJiNTg4MDU0YjE4YjY2OWRkMWEwOWE0ZjM2N2FmYzQiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIyMTYyOTYwMzU4MzQtazFrNnFlMDYwczJ0cDJhMmphbTRsamRjbXMwMHN0dGcuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiIyMTYyOTYwMzU4MzQtazFrNnFlMDYwczJ0cDJhMmphbTRsamRjbXMwMHN0dGcuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDM4MDc4MzIzNTMyNTIzMDc3NDYiLCJlbWFpbCI6ImF3aW5odWFuZ0BnbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwibmJmIjoxNzA4MTQ1MjU3LCJuYW1lIjoiQXdpbiBIdWFuZyIsInBpY3R1cmUiOiJodHRwczovL2xoMy5nb29nbGV1c2VyY29udGVudC5jb20vYS9BQ2c4b2NJZjNQY0d3WjZIcDdYM204b3BjczRlNGVlZnBHQ1pGeVdMamExcjNTVVNKd1ZnPXM5Ni1jIiwiZ2l2ZW5fbmFtZSI6IkF3aW4iLCJmYW1pbHlfbmFtZSI6Ikh1YW5nIiwibG9jYWxlIjoiemgtVFciLCJpYXQiOjE3MDgxNDU1NTcsImV4cCI6MTcwODE0OTE1NywianRpIjoiNzBmNjI3NDFiNzhiYmVlMTYwNjBiZWRlOTY2YmFjYTAyZTY0ZTZkOSJ9.SXAVZ3SXny4YjIc9Cg6fNFHlXKe0jrm-4uwJ7KH41Tmo_vRAQGlbUn7MmVHXWexpKdpMCSVECC8C1VuUielC-vm8AoHMs1PLJCyhdg02hUyTqEMA08ydscfjguGP6kuI3LoMVsxkAl51C06lQi8llYZ4XGkdHxhCWP12fXQStdGPfv-64KNCkPTIfI7Teo7sfJGyjSQsDMRa4v9GWS9qmbCqut06fhpLyj0lEVfntratbuTN8ThekVfuJyJyG29U6xclm1O0NgBp-BnXML_YtBxTBV2Td_DRYY0dfcVivDKxzH135FfY5xpp_2ZIewkjJG5-pTHpin1R_XLVmIhXuA)
- [Raspberry Pi 4 使用 Grafana 监控_influxdb and grafana on raspberrypi-CSDN博客](https://blog.csdn.net/u013360850/article/details/115568985)

View File

@@ -1,52 +0,0 @@
## docker-compose.yml
```yaml
version: '3'
services:
app:
image: nextcloud
ports:
- 8080:80
volumes:
- ./data:/var/www/html
restart: always
```
## config.php
Nextcloud 的 config 檔放在`/var/www/html/config/config.php`,對應到本機就是 `./data/config/config.php`,在安裝完成之後,需要修改 `trusted_domains``overwriteprotocol``overwrite.cli.url` 這幾個參數,如下:
```php
<?php
$CONFIG = array (
'htaccess.RewriteBase' => '/',
'memcache.local' => '\\OC\\Memcache\\APCu',
'apps_paths' =>
array (
0 =>
array (
'path' => '/var/www/html/apps',
'url' => '/apps',
'writable' => false,
),
1 =>
array (
'path' => '/var/www/html/custom_apps',
'url' => '/custom_apps',
'writable' => true,
),
),
'upgrade.disable-web' => true,
'instanceid' => 'ocwc2ntdj6io',
'passwordsalt' => '/uinYW42zbfuqxG5hVNIwS6vWeslUx',
'secret' => 'HBPMSEp6fazNbjhCbD+KpXd5C6QYhjMsc6RvU5BWOFchsPci',
'trusted_domains' =>
array (
0 => 'nc.awin.one',
),
'datadirectory' => '/var/www/html/data',
'dbtype' => 'sqlite3',
'version' => '28.0.2.5',
'overwriteprotocol' => 'https',
'overwrite.cli.url' => 'https://nc.awin.one',
'installed' => true,
);
```

View File

@@ -1,26 +0,0 @@
## Create a site
Use `pelican-quickstart` to create a new site.
## Plugin
```bash
git clone --recursive https://github.com/getpelican/pelican-plugins.git
```
## Theme
先把所有佈景主題都clone下來
```bash
git clone --recursive https://github.com/getpelican/pelican-themes.git
```
`pelicanconf.py`裡面的`THEME`指向theme的目錄就可以換佈景主題了。例如要用[[blue-penguin](https://github.com/jody-frankowski/blue-penguin)]這一個主題。把`pelicanconf.py`裡面加入`THEME = 'pelican-themes/blue-penguin'`就可以了。
## 預覽
```
make html
make serve
```
參考:
- [koko's Note Python - 安裝 Pelican Theme 來改變你的靜態網站主題](https://note.koko.guru/install-pelican-theme.html)
- [nest theme](https://github.com/molivier/nest)
- [Flex theme](https://github.com/alexandrevicenzi/Flex/wiki/Custom-Settings)

View File

@@ -1,260 +0,0 @@
# 安裝
## 下載ISO
- [Get the free Proxmox VE ISO installer](https://www.proxmox.com/en/downloads/category/iso-images-pve)
## 準備USB disk
- 用[Rufus](https://rufus.ie/)的話
1. 在遇到詢問是否要下載 Grub 時,請選擇「否」
2. 必須使用DD mode來建立開機碟。參考[Prepare Installation Media - Proxmox VE](https://pve.proxmox.com/wiki/Prepare_Installation_Media#_instructions_for_windows)
![[Pasted image 20210128212917.png]]
# 設定
## 關閉「闔上螢幕後休眠」
打開`/etc/systemd/logind.conf`
```
nano /etc/systemd/logind.conf
```
找到下面兩行把值改成ignore
```
HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore
```
然後重開機:
```
systemctl restart systemd-logind.service
```
圖示:
![[Pasted image 20210129194144.png]]
## 增加硬碟
先用`lsblk`列出所有硬碟,這裡假設`sda`是我們的開機磁碟,我要要新增`sdb`
```
root@pve:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk <-- 目前在用的
├─sda1 8:1 0 1007K 0 part
├─sda2 8:2 0 512M 0 part
└─sda3 8:3 0 931G 0 part
sdb 8:16 0 111.8G 0 disk <-- 要新增的
├─sdb1 8:17 0 100M 0 part
├─sdb2 8:18 0 16M 0 part
├─sdb3 8:19 0 111.1G 0 part
└─sdb4 8:20 0 563M 0 part
```
然後安裝`parted`,我們要用它來分割硬碟:
```
apt install parted
```
開始分割:
```
parted /dev/sdb mklabel gpt
```
建立primary partition格式為`ext4`
```
parted -a opt /dev/sdb mkpart primary ext4 0% 100%
```
再來將分割好的硬碟格式化為`ext4`label命名為`data2`
```
mkfs.ext4 -L data2 /dev/sdb1
```
再用`lsblk`看一次會發現sdb已經重新分割成1個partition了
```
root@pve:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 1007K 0 part
├─sda2 8:2 0 512M 0 part
└─sda3 8:3 0 931G 0 part
sdb 8:16 0 111.8G 0 disk
└─sdb1 8:17 0 111.8G 0 part
```
`lsblk -fs`可以看到每一個硬碟的檔案系統格式:
```
root@pve:~# lsblk -fs
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda1 zfs_member rpool 11775123664036754029
└─sda zfs_member rpool 11775123664036754029
sda2 vfat rpool 32D0-3449
└─sda zfs_member rpool 11775123664036754029
sda3 zfs_member rpool 11775123664036754029
└─sda zfs_member rpool 11775123664036754029
sdb1 ext4 data2 bc6d2c41-a3ca-4b0f-a5de-51ee28ae9cec <-- 剛剛分割的
└─sdb
```
接下來,將新硬碟掛載到檔案目錄上,先建立一個新目錄來掛載新硬碟:
```shell
mkdir -p /mnt/data
```
接下來編輯`/etc/fstab`,將新硬碟寫進來,這樣開機之後才會自動把它掛載起來:
```
nano /etc/fstab
```
加入這一行(注意:**data2**要改成你自己的label
```
LABEL=data2 /mnt/data ext4 defaults 0 2
```
剛新硬碟掛起來:
```
mount -a
```
`df`就可以看到新硬碟了:
```
root@pve:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 16288892 0 16288892 0% /dev
tmpfs 3262688 9324 3253364 1% /run
rpool/ROOT/pve-1 942667136 1267584 941399552 1% /
tmpfs 16313440 43680 16269760 1% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 16313440 0 16313440 0% /sys/fs/cgroup
rpool 941399680 128 941399552 1% /rpool
rpool/data 941399680 128 941399552 1% /rpool/data
rpool/ROOT 941399680 128 941399552 1% /rpool/ROOT
/dev/fuse 30720 16 30704 1% /etc/pve
tmpfs 3262688 0 3262688 0% /run/user/0
/dev/sdb1 114854020 61464 108915208 1% /mnt/data <-- 新硬碟在這裡
```
參考:
- [How to add storage to Proxmox](https://nubcakes.net/index.php/2019/03/05/how-to-add-storage-to-proxmox/)
## 增加iSCSI磁碟
### 增加需要CHAP認證的iSCSI磁碟
1. 先確認找的到iSCSI磁碟
```
iscsiadm -m discovery -t st -p 192.168.1.11:3260
```
如果有找到的話會回傳一串IQN值像是
```
root@pve:~# iscsiadm -m discovery -t st -p 192.168.1.11:3260
192.168.1.11:3260,1 iqn.2000-01.com.synology:DiskStation.Target-1.3e589efea3
[fe80::211:32ff:fe20:eadd]:3260,1 iqn.2000-01.com.synology:DiskStation.Target-1.3e589efea3
```
2. 有IQN就可以用下列的命令連線與掛載
```
iscsiadm -m node -T iqn.2000-01.com.synology:DiskStation.Target-1.3e589efea3 --op update --name node.session.auth.username --value=名字
iscsiadm -m node -T iqn.2000-01.com.synology:DiskStation.Target-1.3e589efea3 --op update --name node.session.auth.password --value=密碼
iscsiadm -m node -T iqn.2000-01.com.synology:DiskStation.Target-1.3e589efea3 -l #連線
iscsiadm -m node -o update -n node.startup -v automatic #設定開機自動掛載
```
## 增加NFS磁碟
1. 先在Synology上開一個NFS disk設定如下
![[Pasted image 20220506091522.png]]
2. 再到Proxmox的 Datacenter->Storage->Add 來增加一個 *NFS*,設定如下
![[Pasted image 20220506091624.png]]
### 更改NFS mount為soft
1. 編輯`/etc/pve/storage.cfg`
2. 做如下修改
![[Pasted image 20220506095531.png]]
### 參考
- [[經驗分享]Proxmox VE 採用 NFS 連接儲存的重點事項](http://blog.jason.tools/2019/02/pve-nfs-mount.html)
## 設定VM備份目錄
如果將VM或LXC備份到某個目錄先建立要備份的目錄
```shell
mkdir -p /mnt/data/backup/
```
再來用WEB UI操作如下
![[Pasted image 20210129202041.png]]
![[Pasted image 20210129202047.png]]
最後再到 Datacenter->Backups建立一個scheule來備份就可以了
![[Pasted image 20210129202231.png]]
## 將資料備份到NAS
1. 先在NAS開一個share folder跟一個帳號。
![[Pasted image 20210202190402.png]]
![[Pasted image 20210202190537.png]]
2. Proxmox到裡將剛剛新開的folder給掛載起來。
![[Pasted image 20210202190640.png]]
會跳出一個視窗,如下圖來填,記得**content**那一欄有4個要選。
![[Pasted image 20210202190709.png]]
3. Proxmox到 Datacenter->Backup 新增一個排程。
![[Pasted image 20210202190903.png]]
一樣會跳出一個視窗,依需求來填,要注意的是**Storage**必須是前一步驟的**ID****Selection Mode**可以選擇**All**。
![[Pasted image 20210202191150.png]]
參考:
- [HASS + Proxmox: Automatic Backups to Synology NAS](https://kleypot.com/automatic-offline-backups/)
## 設定 UPS
因為 UPS 的 USB 是連接在 NAS 上所以Proxmox這邊必須要去monitor NAS那邊所回報的狀態請確定NAS端有打開「啟用網路不斷電系統伺服器」。
1. 安裝 nut`apt-get install nut`
2. 修改 `/etc/nut/nut.conf`,設定 `MODE=netclient`
3. 修改 `/etc/nut/upsmon.conf`,加入一行:`MONITOR ups@<NAS_IP> 1 <NAS_Username> <NAS_UserPassword> slave`
4. 開始 upsmon`upsmon start`
5.`ps -ef | grep upsmon` 確認 upsmon是否執行
![[Pasted image 20220811145852.png|600]]
6. 若正常可以取回UPS的一些硬體資料`upsc ups@<NAS_IP>`
![[Pasted image 20220811150034.png|360]]
### 參考
- [UPSMON(8)](https://networkupstools.org/docs/man/upsmon.html)
- [不斷電系統 | DSM - Synology 知識中心](https://kb.synology.com/zh-tw/DSM/help/DSM/AdminCenter/system_hardware_ups?version=6)
- [設定 Proxmox VE連動Synology的不斷電系統](https://cychien.tw/wordpress/2022/02/02/%E8%A8%AD%E5%AE%9A-proxmox-ve%E9%80%A3%E5%8B%95synology%E7%9A%84%E4%B8%8D%E6%96%B7%E9%9B%BB%E7%B3%BB%E7%B5%B1/)
## 更新
### 加入更新來源
編輯`/etc/apt/sources.list`,加入:
```
deb http://ftp.debian.org/debian bullseye main contrib
deb http://ftp.debian.org/debian bullseye-updates main contrib
# PVE pve-no-subscription repository provided by proxmox.com,
# NOT recommended for production use
deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription
# security updates
deb http://security.debian.org/debian-security bullseye-security main contrib
```
### 取消訂閱服務
編輯`/etc/apt/sources.list.d/pve-enterprise.list`,把下面這行注釋掉:
```
deb https://enterprise.proxmox.com/debian/pve buster pve-enterprise
```
也就是變成:
```
#deb https://enterprise.proxmox.com/debian/pve buster pve-enterprise
```
使用`apt update`來更新套件。
使用`apt dist-upgrade`來升級系統版本。
## 重灌後要做的事情
1. 建立ZFS pool。
2. 確認S.M.A.R.T. 是否啟用,預設是啟用的。
`smartctl -a /dev/<SDA_N>`
1. 打開IOMMU
2. 打開vm aware
3. 增加NFS共享磁碟
4. 排程備份
5. 上傳安裝Windows需要的驅動ISO
1. [Windows VirtIO Drivers](https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers)
6. 把常用的VM轉為template
7. 安裝[Cockpit-Linux Server](https://pvecli.xuan2host.com/cockpit/), 讓您的PVE有更棒的圖形管理介面。
## 參考
- [套件功能的更新Proxmox update](https://wiki.freedomstu.com/books/proxmox-ve-%E8%99%9B%E6%93%AC%E7%B3%BB%E7%B5%B1%E8%A8%98%E9%8C%84/page/%E5%A5%97%E4%BB%B6%E5%8A%9F%E8%83%BD%E7%9A%84%E6%9B%B4%E6%96%B0%EF%BC%88proxmox-update%EF%BC%89)
- [裝完PVE後的11件必作清單 (中文翻譯)](https://www.youtube.com/watch?v=pY4Lm2Hoqik)
- [Before I do anything on Proxmox, I do this first...](https://www.youtube.com/watch?v=GoZaMgEgrHw&t=0s)
# Trouble shooting
- *Emergency mode*,表示開機失敗,請檢查`/etc/fstab`是不是有無法掛載的disk。
## 參考
- [[Fix] Getting out of emergency mode : Proxmox](https://www.reddit.com/r/Proxmox/comments/hai75k/fix_getting_out_of_emergency_mode/)

View File

@@ -1,119 +0,0 @@
# 步驟摘要
1. 到[https://www.storj.io/host-a-node](https://www.storj.io/host-a-node)申請一個auth token。
2. 用identify產生key。
3. 認證 key。
4. 備份 key
5. Setup storj docker。
6. Run storj docker。
7. 更新
# 1. 申請一個auth token
到[https://www.storj.io/host-a-node](https://www.storj.io/host-a-node)填入email會產生一個伴隨email的隨機碼。
![[Pasted image 20240114200907.png]]
這一串要記下來。
# 用identify產生key
## 下載
### Windows
下載 `https://github.com/storj/storj/releases/latest/download/identity_windows_amd64.zip`
### Linux
#### X86
```bash
curl -L https://github.com/storj/storj/releases/latest/download/identity_linux_amd64.zip -o identity_linux_amd64.zip
unzip -o identity_linux_amd64.zip
chmod +x identity
sudo mv identity /usr/local/bin/identity
```
#### ARM
```bash
curl -L https://github.com/storj/storj/releases/latest/download/identity_linux_arm.zip -o identity_linux_arm.zip
unzip -o identity_linux_arm.zip
chmod +x identity
sudo mv identity /usr/local/bin/identity
```
## 產生 identity
這一步會跑很久建議用CPU比較強的來跑在樹莓派上面會跑很久。
### Windows
`./identity.exe create storagenode`
### Linux
`identity create storagenode`
# 認證 Key
## 認證
等一下的 `<email:characterstring>` 就是第1步說要記起來的那一串
### Windows
`./identity.exe authorize storagenode <email:characterstring>`
### Linux
`identity authorize storagenode <email:characterstring>`
## 確認
### Windows
`(sls BEGIN "$env:AppData\Storj\Identity\storagenode\ca.cert").count` 應該要return 2
`(sls BEGIN "$env:AppData\Storj\Identity\storagenode\identity.cert").count` 應該要return 3
### Linux
`grep -c BEGIN ~/.local/share/storj/identity/storagenode/ca.cert` 應該要return 2
`grep -c BEGIN ~/.local/share/storj/identity/storagenode/identity.cert` 應該要return 3
# 備份 key
Windows 上產生的 key 會放在 `%APPDATA%\Storj\Identity\storagenode`
Linux 上產生的 key 會放在 `~/.local/share/storj/identity/storagenode`
記得備份。
# Setup storj docker
Do this **once**.
```bash
sudo docker run --rm -e SETUP="true" \
--mount type=bind,source="/home/awin/storj/key",destination=/app/identity \
--mount type=bind,source="/home/awin/storj/data",destination=/app/config \
--name storagenode storjlabs/storagenode:latest
```
# Run storj docker
```bash
sudo docker run -d --restart always --stop-timeout 300 \
-p 28967:28967/tcp \
-p 28967:28967/udp \
-p 14002:14002 \
-e WALLET="0x9Ce80345355Ad8C17991620E13d8423900CEDcd0" \
-e EMAIL="awinhuang@gmail.com" \
-e ADDRESS="storj.awin.one:28967" \
-e STORAGE="1.6TB" \
--memory=800m \
--log-opt max-size=50m \
--log-opt max-file=10 \
--mount type=bind,source=/home/awin/storj/key,destination=/app/identity \
--mount type=bind,source=/home/awin/storj/data,destination=/app/config \
--name storagenode storjlabs/storagenode:latest
```
# 更新
更新 node 可以選擇用 docker 裝[storjlabs/watchtower](https://hub.docker.com/r/storjlabs/watchtower/tags) ,或是手動更新
## watchtower
```shell
sudo docker pull storjlabs/watchtower
sudo docker run -d --restart=always --name watchtower -v /var/run/docker.sock:/var/run/docker.sock storjlabs/watchtower storagenode watchtower --stop-timeout 300s
```
等 [[00. Inbox/樹莓派/Watchtower|Watchtower]] 跑起來之後,可以用 `sudo docker exec -it storagenode /app/dashboard.sh` 來即時觀察執行流量。
## 手動
```shell
sudo docker stop -t 300 storagenode
sudo docker rm storagenode
sudo docker pull storjlabs/storagenode:latest
```
# 參考
- [Step 2. Get an Authorization Token - Storj Docs](https://docs.storj.io/node/get-started/auth-token)
- [Step 5. Create an Identity - Storj Docs](https://docs.storj.io/node/get-started/identity)
- [Install storagenode on Raspberry Pi3 or higher version Storj](https://support.storj.io/hc/en-us/articles/360026612332-Install-storagenode-on-Raspberry-Pi3-or-higher-version)

View File

@@ -1,52 +0,0 @@
# docker-compose.yml
```yml
version: '3'
services:
file-browser:
restart: always
image: filebrowser/filebrowser:latest
container_name: filebrowser
user: 1000:1000
ports:
- 8040:80
volumes:
- /media/share:/srv
- ./data/filebrowser.db:/database.db
- ./data/settings.json:/.filebrowser.json
- ./data/gafiled.png:/config/logo.png
- ./data/branding:/branding
security_opt:
- no-new-privileges:true
```
# 準備
`docker compose up -d` 之前,需要先把檔案準備好。
```shell
touch data/filebrowser.db
touch data/settings.json
```
`data/settings.json` 的內容:
```json
{
"port": 80,
"baseURL": "",
"address": "",
"log": "stdout",
"database": "/database.db",
"root": "/srv"
}
```
# 登入
預設的帳號密碼是`admin/admin`,記得要改掉。
# 問題
因為Filebrowser會lock DB所以docker在跑得時候會無法使用Filebrowser的command所以需要先把docker停掉然後用以下命令登入
```shell
sudo docker run -it -v ./data/filebrowser.db:/database.db -v data/settings.json:/.filebrowser.json --entrypoint /bin/sh filebrowser/filebrowser
```
# 參考
- [Filebrowser Docker Installation | All about](https://bobcares.com/blog/filebrowser-installation-in-docker/)
- [filebrowser/filebrowser: 📂 Web File Browser](https://github.com/filebrowser/filebrowser)

View File

@@ -1,26 +0,0 @@
```yml
version: "3"
services:
freshrss:
image: linuxserver/Taipei:latest
restart: unless-stopped
ports:
- "8080:80"
environment:
TZ: Asia/Shanghai
CRON_MIN: "*/60"
PUID: 1000
PGID: 1000
volumes:
- freshrss_data:/var/www/FreshRSS/data
- freshrss_extensions:/var/www/FreshRSS/extensions
rsshub:
image: diygod/rsshub:latest
restart: unless-stopped
expose:
- "1200"
environment:
CACHE_EXPIRE: 3600
```

View File

@@ -1,25 +0,0 @@
{
"nodes":[
{"id":"e724a0b36766d3a9","type":"group","x":440,"y":-480,"width":475,"height":880,"label":"應該是可用的流程"},
{"id":"0138bfb5c46d71f1","type":"text","text":"1. 用[[powercfg powerthrottling]]關閉 VirtualBox power throttling。","x":-149,"y":-191,"width":329,"height":91},
{"id":"d34f3157e07cb50d","type":"text","text":"開始","x":-200,"y":40,"width":100,"height":50,"color":"2"},
{"id":"c276871e8748cbfe","type":"text","text":"[PowerWriteDCValueIndex](https://learn.microsoft.com/zh-tw/windows/win32/api/powersetting/nf-powersetting-powerwritedcvalueindex)\n```c\nPowerWriteDCValueIndex(NULL, scheme,\n &GUID_PROCESSOR_SETTINGS_SUBGROUP, \n &GUID_PROCESSOR_THROTTLE_MAXIMUM, percent);\n```","x":460,"y":-88,"width":429,"height":149},
{"id":"b89cd7d463506018","type":"text","text":"[PowerSetActiveScheme](https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powersetactivescheme)","x":549,"y":100,"width":252,"height":60},
{"id":"dd89a32995de8e4a","type":"text","text":"# 參考\n- [Tweak CPU Power Elegantly on Windows - kkocdko's blog](https://kkocdko.site/post/202110041950)\n- [Powersetting.h header - Win32 apps | Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/api/powersetting/)","x":460,"y":200,"width":435,"height":180},
{"id":"154d88218d26f035","type":"text","text":"[PowerWriteACValueIndex](https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powerwriteacvalueindex)\n```c\nPowerWriteACValueIndex(NULL, scheme, \n &GUID_PROCESSOR_SETTINGS_SUBGROUP,\n &GUID_PROCESSOR_THROTTLE_MAXIMUM, percent);\n```","x":460,"y":-255,"width":429,"height":151},
{"id":"bb0881e617ca2f52","type":"text","text":"[PowerGetActiveScheme](https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powergetactivescheme)\n```c\nGUID guid, *scheme = &guid; PowerGetActiveScheme(NULL, &scheme);\n```","x":502,"y":-460,"width":346,"height":125},
{"id":"1b7a2018be9a2542","type":"text","text":"- [[設定CPU Power mode]]","x":80,"y":35,"width":250,"height":60},
{"id":"034536d7a91d7b62","x":-100,"y":320,"width":133,"height":60,"type":"text","text":"工具設定"},
{"id":"197b4dc40754a989","x":-201,"y":460,"width":335,"height":211,"type":"text","text":"- [[Chrome]]\n- [[freefilesync]]\n- [[Obsidian]]\n- [[SublimeText]]\n- [[vim]]\n- [[Visual Studio Code]]\n- [[Windows 11 重灌]]\n- [[Windows Terminal]]"}
],
"edges":[
{"id":"5c4879a42c2db8ac","fromNode":"d34f3157e07cb50d","fromSide":"top","toNode":"0138bfb5c46d71f1","toSide":"bottom"},
{"id":"631e78e7dee93490","fromNode":"d34f3157e07cb50d","fromSide":"right","toNode":"1b7a2018be9a2542","toSide":"left"},
{"id":"f60c6e07e0ef6a98","fromNode":"c276871e8748cbfe","fromSide":"bottom","toNode":"b89cd7d463506018","toSide":"top"},
{"id":"7fada69bb11ae874","fromNode":"154d88218d26f035","fromSide":"bottom","toNode":"c276871e8748cbfe","toSide":"top"},
{"id":"d4c1beba2bea0171","fromNode":"bb0881e617ca2f52","fromSide":"bottom","toNode":"154d88218d26f035","toSide":"top","label":"SchemeGuid"},
{"id":"7000cd2de2280a0a","fromNode":"1b7a2018be9a2542","fromSide":"right","toNode":"e724a0b36766d3a9","toSide":"left"},
{"id":"82d29d89f73fd716","fromNode":"d34f3157e07cb50d","fromSide":"bottom","toNode":"034536d7a91d7b62","toSide":"top"},
{"id":"035012a29ceb315e","fromNode":"034536d7a91d7b62","fromSide":"bottom","toNode":"197b4dc40754a989","toSide":"top"}
]
}

View File

@@ -1,6 +0,0 @@
對於特定的軟體,使用 `powercfg` 來關閉 powerthrottling。例如讓 [VirtualBox](https://www.virtualbox.org/) 最大效能執行:
```cmd
powercfg /powerthrottling DISABLE /PATH "C:\Program Files\Oracle\VirtualBox\VirtualBoxVM.exe"
powercfg /powerthrottling DISABLE /PATH "C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe"
powercfg /powerthrottling list
```

View File

@@ -1,22 +0,0 @@
## Cache to Ramdisk
1. 關閉 Chrome
2. 開啟檔案總管至以下路徑:`%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default`
3. 刪除 Cache 資料夾
4. 用管理員權限開啟 cmd
5. 輸入以下指令以建立 Symbolic Link: `mklink /d "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Cache\" "R:\TEMP\Chrome\"`
6. (Optional) 如果有多個使用者的話: `mklink /d "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Profile 1\Cache\" "R:\TEMP\Chrome\"`
## 網站黑名單
- 用[uBlacklist](https://chrome.google.com/webstore/detail/ublacklist/pncfbmialoiaghdehhbnbhkkgmjanfhe)來阻擋不想要的網站
- uBlacklist 也可以設定黑名單,推薦黑名單:
- [danny0838/content-farm-terminator at gh-pages](https://github.com/danny0838/content-farm-terminator/tree/gh-pages)
- [標準內容農場清單](https://danny0838.github.io/content-farm-terminator/files/blocklist/content-farms.txt)
- [類內容農場清單](https://danny0838.github.io/content-farm-terminator/files/blocklist/nearly-content-farms.txt)
- [社群內容農場清單](https://danny0838.github.io/content-farm-terminator/files/blocklist/sns-content-farms.txt)
- [假新聞網站清單](https://danny0838.github.io/content-farm-terminator/files/blocklist/fake-news.txt)
- [詐騙網站清單](https://danny0838.github.io/content-farm-terminator/files/blocklist/scam-sites.txt)
- [cobaltdisco/Google-Chinese-Results-Blocklist: 我终于能用谷歌搜中文了……](https://github.com/cobaltdisco/Google-Chinese-Results-Blocklist)
- [中文搜索结果黑名单](https://raw.githubusercontent.com/cobaltdisco/Google-Chinese-Results-Blocklist/master/uBlacklist_subscription.txt)
### 參考
- [效率封殺 Google 搜尋裡面的垃圾結果與內容農場 | jkgtw's blog ](https://www.jkg.tw/p3525/)

View File

@@ -1,275 +0,0 @@
---
tags:
aliases:
date: 2022-05-26
time: 14:51:12
description:
---
## YAML front matter
官方說明:[YAML front matter - Obsidian Help](https://help.obsidian.md/Advanced+topics/YAML+front+matter)
目前使用的front matter是[[front matter]]。
## 自動產生時間日期
Obsidian在抽入template的時候可以使用`{{date}}`來表示日期,用`{{time}}`來表示時間。
### `{{date}}` & `{{time}}`
`{{date}}`產生的時間格式為`2022-05-26`可以使用參數來更改格式例如不要讓月份與日期自動補0可以用`{{date:YYYY-M-D}}`
時間也一樣,`{{time}}`產生的格式為`14:48:45`,也有其他參數來變更格式,其他更詳細參考[Moment.js | Docs](https://momentjs.com/docs/#/displaying/)。
## Customize CSS
路徑是`<valut_name>\.obsidian\snippets\obsidian.css`
Obsidian預設定義了很多CSS class只要更改這些class就可以定義自己喜歡的外觀。
- [Obsidian自定义样式修改教程 - 知乎](https://zhuanlan.zhihu.com/p/373888121)
- [obsidian-css-snippets](https://github.com/Dmytro-Shulha/obsidian-css-snippets/tree/master/Snippets)
- [使用 CSS 代码片段增强 Obsidian 视觉效果(一) | ReadingHere](https://www.readinghere.com/blog/using-css-snippets-to-enhance-obsidian-visuals-cn/)
## My CSS
The CSS content:
```css
/*************************************************************
* Headers
*/
.cm-header-1, .markdown-preview-section h1 {
color: #081f37;
}
.cm-header-2, .markdown-preview-section h2 {
color: #1e549f;
}
.cm-header-3, .markdown-preview-section h3 {
color: #2e79ba;
}
.cm-header-4, .markdown-preview-section h4 {
color: #5fc9f3;
}
.cm-header-5, .markdown-preview-section h5 {
color: #415865;
}
.cm-header-6, .markdown-preview-section h6 {
color: #7a9eb1;
}
/*************************************************************
* List
*/
.cm-list-1 {
font-family: Cascadia Code;
}
.cm-list-2 {
font-family: Cascadia Code;
}
.cm-list-3 {
font-family: Cascadia Code;
}
.cm-list-4 {
font-family: Cascadia Code;
}
.cm-list-5 {
font-family: Cascadia Code;
}
span.cm-formatting-list-ul {
visibility: hidden !important;
}
span.cm-formatting-list-ul:after {
content: '• '; /* ITS theme; for Blue Topaz */
margin-left: -12px;
color: var(--accent); /* ITS theme; for Blue Topaz --text-normal */
visibility: visible !important;
}
ol {
font-family: Cascadia Code;
padding-inline-start: 2.5rem;
}
ul {
font-family: Cascadia Code;
padding-inline-start: 2.4rem;
list-style-type: disc;
}
/*Make list marker to be a circle*/
input[type="checkbox"],
.cm-formatting-task {
-webkit-appearance: none;
appearance: none;
border-radius: 50%;
border: 1px solid var(--text-faint);
padding: 0;
vertical-align: middle;
}
.cm-s-obsidian span.cm-formatting-task {
color: transparent;
width: 1.1em !important;
height: 1.1em;
display: inline-block;
}
input[type="checkbox"]:focus {
outline: 0;
}
input[type="checkbox"]:checked,
.cm-formatting-task.cm-property {
background-color: var(--text-accent-hover);
border: 1px solid var(--text-accent-hover);
background-position: center;
background-size: 60%;
background-repeat: no-repeat;
background-image: url('data:image/svg+xml; utf8, <svg width="12px" height="10px" viewBox="0 0 12 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g transform="translate(-4.000000, -6.000000)" fill="%23ffffff"><path d="M8.1043257,14.0367999 L4.52468714,10.5420499 C4.32525014,10.3497722 4.32525014,10.0368095 4.52468714,9.8424863 L5.24777413,9.1439454 C5.44721114,8.95166768 5.77142411,8.95166768 5.97086112,9.1439454 L8.46638057,11.5903727 L14.0291389,6.1442083 C14.2285759,5.95193057 14.5527889,5.95193057 14.7522259,6.1442083 L15.4753129,6.84377194 C15.6747499,7.03604967 15.6747499,7.35003511 15.4753129,7.54129009 L8.82741268,14.0367999 C8.62797568,14.2290777 8.3037627,14.2290777 8.1043257,14.0367999"></path></g></g></svg>');
}
/*************************************************************
* External link & Internal link
*/
.cm-s-obsidian span.cm-link,
.cm-s-obsidian span.cm-url,
.cm-s-obsidian span.cm-hmd-internal-link {
color: #0000EE;
font-family: Cascadia Code;
}
a.external-link {
color: #0000EE;
font-family: Cascadia Code;
}
/*************************************************************
* Outline
*/
.outline {
font-size: 0.8rem;
font-weight: 200;
}
.outline .tree-item {
line-height: 1.3;
}
.outline .tree-item-self {
padding-top: 0.2rem;
padding-bottom: 0.1rem;
padding-left: 0.5rem;
padding-right: 0.3rem;
}
.outline .tree-item-collapse {
left: 0.1rem;
}
.outline .tree-item-inner{
position:relative;
padding-top: 0.2rem;
/* padding-left: 1rem; */
padding-left: 1.7em;
text-indent: -0.8em;
margin-left: 0.2rem;
/* font-size: 0.9em; */
}
.outline .tree-item-children {
margin-left: 0.7rem;
padding-left: 0.5rem;
margin-top: -0.3rem;
padding-top: 0.3rem;
border-left: 1px solid var(--sidebar-marks, var(--background-modifier-border));
border-radius: 4px;
transition:all 0.5s ease-in-out;
}
.outline .tree-item-children:hover {
border-left-color: var(--sidebar-marks-hover, var(--background-secondary));
}
.outline .collapse-icon + .tree-item-inner {
font-weight: 400;
padding-left: 0.2rem;
/* margin-left: 0rem; */
/* font-size: 1em; */
}
.outline .collapse-icon {
margin-top: 0.2rem;
margin-left: -0.4rem;
margin-right: -0.4rem;
width: 2rem;
}
/*************************************************************
* Sidebar
*/
/*Vault name*/
.nav-folder.mod-root > .nav-folder-title {
padding-left: 6px;
font-size: 14px;
font-weight: bolder;
top: -6px; /* higher */
cursor: default;
color: var(--base2);
}
.nav-folder-title,
.nav-file-title {
font-size: 0.8em;
font-family: consolas;
line-height: 0.8em;
}
.nav-folder-title {
font-weight: bold;
color: #132743;
}
.nav-file-title {
color: #407088;
}
.nav-folder,
.nav-file {
margin: 0 !important;
border-left: 1px solid rgba(118, 158, 165, 0.2);
}
.cm-quote {
line-height: 1.2em;
/*font-style: italic;*/
}
/*************************************************************
* Quote
*/
.cm-formatting-quote:before {
margin-right: -0.1em;
color: var(--color-10) !important;
font-family: "ico";
content: "\edd5";
}
/*************************************************************
* Code block(inline)
*/
.cm-s-obsidian span.cm-inline-code {
/*font-size: 1em;*/
}
```
## 參考
- [使用 CSS 代码片段增强 Obsidian 视觉效果(一) | ReadingHere](https://www.readinghere.com/blog/using-css-snippets-to-enhance-obsidian-visuals-cn/)
- [obsidian-css-snippets](https://github.com/Dmytro-Shulha/obsidian-css-snippets/tree/master/Snippets)
- [Obsidian自定义样式修改教程 - 知乎](https://zhuanlan.zhihu.com/p/373888121)
- [Day 26 : 插件篇 05 — 做好筆記備份,使用 Obsidian Git自動備份筆記到 Github - iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天](https://ithelp.ithome.com.tw/articles/10280373)

View File

@@ -1,24 +0,0 @@
```json
// Settings in here override those in "Default/Preferences.sublime-settings",
// and are overridden in turn by syntax-specific settings.
{
"close_windows_when_empty": true,
"draw_indent_guides": false,
"font_face": "Fira Code",
"font_size": 11,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
],
"show_full_path": true,
"show_tab_close_buttons": false,
"spell_check": false,
"tab_size": 4,
"translate_tabs_to_spaces": true,
"use_tab_stops": true,
"draw_white_space": "all",
"trim_trailing_white_space_on_save": true,
"word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?"
}
```

View File

@@ -1,304 +0,0 @@
# 快速鍵
## 顯示快速鍵列表
- Windows: `Ctrl + k` + `Ctrl + s`
- Mac: `⌘ + k` + `⌘ + s`
## 分割目前視窗
- Windows: `Ctrl + \`
- Mac: `⌘ + \`
## 程式格式化
### 格式化整個文件
`Shift + Alf + f`
### 格式化選取的範圍
`Ctrl + k` + `Ctrl + f`
### setting.json
- `"editor.formatOnType": true`:輸入一行後,自動格式化目前這一行。
- `"editor.formatOnSave": true`:儲存時格式化檔案。
- `"editor.formatOnPaste": true`:貼上程式碼時格式化貼上的內容。
```json
{
// 文字編輯器
"editor.bracketPairColorization.enabled": true,
"editor.fontFamily": "Cascadia Code", // 字型
"editor.fontLigatures": true, //啟用連字
"editor.fontSize": 14, // 文字大小
"editor.fontWeight": "normal",
"editor.guides.bracketPairs": false,
"editor.guides.indentation": false,
"editor.insertSpaces": true,
"editor.minimap.renderCharacters": false,
"editor.renderWhitespace": "boundary",
"editor.renderLineHighlight": "all", // 整行高亮
"editor.snippetSuggestions": "top", // 將程式碼片段建議顯示於頂端
"editor.tabCompletion": "on", // 啟用tab鍵自動完成
"editor.tabSize": 4,
"editor.wordWrap": "off",
// 檔案
"files.trimTrailingWhitespace": true, // 儲存檔案時去除行尾空白
"files.insertFinalNewline": true, // 儲存檔案時在結尾插入一個新行
// 檔案管理員
"explorer.confirmDelete": false,
// 工作台
"workbench.colorTheme": "One Dark Pro", // 主題
"workbench.iconTheme": "material-icon-theme", // Icon主題
"workbench.tree.indent": 15,
"workbench.tree.renderIndentGuides": "always",
"workbench.colorCustomizations": {
"tree.indentGuidesStroke": "#05ef3c"
},
"breadcrumbs.enabled": true, // 啟用麵包屑,可以通過上方路徑來資料夾、文件或者是函數的跳轉
"oneDarkPro.vivid": true,
"diffEditor.wordWrap": "off",
// 終端機
"terminal.integrated.fontFamily": "Fira Code",
"editor.accessibilitySupport": "off",
"[python]": {
"editor.formatOnType": true
},
"polacode.target": "snippet",
"editor.inlineSuggest.enabled": true,
"github.copilot.enable": {
"*": true,
"yaml": false,
"plaintext": false,
"markdown": false,
"scminput": false
}
}
```
## 折疊程式碼
### 收起目前區塊
- Windows: `Ctrl + Shift + [`
- Mac: `⌥ + ⌘ + [`
### 打開目前區塊
- Windows: `Ctrl + Shift + ]`
- Mac: `⌥ + ⌘ + ]`
### 收起目前區塊(整個檔案)
- Windows: `Ctrl + (K => 0) (zero)`
- Mac: `⌘ + (K => 0) (zero)`
### 打開目前區塊(整個檔案)
- Windows: `Ctrl + (K => J) `
- Mac: `⌘ + (K => J)`
## 在「已開啟的檔案」間跳轉
`Ctrl + tab`
# Plugin
## Setting Sync
- 參考:[https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync](https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync)
~~- GIST Token: `e0f7c5233e3c6dafee77047f61ea74f0d01d24e1`~~
- GIST Token: `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`
- GIST ID: [`aaee0ee8733879ef2da2eb1b4bf8a993`](https://gist.github.com/AwinHuang/aaee0ee8733879ef2da2eb1b4bf8a993)
- GIST address: [https://gist.github.com/AwinHuang/aaee0ee8733879ef2da2eb1b4bf8a993](https://gist.github.com/AwinHuang/aaee0ee8733879ef2da2eb1b4bf8a993)
# Code snippets
## html.json
```json
{
"HTML template": {
"prefix": "HTML_template",
"body": [
"<!doctype html>",
"",
"<html lang=\"en\">",
"<head>",
" <meta charset=\"utf-8\">",
" <meta name=\"description\" content=\"Awin's HTML template\">",
" <meta name=\"author\" content=\"Awin Huang\">",
" <script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js\"></script>",
" <title>A HTML template</title>",
"</head>",
"",
"<body>",
" <H1>Awin's HTML template</H1>",
" <p>Click to hide</p>",
"</body>",
"</html>",
"",
"<script>",
" $(document).ready(function(){",
" $(\"p\").click(function(){",
" $(this).hide();",
" });",
" });",
"</script>",
],
"description": "HTML template"
}
}
```
## python.json
```json
{
"Python template": {
"prefix": "Python_Template",
"body": [
"import sys",
"import argparse",
"",
"",
"def main(args=None):",
" ${1:pass}",
"",
"",
"if __name__ == '__main__':",
" parser = argparse.ArgumentParser()",
" parser.add_argument(\"first_file\", help=\"The first file\")",
" parser.add_argument(\"-s\", \"--sample_args\", default=\"sample_args\", help=\"Modify this arguments for you\")",
" args = parser.parse_args()",
" main(args)",
" sys.exit(0)"
],
"description": "Python script template"
},
"F Print": {
"prefix": "f-print",
"body": [
"print(f'$1 = {$1}')"
],
"description": "print() with f-string and default {}"
},
"Q Print": {
"prefix": "q-print",
"body": [
"print('$1 = {}, '.format($1))"
],
"description": "print() with f-string and default {}"
},
"Debug RobotRun": {
"prefix": "debug_robotrun",
"body": [
"import os",
"import sys",
"sys.path.insert(0, 'D:/codes/logitech/')",
"import RobotRun",
"print('+------------------------------------------------------------------------------+')",
"print('| |')",
"print('| RobotRun: {}'.format(RobotRun.__file__))",
"print('| |')",
"print('+------------------------------------------------------------------------------+')",
],
"description": "Change RobotRun to local version"
},
"Flask template": {
"prefix": "Flask_Template",
"body": [
"## Flask template",
"## Author: Awin Huang",
"## Date: 2020/04/09",
"",
"import os, sys",
"import datetime",
"import json",
"from flask import Flask, render_template, request",
"",
"",
"app = Flask(__name__)",
"",
"## Setup log",
"handler = logging.FileHandler('flask.log', delay=False)",
"handler.setLevel(logging.INFO)",
"app.logger.addHandler(handler)",
"app.logger.setLevel(logging.INFO)",
"",
"",
"def info_log(msg):",
" app.logger.info(msg)",
" # print(msg)",
"",
"",
"def error_log(msg):",
" app.logger.error(msg)",
"",
"",
"@app.route('/')",
"def index():",
" info_log('Return main page to user.')",
" return 'Hello, this is main page'",
"",
"",
"## Receive a GET request",
"@app.route('/get_get', methods=['GET'])",
"def run_testcase():",
" command = request.args.get('command')",
" value = 'This is value for GET'",
" return {",
" 'command': command,",
" 'value': value",
" }",
"",
"",
"## Receive a POST request",
"@app.route('/get_post', methods=['POST'])",
"def get_post():",
" command = request.form['command']",
" value = 'This is value for POST'",
" return {",
" 'command': command:",
" 'value': value",
" }",
"",
"",
"if __name__ == '__main__':",
" app.debug = True",
" app.run(host='0.0.0.0')",
],
"description": "Flask template"
},
"Datetime now": {
"prefix": "now_dt",
"body": [
"datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S:%f')"
],
"description": "Get datetime.now() with format '%Y-%m-%d %H:%M:%S:%f'"
},
"Run process": {
"prefix": "runprocess",
"body": [
"import multiprocessing as mp",
"",
"process = mp.Process(target=task_set.run, args=(self.task_sync, args))",
"process.start()",
"process.join()"
],
"description": "Run function in a process"
},
"Sleep with dots": {
"prefix": "sleepdots",
"body": [
"for i in range($1):",
" import time",
" print(\".\", end=\"\", flush=True)",
" time.sleep(1)",
],
"description": "Sleep and print \".\" every second"
},
"Sleep with numbers": {
"prefix": "sleepnum",
"body": [
"for i in range($1):",
" print(f\"{i+1} \", end=\"\", flush=True)",
" time.sleep(1)",
],
"description": "Sleep and print number every second"
},
}
```
## 參考
- [VSCode 是什么](https://geek-docs.com/vscode/vscode-tutorials/what-is-vscode.html)

View File

@@ -1,161 +0,0 @@
# 要保存/恢復的檔案
- `%userprofile%/.config`
- `%userprofile%/.ssh`
- `%userprofile%/.bash_profile`
- `%userprofile%/.bashrc`
- `%userprofile%/.gitconfig`
- `%userprofile%/.vimrc`
# 安裝工具
## 安裝 Chocolatey
1. 安裝[Chocolatey](https://chocolatey.org/)用Administrator身份打開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'))
```
2. 用安裝常用的工具
```
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 obsidian anki enpass.install --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)
- [obsidian](https://community.chocolatey.org/packages/obsidian)
- [anki](https://community.chocolatey.org/packages/anki)
- [Enpass Password Manager](https://community.chocolatey.org/packages/enpass.install)
## 用 Chocolatey 升級軟體
```shell
choco upgrade all -y
```
## 手動安裝
3. Python 3.6.3
4. Python 3.9
7. Visual Studio 2022
8. Office 365
9. Lightroom
11. [ShareX](https://getsharex.com/)
12. [win32diskimager](https://sourceforge.net/projects/win32diskimager/)
13. [卡巴斯基](https://www.kaspersky.com.tw/)
14. 字型
- [Caskaydia](\\diskstation\share\Tools\字型\Caskaydia Cove Nerd Font\)
## `~/.bashrc`
1. 打開`~/.bashrc`
2. 內容如下:
```bash
export PATH="/c/Users/ahuang11/AppData/Local/Android/Sdk/platform-tools:$PATH"
##----- Android -----
alias adb="/c/EasyAVEngine/Tools/Android/ADB/adb.exe"
alias ad='adb devices'
alias fastboot='/c/EasyAVEngine/Tools/Android/ADB/fastboot.exe'
alias fd='fastboot devices'
##----- Logitech coding -----
alias rrp='cd /c/Python363/lib/site-packages/RobotRun'
alias rra='cd /c/RobotRun'
alias rrd='cd /g/My\ Drive/codes/Projects/RobotRunDocs'
alias rro='cd /c/RobotRun/Output'
alias prj='cd /c/Users/awinh/OneDrive/codes/Logitech/project'
alias coderrp='cd "/c/Python363/lib/site-packages/RobotRun" ; code "/c/Python363/lib/site-packages/RobotRun"'
alias coderra='cd "/c/RobotRun"; code "/c/RobotRun"'
alias coderras='code "/d/GoogleDriveLogi/codes/Projects/RobotRunAutoServer"'
alias p3='/c/Python363/python.exe'
##----- Awin coding -----
alias codes='cd /c/Users/awinh/OneDrive/codes'
alias ctest='code "/g/My Drive/codes/test"'
alias jn='C:/Python310/Scripts/jupyter notebook'
alias ipy='C:/Python310/Scripts/ipython'
##----- ELF -----
alias hugo='~/OneDrive/文件/BLOG/Hugo/bin/0.98_extend/hugo.exe'
##----- MISC -----
alias sl="/c/Program\ Files/Sublime\ Text/subl.exe"
alias e.='explorer.exe .'
alias blog="cd ~/OneDrive/文件/BLOG/Hugo/Sites/blog.awin.one"
alias ffmpeg="/c/Users/awinh/OneDrive/codes/CommonLib/RobotRunCommonLib/ffmpeg-n5.0-latest-win64-lgpl-shared-5.0/bin/ffmpeg.exe"
alias ob="cd ~/OneDrive/文件/Obsidian/Main"
alias ffmpeg="/c/Users/awinh/OneDrive/PortableApps/ffmpeg-n5.0-latest-win64-lgpl-shared-5.0/bin/ffmpeg.exe"
##----- Connection -----
alias gods='ssh awin@192.168.1.11'
alias gorp320='ssh pi@192.168.1.20'
alias gopve='ssh root@192.168.1.21'
##----- Git -----
alias gs="git status"
alias gd="git diff"
alias gpull='git pull origin master'
alias gpush='git push origin master'
alias gpushmain='git push origin main'
alias gc='git clone'
alias gclogi='git clone --config user.name="Awin Huang" --config user.email=ahuang11@logitech.com $@'
##----- Python enviroment swich -----
alias pyv='echo PY_PYTHON=$PY_PYTHON'
function set_py() {
echo "Original Python verison is \"$PY_PYTHON\""
export PY_PYTHON=$1
echo " New Python verison is \"$PY_PYTHON\""
if [ ! -z "$2" ]
then
py "${@:2}"
fi
}
function py36() {
set_py "3.6.3" "$@"
}
function py310() {
set_py "3.10" "$@"
}
```
## Setup Windows Terminal
1. 開啟Windows Terminal。
2.`ctrl + ,`打開設定,之後參考[[Windows Terminal]]。
## 恢復右鍵選單
- 以admin身份打開PowerShell執行 `reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve`
- 要恢復Windows 11的右鍵選單則是執行`reg delete "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f`
## 設定使用者環境變數
- `PYTHON_INCLUDE`: `C:\Python363\include`
- `PYTHON_LIB`: `C:\Python363\libs`
- `RobotRunCommonLib`: `C:\Users\awinh\OneDrive\codes\CommonLib\RobotRunCommonLib`
- `SWIGCmd`: `C:\Users\awinh\OneDrive\PortableApps\swigwin-4.0.2\swig.exe`
# 參考
- [How to open the full right-click menu by default on Windows 11](https://www.xda-developers.com/how-to-open-full-right-click-menu-by-default-windows-11/)
- [【教學】Windows 11 系統優化](https://ofeyhong.pixnet.net/blog/post/225581177)

View File

@@ -1,411 +0,0 @@
## Setup
### New tab as Administrator
- [使用系統管理員身分開啟 Windows Terminal 分頁](https://blog.poychang.net/run-windows-terminal-as-administrator-with-elevated-admin-permissions/)
### Use powerline in Git-Bash
- [Light & simple powerline theme for Git bash for windows](https://github.com/diesire/git_bash_windows_powerline)
#### Install
```shell
cd $HOME
mkdir -p .bash/themes/git_bash_windows_powerline
git clone https://github.com/diesire/git_bash_windows_powerline.git .bash/themes/git_bash_windows_powerline
```
And add following lines to `~/.bashrc`.
```
# Theme
THEME=$HOME/.bash/themes/git_bash_windows_powerline/theme.bash
if [ -f $THEME ]; then
. $THEME
fi
unset THEME
```
參考:
- [powerline/fonts: Patched fonts for Powerline users.](https://github.com/powerline/fonts)
## Settings.json
```json
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command":
{
"action": "prevTab"
},
"keys": "ctrl+pgup"
},
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command":
{
"action": "splitPane",
"split": "right"
},
"keys": "ctrl+shift+e"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
},
{
"command": "toggleFullscreen",
"keys": "alt+x"
},
{
"command":
{
"action": "newTab"
},
"keys": "ctrl+t"
},
{
"command": "closePane",
"keys": "ctrl+w"
},
{
"command":
{
"action": "splitPane",
"split": "down"
},
"keys": "ctrl+shift+o"
},
{
"command":
{
"action": "nextTab"
},
"keys": "ctrl+pgdn"
}
],
"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}",
"initialCols": 234,
"initialPosition": "16,950",
"initialRows": 30,
"profiles":
{
"defaults": {},
"list":
[
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"name": "Windows PowerShell"
},
{
"colorScheme": "Solarized Dark",
"commandline": "gsudo.exe powershell.exe",
"font":
{
"face": "Fira Code"
},
"guid": "{41dd7a51-f0e1-4420-a2ec-1a7130b7e950}",
"hidden": false,
"icon": "C:\\Users\\awinh\\OneDrive\\\u5716\u7247\\icon\\console_red.png",
"name": "Windows PowerShell(Administrator)"
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "Command Prompt"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
"font":
{
"face": "CaskaydiaCove NF",
"size": 12
},
"guid": "{00000000-0000-0000-ba54-000000000002}",
"historySize": 9000,
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
"name": "Bash",
"startingDirectory": "C:\\Users\\awinh\\OneDrive\\codes"
},
{
"guid": "{cb5c3884-260a-5acf-98ef-b546d271b4dd}",
"hidden": false,
"name": "Developer Command Prompt for VS 2022",
"source": "Windows.Terminal.VisualStudio"
},
{
"guid": "{e6386983-3aa0-5a19-a174-f3c66538b7bd}",
"hidden": false,
"name": "Developer PowerShell for VS 2022",
"source": "Windows.Terminal.VisualStudio"
},
{
"guid": "{16208362-94fc-5b1f-a491-5b2624d5ab56}",
"hidden": true,
"name": "Visual Studio Debug Console",
"source": "VSDebugConsole"
}
]
},
"schemes":
[
{
"background": "#0C0C0C",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#012456",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell Powershell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#282C34",
"black": "#282C34",
"blue": "#61AFEF",
"brightBlack": "#5A6374",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#98C379",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#98C379",
"name": "One Half Dark",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
},
{
"background": "#FAFAFA",
"black": "#383A42",
"blue": "#0184BC",
"brightBlack": "#4F525D",
"brightBlue": "#61AFEF",
"brightCyan": "#56B5C1",
"brightGreen": "#98C379",
"brightPurple": "#C577DD",
"brightRed": "#DF6C75",
"brightWhite": "#FFFFFF",
"brightYellow": "#E4C07A",
"cursorColor": "#4F525D",
"cyan": "#0997B3",
"foreground": "#383A42",
"green": "#50A14F",
"name": "One Half Light",
"purple": "#A626A4",
"red": "#E45649",
"selectionBackground": "#FFFFFF",
"white": "#FAFAFA",
"yellow": "#C18301"
},
{
"background": "#002B36",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#FFFFFF",
"cyan": "#2AA198",
"foreground": "#839496",
"green": "#859900",
"name": "Solarized Dark",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#FDF6E3",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#002B36",
"cyan": "#2AA198",
"foreground": "#657B83",
"green": "#859900",
"name": "Solarized Light",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#FFFFFF",
"cyan": "#06989A",
"foreground": "#D3D7CF",
"green": "#4E9A06",
"name": "Tango Dark",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#FFFFFF",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#000000",
"cyan": "#06989A",
"foreground": "#555753",
"green": "#4E9A06",
"name": "Tango Light",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#000080",
"brightBlack": "#808080",
"brightBlue": "#0000FF",
"brightCyan": "#00FFFF",
"brightGreen": "#00FF00",
"brightPurple": "#FF00FF",
"brightRed": "#FF0000",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFFF00",
"cursorColor": "#FFFFFF",
"cyan": "#008080",
"foreground": "#C0C0C0",
"green": "#008000",
"name": "Vintage",
"purple": "#800080",
"red": "#800000",
"selectionBackground": "#FFFFFF",
"white": "#C0C0C0",
"yellow": "#808000"
}
]
}
```
## oh-my-posh on bash
以下步驟都是在 [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 ~/OneDrive/appConfigs/ohmyposh/themes/montys.omp.json)"`
注意最後的 `montys.omp.json` 就是第一步下載的theme這邊要改成你自己的路徑。
5. 修改 Windows Terminal 的 setting.json將字型改為 `CaskaydiaCove NF`
![[20220614221618_oh-my-posh_setting.png|600]]
6. 成果
![[20220614220342_oh-my-posh_result.png|600]]
[^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)
## Reference
- [Windows Terminal 美化 for WSL 2 Ubuntu (zsh + zim + powerlevel10k)](http://www.kenming.idv.tw/windows-terminal-%e7%be%8e%e5%8c%96-for-wsl-2-ubuntu-zsh-zim-powerlevel10k/)
- [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)

View File

@@ -1,5 +0,0 @@
1. ![[Pasted image 20210321201359.png]]
2. ![[Pasted image 20210321201503.png]]
參考:
- [FreeFileSync: RealTimeSync - YouTube](https://www.youtube.com/watch?v=9KXo6yOhTWo)

View File

@@ -1,27 +0,0 @@
### `~/.vimrc`
```vim
set t_Co=256
colorscheme koehler
set nocompatible
syntax on
set showmode
set showcmd
set encoding=utf-8
set cindent
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set number
set cursorline
"set textwidth=80
set ruler
set showmatch
set hlsearch
set incsearch
set ignorecase
```

View File

@@ -1,8 +0,0 @@
用 [`PowerWriteACValueIndex()`](https://learn.microsoft.com/en-us/windows/win32/api/powersetting/nf-powersetting-powerwriteacvalueindex) 或是 `PowerWriteDCValueIndex()` 來設定,然後用 `PowerSetActiveScheme()` 使其生效。
關於 scheme 的 GUID: https://learn.microsoft.com/en-us/windows/win32/power/power-setting-guids
C#的使用[C#使用WinAPI 修改电源设置临时禁止笔记本合上盖子时睡眠使用PowerGetActiveScheme等函数以及C#对WINAPI的调用 - findumars - 博客园](https://www.cnblogs.com/findumars/p/6298724.html)
使用 API 的例子:[qt - Disable CPU package idle states in Windows from C++ code - Stack Overflow](https://stackoverflow.com/questions/69346153/disable-cpu-package-idle-states-in-windows-from-c-code)
[API for Minimum(Maximum) Processor State , C++ - Stack Overflow](https://stackoverflow.com/questions/22523708/api-for-minimummaximum-processor-state-c)

View File

@@ -1,25 +0,0 @@
# 安裝
## Synology
直接從套件中心安裝,但是安裝之後要設定。
### 設定
因為 Synology 套件的關係,所以還需要一些設定,參考[Enabling Synology outbound connections](https://tailscale.com/kb/1131/synology#enabling-synology-outbound-connections) 。
步驟如下:
1. 打開「控制台->任務排程表」
2. 新增一個「觸發任務->使用者定義指令碼」
3. 使用者帳號選「root」事件選「開機」
4. 切換到第二頁的「任務設定」,在「使用者定義指令碼」那一區填入 `/var/packages/Tailscale/target/bin/tailscale configure-host; synosystemctl restart pkgctl-Tailscale.service`
5. 如果有開防火牆的話,也要設定防火牆規則
設定防火牆
1. 打開「控制台->任務排程表」,切到「防火牆」那一頁。
2. 按下「編輯規則」
3. 按下「新增」
4. 來源IP選「特定IP」然後按「選擇」
5. 會跳出一個視窗,選「子網路」
6. 「IP位址」那一欄填「`100.64.0.0`
7. 「子網路遮罩 (mask)/Prefix 長度:」那一欄填「`255.192.0.0`
記得按「確定」儲存。然後重開機。
重開機之後打開talscale套件會要你登入登入之後就可以在machine看到機器了。

View File

@@ -1,61 +0,0 @@
## 輸出
{{message}}
## 迴圈
v-for
```javascript
<li v-for="item in list">{{ item }}</li>
```
## 輸入雙向綁定:`v-model`
```html
<input v-model="message">
```
```javascript
var app = Vue.createApp({
data: function() {
return {
message: "要被綁定的訊息"
}
}
});
```
## 事件:`v-on`
```html
<button v-on:click="testEvent">按我</button>
```
```javascript
var app = Vue.createApp({
method: {
testEvent: function() {
alert("你按了button");
}
}
});
```
## 條件式:`v-if`
```html
<div v-if="isShow"></div>
```
```javascript
var app = Vue.createApp({
data: function() {
return {
message: "要被綁定的訊息",
isShow: true
}
}
});
```
## 屬性綁定
### `v-bind`

View File

@@ -1,109 +0,0 @@
## 安裝 Watchtower
```shell
docker pull Watchtower
```
## 使用方法
```shell
docker run --detach \
--name watchtower \
--volume /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower
```
使用剛剛的方法會拉取最新鏡像,但並不會自動刪除舊有鏡像,時間一長就會佔用很大空間,這裡可以使用 `--cleanup` 選項,在更新完舊容器之後自動刪除舊鏡像
```shell
docker run -d \
--name watchtower \
--restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--cleanup
```
### 或使用 docke-compose.yml
```yml
version: "3"
services:
watchtower:
image: containrrr/watchtower
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 86400 --cleanup
```
### 設置自動更新檢測頻率
Watchtower 默認是每 5min 檢測一次,如果需要更改週期,可以使用 `--interval``-i` 選項
如設定每小時檢測一次:
```shell
docker run -d \
--name watchtower \
--restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--cleanup \
-i 3600
```
`-i 3600`:這裡的 `3600` 是設置的時間週期,單位是**秒** `3600` 即 1 小時
### 指定更新檢測時間
除了設置頻率,還可以使用 `--schedule``-s` 選項指定時間 如指定每天 UTC+8 時間凌晨 3 點更新。
```shell
docker run -d \
--name watchtower \
--restart always \
-e TZ=Asia/Taipei \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--cleanup \
-s "0 0 3 * * *"
```
這裡的執行時間為 UTC 時間,如果不指定時區,會比台北的 UTC+8:00 時間晚 8 小時
### 制定需要更新的容器
如果不想更新所有容器,可以設置指定的容器進行更新
`nginx``netdata` 這兩個容器舉例:
```shell
docker run -d \
--name watchtower \
--restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--cleanup \
nginx netdata
```
這裡指定的容器只需要填寫**容器名**,而不是填寫該容器的**鏡像名**
## 手動更新
如果不想在使用容器時被自動更新打斷,可以使用 Watchtower 進行手動更新
由於是手動更新Watchtower 只需要用到一次,可以添加 `--rm``--run-once` 參數,在更新完之後過河拆橋
### 手動更新所有容器
```shell
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--cleanup \
--run-once
```
## 手動更新指定容器
繼續以 `nginx``netdata` 這兩個容器舉例
```shell
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--cleanup \
--run-once \
nginx netdata
```
## 參考
- [使用Watchtower自動更新Docker鏡像和容器 - Docker容器 - 計算機 | 🧂 = 鹽🧂的記事本 = ( ´∀`)ヵヵヵ](https://www.sio.moe/2021/12/18/computer/Docker-Container/Use-Watchtower-to-automatically-update-Docker-images-and-containers/)
- [storjlabs/watchtower Tags | Docker Hub](https://hub.docker.com/r/storjlabs/watchtower/tags)

View File

@@ -1,34 +0,0 @@
{
"nodes":[
{"id":"6c6ff5d0e7850ea8","type":"group","x":920,"y":-360,"width":940,"height":1280,"label":"Docker"},
{"id":"e94c9e71b9aeaa89","type":"group","x":440,"y":-360,"width":400,"height":1100,"label":"基本設定"},
{"id":"acb6cf6a8010bb24","type":"group","x":1940,"y":-360,"width":480,"height":349,"label":"備份設定"},
{"id":"d624199752cf24de","type":"text","text":"![[更新與安裝工具]]","x":460,"y":-340,"width":360,"height":120},
{"id":"6875474760fafe7c","type":"text","text":"![[raspi-config]]","x":460,"y":-200,"width":360,"height":140},
{"id":"6e59f6b9f36b24e2","type":"text","text":"![[安裝]]","x":-40,"y":132,"width":383,"height":177},
{"id":"a63a5baed201beda","type":"text","text":"![[設定日誌大小]]","x":460,"y":163,"width":360,"height":180},
{"id":"b77234a9cdf72aad","type":"text","text":"# 安裝 docker\n[[00. Inbox/Linux/Docker|Docker]]","x":940,"y":-340,"width":440,"height":120},
{"id":"d0711febf5985ed5","type":"text","text":"# 安裝nginx-certbot\n教學: [iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天](https://ithelp.ithome.com.tw/m/articles/10301801\n\nGithub: [JonasAlfredsson/docker-nginx-certbot: Automatically create and renew website certificates for free using the Let's Encrypt certificate authority.](https://github.com/JonasAlfredsson/docker-nginx-certbot)","x":940,"y":-190,"width":440,"height":240},
{"id":"b900ad17a2841b99","type":"text","text":"# 安裝 Filebrowser\n[官方安裝流程](https://filebrowser.org/installation#docker)","x":1400,"y":-340,"width":440,"height":120},
{"id":"bc030994aafc5a3b","type":"text","text":"![[bashrc]]","x":460,"y":-37,"width":360,"height":177},
{"id":"f210470376a4829d","type":"text","text":"![[設定Cloudflare DDNS]]","x":460,"y":370,"width":360,"height":150},
{"id":"ef9431e16c90f57f","type":"text","text":"設定![[smb client]]","x":460,"y":540,"width":360,"height":180},
{"id":"2a7d5efcc0f2dc0e","type":"text","text":"# 安裝 Portainer\n教學 [Portainer一款圖形化容器管理工具方格子 vocus](https://vocus.cc/article/643e9f74fd89780001b51739)\n\n官網[Portainer: Container Management Software for Kubernetes and Docker](https://www.portainer.io/)","x":940,"y":489,"width":440,"height":191},
{"id":"8cac63e48dff1f2a","type":"text","text":"# 安裝 Gitea\n官方教學[Installation with Docker](https://docs.gitea.com/installation/install-with-docker)\n\n設定Gmail寄信[Gitea 使用 Gmail 寄信 - 筆記ZONE](https://zonego.tw/2021/11/14/gitea-gmail/)\n","x":940,"y":80,"width":440,"height":140},
{"id":"94fa9ef036dbe62a","type":"text","text":"# Speedtest 測試\n超簡單命令`docker run --rm robinmanuelthiel/speedtest:latest`\n\nGithub: [robinmanuelthiel/speedtest: Check internet bandwidth from a Docker container and save the results to an InfluxDB](https://github.com/robinmanuelthiel/speedtest)","x":940,"y":253,"width":440,"height":207},
{"id":"94f3e389e2687b35","type":"text","text":"# 安裝 Watch Tower\n![[Watchtower#或使用 docke-compose.yml|docke-compose.yml]]","x":1400,"y":-190,"width":440,"height":322},
{"id":"fc32cf264646fdec","type":"text","text":"# 安裝 Storj\n![[Storj]]","x":1400,"y":160,"width":440,"height":300},
{"id":"ff16e3814718d144","type":"text","text":"# 設定 crontab\n1. 用[[ddns.sh]]定時更新DNS\n2. 用[[backup_docker_gitea.sh]]備份 gitea docker\n3. 用[[backup_pi.sh]]備份整張SD卡","x":1960,"y":-340,"width":440,"height":150},
{"id":"3f1bf9d99d9d544d","type":"text","text":"# 安裝 [Nxtcloud](https://nextcloud.com/)\n![[Nextcloud]]","x":1400,"y":489,"width":440,"height":191},
{"id":"dac28a6e83be787c","x":940,"y":720,"width":440,"height":180,"type":"text","text":"# 安裝 Grafana\n![[Grafana]]"}
],
"edges":[
{"id":"9683c15c63c167c0","fromNode":"6e59f6b9f36b24e2","fromSide":"right","toNode":"e94c9e71b9aeaa89","toSide":"left"},
{"id":"af36558e6c250c94","fromNode":"d624199752cf24de","fromSide":"bottom","toNode":"6875474760fafe7c","toSide":"top"},
{"id":"feff628bc758f1e4","fromNode":"6875474760fafe7c","fromSide":"bottom","toNode":"bc030994aafc5a3b","toSide":"top"},
{"id":"f1a7af20d2d64873","fromNode":"bc030994aafc5a3b","fromSide":"bottom","toNode":"a63a5baed201beda","toSide":"top"},
{"id":"64bd8b56a86d56af","fromNode":"a63a5baed201beda","fromSide":"bottom","toNode":"f210470376a4829d","toSide":"top"},
{"id":"28432d91108beecd","fromNode":"e94c9e71b9aeaa89","fromSide":"right","toNode":"6c6ff5d0e7850ea8","toSide":"left"},
{"id":"999cc182541e11a4","fromNode":"6c6ff5d0e7850ea8","fromSide":"right","toNode":"acb6cf6a8010bb24","toSide":"left"}
]
}

View File

@@ -1,20 +0,0 @@
```shell
#!/bin/sh
WORK_DIR="/home/awin/docker/gitea"
SAVE_PATH="/media/upload"
NOW_DATETIME="$(date +'%Y%m%d_%H%M%S')"
BACKUP_FILE_PATH="$SAVE_PATH/docker_backup/gitea/backup_docker_gitea_$NOW_DATETIME.tar"
BACKUP_CMD="sudo tar -cvf $BACKUP_FILE_PATH data docker-compose.yml"
echo "$BACKUP_FILE_PATH"
echo "$(date +'%F %R:%S'): Backup start. CMD = $BACKUP_CMD" > /home/awin/log/backup_docker_gitea.log
mkdir -p $SAVE_PATH/docker_backup/gitea
sudo docker compose -f $WORK_DIR/docker-compose.yml down
cd $WORK_DIR
$BACKUP_CMD
sudo docker compose -f $WORK_DIR/docker-compose.yml up -d
echo "$(date +'%F %R:%S'): Backup finished." >> /home/awin/log/backup_docker_gitea.log
```

View File

@@ -1,15 +0,0 @@
```shell
#!/bin/sh
NOW_DATETIME="$(date +'%Y%m%d_%H%M%S')"
SAVE_FOLDER="/media/upload/pi_backup"
SAVE_FILENAME="pi4_$NOW_DATETIME.img"
CMD="sudo /home/awin/bin/image-utils/image-backup -i $SAVE_FOLDER/$SAVE_FILENAME"
LOG_FILE="/home/awin/log/backup_pi4.log"
mkdir -p $SAVE_FOLDER
echo "$(date +'%F %R:%S'): Backup start. CMD = $CMD" > $LOG_FILE
$CMD
echo "$(date +'%F %R:%S'): Backup finished." >> $LOG_FILE
```

View File

@@ -1,5 +0,0 @@
## `~/.bashrc`
```bash
alias ll='ls -al'
alias pwoff='sudo shutdown -h now'
```

View File

@@ -1,40 +0,0 @@
## `/home/awin/script/ddns.sh`
```bash
#!/bin/bash
CF_ACCESS_TOKEN=033xQP4_ZpTq3sSkeftz5J6BWw_R9eoDNTba7zfH
CF_ZONE_ID=1d6a623d1780c31544fc86f718dac16e
URLS=('awin.one'
'blog.awin.one'
'ftp.awin.one'
'git.awin.one',
'storj.awin.one')
CF_RECORD_IDS=('d67b2a1b3d7cd520b8e8dad2cb522460'
'69dcc0bd619b1a3d4a71458faff2aa50'
'bd397d9779d42c0b92c9c9c47b765769'
'4eccb48e85f2daa8fefeb92c8cb4b4ee'
'216d631bc860c6a11b62e3a1003f3e3e')
INTERNET_IP=`curl -s http://ipv4.icanhazip.com`
INTERFACE_IP=`ip address show ppp0 | grep ppp0 | grep global | awk '{print$2}'`
DNS_RECORD_IP=`dig +short "${URLS[0]}" | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | awk 'NR==1{print}'`
NOW_TIME=`date`
if [ "$INTERNET_IP" != "$DNS_RECORD_IP" ]
then
echo "Renew IP: ${DNS_RECORD_IP} to ${INTERNET_IP}"
echo "${NOW_TIME}: Renew IP: ${DNS_RECORD_IP} to ${INTERNET_IP}" > /home/awin/log/ddns.log
for ((i = 0; i < ${#URLS[@]}; i++)); do
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/dns_records/${CF_RECORD_IDS[$i]}" \
-H "Authorization: Bearer ${CF_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"'${URLS[$i]}'","content":"'${INTERNET_IP}'","ttl":120,"proxied":false}'
done
else
echo "No change: ${INTERNET_IP}"
echo "${NOW_TIME}: No change: ${INTERNET_IP}" > /home/awin/log/ddns.log
fi
```
### 參考
- [5 分鐘整合 Cloudflare API 實做 Cloudflare DDNS 動態 IP 對應網址](https://blog.toright.com/posts/7333/cloudflare-ddns)
- [自架 DDNS 教學:用 Cloudflare API 達成多域名同步更新! | by Rex | Medium](https://blog.rexyuan.com/%E7%94%A8-cloudflare-dns-api-%E4%BE%86%E9%81%94%E6%88%90-ddns-adaee3c5a84d)

View File

@@ -1,3 +0,0 @@
## `raspi-config`
1. 打開ssh與vnc
2. 開機進入console

View File

@@ -1,5 +0,0 @@
1. 到[官網](https://www.raspberrypi.com/software/)下載`imager`
2. 記得在`imager`裡面設定
1. ssh public key
2. WIFI
3. account/password

View File

@@ -1,3 +0,0 @@
1. `sudo apt update`
2. `sudo apt upgrade -y`
3. `sudo apt install dnsutils`

View File

@@ -1,3 +0,0 @@
用[[crontab]]設定[[ddns.sh]]
1. `crontab -e`
2. 加入 `*/15 * * * * /home/awin/script/ddns.sh`

View File

@@ -1,7 +0,0 @@
打開`/etc/systemd/journald.conf`
- `SystemMaxUse=1G`
- `RuntimeMaxUse=100M`
![[journalctl#重啟日誌]]
journalctl使用說明[[journalctl]]