用 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://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 就可以了.

Extract Images from an Excel Document

出至:http://stackoverflow.com/questions/5503015/extract-images-from-an-excel-document

First, use unoconv to convert the .xls to .pdf:

http://dag.wieers.com/home-made/unoconv/

On Ubuntu 10.10 command line:

sudo apt-get install unoconv
unoconv -f pdf file.xls
Then extract the images from the pdf using pdfimages (which seems to come bundled with Ubuntu):

http://en.wikipedia.org/wiki/Pdfimages

Back on the command line:

pdfimages file.pdf fileimage
And done! All of the images in the .xls are now in separate files in the directory. This could be done very easily on most Linux systems using your language of choice. In python, for example:

import subprocess
subprocess.call([‘unoconv’,’-f’,’pdf’,’file.xls’])
subprocess.call([‘pdfimages’,’file.pdf’,’fileimage’])

I would love to hear a simpler solution if somebody has one.
******************************************************************************************

If a excel file is a compressed file.(xlsx)

$ unzip file.xlsx

in xl/media/ are all pictures

How do I indent multiple lines quickly in vi ? ( vim 如何多行縮排)

出至:http://stackoverflow.com/questions/235839/how-do-i-indent-multiple-lines-quickly-in-vi

Use the > command. To indent 5 lines, 5>>. To mark a block of lines and indent it, Vjj> to indent 3 lines (vim only). To indent a curly-braces block, put your cursor on one of the curly braces and use >%.

If you’re copying blocks of text around and need to align the indent of a block in its new location, use ]p instead of just p. This aligns the pasted block with the surrounding text.

Also, the shiftwidth setting allows you to control how many spaces to indent.

wget下載 sun jdk , 解決 wget 缺陷

基於 wget 重定向問題,我們可以「欺騙服務器」,即添加一些參數

#wget –no-cookie –header “Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" http://download.oracle.com/otn-pub/java/jdk/7u10-b18/jdk-7u10-linux-i586.rpm

然後把下載來的 jdk 改名
#mv jdk-7u7-linux-* jdk-7u10-linux-i586.rpm

截取至:http://www.cnblogs.com/wanghaosoft/archive/2013/01/12/2857411.html

user join to a new group and effect right now without logout

user join to a new group and effect right now without logout

If you modified your own user account while logged in with it, the changes will not have an effect until you next login.

If you don’t want to logout, you can replace your current BASH shell with a new one to achieve the same thing by running the follow:

# su -m -c “$(which $SHELL) –login -i" $(whoami)

This will switch-user to yourself, replacing your current shell with a new instance of itself. You will be prompted for your password.

If you don’t specify a command to run you’ll probably get an error to the effect of “cannot execute bash: file not found” because it won’t be on the environment. You could use –shell to point su at it, but your shell wouldn’t be a “login” shell and therefore won’t read your .bash_profile etc.

squid setting transparent proxy for every version

If you don’t want to modify the browser for using a proxy there is a method that is called “Transparent Proxy“; to use this you need to do like this:

Prior to Squid Version 2.6:

httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

Squid Version 2.6 to 3.0:

http_port 3128 transparent

Squid Version 3.1+ :

http_port 3128 intercept

Thanks for taking the time to read this guide, I hope it’s helpful.

domain name list to ip resolve by host, xargs, commands

domain_list

jerry@jerry-P5Q-office:~$ less query_domain_list

tw.yahoo.com
www.google.com.tw
www.facebook.com
www.hinet.net
www.bot.com.tw
query_domain_list (END)

resolve ip address from domain_list

jerry@jerry-P5Q-office:~$ cat query_domain_list |xargs -L 1 host >> resoleved_list
jerry@jerry-P5Q-office:~$ less resoleved_list

tw.yahoo.com is an alias for tw.frontpage.wg1.b.yahoo.com.
tw.frontpage.wg1.b.yahoo.com is an alias for tw-tw.frontpage.wg1.b.yahoo.com.
tw-tw.frontpage.wg1.b.yahoo.com has address 203.188.197.200
tw-tw.frontpage.wg1.b.yahoo.com has address 119.160.246.241
www.google.com.tw has address 74.125.31.94
www.google.com.tw has IPv6 address 2404:6800:4008:c00::5e
www.facebook.com is an alias for star.c10r.facebook.com.
star.c10r.facebook.com has address 31.13.75.23
star.c10r.facebook.com has IPv6 address 2a03:2880:10:8f02:face:b00c:0:1
star.c10r.facebook.com mail is handled by 10 smtpin.mx.facebook.com.
www.hinet.net has address 202.39.224.7
www.hinet.net has IPv6 address 2001:b000:180:3::7
www.bot.com.tw has address 103.21.63.120
www.bot.com.tw has address 210.71.212.120