用 Shell 在 PDF 檔案中,找出指定字串

From: http://stackoverflow.com/questions/14449968/find-string-inside-pdf-with-shell

Find string inside pdf with shell

As nicely pointed by Simon, you can simply convert the pdf to plain text using pdftotext, and then, just search for what you’re looking for.

After conversion, you may use grep, bash regex, or any variation you want:

while read line; do

    if [[ ${line} =~ [0-9]{4}(-[0-9]{2}){2} ]]; then
        echo ">>> Found date;";
    fi

done <<(pdftotext infile.pdf -)

vim 編輯文件時,每行後面總有個錢字符號「$」

出至:http://stackoverflow.com/questions/11735560/dollar-sign-at-the-end-of-every-line

Dollar sign at the end of every line

I am relatively new to Vim and am planning to code and learn Ruby on it. But whenever I start the Vim (e.g. vim LearnRuby.rb), a dollar sign appears at every line. I am wondering what’s it all about.

:set nolist

will turn off special characters for the current buffer, such as tabs being presented as ^I and end of line characters showing up as $.

However, if it’s doing that consistently when you run vim, you need to look into your .vimrc (or other startup file where applicable) and find out what’s doing the set list that causes it.

它「$」是特殊字元用來代表每一行的結尾。
在 vim 執行「:set list!」命令,切換顯示或隱藏這一些特殊字元。

vim 中如何取代特殊字元^M

出至:http://stackoverflow.com/questions/5939142/replacing-m-with-enter

Replacing ^M with Enter

I know how to remove ^M in my files (%s/^M//g), but this one is just one line I’d like to replace ^M with enter… what’s the enter character in VIM (to use in commnad-line mode).

You can replace one character using r<CR> in normal mode.
Or you can enter a “return" in command line mode by typing <C-v><CR>.

一般模式下取代一個字元,直接用「r<CR>」。<CR>是Enter鍵的意思!

或是在命令列模式中先按下「Ctrl+V」就會出現「^」字元,接著再按下「Enter」就能順利打出「^M」這個符號了。

How do I edit an incorrect commit message in Git?

From: http://stackoverflow.com/questions/179123/how-do-i-edit-an-incorrect-commit-message-in-git

git commit –amend -m “New commit message"

Used to amend the tip of the current branch. Prepare the tree object you would want to replace the latest commit as usual (this includes the usual -i/-o and explicit paths), and the commit log editor is seeded with the commit message from the tip of the current branch. The commit you create replaces the current tip — if it was a merge, it will have the parents of the current tip as parents — so the current top commit is discarded.

It is a rough equivalent for:

$ git reset –soft HEAD^
$ … do something else to come up with the right tree …
$ git commit -c ORIG_HEAD
but can be used to amend a merge commit.

How can I uncommit the last commit in a git bare repository?

From: http://stackoverflow.com/questions/4624881/how-can-i-uncommit-the-last-commit-in-a-git-bare-repository

You can use the git update-ref command. To remove the last commit, you would use:

$ git update-ref HEAD HEAD^
Or if you’re not in the branch from which you cant to remove the last commit:

$ git update-ref refs/heads/branch-name branch-name^
You could also pass a sha1 if you want:

$ git update-ref refs/heads/branch-name a12d48e2
See the documentation of the git-update-ref command.

關閉 vim 搜尋的反白 指令

來源:http://usagiblog.wordpress.com/2006/03/03/%E9%97%9C%E6%96%BC-vim-%E7%9A%84%E6%90%9C%E5%B0%8B%E5%8F%8D%E7%99%BD/

關於 vim 的搜尋反白

各家 distrobution 或者各個工作站的 global settings 裡的 vimrc 可能都有各自的設定, 若您遇到的環境剛好預設把「搜尋反白」打開(set hlsearch), 說不定您會想把它關掉.

如果是搜尋動作完, 想把反白弄掉而已, 可以用「讓 vim 搜尋一段檔案裡不可能出現的字串」的方式, 我的習慣是打:

/aaaaaaaaaaaaaaaaaaaaaa

若想暫時關掉, 可打:

:set nohlsearch

或是打上:
:noh

若想把這功能永遠關閉的話, 在 ~/.vimrc 裡寫入 set nohlsearch 就可以了.

[nagios] CRITICAL – popen timeout received, but no child process

CRITICAL – popen timeout received, but no child process.

需要指定使用 ipV4 參數來執行 check_ping 的檢查

修正 nagios 的 command.cfg check_ping 命令的設定僅使用IPV4來檢查

define command{
        command_name    check-host-alive
        command_line    $USER1$/check_ping -4 -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5 -4
}