發表文章

目前顯示的是 11月, 2014的文章

讓 GDB 可以顯示完整程式碼除錯

圖片
方法一:         在執行到中斷點的時候,敲入指令 "l"(小寫L),就可以得到以目前執行位置為中心往上與往下擴展5行的程式碼: 方法二:         把程式碼與指令畫面切割,可以單步執行並顯示所在程式碼,則需要在啟動 gdb 時加入參數 "-tui",例如:         $: gdb -tui ./a.out         不過程式在執行過程如果有印出資料,可能會破壞掉現有的檢視畫面,建議把執行過程的輸出導入到 null 裝置,如:         $: (gdb) r > /dev/null         如此一來,就可以不被干擾。

Git - Diff 的小技巧,只比較特定檔案

        一般來說,git-diff 會把所有追蹤中的檔案差異顯示出來,如果我們只要顯示 *.c 副檔名的檔案差異呢? $: git diff --name-only <branch> -- '*.c'         如此一來,就會限制輸出C檔案的差異!其中 --name-only 是為了突顯出有哪些檔案有差異,而查看差異內容。

善用 Linux 的 history command

圖片
Linux console 的重度使用者一定不能忽略這個指令 -- history,他除了顯示出輸入指令的歷史紀錄之外,也可以利用這些資訊加速操作過程,例如: 執行前一道指令的方式: 輸入 "!!" ,然後按下 Enter 輸入 "!-1" ,然後按下 Enter 按下 Ctrl+P,然後按下 Enter 從歷史紀錄中執行特定指令         例如要重複執行如上圖的某道指令,只需 在數字前面加驚嘆號 :         $: !1095         又或者想直接執行某道歷史指令,而懶得打後面的參數,只需 在指令前面加上驚嘆號 :         $: !sudo 清除歷史紀錄         $: history -c

Heroku + Bootstrappers 快速佈署

Using `bootstrappers` to create an App $: bootstrappers <App> $: cd <App> $: git init $: git add . $: git commit -m 'Init' Modify Gemfile group :production do gem ‘pg' gem 'rails_12factor' end Update bundles with... $: bundle Deploy to Heroku $: heroku create <AppName> $: git push heroku master $: heroku run rake db:migrate $: heroku open => Check site.

Ubuntu 下掛載 Cpuid 與 Msr Module

/dev/cpu ├── 0 │   ├── cpuid │   └── msr ├── 1 │   ├── cpuid │   └── msr ├── 2 │   ├── cpuid │   └── msr ├── 3 │   ├── cpuid │   └── msr ├── 4 │   ├── cpuid │   └── msr ├── 5 │   ├── cpuid │   └── msr ├── 6 │   ├── cpuid │   └── msr ├── 7 │   ├── cpuid │   └── msr └── microcode 如上,要產生以上的樹狀結構,在 Ubuntu 下需要執行以下指令: $: sudo modprobe -v msr $: sudo modprobe -v cpuid 載入對應的 Module 才能讀取 CPUID 與 MSR 資訊。

在 Linux 下變更圖檔大小

$: convert <source.img> -resize <geometric> <new.img> Example:  $: convert Add.png -resize 16x16 AddSmall.png

Git - 指定 Branch 匯出原始碼不含版本控制資訊

匯出 master 的內容並打包:   $ git archive master | tar -x -C /somewhere/else 指定特定格式,匯出然後壓縮,如匯出成 *.zip:   $ git archive --format zip --output /full/path/to/zipfile.zip master

如何在 Heroku 設定自己的網域 (以 PcHome 為例)

圖片
Pchome 設定:   1. 更改 DNS 設定,參考下圖連結,進入網頁   2. 在表單中新增一筆 CNAME 紀錄,如下圖的 quic,並且指定地址為 example.herokuapp.com. , example 是你的 App 名稱,而且 地址最後務必加上一個「.」 Heroku 設定:   1. 在 Setting 頁面,找到 Domain 欄位,點擊 "Edit" 後會跳出新增 Domain Name 的表單如下,編輯完按下 「+」,然後儲存即可! 設定很簡單,而且建立後馬上生效!