Hero Image
How to Detect RAID Information in Linux

How to Detect RAID Information in Linux lspci lspci | grep RAID 00:1f.2 RAID bus controller: Intel Corporation 82801 Mobile SATA Controller [RAID mode] (rev 04) lshw lshw -class storage *-raid description: RAID bus controller product: 82801 Mobile SATA Controller [RAID mode] vendor: Intel Corporation physical id: 1f.2 bus info: pci@0000:00:1f.2 logical name: scsi0 version: 04 width: 32 bits clock: 66MHz capabilities: raid msi pm bus_master cap_list emulated configuration: driver=ahci latency=0 resources: irq:26 ioport:f0d0(size=8) ioport:f0c0(size=4) ioport:f0b0(size=8) ioport:f0a0(size=4) ioport:f060(size=32) memory:f7e36000-f7e367ff smartctl dmesg | grep -i scsi [ 0.210852] SCSI subsystem initialized [ 0.341280] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 243) ... [ 1.213299] scsi 0:0:0:0: Direct-Access ATA ST320LT012-9WS14 YAM1 PQ: 0 ANSI: 5 [ 1.319886] sd 0:0:0:0: [sda] Attached SCSI disk [ 19.571008] sd 0:0:0:0: Attached scsi generic sg0 type 0 smartctl --all /dev/sda Model Family: Seagate Laptop HDD Device Model: ST320LT012-9WS14C Serial Number: S0V3R9LL LU WWN Device Id: 5 000c50 05be4653c Firmware Version: 0001YAM1 User Capacity: 320,072,933,376 bytes [320 GB] Sector Sizes: 512 bytes logical, 4096 bytes physical Rotation Rate: 5400 rpm Form Factor: 2.5 inches Device is: In smartctl database 7.3/5319 ATA Version is: ATA8-ACS T13/1699-D revision 4 SATA Version is: SATA 2.6, 3.0 Gb/s (current: 3.0 Gb/s) Local Time is: Sat Nov 19 20:52:01 2022 PKT SMART support is: Available - device has SMART capability. SMART support is: Enabled ... MegaCLI megacli -LDInfo -Lall -aALL Adapter 0 -- Virtual Drive Information: Virtual Drive: 0 (Target Id: 0) Name : SEAGATE RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0 Size : 320 GB Sector Size : 512 Mirror Data : 320 GB State : Optimal ... lsscsi lsscsi [0:0:0:0] disk ATA ST320LT012-9WS14 YAM1 /dev/sda Vendor-Specific Tools omreport storage vdisk List of Virtual Disks in the System Controller SEAGATE Laptop HDD ID : 0 Status : Ok Name : SEAGATE State : Ready Hot Spare Policy violated : Not Assigned Encrypted : No Layout : RAID-0 Size : 320.00 GB (343597383680 bytes) T10 Protection Information Status : No Associated Fluid Cache State : Not Applicable Device Name : /dev/sda Bus Protocol : ATA Media : HDD Read Policy : Adaptive Read Ahead Write Policy : Write Back Cache Policy : Not Applicable Stripe Element Size : 128 KB Disk Cache Policy : Enabled

Hero Image
How to Delete Files With Names That Contain Non-printable Characters

How to Delete Files With Names That Contain Non-printable Characters ls -l total 13 -rw-r--r-- 1 ZZ 197121 4 Nov 6 07:08 ' ' -rw-r--r-- 1 ZZ 197121 162 Apr 16 2022 '~$iscord.docx' -rw-r--r-- 1 ZZ 197121 6 Nov 6 06:03 ''$'\302\226' -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:01 ''$'\302\226''Λ---ω' -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:13 '␴?␴??␴??::␴?␴' -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:12 ␴__␴ -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:14 ␴␴␴␴␴␴␴␴␴␴␴␴␴␴␴␴␴ -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:18 '␴ω␴␴␣␦'$'\342\220\264' -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:16 ␣␣␣␣␣␣␣␣ -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:26 ␣ μ μ Ω Ω -rw-r--r-- 1 ZZ 197121 14 Nov 6 06:23 '␣ μ ␴'$'\342\220\264''Ξ' -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:27 -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:27 Using ANSI-C Quoting # Using ANSI-C Quoting rm ''$'\302\226' # We can also use the $ special character before enclosing the filename in single quotes rm $'\356\200\215' # pass an item's name to rm without using the ANSI-C quoting rm '\026\033' rm: cannot remove '\026\033': No such file or directory Using Inode Numbers ls -li total 11 ... 6517085 -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:18 '␴ω␴␴␣␦'$'\342\220\264' 7826050 -rw-r--r-- 1 ZZ 197121 3 Nov 9 04:23 ''$'\356\200\215\356\200\215\356\200\215' 4685554 -rw-r--r-- 1 ZZ 197121 4 Nov 6 06:27 we can delete the desired file by passing its inode number to the -inum switch of the find command

Hero Image
善用 Go Fuzzing,幫助你寫出更完整的單元測試

善用 Go Fuzzing,幫助你寫出更完整的單元測試 func Pow(base uint, exponent uint) uint { if exponent == 0 { return 1 } return base * Pow(base, exponent-1) } func FuzzPow(f *testing.F) { f.Fuzz(func(t *testing.T, x, y uint) { assert := assert.New(t) assert.Equal(Pow(x, 0), uint(1)) assert.Equal(Pow(x, 1), x) assert.Equal(Pow(x, 2), x*x) if x > 0 && y > 0 { assert.Equal(Pow(x, y)/x, Pow(x, y-1)) } }) } go test -fuzz=Fuzz -fuzztime 20s 在做 Fuzzing Test 的時候如果跑一跑 FAIL 了,Go 會幫忙把那組 input 記在 testcase/ 裡面 看了之後會發現在 x=6、y=30 時 assert 會失敗,也就是說 pow(6, 30)/6 不會等於 pow(6, 29)。但這也太奇怪了吧?仔細實驗之後才發現是因為在計算 pow(6, 30) 的時候會發生 overflow。 因為 Go 定義的 max.MaxUint 大約是 18 * 10¹⁸,但 6²⁹ 大概是 7 * 10¹⁸。如果把 6²⁹ 再乘上 6,就會發生 overflow 得到 8 * 10¹⁸,很像繞了操場兩圈結果在跟原本差不多的位置。 var ErrOverflow = fmt.Errorf("overflow") func Pow(base uint, exponent uint) (uint, error) { if exponent == 0 { return 1 } prevResult, err := Pow(base, exponent-1) if math.MaxUint/base < prevResult { return 0, ErrOverflow } return base * prevResult, nil } func FuzzPow(f *testing.F) { f.Fuzz(func(t *testing.T, x, y uint) { assert := assert.New(t) if result, err := Pow(x, 1); err != ErrOverflow { assert.Equal(result, x) } if result, err := Pow(x, y); x > 0 && y > 0 && err != ErrOverflow { resultDivX, _ := Pow(x, y-1) assert.Equal(result/x, resultDivX) } }) }

Hero Image
一張圖學會【拼音輸入法】

一張圖學會【拼音輸入法】 聲母(Initials) 聲母 拼音 例字 ㄅ b 爸 ba、別 bie、奔 ben ㄆ p 撇 pie、平 ping、鵬 peng ㄇ m 媽 ma、莫 mo、某 mou ㄈ f 發 fa、飯 fan、風 feng ㄉ d 的 d、但 dan、段 duan ㄊ t 他 ta、貼 tie、團 tuan ㄋ n 你 ni、農 nong、暖 nuan ㄌ l 李 li、亂 luan、亮 liang ㄍ g 跟 gen、怪 guai、灌 guan ㄎ k 快 kuai、考 kao、狂 kuang ㄏ h 哈 ha、漢 han、橫 heng ㄐ j 叫 jiao、雞 ji、京 jing ㄑ q 七 qi、琴 qin、巧 qiao ㄒ x 西 xi、寫 xie、小 xiao ㄓ zh 知 zhi、戰 zhan、正 zheng ㄔ ch 吃 chi、船 chuan、重 chong ㄕ sh 是 shi、山 shan、刷 shuan ㄖ r 日 ri、讓 rang、人 ren ㄗ z 字 zi、讚 zan、昨 zuo ㄘ c 次 ci、菜 cai、餐 can ㄙ s 三 san、四 si、算 suan 介音 / 特殊聲母 類型 拼音 例字 y yi / i 以 yi、依 yi、修 xiu w wu / u 無 wu、溫 wen、船 chuan v yu / ü 律 lü、雨 yu、院 yuan 單韻母(Finals) 韻母 拼音 例字 ㄚ a 沙 sha、撒 sa、奧 ao ㄛ o 哦 o、偶 ou、歐 ou ㄜ e 餓 e、樂 le、設 she ㄝ ê / ye 也 ye、學 xue、切 qie ㄞ ai 愛 ai、篩 shai、崖 yai ㄟ ei 雷 lei、最 zui、脆 cui ㄠ ao 凹 ao、老 lao、笑 xiao ㄡ ou 歐 ou、樓 lou、手 shou ㄢ an 安 an、蘭 lan、算 suan ㄣ en 恩 en、林 lin、冷 leng ㄤ ang 昂 ang、浪 lang、讓 rang ㄥ eng 成 cheng、冷 leng、令 ling ㄦ er 二 er、兒 er、而 er 複韻母 / 組合韻 拼音 例字 ye 也 ye、結 jie、血 xie iu 六 liu、有 you、謬 miu in 音 yin、新 xin、林 lin ing 英 ying、靈 ling、醒 xing uan 元 yuan、卷 juan、團 tuan ue 略 lue、學 xue yun 雲 yun、巡 xun、群 qun ong 用 yong、兇 xiong、同 tong ui 鬼 gui、為 wei、虧 kui un 文 wen、混 hun、準 zhun ua 華 hua、抓 zhua、蛙 wa uai 壞 huai、快 kuai、踹 chuai