2014-08-27

win8 + ubuntu 14 雙系統




environment: windows 8.1 + ubuntu 14.04 LTS 雙系統


  • 安裝:
    • 安裝好 windows 8 後,接著安裝 ubuntu。
      • 由於在 windows 中,C, D 都設成了 primary disk。
      • 壓縮 C 切出一個空的 partition。
      • 以致於 ubuntu 再切時,/ 可以設成 primary disk,但不能再新增 swap。很有可能是因為已經有了4個 primary disk 了。改將 / 設成 logic disk,就可以新增 swap 了。
      • 不過,很有可能因為上述,變成開機直接進入 windows 而沒有 boot menu 可以選擇進入 ubuntu。
    • 開機進入 windows 8 後,下載使用 EasyBCD 軟體:
      • Add New Entry: Linux/BSD, type: Grub 2, partition 選擇安裝的 ubuntu partition。儲存套用,重開機後,boot menu 就出現可以選擇 windows 或是 自定的名稱了。
    • 故障排除:
      • 安裝時,如果出現 "The installer encountered an unrecoverable error. A desktop session will now be run so that you may investigate the problem or try installing again." 這樣子的錯誤訊息,在一開始就無法安裝了。
        檢查了 iso MD5,試了 ubuntu 14.01 光碟、14.10 USB 開機安裝,都是這樣的錯誤訊息。網路上也有人認為關閉安裝的介紹(slide show)可以解決,但我都不行。(不過,linux Mint 是可以的)
        解法:不要啟動無線網路,也不要安裝時更新,直接就光碟內容安裝即可進行下去

  • 中文:
    • 字型:
    • ibus 中文輸入法的設定畫面:
      • > ibus-setup
      • ref: http://www.pinyinjoe.com/linux/ubuntu-12-chinese-setup.htm
        http://www.pinyinjoe.com/linux/ubuntu-10-chinese-input-pinyin-chewing.htm
      • http://wiki.linux.org.hk/w/Configure_IBus
    • 安裝 gnome classic version 後,language support icon 不見了:
      • sudo apt-get install language-selector-gnome
      • 改選 gcin 輸入法
      • 倉頡:可使用五四三倉頡。

2013-09-30

在 windows 裡架起 Cassandra

install Cassandra in windows system

在 windows 系統上,加起 cassandra,實作起來不難,簡單步驟為:
(1) 安裝 java (JRI)
(2) 下載 cassandra tar, 並解開。
(3) 設定新增兩個系統環境變數: JAVA_HOME , CASSANDRA_HOME
(4) 修改 cassandra 設定檔 cassandra.yaml , 設好 cassandra 目錄所在。
(5) 啟動 cassanda,完成。


2013-08-28

How to union multiple table in MySQL?

database: MySQL

如果有多個 table 要合併起來,如果有 foreign key 要對應,一般都是用上 join 的語法。
但是,table 之間沒有關係,純綷只是要將各 table 中的所有 record 集合起來,那麼,就可以用上 union 的語法了:

select agentid as id, agentname as name  from agent
union
select cid, name from category
union
select id, adid from admanagement;

result:
id name
--------------
1 agent1
2 agent2
1 ca1
2 ca2
1 ad1
2 ad2

也可以加上一個欄位(文字或數值),直接來區分屬於那個 table 的內容:


select agentid as id, agentname as name, "agent" as type from agent
union
select cid, name, "category" from category
union
select id, adid, "ad" from admanagement;

result:

id name type
-----------------------
1 agent1 agent
2 agent2 agent
1 ca1 category
2 ca2 category
1 ad1 ad
2 ad2 ad

後記: 當資料量大時,效能不知如何...



後來,再查時,發現使用 union all 的速度會快過使用 union,原因在於 union all 不會去除重複,而 union 語法時,MySQL 會試著去過濾重複的資料。因此,如果確定 table 之間不會有重複的資料,可以直接下 union all 試看看:

select agentid as id, agentname as name, "agent" as type from agent
union all
select cid, name, "category" from category
union all
select id, adid, "ad" from admanagement;


2013-02-01

root TF101, and upgrade to EOS 4 JELLYBEAN (4.2)

自從 TF101 由 Android 3.x 升級到官方所釋出的 Android 4.0 之後,使用經驗是大打折扣。原因有二:

(1) 首先,桌面圖示有時會憑空消失了。再怎麼試也無法出現,除非重新開始。
而這會有什麼影響呢? 除了最近開啟過的 app 之外,只剩下"設定"的功能可以用而已,無法再啟動其他的 app 了。
後來,安裝了 Apex launcher,再改用 Nova launcher,情況改善了,但是還是偶爾會發生桌面 app icon 全部消失的狀況。

(2) 另外,前一陣蠻著迷 2013 棒球的遊戲。結果,遊戲一啟動或是進行到一半,會突然出現一半亂彩色的畫面,接著畫面就沒有反應了。必須 kill 遊戲再重啟,但還是會再發生。常常必須得重新開機才行。

眼看著原廠似乎沒有支援 TF101 這第一代平板的 OS 升級打算,於是就想到: 既然過了保固了,那就來 root & 升級 OS 吧!!


2012-11-30

compare performance in Dictionary and ConcurrentDictionary

Dictionary 類別,是不支援 thread safe 的。
意思是說,在 multi-thread 環境下,如果同時直接 read/write dictionary 、而不 lock (或沒有使用 InterChange) 的話,就有可能發生 exception。

在 .net 4.0 之後,針對平行處理提供了許多類別,其中之一就是 ConcurrentDictionary (so also)。
也就是在 multi-thread 環境,就算有同時 read/write 的可能,也不用自己實做 lock 機制,系統支援了。

這當然是一個好消息。

但是,第一個首要擔心的是: 效能會不會掉。

這裡,先就 single thread 來簡單測試一下:

2012-09-10

MySQL exception: Host 'host_name' is blocked

[環境]

  • client
  1. 數台機器定時向 MySQL database 取得資料。
  2. windows 2008 R2 standard
  3. .net 2.0 sp2
  4. c#
  • db server
  1. MySQL 5.0.45
  2. windows 2008 R2 standard


[狀況]

突然間(about 2am. orz),有一台機器連不到 MySQL,但其他機器仍正常運作。

MySql.Data.MySqlClient.MySqlException: Host 'xxx' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'   在 MySql.Data.MySqlClient.PacketReader.CheckForError()
   在 MySql.Data.MySqlClient.NativeDriver.Open()
   在 MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   在 MySql.Data.MySqlClient.MySqlPool.GetConnection()
   在 MySql.Data.MySqlClient.MySqlConnection.Open()
   在 SQLDB.MySQLNativeDB.reCreateSqlCommand() 位置 D:\projects\vs2008\source\MatchEngine\Scupio2.0\SQLDB\MySQLNativeDB.cs:行号 132
   在 SQLDB.MySQLNativeDB.ExecuteCmdNonQuery(String sqlcmd, IDataParameter[] parameters) 位置 D:\projects\vs2008\source\MatchEngine\Scupio2.0\SQLDB\MySQLNativeDB.cs:行号 86

這個例外訊息看起來蠻明確的: 機器 xxx 被 MySQL db server 擋(block)了。


2012-04-15

zoom out of Chrome browser

前幾個星期,突然發現 chrome 瀏覽器的縮放倍率改變了!

之前,由 100% 直接跳到 125%,對寬螢幕的筆電來說,100% 字過小,而 125% 字有點過大,但最要緊的是一個畫面看不了幾行。

在前幾個星期時,按下 ctrl + 時,突然發現字沒有那麼大了,檢查了一下,110% 的放大倍率出現了,對寬螢幕來說,感覺大小適中,真是增加了使用者的方便啊 -- 雖說,firefox 古早古早就是如此了。