feat: update helper tool (Sep 16th)

This commit is contained in:
2026-09-16 01:47:47 +00:00
commit 953ad22dce
7 changed files with 630 additions and 0 deletions

334
BLESH_BASH.md Normal file
View File

@@ -0,0 +1,334 @@
# Custom Bash Terminal
Ghi chú cấu hình terminal Bash trên môi trường dev để có prompt ngắn gọn, Git status, màu sắc và auto-completion/autosuggestion.
## 1. Kiểm tra shell đang sử dụng
```bash
echo $SHELL
ps -p $$ -o comm=
```
Kết quả hiện tại:
```text
/bin/bash
bash
```
→ Đang sử dụng **Bash**.
---
## 2. Custom Bash Prompt
### Mục tiêu
Thay prompt dài mặc định:
```text
jovyan@coder-huythai855-dev:~/projects/ivp-core$
```
thành:
```text
ivp-core customer/phuquoc ✓ ❯
```
Quy ước:
* Folder hiện tại → **cyan**
* Git branch → **tím**
* `✓` → **xanh**, Git working tree clean
* `*` → **vàng**, có thay đổi chưa commit
* `❯` → **xanh**
Ngoài Git repository:
```text
projects ❯
```
### Cấu hình
Mở:
```bash
nano ~/.bashrc
```
Thêm:
```bash
# ===== Custom Bash Prompt =====
update_prompt() {
local branch
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
branch=$(git branch --show-current 2>/dev/null)
# Detached HEAD
if [ -z "$branch" ]; then
branch=$(git rev-parse --short HEAD 2>/dev/null)
fi
if [ -z "$(git status --porcelain 2>/dev/null)" ]; then
# Git clean
PS1='\[\e[36m\]\W\[\e[0m\] \[\e[35m\]'"$branch"'\[\e[0m\] \[\e[32m\]✓\[\e[0m\] \[\e[32m\]❯\[\e[0m\] '
else
# Git modified
PS1='\[\e[36m\]\W\[\e[0m\] \[\e[35m\]'"$branch"'\[\e[0m\] \[\e[33m\]*\[\e[0m\] \[\e[32m\]❯\[\e[0m\] '
fi
else
# Outside Git repo
PS1='\[\e[36m\]\W\[\e[0m\] \[\e[32m\]❯\[\e[0m\] '
fi
}
PROMPT_COMMAND=update_prompt
```
Reload:
```bash
source ~/.bashrc
```
---
## 3. Bash Completion
Cài:
```bash
sudo apt update
sudo apt install -y bash-completion
```
Thêm vào `~/.bashrc`:
```bash
# Enable bash completion
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
fi
```
Reload:
```bash
source ~/.bashrc
```
Ví dụ:
```text
git sta<Tab>
```
→ autocomplete thành:
```text
git status
```
Hoặc:
```text
git s<Tab><Tab>
```
→ hiển thị các Git subcommand bắt đầu bằng `s`.
---
## 4. Autosuggestion với ble.sh
Mục tiêu là có suggestion dựa trên history.
Ví dụ đã từng chạy:
```bash
git status
```
Lần sau chỉ cần gõ:
```text
git s
```
terminal sẽ gợi ý phần còn lại của:
```text
git status
```
### Cài ble.sh
Clone:
```bash
git clone --recursive --depth 1 https://github.com/akinomyoga/ble.sh.git ~/.local/share/blesh
```
ble.sh cần `gawk` để build:
```bash
sudo apt update
sudo apt install -y gawk
```
Build:
```bash
make -C ~/.local/share/blesh
```
Kiểm tra:
```bash
ls ~/.local/share/blesh/out/ble.sh
```
Thêm cuối `~/.bashrc`:
```bash
# ble.sh - autosuggestion + syntax highlighting
source ~/.local/share/blesh/out/ble.sh
```
Reload:
```bash
source ~/.bashrc
```
### Cách sử dụng
* `→` → accept autosuggestion
* `Tab` → shell completion
* `↑ / ↓` → command history
Khuyến nghị giữ cách hoạt động này thay vì override `Tab`.
---
## 5. Lưu ý về PATH
Trong quá trình sửa `.bashrc`, có thể vô tình xóa dòng cấu hình `PATH`.
Triệu chứng:
```text
codex
bash: codex: command not found
[ble: exit 127]
```
`exit 127` nghĩa là **command not found**, không phải ble.sh bị lỗi.
Kiểm tra PATH:
```bash
echo $PATH
```
Kiểm tra Codex:
```bash
which codex
command -v codex
```
Tìm binary:
```bash
find ~/.local ~/.npm ~/ -type f -name codex 2>/dev/null | head -20
```
Nếu Codex được cài bằng npm:
```bash
npm config get prefix
```
Ví dụ npm prefix là:
```text
/home/jovyan/.npm-global
```
thì cần:
```bash
export PATH="$HOME/.npm-global/bin:$PATH"
```
Nếu binary nằm trong `~/.local/bin`:
```bash
export PATH="$HOME/.local/bin:$PATH"
```
Kiểm tra các cấu hình PATH hiện có:
```bash
grep -n "PATH" ~/.bashrc
```
và:
```bash
grep -n "PATH" ~/.profile ~/.bash_profile ~/.bash_login 2>/dev/null
```
**Không nên overwrite PATH** kiểu:
```bash
export PATH="/usr/local/bin:/usr/bin:/bin"
```
vì sẽ làm mất các path đã có.
Nên prepend/append:
```bash
export PATH="$HOME/.local/bin:$PATH"
```
hoặc:
```bash
export PATH="$HOME/.npm-global/bin:$PATH"
```
---
## 6. Cấu hình mong muốn cuối cùng
Terminal:
```text
ivp-worker customer/phuquoc ✓ ❯
```
Khi source code thay đổi:
```text
ivp-worker customer/phuquoc * ❯
```
Có:
* Bash prompt ngắn gọn
* Màu sắc
* Git branch
* Git clean/dirty status
* Bash completion
* Git completion
* Command history
* Autosuggestion qua ble.sh
* Giữ nguyên PATH cho các CLI như `codex`

27
CODEGRAPH.md Normal file
View File

@@ -0,0 +1,27 @@
# CodeGraph
When an AI agent needs to understand code — to answer a question or make a change — it discovers structure the slow way: grep, glob, and Read, one file at a time, rebuilding call paths and dependencies by hand. That's a pile of tool calls and round-trips before it even starts the real work.
CodeGraph hands the agent the exact code it needs in one call. It's a pre-built knowledge graph of every symbol, call edge, and dependency in your codebase — so instead of crawling files, the agent asks one question and gets back the relevant source, the call paths between those symbols (including dynamic-dispatch hops grep can't follow), and the blast radius of a change. Surgical context, not a file-by-file search — which means fewer tool calls and faster answers on every codebase, large or small.
### Check Codex & NPM installed
codex --version
node --version
npm --version
### Install CodeGraph
npm install -g @colbymchenry/codegraph
codegraph --version
codegraph install --target=codex
### Init CodeGraph for project
codegraph init
### Reindex for project
codegraph index / codegraph sync
### Check status
codegraph status

18
HELM.md Normal file
View File

@@ -0,0 +1,18 @@
## Helm install
```
HELM_BUILDKITE_APT_KEY_ID="DDF78C3E6EBB2D2CC223C95C62BA89D07698DBC6"
sudo apt-get install curl gpg apt-transport-https --yes
curl -fsSL https://packages.buildkite.com/helm-linux/helm-debian/gpgkey > "${TMPDIR:-/tmp}/helm.gpg"
# Ensure that the key ID matches to prevent a repository compromise from establishing an attacker controlled key
if [ "$(gpg --show-keys --with-colons "${TMPDIR:-/tmp}/helm.gpg" | awk -F: '$1 == "fpr" {print $10}' | head -n 1)" != "${HELM_BUILDKITE_APT_KEY_ID}" ]; then echo "ERROR: Unexpected Helm APT key ID: potential key compromise"; exit 1; fi
cat "${TMPDIR:-/tmp}/helm.gpg" | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/helm.gpg] https://packages.buildkite.com/helm-linux/helm-debian/any/ any main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
```

144
K9S.md Normal file
View File

@@ -0,0 +1,144 @@
wget https://github.com/derailed/k9s/releases/latest/download/k9s_linux_amd64.deb && sudo apt install ./k9s_linux_amd64.deb && rm k9s_linux_amd64.deb
/root/.config/k9s/config.yaml
```
k9s:
refreshRate: 2
ui:
skin: light4
enableMouse: true
```
/root/.config/k9s/skins/light4.yaml
```
# -----------------------------------------------------------------------------
# Transparent skin
# Preserve your terminal session background color
# -----------------------------------------------------------------------------
# Skin...
k9s:
body:
bgColor: default
prompt:
bgColor: default
info:
sectionColor: default
dialog:
bgColor: default
labelFgColor: default
fieldFgColor: default
frame:
crumbs:
bgColor: default
title:
bgColor: default
counterColor: default
menu:
fgColor: default
views:
charts:
bgColor: default
table:
bgColor: default
header:
fgColor: default
bgColor: default
xray:
bgColor: default
logs:
bgColor: default
indicator:
bgColor: default
toggleOnColor: default
toggleOffColor: default
yaml:
colonColor: default
valueColor: default
```
## Fix trên máy jovyan / coder workspace
Máy này đang chạy bằng user `jovyan`, nên cấu hình k9s nằm ở:
```
/home/jovyan/.config/k9s/config.yaml
/home/jovyan/.config/k9s/skins/light4.yaml
```
Không dùng `/root/.config/k9s` trừ khi đang chạy k9s bằng user `root`.
Cấu hình theme đã set:
```
k9s:
refreshRate: 2
ui:
skin: light4
enableMouse: true
```
Nếu `k9s version` chạy được nhưng `k9s` thoát ngay, kiểm tra log:
```
k9s info
tail -n 80 /home/jovyan/.local/state/k9s/k9s.log
```
Lỗi đã gặp:
```
No context configured
Conn check failed. Bailing out!
```
Nguyên nhân: kubeconfig của user `jovyan` bị rỗng, không có `current-context`.
`kubectl` vẫn có thể gọi API bằng service account trong pod, nhưng k9s cần kubeconfig có context rõ ràng.
Cách tạo lại kubeconfig `in-cluster`:
```
install -d -m 0700 /home/jovyan/.kube
kubectl config set-cluster in-cluster \
--server=https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT} \
--certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
--embed-certs=true
kubectl config set-credentials reserve-workspace \
--token="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"
kubectl config set-context in-cluster \
--cluster=in-cluster \
--user=reserve-workspace \
--namespace=default
kubectl config use-context in-cluster
```
Kiểm tra lại:
```
kubectl config current-context
kubectl get pods -n minio --request-timeout=5s
k9s
```
Sau khi sửa, k9s hiển thị:
```
Context: in-cluster [RW]
Cluster: in-cluster
User: reserve-workspace
K8s Rev: v1.35.5+rke2r1
```
Một số warning RBAC vẫn có thể xuất hiện vì service account hiện tại không có quyền list CRD/node metrics:
```
CRDs load Fail
No nodes metrics access
```
Đây không phải lỗi theme và cũng không phải lỗi khởi động k9s.

31
MINIO.md Normal file
View File

@@ -0,0 +1,31 @@
curl -LsSf https://astral.sh/uv/install.sh | sh
uv init
uv venv
source .venv/bin/activate
uv add "huggingface_hub[cli]"
hf download deepseek-ai/deepSeek-v4-flash --local-dir /home/jovyan/projects/models/deepseek-v4-flash
curl --progress-bar -L https://dl.min.io/aistor/mc/release/linux-amd64/mc --create-dirs -o $HOME/aistor-binaries/mc
chmod +x ~/aistor-binaries/mc
~/aistor-binaries/mc --help
export MINIO_ENDPOINT=http://minio.minio.svc.cluster.local:9000
export MINIO_ACCESS_KEY=admin
export MINIO_SECRET_KEY='vtsaiplatform@54321'
export MODEL_STORAGE_PATH=models
mc alias set minio "$MINIO_ENDPOINT" "$MINIO_ACCESS_KEY" "$MINIO_SECRET_KEY" --api S3v4
mc mirror --overwrite \
/home/jovyan/projects/models/deepseek-v4-flash \
minio/$MODEL_STORAGE_PATH/deepseek-v4-flash
mc ls --recursive --summarize minio/$MODEL_STORAGE_PATH/deepseek-v4-flash

7
TMUX.md Normal file
View File

@@ -0,0 +1,7 @@
sudo apt update && sudo apt install tmux
- tmux a
- tmux a -t 0
- (in session) Ctrl + B + D
- tmux kill-session -t 0

69
adminer.yaml Normal file
View File

@@ -0,0 +1,69 @@
apiVersion: v1
kind: Namespace
metadata:
name: adminer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: adminer
namespace: adminer
spec:
replicas: 1
selector:
matchLabels:
app: adminer
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:
metadata:
labels:
app: adminer
spec:
containers:
- name: adminer
image: adminer:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
protocol: TCP
restartPolicy: Always
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
name: adminer
namespace: adminer
spec:
type: ClusterIP
selector:
app: adminer
ports:
- port: 80
targetPort: 8080
protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: adminer
namespace: adminer
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: db-h200.vts-ai.space
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: adminer
port:
number: 80