Install aglio in Ubuntu 14.04

  1. Install nodejs

    Ref. NodeSource Node.js Binary Distributions

    apt-get install -y nodejs nodejs-legacy
    
  2. Install python

    apt-get install python-dev
    
  3. Install aglio

    Ref. Github : aglio

    npm install -g aglio
    
Posted in Aglio, Ubuntu | Leave a comment

Mac 安裝 brew cask

brew install caskroom/cask/brew-cask

Posted in Mac | Leave a comment

sed 筆記

每第9個”;”換行
Ref: http://arstechnica.com/civis/viewtopic.php?f=20&t=370486
sed -E ‘s/(([^;];){8}[^;]);/1n/g’ sed.txt

擷取 plist= 與 ;erUid 中間的字串
sed -e ‘s/.plist=(.);erUid.*/1/p’

Posted in sed | Leave a comment

[Apache HBase] Install Apache HBase in Ubuntu 14.04

  • Java 1.7

    add-apt-repository ppa:webupd8team/java
    apt-get update
    apt-get install oracle-java7-installer
    apt-get install oracle-java7-set-default
    
  • Cloudera HBase

Ref. installing-apache-hbase-on-ubuntu-for-standalone-mode

Note.
hbase tar file choose http://archive.apache.org/dist/hbase/hbase-0.98.5/hbase-0.98.5-hadoop1-bin.tar.gz
(or http://ftp.mirror.tw/pub/apache/hbase/hbase-0.98.11/hbase-0.98.11-hadoop1-bin.tar.gz )

Posted in HBase, Ubuntu | Leave a comment

REST API

REST:REpresentational State Transfer

RESTful Web Service:以HTTP為基礎
1. 所有API或是以Resource的形式存在
2. 可以接受與返回某個 MIME-Type,常見JSON格式,可以回傳PNG/JPG/TXT等格式
3. 對資源的操作會支援各種請求方法(例如GET, POST, PUT ,DELETE)

WADL:Web Application Description Language
URI:Uniform Resource Identifier
CRUD:Create, Read, Update, Delete

Posted in 名詞解釋 | Leave a comment

[Git] Git command…

  • git stash: 暫存機制

    • git stash: 暫存機制,可保留目前狀態,重新取回其他版本的code

    • git stash clear: 清除所有暫存空間

    • git stash drop {git status name}: 清除指定的暫存狀態,如果不加參數,則刪除最近的那一個

    • git stash list: 查看目前暫存列表

    • git stash apply {git stash name}: 取回暫存的狀態,如果不加參數,則抓取最近的版本

    • git stash show {git stash name}: 查看指定的暫存與parent差異的部分,如果不加參數,則顯示最近的那一個版本

    • git stash branch {git stash name}: 將指定暫存轉為branch,同時暫存的部分會消失,如果不加參數,則轉換最近的版本

    • git stash save –keep-index: 將程式編輯時可能會產生的與遠端不相容的檔案先放置stash暫存中,之後再刪除,避免push至遠端

  • 忽略檔案設定

    編輯 .gitignore,假設要使git不追蹤 .jpg 檔案

      *.jpg
    

    假設要使git不追蹤 .o 及 .a 的檔案

      *.[oa]
    
  • git status: 查詢目前狀態,位於哪個branch,暫存區的檔案資訊

  • git diff: 顯示未進入暫存區、commit 的目前詳細狀態,包含檔案中哪一行新增、刪除、修改等

    • git diff: –staged 顯示暫存區域及最後一次commit的差異

    • git diff {file_name}: 查詢檔案與所在branch中的原始檔案的差異資訊

  • git commit: 標註修改說明

    • git commit -m “說明文字”: 針對已加入準備push的暫存資料進行標註修改說明

    • git commit -a: 同上,會使用設定的預設文字編輯器跳出修改說明填寫畫面

  • git add 將檔案加入追蹤

    Ref: http://stackoverflow.com/questions/572549/difference-between-git-add-a-and-git-add/16162511#16162511

    version 1.x:
    git add .: 針對新增、修改的檔案修改追蹤狀態,刪除的不會更動
    git add [-A|–all]: 針對新增、修改、刪除的檔案修改追蹤狀態
    git add -u: 針對修改、刪除的檔案修改追蹤狀態,新增的檔案不會加入追蹤

    version 2.x:
    git add [-A|–all]: 針對新增、修改、刪除的檔案修改追蹤狀態
    git add .: 針對新增、修改、刪除的檔案修改追蹤狀態
    git add –ignore-removal .: 針對新增、修改的檔案修改追蹤狀態,刪除的不會更動
    git add -u: 針對修改、刪除的檔案修改追蹤狀態,新增的檔案不會加入追蹤

  • git log: 查詢 commit log

  • git blame {file name}: 查詢檔案每一行是由誰修改的

  • git rm {file_name}: 移除git中的檔案,同時一併刪除硬碟中的檔案

    • git rm -cached {file_name}: 移除已經add但還沒commit的檔案,即移除git index中的紀錄
  • git push: 將本地端的檔案push到預設的remote branch

    • git push origin branch_name: 將本地端的檔案push到遠端origin上的指定branch_name

    • git push origin :branch_name: 刪除遠端origin上指定的branch

    • git push origin –delete branch_name: 刪除遠端origin上指定的branch

    • git branch -d branch_name: 刪除本地的branch

  • git remote: 遠端操作

    • git remote: 顯示目前使用的遠端git_url (git://server_host/user_name/git_name)

    • git remote -v: 顯示所有的git_url資訊

    • git remote add remote_name git_url: 將遠端git_url設定別名成remote_name

    • git remote show origin: 查看遠端origin上的資料

    • git remote rename remote_name_old remote_name_new: 將遠端git server的別名進行更改

    • git remote rm remote_name: 刪除git server資訊

  • git pull: 將遠端的檔案拉回

    • git pull: 至預設的remote_name拉回檔案並merge進本地端正在進行的branch中

    • git pull local_branch_name remote_name/remote_branch_name: 至remote_name中拉回remote_branch_name並merge至本地的local_branch_name中

      git pull 動作完成後記得先使用git status檢視是否有衝突發生,若有,則需要先把衝突解決

    • git pull –rebase: 先把本地 repo. 從上次 pull 之後的變更暫存起來,回復到上次 pull 時的情況,接著套用遠端的變更,最後再套用剛暫存下來的本地變更

  • git branch: 分支

    • git branch: 查看本地端的branch清單

    • git branch -r: 查看遠端的branch清單

    • git branch new_local_branch_name: 從master複製一個新的本地端new_local_branch_name

    • git branch -d branch_name: 刪除本地端的branch_name

    • git branch –track local_branch_name remote_branch_name: 建立一個tracking遠端remote_branch_name的本地端local_branch_name,之後本地端的branch進行push或pull等動作將直接對應到遠端的branch

  • git checkout: 切換branch

    • git checkout local_branch_name: 切換至本地端指定的local_branch_name,若切換之前已有修改追蹤的檔案,務必先commit

    • git checkout -b new_local_branch_name: 以當前分支為根本,於本地端新建分支new_local_branch_name,並切換至new_local_branch_name (意即先 git branch new_local_branch_name 再 git checkout new_local_branch_name)

    • git checkout — file_name: 還原檔案file_name至於此branch中未修改的狀態

    • git checkout –: 將全部檔案還原至branch未修改的狀態

    • git checkout -f: 將全部檔案還原至branch未修改的狀態

  • git merge: 合併branch

    merge最重要的觀念是切換至主要的branch,再進行merge動作,意即先 git checkout master_branch,再git merge fixed_branch

    • git merge branch_name: 將branch_name套用至目前branch上
  • git reset: 回復

Ref. http://blog.miniasp.com/post/2013/08/19/Learning-Git-Part-1-Installation-Options-Tool-Usage-on-Local.aspx

Ref. http://kingofamani.gitbooks.io/git-teach/content/chapter_3_branch/chapter_3_branchmerge.html

  • git reset –hard [commit_id]: 回復至指定的commit_id版本,若沒指定,預設為HEAD,表示取消這次的merge,所有本地端的變更都會遺失

    • git reset –hard ORIG_HEAD: 回復到合併前的上一版,所有本地端的變更都會遺失

    • git reset –soft: 取消commit,檔案還在

    • git reset –mixed: 取消commit,取消add新增的檔案 <==預設動作

    • git reset commit_id: 回復至指定的commit_id版本,修改的檔案還在

    • git reset –soft HEAD^: 回復至上次commit後的動作

  • git clean -df: 清除暫存檔案,包含目錄

Posted in Git | Leave a comment

[Cloudera HBase] Install Cloudera HBase in Ubuntu 14.04 x64

  • Install Oracle Sun Java 1.7.

    • Add Repository.

      sudo add-apt-repository ppa:webupd8team/java
      
    • Repository update.

      sudo apt-get update
      
    • Install Java 1.7.

      sudo apt-get install oracle-java7-installer
      
    • Install Java Environment Variable.

      sudo apt-get install oracle-java7-set-default 
      
  • Cloudera HBase

    Ref 1. – Installing the Latest CDH 5 Release

    Ref 2. – Starting HBase in Standalone Mode

    • Download the repository deb file for Ubuntu 14.04 from Cloudera , and use the command ‘dpkg’ to install it.

      wget http://archive.cloudera.com/cdh5/one-click-install/trusty/amd64/cdh5-repository_1.0_all.deb
      sudo dpkg -i cdh5-repository_1.0_all.deb
      
    • Repository update.

      sudo apt-get update
      
    • Install Hbase-master. It will install package {hadoop hadoop-hdfs hadoop-mapreduce hadoop-yarn hbase hbase-master parquet parquet-format zookeeper}.

      sudo apt-get install hbase-master
      

      Notice

      After installation finished, the service ‘hbase-master’ will automatically start.
      Start script file: /etc/init.d/hbase-master
      Start script: service hbase-master [start | stop | restart]
      Configuration directory: /etc/hbase/conf/
      HBase_Home Directory: /usr/lib/hbase/

    • Check hostname and edit /etc/hosts.

      #127.0.0.1  localhost
      #127.0.0.1  {$hostname}
      {$IP}       localhost {$hostname}       
      
    • Edit hosts at remote client.

      $hbase_ip   {$hbase_hostname}.
      
Posted in Cloudera, HBase | Leave a comment

[Ubuntu] Enable exFAT support

All you need is install the exfat-* packages.

sudo apt-get install exfat-fuse exfat-utils
Posted in Ubuntu | Leave a comment

Bitwise operator (位元運算)

Ref. Wiki
Bitwise operations are contrasted by byte-level operations which characterize the bitwise operators’ logical counterparts, the AND, OR and NOT operators. Instead of performing on individual bits, these operators perform on strings of eight bits (known as bytes) at a time. The reason for this is that a byte is normally the smallest unit of addressable memory (i.e. data with a unique memory address.)

  • AND
  • OR
  • XOR
  • ~

Ex. In Java

0 AND 0 : 0 & 0 => 0
0 AND 1 : 0 & 1 => 0
1 AND 0 : 1 & 0 => 0
1 AND 1 : 1 & 1 => 1

0 OR 0 : 0 | 0 => 0
0 OR 1 : 0 | 1 => 1
1 OR 0 : 1 | 0 => 1
1 OR 1 : 1 | 1 => 1

0 XOR 0 : 0 ^ 0 => 0
0 XOR 1 : 0 ^ 1 => 1
1 XOR 0 : 1 ^ 0 => 1
1 XOR 1 : 1 ^ 1 => 0

the complement of 0 : ~0 => -1
the complement of 1 : ~1 => -2
the complement of 2 : ~2 => -3
the complement of 3 : ~3 => -4
Posted in 名詞解釋 | Leave a comment

Camel Case (駝峰式命名法)

Ref. Wiki
Camel case may start with a capital or, especially in programming languages, with a lowercase letter.

Ex. ageOfStudent => the age of the student.

Posted in 名詞解釋 | Leave a comment