標籤

二元樹 (1) 字串常數池 (1) 投資 (3) 每月損益 (37) 例外處理 (1) 泛型 (2) 股票 (15) 指標 (5) 英文 (8) 基本資料型別 (1) 期貨 (1) 程式交易 (10) 量化投資 (5) 亂亂寫 (3) 概念 (3) 資料結構 (3) 演算法 (3) 數學 (3) 轉型 (1) AMA (1) ArrayList (1) assert (1) BeautifulSoup (1) C/C++ (8) casting (1) ClassCastException (1) classpath (1) Collection (4) Comparable (1) comparTo() (1) constructor (1) database (3) Debian (1) Dropbox (2) EA (2) enum (1) equals() (2) exception (3) extends (1) ffmpeg (1) final (1) Git (1) HashMap (1) HashSet (1) hasNext() (1) HTS (3) instanceof (1) IS-A (1) Iterator (1) JAVA (43) length (1) Linux (31) List (1) Mac (6) Map (1) ML (2) MT4 (6) MySQL (2) next() (1) NullPointerException (1) Number (1) Numpy (2) OpenCart (1) OpenCV (3) OSX (1) overloading (1) overriding (3) pandas (2) PHP (8) PriorityQueue (1) Python (11) Queue (1) random() (1) reverse() (1) Samba (1) SCJP (21) sqrt() (1) synchronized (1) talib (1) ufw (1) uTorrent (1) var-args (2) VHF (1) vim (2) Yhoo知識+ (4)

2013年10月29日 星期二

於Ubuntu同步Google硬碟

安裝 Grive

$sudo add-apt-repository ppa:nilarimogard/webupd8
$sudo apt-get update
$sudo apt-get install grive

/*
原始碼編譯安裝也可以,首先安裝一些必要套件:
$sudo apt-get install cmake build-essential libgcrypt11-dev libjson0-dev libcurl4-openssl-dev libexpat1-dev libboost-filesystem-dev libboost-program-options-dev binutils-dev

Grive下載原始碼,或直接使用 wget 下載:
$wget http://www.lbreda.com/grive/_media/packages/0.2.0/grive-0.2.0.tar.gz
$tar xvfvz grive-0.2.0.tar.gz
$cd grive-0.2.0
$cmake .
$make
$sudo make install

*/

安裝完成之後,第一次執行:
mkdir ~/google_drive
cd ~/google_drive
grive -a


然後打開連結,按確定,就會出現一個授權碼,再貼回終端機裡,按下 Enter 鍵,就會開始下載GoogleDrive裡的資料。


使用 Grive 進行同步

command進GoogleDrive的資料夾,輸入grive,就會自動同步了.


參考自

2013年10月27日 星期日

ffmpeg mp3 merge and mp3+pic=flv

ffmpeg -i "concat:12-03.mp3|12-04.mp3|12-05.mp3|12-06.mp3|12-07.mp3|12-08.mp3|12-09.mp3|12-10.mp3" -acodec copy merge.mp3

ffmpeg -loop_input -i RedRiver.jpg -i merge.mp3 -f flv -acodec copy -r 1 output.flv

2013年10月23日 星期三

medianBlur


medianBlur

Blurs an image using the median filter.
C++: void medianBlur(InputArray src, OutputArray dst, int ksize)
Python: cv2.medianBlur(src, ksize[, dst]) → dst
Parameters:
  • src – input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be CV_8UCV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U.
  • dst – destination array of the same size and type as src.
  • ksize – aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ...
The function smoothes an image using the median filter with the \texttt{ksize} \times \texttt{ksize} aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported.

cvHoughLines2


HoughLines

Finds lines in a binary image using the standard Hough transform.
C++: void HoughLines(InputArray image, OutputArray lines, double rho, double theta, intthreshold, double srn=0, double stn=0 )
Python: cv2.HoughLines(image, rho, theta, threshold[, lines[, srn[, stn]]]) → lines
C: CvSeq* cvHoughLines2(CvArr* image, void* line_storage, int method, double rho, double theta, int threshold, double param1=0, double param2=0 )
Python: cv.HoughLines2(image, storage, method, rho, theta, threshold, param1=0, param2=0) → lines
Parameters:
  • image – 8-bit, single-channel binary source image. The image may be modified by the function.
  • lines – Output vector of lines. Each line is represented by a two-element vector (\rho, \theta) . \rho is the distance from the coordinate origin (0,0) (top-left corner of the image). \theta is the line rotation angle in radians ( 0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line} ).
  • rho – Distance resolution of the accumulator in pixels.
  • theta – Angle resolution of the accumulator in radians.
  • threshold – Accumulator threshold parameter. Only those lines are returned that get enough votes ( >\texttt{threshold} ).
  • srn – For the multi-scale Hough transform, it is a divisor for the distance resolution rho . The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn . If both srn=0 andstn=0 , the classical Hough transform is used. Otherwise, both these parameters should be positive.
  • stn – For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
  • method –
    One of the following Hough transform variants:
    • CV_HOUGH_STANDARD classical or standard Hough transform. Every line is represented by two floating-point numbers (\rho, \theta) , where \rho is a distance between (0,0) point and the line, and \theta is the angle between x-axis and the normal to the line. Thus, the matrix must be (the created sequence will be) of CV_32FC2 type
    • CV_HOUGH_PROBABILISTIC probabilistic Hough transform (more efficient in case if the picture contains a few long linear segments). It returns line segments rather than the whole line. Each segment is represented by starting and ending points, and the matrix must be (the created sequence will be) of the CV_32SC4 type.
    • CV_HOUGH_MULTI_SCALE multi-scale variant of the classical Hough transform. The lines are encoded the same way asCV_HOUGH_STANDARD.
  • param1 –
    First method-dependent parameter:
    • For the classical Hough transform, it is not used (0).
    • For the probabilistic Hough transform, it is the minimum line length.
    • For the multi-scale Hough transform, it is srn.
  • param2 –
    Second method-dependent parameter:
    • For the classical Hough transform, it is not used (0).
    • For the probabilistic Hough transform, it is the maximum gap between line segments lying on the same line to treat them as a single line segment (that is, to join them).
    • For the multi-scale Hough transform, it is stn.
The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm for a good explanation of Hough transform. See also the example in HoughLinesP() description.

cvCanny


C: void cvCanny(const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3 )
Parameters:
  • image – single-channel 8-bit input image.
  • edges – output edge map; it has the same size and type as image .
  • threshold1 – first threshold for the hysteresis procedure.
  • threshold2 – second threshold for the hysteresis procedure.
  • apertureSize – aperture size for the Sobel() operator.
  • L2gradient – a flag, indicating whether a more accurate L_2 norm=\sqrt{(dI/dx)^2 + (dI/dy)^2} should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default L_1 norm=|dI/dx|+|dI/dy| is enough ( L2gradient=false ).

2013年10月15日 星期二

vi指令說明

vi指令說明(完整版)
.vi 的操作模式
==============
        vi 提供兩種操作模式:輸入模式(insert mode)和指令模式(command mode)
        。當使用者進入 vi 後,即處在指令模式下,此刻鍵入之任何字元皆被視為
        指令。在此模式下可進行刪除、修改等動作。若要輸入資料,則需進入輸入
        模式。
.輸入模式
=========
        如何進入輸入模式
                a (append)      由游標之後加入資料。
                A               由該行之末加入資料。
                i (insert)      由游標之前加入資料。
                I               由該行之首加入資料。
                o (open)        新增一行於該行之下供輸入資料之用。
                O               新增一行於該行之上供輸入資料之用。
        如何離開輸入模式
                《ESC》 結束輸入模式。
.指令模式
=========
游標之移動
        h       向左移一個字元。
        j       向上移一個字元。
        k       向下移一個字元。
        l       向右移一個字元。
        0       移至該行之首
        $       移至該行之末。
        ^       移至該行的第一個字元處。
        H       移至視窗的第一列。
        M       移至視窗的中間那列。
        L       移至視窗的最後一列。
        G       移至該檔案的最後一列。
        +       移至下一列的第一個字元處。
        -       移至上一列的第一個字元處。
        (       移至該句之首。 (註一)
        )       移至該句之末。
        {       移至該段落之首。 (註二)
        }       移至該段落之末。
        nG      移至該檔案的第 n 列。
        n+      移至游標所在位置之後的第 n 列。
        n-      移至游標所在位置之前的第 n 列。
        <Ctrl><g>       會顯示該行之行號、檔案名稱、檔案中最末行之行號、游標
                        所在行號佔總行號之百分比。
        註一:句子(sentence)在vi中是指以『!』、『.』或『?』結束的一串字。
        註二:段落(paragraph)在vi中是指以空白行隔開的文字。
.視窗的移動
===========
        <Ctrl><f>       視窗往下捲一頁。
        <Ctrl><b>       視窗往上捲一頁。
        <Ctrl><d>       視窗往下捲半頁。
        <Ctrl><u>       視窗往上捲半頁。
        <Ctrl><e>       視窗往下捲一行。
        <Ctrl><y>       視窗往上捲一行。
.刪除、複製及修改指令介紹 (此單元較少使用)
=========================
        d(delete)、c(change)和y(yank)這一類的指令在 vi 中的指令格式為:
        Operator + Scope = command
        (運算子)   (範圍)
        運算子:
        d       刪除指令。刪除資料,但會將刪除資料複製到記憶體緩衝區。
        y       將資料(字組、行列、句子或段落)複製到緩衝區。
        p       放置(put)指令,與 d 和 y 配和使用。可將最後delete或yank的資
                料放置於游標所在位置之行列下。
        c       修改(change)指令,類似delete與insert的組和。刪除一個字組、句
                子等之資料,並插入新鍵資料。
        範圍:
        e       由游標所在位置至該字串的最後一個字元。
        w       由游標所在位置至下一個字串的第一個字元。
        b       由游標所在位置至前一個字串的第一個字元。
        $       由游標所在位置至該行的最後一個字元。
        0       由游標所在位置至該行的第一個字元。
        )       由游標所在位置至下一個句子的第一個字元。
        (       由游標所在位置至該句子的第一個字元。
        {       由游標所在位置至該段落的最後一個字元。
        }       由游標所在位置至該段落的第一個字元。
        整行動作
        dd      刪除整行。
        D       以行為單位,刪除游標後之所有字元。
        cc      修改整行的內容。
        yy      yank整行,使游標所在該行複製到記憶體緩衝區。
.刪除與修改
===========
        x       刪除游標所在該字元。
        X       刪除游標所在之前一字元。
        dd      刪除游標所在該行。
        r       用接於此指令之後的字元取代(replace)游標所在字元。
                如: ra 將游標所在字元以 a 取代之。
        R       進入取代狀態,直到《ESC》為止。
        s       刪除游標所在之字元,並進入輸入模式直到《ESC》。
        S       刪除游標所在之該行資料,並進入輸入模式直到《ESC》。
.搬移與複製
==========
        利用 delete 及 put 指令可完成資料搬移之目的。
        利用 yank 及 put 指令可完成資料複製之目的。
        yank 和 delete 可將指定的資料複製到記憶體緩衝區,而藉由 put 指令
        可將緩衝區內的資料複製到螢幕上。
        例:
        搬移一行        ‧在該行執行 dd
                        ‧游標移至目的地
                        ‧執行 p
        複製一行        ‧在該行執行 yy
                        ‧游標移至目的地
                        ‧執行 p
.指令重複
=========
        在指令模式中,可在指令前面加入一數字 n,則此指令動作會重複執行 n
        次。
        例:
        刪除10行                ‧10dd
        複製10行                ‧10yy
                                ‧游標移至目的地
                                ‧p
        指標往下移10行  ‧10j
.取消前一動作(Undo)
===================
        即復原執行上一指令前的內容。
        u       恢復最後一個指令之前的結果。
        U       恢復游標該行之所有改變。
.搜尋
=====
        在vi中可搜尋某一字串,使游標移至該處。
        /字串           往游標之後尋找該字串。
        ?字串           往游標之前尋找該字串。
        n               往下繼續尋找下一個相同的字串。
        N               往上繼續尋找下一個相同的字串。
.資料的連接
===========
        J       句子的連接。將游標所在之下一行連接至游標該行的後面。
        若某行資料太長亦可將其分成兩行,只要將游標移至分開點,進入輸入模式
        (可利用 a、i等指令)再按《Enter》即可。
.環境的設定
===========
        :set nu                設定資料的行號。
        :set nonu              取消行號設定。
        :set ai                自動內縮。
        :set noai              取消自動內縮。
        自動內縮(automatic indentation)
        在編輯文件或程式時,有時會遇到需要內縮的狀況,『:set ai』即提供自
        動內縮的功能,用下例解釋之:
        ‧vi test
        ‧(進入編輯視窗後)
          this is the test for auto indent
          《Tab》start indent           ← :set ai (設自動內縮)
          《Tab》data
          《Tab》data
          《Tab》data                   ← :set noai (取消自動內縮)
        the end of auto indent.
        ‧註:<Ctrl><d> 可刪除《Tab》字元。
.ex指令
=======
        讀寫資料
        :w                     將緩衝區的資料寫入磁碟中。
        :10,20w test   將第10行至第20行的資料寫入test檔案。
        :10,20w>>test  將第10行至第20行的資料加在test檔案之後。
        :r test                將test檔案的資料讀入編輯緩衝區的最後。
        刪除、複製及搬移
        :10,20d                刪除第10行至第20行的資料。
        :10d                   刪除第10行的資料。
        :%d                    刪除整個編輯緩衝區。
        :10,20co30             將第10行至第20行的資料複製至第30行之後。
        :10,20mo30             將第10行至第20行的資料搬移至第30行之後。
        字串搜尋與取代
        s(substitute)指令可搜尋某行列範圍。
        g(global)指令則可搜尋整個編輯緩衝區的資料。
        s指令以第一個滿足該條件的字串為其取代的對象,若該行有數個滿足該條
        件的字串,也僅能取代第一個,若想取代所有的字串則需加上g參數。
        :1,$s/old/new/g                將檔案中所有的『old』改成『new』。
        :10,20s/^/   /         將第10行至第20行資料的最前面插入5個空白。
        :%s/old/new/g          將編輯緩衝區中所有的『old』改成『new』。
.恢復編輯時被中斷的檔案
=======================
        在編輯過程中,若系統當掉或連線中斷,而緩衝區的資料並還未
        被寫回磁碟時,當再度回到系統,執行下列指令即可回復中斷前
        的檔案內容。
        %vi -r filename
.編輯多個檔案
=============
        vi亦提供同時編輯多個檔案的功能,方法如下:
        %vi file1 file2 ..
        當第一個檔案編修完成後,可利用『:w』將該緩衝區存檔,而後
        再利用 『:n』載入下一個檔案。



參考自: vi指令說明




Linux Vi 删除全部内容,删除某行到结尾,删除某段内容 的方法

1.打开文件
引用代码:
vi filename

2.转到文件结尾 
引用代码:
G

或转到第9行 
引用代码:
9G

3.删除所有内容(先用G转到文件尾),使用: 
引用代码:
:1,.d

或者删除第9行到第200行的内容(先用200G转到第200行),使用 
引用代码:
:9,.d


删除说明:这是在vi中,“.”当前行,“1,.”表示从第一行到当前行,“d”删除

2013年10月7日 星期一

安裝Java7 JDK在Ubuntu上

There is a similar question on how to install JRE 7.

Install the JDK

  • Download he 32bit or 64bit Linux "compressed binary file" - it has a ".tar.gz" file extension i.e. "[java-version]-i586.tar.gz" for 32bit and "[java-version]-x64.tar.gz" for 64bit
  • Uncompress it
    tar -xvf jdk-7u2-linux-i586.tar.gz (32bit)
    tar -xvf jdk-7u2-linux-x64.tar.gz (64bit)
JDK 7 package is extracted into ./jdk.1.7.0_02 directory. N.B. check carefully this folder name since Oracle seem to change this occasionally with each update.
  • Now move the JDK 7 directory to /usr/lib
sudo mkdir -p /usr/lib/jvm
sudo mv ./jdk.1.7.0_02 /usr/lib/jvm/jdk1.7.0
  • Now run
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
  • This will assign Oracle JDK a priority of 1, which means that installing other JDKs will replace it as the default. Be sure to use a higher priority if you want Oracle JDK to remain the default.
  • Correct the file ownership and the permissions of the executables:
sudo chmod a+x /usr/bin/java 
sudo chmod a+x /usr/bin/javac 
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.7.0
N.B. remember - Java JDK has many more executables that you can similarly install as above. java, javac, javaws are probably the most frequently required.
This answer lists the other executables available.
  • Run
sudo update-alternatives --config java
You will see output similar one below - choose the number of jdk1.7.0 - for example 3 in this list:
$sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode.
Check the version of you new JDK 7 installation:
java -version
java version “1.7.0”
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode) 
Repeat the above for:
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
 
參考自: http://askubuntu.com/questions/55848/how-do-i-install-oracle-java-jdk-7

2013年10月6日 星期日

Lubuntu安裝Java7記錄

下載jdk7之後,解壓縮在自己喜歡的資料夾,然後# java -version ,會看不到java版本。所以:
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer
之後,就看的到java -version了。

linux基本指令

移動檔案或目錄
$ mv temp1/ temp2/ (複製temp1整個目錄到temp2 )

改檔名
$ mv -v squareDec.c squareDec.cpp
‘squareDec.c’ -> ‘squareDec.cpp’    //加-v就會顯示這一行


解.tar.gz包
$ tar zxvf xxx.tar.gz

解壓 zip 檔
$ unzip filename.zip

重新啟動 X-windows
$ sudo pkill X

拷貝檔案,把123/aaa.cpp拷貝到456/aaa.cpp
$ cp /123/aaa.cpp /456/aaa.cpp

拷貝資料夾 aaa底下的所有東西到 資料夾 bbb
$ cp -r /123/aaa/  /bbb

刪檔案
$ rm file.name

刪檔案夾
$ rm -r folder

用gcc編譯c程式
$ gcc -o test test.c     // -o後要接執行檔名
$ ./test

用make編譯
$ make

下載謎片
$ wget http://avvideos/kazayumi/001.avi

搜尋檔案
$ find /資料夾 搜尋名稱
要搜尋整台電腦 find: / filename

搜尋檔案內容

$ find ./ -name "*.java" -exec grep -H "要搜尋的文字" {} \;

改變檔案(夾)的群組 change group
$ chgrp (-R) dirname/filename     //-R是recursive遞迴,子資料夾也一起改
$ chgrp -R www-data *    //改變www資料夾裡的所有檔案的群組

改變檔案(夾)的所有者 change owner
$ chown (-R) 使用者.群組 dirname/filename
$ chown -R superppp.root www-data * //改變www資料夾裡所有檔案所有者

關機
# shutdown -h now

重開機
# reboot

查核心版本
$ uname -a

查linux版本
$ cat /etc/*-release

移除軟體
sudo apt-get remove software_name
sudo apt-get autoremove    //remove 相關套件
or 出現'apt --fix-broken install'
dpkg --purge xxx


強制關閉程式
$ xkill
然後用滑鼠點一下要關閉程式的視窗

查看程式CPU使用量
$ top

com mand line 關閉程式,ID號碼從top指令可看出
$ kill ID號碼

安裝deb檔
$ sudo dpkg -i xxx.deb

畫面不動
Ctrl + a +q