原來會有這個現象還跟不同平台的行尾有關

Linux 行尾: \n (0x0A) -> LF(LineFeed)

Windows 行尾: \r\n (0x0D, 0x0A) -> CR LF (CarriageReturn LineFeed)

之前我在 .gitconfig 檔案內

新增了

kk 發表在 痞客邦 留言(0) 人氣()

小的檔案可以用 cat, 或 vim

超大檔案如果只看特定行數可以搭配 sed

1. 列出第五行

$ sed -n 5p file

2. 列出第五行, 第八行

kk 發表在 痞客邦 留言(0) 人氣()

usb drive 來回 windows/linux 過程中, 有時會出現不當的操作導致 linux 環境下 usb drive 變成 read-only

在 linux 這邊要下指令 remount

sudo mount -o remount,rw /xxx/usb-drive

Reference:

https://askubuntu.com/questions/47538/how-to-make-read-only-file-system-writable

kk 發表在 痞客邦 留言(0) 人氣()

cpp 的 compiler 會把 funcion 再添加一些東西,

當 cpp 直接 invoke c function, compile 很容易產生 symbol 錯亂問題.

解法

1. c header file 加上 defensive guard

2. cpp 在 include c-header-file 的地方

kk 發表在 痞客邦 留言(0) 人氣()

常見的 FIFO reader 範例是 

open("fifo", O_RDONLY | O_NONBLOCK);

一旦搭配 select, 會發現 select 經常被 trigger,

失去了 select 該有的功效 ...

原來當 peer 關掉 write end of FIFO,

kk 發表在 痞客邦 留言(0) 人氣()

使用 gettid 獲取 thread id, compile 卻發生 error -> error: ‘gettid’ was not declared in this scope

照定義, 應該只要 include <sys/types.h> 即可,

但事與願違 ...

最後才找到有人分享 workaround

#include<unistd.h>#include<sys/syscall.h>#define gettid() syscall(SYS_gettid)

kk 發表在 痞客邦 留言(0) 人氣()

新增兩個 shell script 方便多檔案的 git status 和 git add

複習以前學過的, 也學習以前不知道的 shell script 檔案處理工具用法.

1. status.sh

if [ $# == 2 ]
then

kk 發表在 痞客邦 留言(0) 人氣()

直接傳一個固定大小的 buffer 可能會因為 size 不夠而產生 Host not resolved 錯誤,

所以要看回傳值, 動態配置大小.

Reference:

http://stackoverflow.com/questions/6517478/how-to-use-gethostbyname-r-in-linux

kk 發表在 痞客邦 留言(0) 人氣()

https://iperf.fr

ex:

server: iperf -s

client (windows):

1. cmd

kk 發表在 痞客邦 留言(0) 人氣()

測試

kk 發表在 痞客邦 留言(0) 人氣()

使用情境:

embedded 內含 tftp 指令, 電腦安裝 tftp server,

在 embedded console 使用 tftp 指令進行檔案下載或上傳

0. 電腦執行 tftp server:

ex: Tftpd64

kk 發表在 痞客邦 留言(0) 人氣()

系統: windows 7

推測原因: 可能正在做什麼事卻被 windows update 重新開機,

導致舊登入沒有刪掉

1. 打開 cmd

2. net use

kk 發表在 痞客邦 留言(0) 人氣()

Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。