2011-12-29

Ubuntu 11.10 - Eclipse 的圖示是問號!?

Ubuntu 上裝好了 Eclipse,也可以正常執行,
但是在 ubuntu 的 unity 桌面環境上卻只能看到 eclipse 的圖示是一個問號...

補上圖示的設定就好了
vi ~/.local/share/applications/eclipse.desktop

eclipse.desktop 的檔案內容:
[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Name[zh_TW]=Eclipse
Comment=Eclipse IDE
Exec=/home/user/eclipse/eclipse
Icon=/home/user/eclipse/icon.xpm
Terminal=false
StartupNotify=true
Type=Application
Categories=Application;Development;

對照 eclipse 的路徑調整設定就可以了

完成後,圖示就不再是問號了

2011-12-28

[PHP] number_format()

php 提供了一個 function,讓我們可以輕鬆的格式化數字

number_format

string number_format ( float $number [, int $decimals = 0 ] )
string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )

可以運用這個 function,
決定你的浮點數小數點後要輸出幾位($decimals),

或是,
調整你輸出的數字格式所要使用的小數點字元($dec_point),跟千位數的分隔字元($thousands_sep)

當然,不想用其中一個符號時,放個空字串('')也是可以的


Reference:
PHP: number_format

2011-12-18

[MySQL] char vs. varchar


可用長度:
char 0 ~ 255
varchar 0 ~ 65535

儲存資料長度:
char 為建立 table 時所決定的長度
varchar 依你所存放的資料而定,直到你決定的最大長度


char

char 在實際儲存資料時,在右邊補滿空白

name CHAR(5)

  ---------------------------------------
    value      actual_storage   Space
  ---------------------------------------
    'ex'       'ex   '          5 bytes
    'exper'    'exper'          5 bytes
    'expert'   'exper'          5 bytes
  ---------------------------------------

varchar

varchar 不填補空白,而是在額外用 1 到 2 byte 去記錄
長度在 255 內用 1 byte,超過 255 就用到 2 byte

name VARCHAR(5)

  ---------------------------------------
    value      actual_storage   Space
  ---------------------------------------
    'ex'       'ex'             3 bytes
    'expe'     'expe'           5 bytes
    'expert'   'exper'          6 bytes
  ---------------------------------------


Reference:
CHAR vs VARCHAR in MySQL
Tsung's Blog - MySQL 欄位格式 CHAR 與 VARCHAR 的差異