Month: August 2016

  • Model-Based Testing for RESTful API

    工作需要,要寫 API 相關的 test cases。目前只有先測 API interface 的部份,寫著寫著發現我根本在造重複的輪子,幾乎在做複製貼上跟填空的工作,程式碼大概長的像下面這樣: class Foo_0000: “”” POST /login/token “”” def __init__(self): self.REST_PATH = “/login/token” self.headers = {“content-type”: “application/json”} self.parse_response = {{ 200: self.parse_response_200, 400: self.parse_response_400, 500: self.parse_response_500 }} def post_api(self, payload): payload = json.dumps(payload) r = requests.post(CONFIG.HOST + self.REST_PATH, data=payload, headers=self.headers) return r def parse_response_200(self, payload, r): if self.expect_status_code !=…

  • Linux Reading List

    Books 現在正在讀的 Linux 相關的書 Kernel http://www.dedoimedo.com/computers/crash-book.html Debugging Linux System Yocto Linux Dev  Linux Inside 4 path to being a kernel hacker

  • 現在正在讀的 Linux 相關的書

    Linux kernel Linux Kernel Development / 3e (精通 Linux 核心開發) Linux Device Drivers / 3e (Linux 驅動程式) Linux Kernel and Driver Development Training – free electrons (PDF) Debug Hacks 除錯駭客:極致除錯的技巧與工具 Advanced Programming in the UNIX Environment / 3e C Expert C Programming – Deep C Debugging with gdb – The gnu Source-Level Debugger 透視 C…

  • 正宗哥吉拉觀後感

    看完哥吉拉,有種在看 EVA 的感覺…… 尤其是在配樂的地方,聽到那種聖歌型態的配樂,加上打仗前的定音鼓,我在猜要是最後打不贏,大概EVA就會從地底下跑出來打哥吉拉吧。 最後字幕跑跑跑,果然配樂是鷺巢詩郎XD 這部片的可以說是喜劇片,用來看日本內閣官僚體系的運作方式。

  • delete git branch local and remote (刪除本地跟遠端 git branch)

    剛剛不小心推錯 commit 到新的 branch 上面,因為只有這個 commit,就想說直接把 branch 給刪掉就好。 git branch -D wip/foobar 但是到 gitlab 上看 branch 還是存在於 remote 端。 回到 cli 下 git push 卻告訴我 Already up to date…… 上網看了一下,要把 branch 推回 remote 端才行 git push origin wip/foobar 搞定!

  • 罗辑思维 184 怎么样成为一个高手

    有效的學習要刻意的去學習,不是以賽代練,是要能去操作小片斷的學習。針對性重複練習。持續做你不會做的事情。 看了文章要記得寫筆記或心得,跟文章做一次互動。 「人類不僅創造了工具,工具反過來也塑造人類」 —- 拿來程式上來看,是不是就是一直去看 code 呢?如果把 code 當詩詞來看,會讓自己的工具庫變大嗎? 這集跟學徒模式這本書裏面說的很相似。脫離舒適圈,進入深水區,練習練習再練習,找個老師…etc

  • 4.x Linux kernel procfs guide (continue)

    今天正在釐清在 4.x 上可行的 procfs 應用方式,使用的範例是來自 crashcourse.ca 的 Introduction linux kernel programming,裏面系統的介紹了 procfs 與 seq_file 的使用方式,一共有三節可以看。 做完上面的練習之後,目前正在更新舊的 Linux kernel procfs guide,proting 成新版的 4.x Linux kernel procfs guide,整理之後,希望可以幫助到其他人學習這個地方。

  • Linux procfs example (4.x 可用的)

    網路上很多有關 Linux kernel 的 snippet 或是 tutorial 其實都已經過期很久了… 例如說今天想要找 procfs 的範例: Documents/Kernel-Docbooks Linux Kernel Procfs Guide http://www2.mta.ac.il/~carmi/Teaching/OSLinux/Slides/Lec08/procfs-1.c http://www.ittc.ku.edu/kusp/new/howto/kmods/setup.html …etc 以上都是過期的範例,大約是在 kernel 2.6 時候的 code. 目前 (2016/08/24) 的 kernel version 已經來到 4.8.0-rc3,而 create_proc_entry() 是在 3.10 版的時候被拋棄掉的。但是很多的 example 都還留在 2.6 的時代,連目前市面上的書也是如此,像是 LDD3,LKD等,在版本上都已經過期許久。 目前有找到的新的 procfs 範例有這些: http://www.cs.fsu.edu/~cop4610t/lectures/project2/procfs_module/proc_module.pdf http://www.lifl.fr/~lipari/courses/ase_lkp/ase_lkp.html https://chengyihe.wordpress.com/2015/11/03/android-kernel-procfs-seq_file-the-simplest-way-to-export-to-user-space/ 在 kernel newbies mailing list 的這串討論串也可以看看, 裏面有提到比較新的 kernel develop 的教材。…

  • Declaration and Definition in C

    Definition: 定義 occurs in only one place (只能出現一次) specifies the type of an object; reserves storage for it; is used to create new objects example:  int my_array[100]; Declaration: 宣告 can occur multiple times (可以出現多次) describes the type of an object; is used to refer to objects defined elsewhere (e.g., in another file) example:  extern int…

  • Linux time difference in nano-second persision

    在 Linux 中算出 nano-second 級時差 當你在需要跟時間差有高精確度的需求的時候,可能會先想到用 gettimeofday 來處理,像是這樣: gettimeofday #include <sys/time.h> struct timeval start, end; gettimeofday(&start, NULL); … gettimeofday(&end, NULL); /* print diff in time */ diff(start, end); 那如果要更高的精確度呢?例如說到 nano-seconds? 就必須要使用 clock_gettime 來處理。 nano-second diff #include <time.h> static long diff_in_ns(struct timespec t1, struct timespec t2) { struct timespec diff; if (t2.tv_nsec-t1.tv_nsec < 0) { diff.tv_sec…