Open vscode with command code
21 Oct 2025sudo chown -R yourUsername /usr/local/bin- Open Vscode and press
cmd + shift + p - Search for install
codeand press Enter
sudo chown -R yourUsername /usr/local/bincmd + shift + pcode and press Enter在 go 專案下要 build bin 檔的時候出現 error :
34.21 go: xxxx.com/qson/libraries/qlib@v0.2.73: unrecognized import path "xxxx.com/yy/libraries/qlib": https fetch: Get "https://xxxx.com/yy/libraries/lib?go-get=1": dial tcp 122.17.60.101:443: connect: no route to host
------
Dockerfile:34
--------------------
33 | COPY go.* .
34 | >>> RUN --mount=type=secret,id=netrc,dst=/root/.netrc \
35 | >>> --mount=type=cache,target=/go/pkg/mod \
36 | >>> --mount=type=cache,target=/root/.cache/go-build \
37 | >>> go install github.com/swaggo/swag/cmd/swag@latest && \
38 | >>> go install github.com/t-yuki/gocover-cobertura@latest && \
39 | >>> go install gotest.tools/gotestsum@latest && \
40 | >>> go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
41 | >>> go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && \
42 | >>> go mod download
43 |
--------------------
ERROR: failed to solve: process "/bin/sh -c go install github.com/swaggo/swag/cmd/swag@latest && go install github.com/t-yuki/gocover-cobertura@latest && go install gotest.tools/gotestsum@latest && go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && go mod download" did not complete successfully: exit code: 1
這是由於 go.mod 中有一個私有模組,但 Docker 容器在 go mod download 的時候連不到內部伺服器,所以整個步驟失敗。
go mod vendor,然後 Dockerfile 改成:
COPY go.* .
COPY vendor/ vendor/
RUN go mod vendor && \
go install ...
這樣 build 時不需要再上網抓私有套件。
用 systemctl start xx.service 啟動某個 daemon 的時候,出現下面錯誤:
EXT4-fs (sde3): ext4_check_descriptors: Checksum for group 0 failed (9679!=59862)
EXT4-fs (sde3): group descriptors corrupted!
這表示 /dev/sde3 分區的 ext4 superblock 或 group descriptor 出現校驗錯誤(corruption)。
執行
umount /dev/sde3 # 如果已掛載
e2fsck -f /dev/sde3
這會掃描並修復損壞的 metadata(會詢問是否修復,建議按 y) 如果你看到類似 “Inode bitmap checksums invalid” 等錯誤,也會自動修!
You are given an array of integers nums and an integer target.
Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 10^9 + 7.
Input: nums = [3,5,6,7], target = 9
Output: 4
Explanation: There are 4 subsequences that satisfy the condition.
[3] -> Min value + max value <= target (3 + 3 <= 9)
[3,5] -> (3 + 5 <= 9)
[3,5,6] -> (3 + 6 <= 9)
[3,6] -> (3 + 6 <= 9)
Input: nums = [3,3,6,8], target = 10
Output: 6
Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).
[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]
### Example 3:
Input: nums = [2,3,3,4,6,7], target = 12
Output: 61
Explanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).
Number of valid subsequences (63 - 2 = 61).
two poiner
func numSubseq(nums []int, target int) int {
const MOD = 1_000_000_007
sort.Ints(nums)
n := len(nums)
pow2 := make([]int, n+1)
pow2[0] = 1
for i:=1; i<=n; i++ {
pow2[i] = pow2[i-1]*2 % MOD
}
res := 0
l, r := 0, n-1
for l <= r {
if nums[l] + nums[r] <= target {
res += pow2[r-l]
res %= MOD
l++
} else {
r--
}
}
return res
}
從 nums[l+1] 到 nums[r] 這段長度為 r - l 中挑選任意個元素(可以不挑),總共會有 2^(r - l) 個子集合(不包含 nums[l])
這些子集合的前提是我們已經固定選了 nums[l](因為我們要它當「最小值」)。固定選 nums[l](最小值),然後從 nums[l+1..r] 這段中挑選 0~(r-l) 個元素,這 2^(r - l) 個子序列都是合法的。
遇到錯誤 Error loading key “/root/.ssh/repo_key”: error in libcrypto ,卡了非常久,試過 chatgpt 建議的各種方法。 最後發現是 private key 檔案後必須要有 newline…