2015年8月18日 星期二

字元編碼 Unicode


1.  編碼最早是  ASCII 有 1 byte , 8 bits

2. 微軟發展出 Big 5 支援其他語系, 有 2 bytes, 16bits
    缺點是:  a. 有些文字是 2 bytes, 但此時英文語系還是 1 byte
                 b. 固定每個國家不同
                 c. 會有 許功蓋 問題, 因為跳脫字元


3.  Unicode 出現
    a.  支援所有國家的字元, 用 2 bytes 表示所有字元
    b.  是一個 Table 來存所有國家字元


4. UTF8
    a. 是個編碼方法,為了動態決定 Unicode 長度
    b. 在記憶體的字元是 Unicode, 但寫到檔案, 網路傳輸 將字元編碼成 UTF8
    c. 在讀取檔案時, 指定 UTF8 才會解碼 UTF8 到 Unicode string

2015年8月12日 星期三

Eclipse install Python PyDev



1. Eclipse
Eclipse toolbar -> help -> install new software

2. Install pydev
work with type: https://dl.bintray.com/fabioz/pydev/all
search: pydev


3. Setting python version
Eclipse toolbar -> Windows -> preference -> PyDev -> Python Interpretor



Reference:
Chinese python-eclipsepydev
Official PyDev


python 3 source install On Centos

1. Download tar source
 https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz

2.  Untar
tar -xzf   Python-3.4.3.tgz

3. Compiler
./configure --prefix=/home/Andy/IBMS/Software/python/Python-3.4.1/bin
make
make test
make install

2015年8月3日 星期一

Raspberry pi NOOBS install on linux

Main -> http://qdosmsq.dunbar-it.co.uk/blog/2013/06/noobs-for-raspberry-pi/
https://github.com/raspberrypi/noobs/wiki/NOOBS-partitioning-explained
https://github.com/raspberrypi/noobs
http://blogger.gtwang.org/2014/12/raspberry-pi-b-plus-noobs-linux-installation.html

# unmount the sdcard
umount /media/3466-6661/

# check sd card
fdisk -l

# format sdcard
fdisk /dev/sdc
// detail
----------
# delete them using the ‘d’ command repeat until you have deleted them all.
Command (m for help): d
Selected partition 1

# Listing the existing partitions afterwards should show the following:
Command (m for help): p

# create a single new partition
Command (m for help): n
Select (default p): p
Partition number (1-4, default 1): 1
First sector (1-15523839, default 2048): 1
Last sector (1-15523839, default 2048): 15523839

# The partition type is FAT32
Command (m for help): t
Hex code (type L to list codes): b

# Print content
Command (m for help): p
Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        1936    15550888+   b  W95 FAT32


# All that remains now is to write the new partition table to the SD card
Command (m for help): w
The partition table has been altered!

------

# finally format the particial
mkfs.vfat /dev/sdc1



# check noobs boot integraty
>sha1sum NOOBS_v1_4_1.zip
279cdeb50861d2ef2681b4d1f5e98c40581f48b1  NOOBS_v1_4_1.zip



# mount the sdcadrd
mount -t vfat  /dev/sdc1 /media/pi


# cp the boot file
cd /media/pi/
unzip /home/Andy/IBMS/Software/pi/NOOBS_v1_4_1.zip


# exit
cd ~
umount /media/pi

2015年8月2日 星期日

First For Backbone.js of simple hello world


Backbone.js provide the MVC pattern for web development

1. HTML code

  <!DOCTYPE html>
  <html>
  <head>
    <meta charset="utf-8">
    <title>hello-backbonejs</title>
  </head>
  <body>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js"></script>
  <script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore.js"></script>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.0/backbone-min.js"></script>

  <script src="1.js"></script>


  </body>
  </html>


2. JS code
// This example illustrates the declaration and instantiation of a minimalist View.
 (function($){
          var ListView = Backbone.View.extend({
//                 el: $('body'), // attaches `this.el` to an existing element.
                 el: 'body', // attaches `this.el` to an existing element.

                initialize: function(){
                        _.bindAll(this, 'render'); // fixes loss of context for 'this' within methods
                       this.render(); // not all views are self-rendering. This one is.
                },
                render: function(){
                      $(this.el).append("<ul> <li> cool hello world</li> </ul>");
                }
          });
         var listView = new ListView();
})(jQuery);


Reference
1. hello-backbonejs_example
2. tutorials_eample
3. backbonejs_doc