2013年4月20日 星期六

Bass低音吉他基本知識

https://zh.wikipedia.org/wiki/%E9%9B%BB%E8%B2%9D%E6%96%AF

四弦:

空弦由粗至細為E、A、D、G

電子貝斯已經不僅只有基本的4弦,也有5弦和6弦之別,而5弦的電子貝斯,從第一弦到第五弦(由細到粗)的空弦音分別為:G、D、A、E、B,也有的空弦音分別為:C、G、D、A、E,依各大廠商自訂;至於6弦的電子貝斯,從第一弦到第六弦的空弦音分別為:C、G、D、A、E、B

Python為"強型別"的語言

在Python中,字串是不可變動的(Immutable),所以+實際會產生新的字串,在強弱型別的光譜中,Python比較偏強型別,型態較不能自行轉換,例如Python中,不能混合字串與數字進行+運算,你得自己將數字轉為字串,才可以進行字串串接:
>>> 'score: ' + 90Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Can't convert 'int' object to str implicitly
>>> 'score: ' + str(90)
'score: 90'
>>>


Python List/Set/Dict/Tuple之比較


https://docs.google.com/spreadsheet/ccc?key=0Aoj2FuNX9qdGdGNCTXE2NG9yMHRSQVBsNXdoZDJyTXc&usp=sharing

python在函式參數傳遞上的重要基礎概念: *args 與 **kwargs 到底有啥不一樣呢?



好!!為啥會談論到這個東西?!因為python跟一般所學的C/C++很不一樣


一般來說  在呼叫函式的時候  是以  argument = parameter  的方式傳入
                                                              (引數)        (參數)

而python在引數(arguments)這一塊有所謂的匹配模式(match pattern)概念在。

Q: 至於Python有那些的匹配模式呢!?
 ANS:
一般來說可以分成兩種狀況:
”位置”的方式來匹配
            ----由左到右的方式進行匹配
”關鍵字”的方式來匹配
            ---- 以引數的名稱來進行匹配
  

而引數在設定有兩種額外的方法:

1. 引數預設值
            在python的函式中可以指定引數的預設值。(以name=value的型式)
            ex:   func( x=3, y=2, z=1)

2. 變動引數(varargs)

-- python中,在函式宣告時可以利用萬用字元(*)來收集任意數量的額外引數(此概念是源自於C語言的varargs) ;

-- 而函式在呼叫時,可以用萬用字元(*)將引數集合體給分解成個別的引數,表示欲傳遞任意多個引數。




[Function定義語法格式]


def  function_name(param1=arg1, param2=arg2, ....):
      """ 
           Here is function body !!!
      """



[引數的匹配方式]

呼叫    

語法                       位置           說明                                              
func(value)                  呼叫者    普通引數: 以"位置"來匹配。
func(name=value)        呼叫者    關鍵字引數:以"名稱"來匹配。
func(*name)                呼叫者    把name之中所有物件傳遞進來,當作個別的位置引數
func(**name)              呼叫者    把name之中的所有key/value pairs傳遞進來,當成個別關鍵字引數

*/**在呼叫時,是解開任意數量之引數


定義

def  func(name)              函式     普通引數: 以"位置"或"名稱"的方式去匹配
def  func(name=value)    函式     預設引數值(如果在沒呼叫時傳遞)
def  func(*name)            函式     先匹配再收集剩餘的"位置引數"在tuple
def  func(**name)          函式     先匹配再收集剩餘的"關鍵字引數"在dict(辭典)

*/**在定義時,是建立任意數量之引數




Reference:
http://www.loliman3000.com/tech/2fe2eea4a80e94fd3811629.php




利用sed來移除空白行(列)



使用 sed 來移除整列都是空白(沒有資料)的行, 語法如下:

sed '/^$/d'
註: sed '/\n/d' 沒有用. XD

Reference

顯示出 sys.modules()


http://www.diveintopython.net/file_handling/more_on_modules.html

Associative Arrays in Bash Scripts

http://stackoverflow.com/questions/688849/associative-arrays-in-shell-scripts

http://www.artificialworlds.net/blog/2012/10/17/bash-associative-array-examples/

http://www.gnu.org/software/bash/manual/html_node/Arrays.html

http://stackoverflow.com/questions/6660010/bash-how-to-assign-an-associative-array-to-another-variable-name-e-g-rename-t

for...in迴圈的比較


Bash Scripts

Python

SFP: Small Form Pluggable

GBIC


SFP

SFPSMALL FORM PLUGGABLE的縮寫,可以簡單的理解為GBIC的升級版本。SFP模組體積比GBIC模組減少一半,可以在相同的面板上配置多出一倍以上的埠數量。SFP模組的其他功能基本和GBIC一致。有些交換機廠商稱SFP模組為小型化GBICMINI-GBIC)。 SFP模組體積比GBIC模組減少一半,可以在相同的面板上配置多出一倍以上的埠數量。SFP模組的其他功能基本和GBIC相同。

詳全文 什麼是GBIC?什麼是SFP?光纖分為哪幾種?-Optech Technology 歐普科技-新浪部落 http://blog.sina.com.tw/optech/article.php?pbgid=70553&entryid=586142



光纖:   單模光纖  vs 多模光纖

單模光纖


多模光纖




Reference:
http://blog.sina.com.tw/optech/article.php?pbgid=70553&entryid=586142

cinder-manage




Usage:

cinder-manage sm flavor_create <label> <description>
cinder-manage sm flavor_delete<label>
cinder-manage sm backend_add <flavor label> <SR type> [config connection parameters]
Note: SR type and config connection parameters are in keeping with the Xen Command Line Interface.http://support.citrix.com/article/CTX124887
cinder-manage sm backend_delete <backend-id>

Examples:

cinder-manage sm flavor_create gold “Not all that glitters”
cinder-manage sm flavor_delete gold
cinder-manage sm backend_add gold nfs name_label=toybox-renuka server=myserver serverpath=/local/scratch/myname
cinder-manage sm backend_remove 1

XCP / Citrix Xenserver Volume Drivers on OpenStack

PS: Cinder是由Folsom版本開始從原本的nova-volume這部分去進行抽離的子專案



XenAPINFS

XenAPINFS is a Block Storage (Cinder) driver which is using an NFS share through XenAPI's Storage Manager to store virtual disk images and exposing those virtual disks as volumes.

XenAPINFS不能直接存取NFS,只能透過XenAPI Storage Manager來存取NFS。
( This driver is not accessing the NFS share directly, it is only accessing the share through XenAPI Storage Manager. )

This driver should be considered as a reference implementation for using XenAPI's storage manager in OpenStack ( present in XenServer and XCP).


配置方式

  1. Local:
    推薦的做法,這樣的話可以使用qemu-img,但必須在當作Storage Controller上的XCP/Xenserver host上開啟一台PV guest VM安裝 cinder + XenAPINFS driver
  2. Remote:
    不需要使用PV guest VM,直接拿XCP/Xenserver當作Storage Controller。但這樣的話只能用VDI格式的VHD。


Source Code:

1. Grizzly cinder, https://github.com/openstack/cinder/blob/stable/grizzly/cinder/volume/drivers/xenapi/sm.py



XenAPI Storage Manager Volume Driver ( only in Folsom version, 在grizzly版中似乎已經移除 )

The Xen Storage Manager Volume driver (xensm) is a XenAPI hypervisor specific volume driver

功用:

  1. provide basic storage functionality, including volume creation and destruction, on a number of different storage back-ends.
  2. It also enables the capability of using more sophisticated storage back-ends for operations like cloning/snapshots, etc.


The list below shows some of the storage plugins already supported in Citrix XenServer and Xen Cloud Platform (XCP):

  1. NFS VHD: 
    Storage repository (SR) plugin which stores disks as Virtual Hard Disk (VHD) files on a remote Network File System (NFS).

  2. Local VHD on LVM: 
    SR plugin which represents disks as VHD disks on Logical Volumes (LVM) within a locally-attached Volume Group.

  3. HBA LUN-per-VDI driver: 
    SR plugin which represents Logical Units (LUs) as Virtual Disk Images (VDIs) sourced by host bus adapters (HBAs). E.g. hardware-based iSCSI or FC support.

  4. NetApp: 
    SR driver for mapping of LUNs to VDIs on a NETAPP server, providing use of fast snapshot and clone features on the filer.

  5. LVHD over FC: 
    SR plugin which represents disks as VHDs on Logical Volumes within a Volume Group created on an HBA LUN. E.g. hardware-based iSCSI or FC support.

  6. iSCSI: 
    Base ISCSI SR driver, provides a LUN-per-VDI. Does not support creation of VDIs but accesses existing LUNs on a target.

  7. LVHD over iSCSI: 
    SR plugin which represents disks as Logical Volumes within a Volume Group created on an iSCSI LUN.

  8. EqualLogic: 
    SR driver for mapping of LUNs to VDIs on a EQUALLOGIC array group, providing use of fast snapshot and clone features on the array.

2013年4月19日 星期五

Kafka和Storm


Kafka

Kafka 是一個用於截取與管理資料流(Data Stream)的即時框架(Real-Time Framework),也就是訊息發佈與訂閱的分散式管理系統。像 Twitter 和 Square 就是用 Kafka 來做日誌檔的管理,以便即時監控與處理事件的發生。

Storm

Storm 則是用於處理這些訊息資料流的框架,它與 Kafka 之間的關係,就像是 Hadoop 分散式系統與 MapReduce 之間的關係,也就是 Kafka 用來儲存訊息,Storm 則用來處理這些訊息,但是,Kafka 和 Storm 的速度即時多了。”

Sawzall: 一種宣告式語言,用來處理bigdata


http://en.wikipedia.org/wiki/Sawzall_(programming_language)

LVS: Linux Virtual Server

http://www.cnblogs.com/lgfeng/archive/2012/10/16/2726308.html

Linux Security Hardening



sysctl: used to modify kernel parameters at runtime

sysctl is an interface that allows you to make changes to a running Linux kernel.

With /etc/sysctl.conf you can configure various Linux networking and system settings such as:
  1. Limit network-transmitted configuration for IPv4
  2. Limit network-transmitted configuration for IPv6
  3. Turn on execshield protection
  4. Prevent against the common 'syn flood attack'
  5. Turn on source IP address verification
  6. Prevents a cracker from using a spoofing attack against the IP address of the server.
  7. Logs several types of suspicious packets, such as spoofed packets, source-routed packets, and redirects.




http://www.cyberciti.biz/faq/linux-kernel-etcsysctl-conf-security-hardening/