<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9140489</id><updated>2012-01-26T09:33:17.329+08:00</updated><category term='logging'/><category term='c/c++'/><category term='translate'/><category term='twisted'/><category term='surfing'/><category term='link2sd'/><category term='boo'/><category term='vm'/><category term='canon'/><category term='cups'/><category term='lyrics'/><category term='電子書'/><category term='epub'/><category term='firefox'/><category term='audio'/><category term='powershell'/><category term='git'/><category term='printer'/><category term='rss'/><category term='pam'/><category term='vim'/><category term='greasemonkey'/><category term='opera'/><category term='barcode'/><category term='skydrive'/><category term='centos'/><category term='java'/><category term='政治(politics)'/><category term='diff'/><category term='memory'/><category term='algorithm'/><category term='bash'/><category term='django'/><category term='root'/><category term='wordpress'/><category term='batch'/><category term='z4root'/><category term='Cook'/><category term='movie'/><category term='j2me'/><category term='android'/><category term='software'/><category term='glib'/><category term='ssl'/><category term='statistics'/><category term='ubuntu'/><category term='json'/><category term='svn'/><category term='Python'/><category term='yahoo'/><category term='zxing'/><category term='mmap'/><category term='javascript'/><category term='fuse'/><category term='.Net'/><category term='wine'/><category term='http'/><category term='webview'/><category term='bing'/><category term='excel'/><category term='瀏覽器(browser)'/><category term='skydirve'/><category term='oauth2'/><category term='woeid'/><category term='script'/><category term='uml'/><category term='mindmap'/><category term='qrcode'/><category term='gcin'/><category term='virtualenv'/><category term='monodevelop'/><category term='linux'/><category term='jsonp'/><category term='debug'/><category term='currying'/><category term='embedded'/><category term='vba'/><category term='math'/><category term='cvs'/><category term='note'/><category term='scm'/><category term='gtk'/><category term='ssh'/><category term='blog'/><category term='tkinter'/><category term='gae'/><category term='語言治療'/><category term='gps'/><category term='jquery'/><category term='liveconnect'/><category term='ruby on rails'/><category term='gtksharp'/><category term='twitter'/><category term='samba'/><category term='lex'/><category term='svk'/><category term='mono'/><title type='text'>Thinking more...</title><subtitle type='html'>Let's thinking more...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default?start-index=101&amp;max-results=100'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>858</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9140489.post-3188086520140588316</id><published>2012-01-26T09:33:00.001+08:00</published><updated>2012-01-26T09:33:17.336+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2012/1/20~2012/1/26)</title><content type='html'>&lt;a href="http://www.flickr.com/photos/63401014@N00/6078426728/" title="Flickr 上 aresryo 的 2011_rise_of_the_planet_of_the_apes-wide"&gt;&lt;img alt="2011_rise_of_the_planet_of_the_apes-wide" height="313" src="http://farm7.staticflickr.com/6088/6078426728_529fb32d60.jpg" width="500" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Rise of The Planet of The Apes(&lt;a href="http://www.imdb.com/title/tt1318514/" target="_blank" title="Rise of The Planet of The Apes"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Rise_of_the_Planet_of_the_Apes" target="_blank" title="Rise of The Planet of The Apes"&gt;Wikipedia&lt;/a&gt;)，中譯：猩球崛起。很好看的電影，是多年前決戰猩球的前傳，描述為什麼地球會演變成猩猩變成高等人類的星球。其實就是Will為了解決父親老人癡呆症的問題，而去研發出一種新的病毒作為新藥，經過實驗，猩猩的智力的確有驚人的成長。後來，因為某些變故，使實驗室主持人下令將這批猩猩銷毀，但是有一隻小猩猩，Robert不忍心下手，就交給了Will。小猩猩Caesar繼承了媽媽的血，也有高等智慧。經過數年之後，小猩猩越發聰明了，而Will偷偷把還沒人體試驗的藥物用在自己的父親身上，也得到了很好的成效。但是，隨著時間過去，Will發現父親的免疫系統已經開始可以抵抗病毒，老人癡呆症也愈來愈嚴重。Will決定冒險開發新的藥物，以解決父親的病症，於是他告訴實驗室主持人說自己已經拿父親試驗過，希望可以開發新的藥物。實驗室主持人在知道藥物有效之後，就決定繼續進行研發計劃。就在藥物快要完成的時候，出現了實驗室意外，Robert不小心吸入了病毒。而Will的父親老人癡呆症也越發嚴重，讓猩猩Caesar為了救他而讓鄰居嚇到，並因此被關到動物管制中心。Caesar在管制中心裡並不愉快，很想要離開，但是受限於法律，Will沒辦法。過了一段時間，聰明的Caesar偷到了小刀，並且收買了中心裡最強壯的猩猩，對抗欺負他的猩猩，然後成為中心裡領袖的角色，為了讓同伴更加聰明，他去Will的實驗室偷到新藥物給猩猩，讓所有的猩猩變得非常聰明。某天，這些猩猩就發難逃了出去，引起軒然大波，並逃到了舊金山北邊的Redwood。而Robert去Will家裡找不到Will的情況下，讓Will的鄰居感染了病毒，而Will的鄰居剛好又是機長，要飛到全世界，於是病毒擴散到整個世界，剛好這個時候又有太空人飛到太空去。飾演Caesar的角色其實是Andy Serkis，之前曾經飾演過&lt;a href="http://www.imdb.com/character/ch0000152/" target="_blank" title="Gollum"&gt;Gollum&lt;/a&gt;，也難怪在講猩猩的時候，讓人真的以為他是人。&lt;/li&gt;&lt;li&gt;Attack of the 50 Foot Woman(&lt;a href="http://www.imdb.com/title/tt0106317/" target="_blank" title="Attack of the 50 Foot Woman"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Attack_of_the_50_Foot_Woman" target="_blank" title="Attack of the 50 Foot Woman"&gt;Wikipedia&lt;/a&gt;)，中譯：巨型女的襲擊。自己笨，被簡介跟海報騙了，特技效果不突出(1993年的電影)、故事普普，而且還看了國語配音的，才看了沒幾分鐘，就沒耐心地開始亂跳著看完。主角Nancy被丈夫背叛，被父親操控，整個很不爽。有一天被飛碟的光照到，然後就變大了。變大以後，心智也慢慢改變，所以後來就愈來愈不爽，就開始發飆。後面被直昇機打到，就昏倒，被飛碟救走，被救走的時候，她花心的老公也被帶走，片尾是3個巨型女在飛碟裏面看3個花心男在那邊吵架的畫面。&lt;/li&gt;&lt;/ul&gt;&amp;nbsp;參考資料：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://4bluestones.biz/mtblog/2011/07/post-2288.html"&gt;猩球崛起：眼神會說話&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://4bluestones.biz/mtblog/2011/08/post-2289.html"&gt;猩球崛起：動物園神話&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://blog.roodo.com/blue1989/archives/16381229.html"&gt;猩球崛起&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3188086520140588316?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3188086520140588316/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3188086520140588316' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3188086520140588316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3188086520140588316'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/20121202012126.html' title='電影流水帳(2012/1/20~2012/1/26)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6872433585934289157</id><published>2012-01-19T11:48:00.001+08:00</published><updated>2012-01-19T11:48:09.152+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2012/1/9~2012/1/19)</title><content type='html'>&lt;a href="http://www.flickr.com/photos/ania_odense/2416453234/" title="Flickr 上 ania_odense 的 little mermaid"&gt;&lt;img alt="little mermaid" height="500" src="http://farm3.staticflickr.com/2262/2416453234_82b1a0c14f.jpg" width="363" /&gt;&lt;/a&gt;三部片。&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The adjustment Bureau(&lt;a href="http://www.imdb.com/title/tt1385826/" title="The adjustment Bureau"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/The_Adjustment_Bureau" title="The adjustment Bureau"&gt;Wikipedia&lt;/a&gt;)，中譯：命運規劃局。這應該算是一部頗揪心的愛情片。男主角David參加眾議員競選，投票前被爆了醜聞，結果沒上。要發表落選演說時，遇到女主角Elise，一見鍾情又一見傾心，還沒來的及留下電話，就分開了，David因此發表了一篇不凡的落選演說。後來，David要上班時，竟然在公車上巧遇Elise，兩人超happy，互留了電話。David到了辦公室，發現好奇怪，一堆人都被停住了，他遇到了The adjustment team正在調整眾人的思維，他就拼命逃，可是還是沒能逃過The adjustment team的魔掌。他被警告說，不可以洩漏我們的存在，在Elise的電話號碼被撕掉以後，David被放走。之後，The adjustment team裡的Thompson出來偷偷告訴David一些事情，David只好放棄。隔了3年之後，David上班途中竟然再次看到Elise，重新邂逅，The adjustment team出來強制干預，並要脅David，跟Elise分開的話，你會變成總統，Elise會變成知名舞者，如果不從，Elise的腿可能就不只是扭傷而已。於是David為了Elise好，就把Elise丟在醫院，忍痛走了。又隔了好一陣子，David在報上看到Elise要結婚了，他真的不能忍受，而Elise也很猶豫，透過Thompson的幫助下，David成功的阻婚，並在The adjustment team的阻撓下，逃到了某大樓上。最後的結局是，The adjustment team其實是天使，而命運則是由上帝寫的，因為上帝很感動，就改寫了他們兩人的命運，然後就沒了。&lt;/li&gt;&lt;li&gt;Detroit Metal City(&lt;a href="http://www.imdb.com/title/tt1142972/" title="Detroit Metal City"&gt;IMDB&lt;/a&gt;, &lt;a href="http://ja.wikipedia.org/wiki/%E3%83%87%E3%83%88%E3%83%AD%E3%82%A4%E3%83%88%E3%83%BB%E3%83%A1%E3%82%BF%E3%83%AB%E3%83%BB%E3%82%B7%E3%83%86%E3%82%A3" title="デトロイト・メタル・シティ"&gt;Wikipedia&lt;/a&gt;)，中譯：重金搖滾雙面人。根岸熱愛音樂，在大學畢業後，卻誤進了重金屬搖滾的唱片公司，組成了Detroit Metal City，非常的紅。某天，他遇到了大學時代心儀的舊識由利，開心的聊了起來。之後發生了一連串的誤會，並且又不小心成了日本最紅的樂團，成了美國重金屬搖滾樂團的目標。就在這個時候，他被由利很深的誤會，非常灰心，回去老家。在老家，他扮為克勞薩二世，教訓了弟弟，並且，也接受母親的開導而想開，決定回到東京接受挑戰。最後就以戰勝美國重金屬樂團而告終。裏面蠻多好笑的片斷，像是社長弄息煙的方式跟克勞薩二世在老家開割草車等等，蠻好看的片。&lt;/li&gt;&lt;li&gt;Pirates of the Caribbean: On Stranger Tides(&lt;a href="http://www.imdb.com/title/tt1298650/" title="Pirates of the Caribbean: On Stranger Tides"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/.../Pirates_of_the_Caribbean:_On_Stranger_Tides" title="Pirates of the Caribbean: On Stranger Tides"&gt;Wikipedia&lt;/a&gt;)，中譯：神鬼奇航-幽靈海。還算可以的續集片，沒什麼特別的亮點。就一堆人陰錯陽差去找不老泉，有人是為了報仇，有人是為了生命，有人是去看熱鬧，有人是去搞破壞。Sparrow跟Gibbs有地圖，是知道路的人，主要是去看熱鬧順便把黑珍珠號拿回來的，Barbossa去報Black beard的仇，Black beard是為了生命，他快死了，豈知後來因此而死，西班牙國王去搞破壞，他不允許有東西超越上帝賜與人的生命。最後就是泉水被西班牙破壞，Barbossa得償所願，Black beard掛掉，Angelica被放逐，Sparrow跟Gibbs拿到黑珍珠號跟其他一堆船，看起來是還會有續集的樣子。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6872433585934289157?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6872433585934289157/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6872433585934289157' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6872433585934289157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6872433585934289157'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/2012192012119.html' title='電影流水帳(2012/1/9~2012/1/19)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-4711121724307180975</id><published>2012-01-18T16:36:00.001+08:00</published><updated>2012-01-18T16:36:21.300+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>ping in Android(續)</title><content type='html'>&lt;p&gt;後來發現裏面有包ping這指令，而且有設置setgid權限，那麼應該是可以執行。只是試了之後，卻不行，然後我就以為不行。之後不死心，把stderr接出來看，才知道我下錯指令，於是修正以後，就可以了。&lt;/p&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;final class Helper {&lt;br /&gt;  private final String TAG="Helper";&lt;br /&gt;  private void pingInExec(String host) {&lt;br /&gt;    Runtime runtime = Runtime.getRuntime();&lt;br /&gt;    String command = String.format("/system/bin/ping -c 2 %s", host);&lt;br /&gt;    Process proc;&lt;br /&gt;    try {&lt;br /&gt;      proc = runtime.exec( command );&lt;br /&gt;      BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));&lt;br /&gt;      BufferedReader err = new BufferedReader(new InputStreamReader(proc.getErrorStream()));&lt;br /&gt;      &lt;br /&gt;      String inputLine;&lt;br /&gt;      while ((inputLine = in.readLine()) != null) {&lt;br /&gt;        Log.d(TAG, inputLine );&lt;br /&gt;      }&lt;br /&gt;      in.close();&lt;br /&gt;      while ((inputLine = err.readLine()) != null) {&lt;br /&gt;        Log.e(TAG, inputLine );&lt;br /&gt;      }&lt;br /&gt;      err.close();&lt;br /&gt;      proc.waitFor();&lt;br /&gt;      int exit = proc.exitValue();&lt;br /&gt;      Log.d(TAG, String.format("exitcode=%d", exit) );&lt;br /&gt;      if (exit == 0) { // normal exit&lt;br /&gt;        Log.d(TAG, "RESPONSE_OK");&lt;br /&gt;      } else { // abnormal exit, so decide that the server is not reachable&lt;br /&gt;        Log.d(TAG, "RESPONSE_TIMEOUT" );&lt;br /&gt;      }&lt;br /&gt;    } catch (IOException e) {&lt;br /&gt;      Log.e( TAG, e.getMessage() );&lt;br /&gt;    } catch (InterruptedException e) {&lt;br /&gt;      Log.e( TAG, e.getMessage() );&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-4711121724307180975?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/4711121724307180975/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=4711121724307180975' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4711121724307180975'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4711121724307180975'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/ping-in-android_18.html' title='ping in Android(續)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7158259184008856301</id><published>2012-01-17T15:39:00.001+08:00</published><updated>2012-01-17T15:39:47.194+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>ping in Android</title><content type='html'>&lt;p&gt;上網找了一下，一般對於ping的建議是直接利用java內建的InetAddress.isReachable()來做，實際上在ping內部網路的伺服器時，是沒問題的，但是如果要ping位於外部網路的伺服器時，就會失敗而回傳False。&lt;/p&gt;&lt;p&gt;Android內部的實作是在libcore/luni/src/main/java/java/net/InetAddress.java裡，這裡就很簡單的建立socket，然後試著連到指定位址的port 7，如果可以連，或者是伺服器明確地拒絕，就視為伺服器存在，可以連線。這就解釋了為什麼無法ping位於外部網路的伺服器，因為ISP為了安全或是其他考量，而不允許。我分別以python與java寫了與Android實作相似的程式去實驗，的確都不行。&lt;/p&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;import sys&lt;br /&gt;import socket&lt;br /&gt;&lt;br /&gt;if len(sys.argv)&lt;2:&lt;br /&gt;    print( "Need at least 1 parameters." )&lt;br /&gt;    print( "Usage: {0} host".format( sys.argv[0] ) )&lt;br /&gt;    sys.exit(-1)&lt;br /&gt;&lt;br /&gt;r = False&lt;br /&gt;try:&lt;br /&gt;    s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )&lt;br /&gt;    s.settimeout(5)&lt;br /&gt;    s.connect( (sys.argv[1], 7) )&lt;br /&gt;    r = True&lt;br /&gt;except socket.error, ex:&lt;br /&gt;    if ex.errno==111:&lt;br /&gt;        r = True&lt;br /&gt;    else:&lt;br /&gt;        print( ex )&lt;br /&gt;&lt;br /&gt;if r:&lt;br /&gt;    print( "{0} is reachable.".format( sys.argv[1] ) )&lt;br /&gt;else:&lt;br /&gt;    print( "{0} is NOT reachable.".format( sys.argv[1] ) )&lt;br /&gt;&lt;/pre&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;import java.net.InetAddress;&lt;br /&gt;import java.net.UnknownHostException;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;&lt;br /&gt;class Ping {&lt;br /&gt;    public static void main(String[] args) {&lt;br /&gt;        InetAddress in;&lt;br /&gt;                    &lt;br /&gt;        try {&lt;br /&gt;            in = InetAddress.getByName(args[0]);&lt;br /&gt;            boolean result = in.isReachable(5000);&lt;br /&gt;            if (result) {&lt;br /&gt;                System.out.println("Response OK");&lt;br /&gt;            }&lt;br /&gt;            else {&lt;br /&gt;                System.out.println("Response fail");&lt;br /&gt;            }&lt;br /&gt;        } catch (UnknownHostException e) {&lt;br /&gt;            System.out.println(e.getMessage());&lt;br /&gt;        } catch (IOException e) {&lt;br /&gt;            System.out.println(e.getMessage());&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Java裡只能建立 stream(TCP) 或 dgram(UDP) 的socket，那麼只能用JNI，用C寫ping了，但經過實驗結果，發現會因為權限的關係而無法建立socket，原來要建立raw與IPPROTO_ICMP的socket，需要root權限。一般linux裡，非root使用者可以使用ping，是因為ping加上了setuid權限，才能使用。在Android裡，要不就是建立service，要不就是設法為ping加上setuid，否則是都無法使用的。&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7158259184008856301?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7158259184008856301/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7158259184008856301' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7158259184008856301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7158259184008856301'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/ping-in-android.html' title='ping in Android'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-9009839281908915026</id><published>2012-01-11T18:10:00.001+08:00</published><updated>2012-01-11T18:10:59.979+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Get IP Address in Android</title><content type='html'>這篇&lt;a href="http://www.droidnova.com/get-the-ip-address-of-your-device,304.html"&gt;Get the ip address of your device on Android Development&lt;/a&gt;其實就講的很清楚了，就是用NetworkInterface.getNetworkInterfaces()去取得所有網路介面，然後再用網路介面的getInetAddresses()去看該網路卡上的所有IP位址，然後把Loopback位址排除掉，就可以取得了。該開的權限有android.permission.INTERNET與android.permission.ACCESS_WIFI_STATE。&lt;br /&gt;我工作上的需求，是要拿到3G那邊的IP，經過實驗，發現在WiFi開啟的情況下，只會拿到WiFi網路介面的IP位址，而非3G網路介面的。如果把WiFi網路介面關閉，就可以拿到3G網路介面的IP。我以為是程式邏輯的關係，可是在確認過NetworkInterface.getNetworkInterfaces()傳回的網路介面數量以後，發現都是取得兩個網路介面，而非我預期的三個。好，那我不使用NetworkInterface.getNetworkInterfaces()改用NetworkInterface.getForName()去取的話，在WiFi開啟的情況下，取得的結果會是null，也就是說該網路介面被關掉了。&lt;br /&gt;直接去看底層，在 mydroid/libcore 下NetworkInterface的JNI函式，那邊是使用netlink去跟kernel問所有的網路介面，然後解析之後傳回。那麼底層應該是沒有問題，看來是中間層為了能取得較快的網路速度，而自動把3G網路介面給關閉了。看來也只能在程式執行前，先把WiFi給關閉，才能取得3G網路介面的IP位址了。&lt;br /&gt;參考資料：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.krvarma.com/2010/07/getting-ip-address-of-the-device-in-android/"&gt;Getting IP address of the device in Android&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://thiranjith.wordpress.com/2011/03/31/how-to-monitor-network-connectivity-in-android/"&gt;How to monitor network connectivity in Android&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-9009839281908915026?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/9009839281908915026/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=9009839281908915026' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/9009839281908915026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/9009839281908915026'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/get-ip-address-in-android.html' title='Get IP Address in Android'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8603403586726198562</id><published>2012-01-11T17:33:00.002+08:00</published><updated>2012-01-11T17:33:09.180+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='excel'/><category scheme='http://www.blogger.com/atom/ns#' term='vba'/><title type='text'>[ExcelVBA]刪掉所有sheet，只留下指定的sheet</title><content type='html'>&lt;p&gt;上星期的某天花了一個小時在寫這個Script來幫我刪sheet，程式邏輯很簡單，很快就搞定了，只是另存新檔，打開以後，卻什麼東西都沒看到。存為 .csv 的話，的確是有資料，那就奇怪了，百思不得其解。一放就又放了一個星期，這次終於解開秘密了。另存新檔以後，不知道為什麼，打開以後視窗會被隱藏，所以什麼都看不到。只要取消隱藏視窗就可以看到了。程式的話，就是要這樣寫： Application.Windows(1).Visible=True，下面就是整個程式：&lt;/p&gt;&lt;script src="https://gist.github.com/1559502.js?file=gistfile1.vb"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8603403586726198562?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8603403586726198562/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8603403586726198562' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8603403586726198562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8603403586726198562'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/excelvbasheetsheet.html' title='[ExcelVBA]刪掉所有sheet，只留下指定的sheet'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2038460117372159811</id><published>2012-01-08T06:40:00.001+08:00</published><updated>2012-01-08T06:40:02.894+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2012/1/1~2012/1/8)</title><content type='html'>轉眼又是新的一年。&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Cowboys &amp;amp; Aliens(&lt;a href="http://www.imdb.com/title/tt0409847/" target="_blank" title="Cowboys &amp;amp; Aliens Poster"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Cowboys_%26_Aliens" target="_blank" title="Cowboys &amp;amp; Aliens Poster"&gt;Wikipedia&lt;/a&gt;)，中譯：星際飆客。中文翻譯還蠻能唬人的，算了。這是一部西部片，只是對抗的人變成了外星人。故事很簡單，男主角一開始是喪失記憶的，手上帶了一個莫名其妙的手環，然後他到了小鎮。小鎮旋即被外星人襲擊，一堆人被擄走要解剖用。然後男主角就跟小鎮上最硬的人組隊去救人，在途中，男主角慢慢想起以前的事情，也跟女主角等人慢慢熟起來。然後終於找到外星人的飛船，就決定先把外星人引出來打，男主角跟女主角趁機進去救人。外面真的幾乎是一場一面倒的戰役，那個時代的槍沒打到要害的話，基本上是打不死人的，就子彈卡在肌肉裡這樣，所以外星人根本是所向披靡。不過在電影的加持之下，還是幹掉了不少外星人。題外話，其實外星人的設定不是很合理，為什麼身體還會打開，把要害攤給別人看還會伸出另外兩隻手呢？不過反正是外星人，我想我就別在意了。在硬撐了許久之後，終於把人救了出來，女主角其實也是外星人，是要來報仇的外星人，所以就拿了男主角的手環下來，轉成炸彈，進去核心。男主角趁機會趕緊逃了出來，女主角最後就把外星人的船炸掉，就這樣。大致上不難看啦，最可惜的一幕是女主角死而復生的那一段，她從火裡走出來，衣服都被燒光光，我蠻想加入那些圍觀的人說，想知道為什麼他們那麼驚訝。(你劃錯重點了好嗎?驚訝是因為她死了又再復活，不是沒穿衣服的問題!!)&lt;/li&gt;&lt;li&gt;Iron Man 2(&lt;a href="http://www.imdb.com/title/tt1228705/" target="_blank" title="Iron Man 2"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Iron_Man_2" target="_blank" title="Iron Man 2"&gt;Wikipedia&lt;/a&gt;)，中譯：鋼鐵人2。Tony因為控制不住&lt;a href="http://en.wikipedia.org/wiki/Palladium" title="Palladium"&gt;palladium&lt;/a&gt;的關係，生命不長久了，所以就開始亂搞，並且讓Pepper當CEO。在西班牙遇到他老爸朋友的兒子&lt;a href="http://en.wikipedia.org/wiki/Whiplash_%28comics%29#Film" title="Whiplash (comics)"&gt;Ivan Vanko&lt;/a&gt;，一陣亂打讓鋼鐵人跟Starks工業的名聲大為降低，讓對手Hammers工業趁機而入。一整個low到谷底，一具鋼鐵人又被美國國防部拿走的情況下，神盾局的人跑出來跟他說&lt;a href="http://en.wikipedia.org/wiki/Palladium" title="Palladium"&gt;palladium&lt;/a&gt;不是最好的元素，給他打了抑制Palladium的藥物並給了他他老爸的遺物，說有更好的元素可以用，他摸索一陣子之後，找到了製造新元素的方法，然後噹噹噹，新的core誕生了，arc reactor更為強大。Ivan被Hammers吸收以後，幫他們研發，但不聽他們的話，而是搞自己的，所以在Expo時，他遙控一堆機器人跟Iron Man打，這堆機器人真的很酷啊，但Iron Man跟他的朋友聯手把這堆機器人幹掉，Ivan大魔王現身，最後以解決掉大魔王告終。這一集Pepper的戲份不多，好可惜，我很喜歡她說。然後飾演Natalie的&lt;a href="http://en.wikipedia.org/wiki/Scarlett_Johansson" title="Scarlett Johansson"&gt;Scarlett Johansson&lt;/a&gt;是一個亮點，她的武術動作真的好酷，然後她真的很適合演這種酷酷的角色，&lt;span class="vcard"&gt;&lt;span class="fn"&gt;&lt;a href="http://en.wikipedia.org/wiki/The_Spirit_%28film%29" title="The Spirit (film)"&gt;The Spirit&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vcard"&gt;&lt;span class="fn"&gt;裡是這樣(有多一點搞笑)，這裡也是這樣。&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;http://en.wikipedia.org/wiki/Whiplash_(comics)#Film&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2038460117372159811?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2038460117372159811/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2038460117372159811' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2038460117372159811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2038460117372159811'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/201211201218.html' title='電影流水帳(2012/1/1~2012/1/8)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-5867719944668820094</id><published>2012-01-08T05:57:00.001+08:00</published><updated>2012-01-08T05:57:52.818+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fuse'/><category scheme='http://www.blogger.com/atom/ns#' term='skydirve'/><title type='text'>skydrive+FUSE的read</title><content type='html'>這幾天弄skydrive+fuse的時候，一直在想，這到底適不適合用FUSE來實作?&lt;br /&gt;&lt;ol&gt;&lt;li&gt;以網路程式來說，讀取的時候，要可以告訴伺服器端，客戶端要下載那一段，要下載多少，以HTTP來說，這可以用Range這個header來達成，只要在發request的時候，加上Range header就可以指定。那麼skydrive伺服器端有支援續傳嗎?這個我還沒去確定。&lt;/li&gt;&lt;li&gt;那麼FUSE的read裡可以使用續傳嗎?在read裡會指定要讀取多少，從哪裡開始讀取，看來是可以使用續傳，可是使用續傳的話，就要考慮一下客戶端的情況，一般在做這種read的時候，是使用一個回圈，然後一次只讀取一部份到緩衝區裡，並不是一次讀完，因此，只讀取一部份的結果，等於會送出許多次的request給伺服器端。&lt;/li&gt;&lt;li&gt;可以不要送出許多次的request嗎?這樣網路會折返很多次。一次下載完，先放到硬碟的話，就要面對同步的問題。首先第一次read時，就要可以傳回一部份值，並且要把這個下載的動作放到thread去執行，繼續下載，並放到某個暫存的地方，直到下載完成。那接下來第二次要read時，再去讀取已經下載的部份並傳回。這樣會少掉比較多的request，效率也會比較高一點。可是thread在寫的時候，另外一個thread可以去讀取正在寫入的檔案嗎?會不會有什麼奇怪的事情發生呢?這個是需要實驗的地方。&lt;/li&gt;&lt;li&gt;延續前面的討論，現在已經放到暫存的地方，存取會快很多，可是該怎麼知道伺服器端的檔案被更改了?這應該可以在一開始要read的時候，去判斷檔案大小跟屬性來判斷是不是要重新下載。另外也要考慮到伺服器端檔案被頻繁更動的情況。&lt;/li&gt;&lt;li&gt;既然會放到暫存的地方的話，是不是乾脆像dropbox那樣用sync的方式來做會比較好?&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-5867719944668820094?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/5867719944668820094/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=5867719944668820094' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5867719944668820094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5867719944668820094'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/skydrivefuseread.html' title='skydrive+FUSE的read'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-5234485803160392445</id><published>2012-01-06T10:50:00.001+08:00</published><updated>2012-01-06T10:50:10.967+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><title type='text'>家裡server升級</title><content type='html'>先從昨天講起，昨天早上本想在今天下午請特別假的，卻發現沒辦法請特別假了。仔細看，才發現原來可以請特別假的期間是到職日到隔年到職日的前一天，啊啊啊!!我還以為跟前公司一樣說，一整個晴天霹靂。所以我去年短短的6個半月時間，就把所有特別假都請完了，今年要撐半年以後才能放特別假啊~&lt;br /&gt;好吧，去年最後一天有請特別假，也是最後一個特別假，然後在家裡升級伺服器，中午有出去吃火鍋，載太座大人回家。去年我弟換NB時，就把他的桌機給我了，一直有打算要幫家裡伺服器升級，但一直沒動手。這次的升級遇到的問題是，機器按了電源開關以後，電源燈一閃即逝，猜想是短路的問題，所以就整個拆掉，看有沒有裝上墊片。拆開一看，發現沒裝墊片，然後機版不是用銅柱去鎖主機板，而是靠凸起跟主機板接觸去鎖。這下可就傷腦筋，就上網查了一下，說這種的比較容易短路，所以他是用透明膠帶去貼凸起，然後戳洞以後再鎖。我就如法泡製，再把主機板...等等的東西都再裝上。裝上、按前面的電源以後，怎麼還是閃了一下就滅掉，於是確定後面的電源開關以後，再去按前面的電源開關，這下就可以了。所以或許不用整個拆掉，可能只是自己耍白痴，後面的電源開關搞錯開跟關了?!算了，反正已經都弄好，硬碟也裝上，可以順利開機就好。&lt;br /&gt;可是，事情往往不是這麼簡單就可以解決。原本有一顆SATA硬碟，我加裝兩顆原來伺服器的IDE硬碟上去，主要的那顆用IDE轉SATA接，另外一個次要的用IDE接。我是想說用原來伺服器主要的那顆硬碟來開機，可是怎麼弄都不行，經過兩個多小時，無數次的試驗之後，發現是因為CentOS做出來的initrd沒有載入SATA的驅動模組，那接下來就無法找到硬碟去掛載主要硬碟上的分割區。本來是想為initrd補上SATA驅動模組的，後來放棄了，就把主要硬碟改用IDE接，次要的則用IDE轉SATA接，這樣，就順利開機了，拜Linux所賜，也不需要重灌，就稍微調整了一下設定、日期時間就收工了。&lt;br /&gt;升級以後的確是爽，原本的伺服器是Celeron 566MHz加384MB的RAM，新的伺服器是AMD Sempron 3000+加1G RAM，雖然規格還是跟現在的電腦差很多，但是速度跟以前伺服器比快了好多啊!!&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-5234485803160392445?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/5234485803160392445/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=5234485803160392445' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5234485803160392445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5234485803160392445'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/server.html' title='家裡server升級'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2425772464823126069</id><published>2012-01-03T11:23:00.001+08:00</published><updated>2012-01-03T11:23:52.744+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='logging'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>UnicodeDecodeError when logging utf-8 string</title><content type='html'>&lt;p&gt;我的python有使用logging library，可是卻出現下面的錯誤訊息：&lt;pre&gt;UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 56: ordinal not in range(128)&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;百思不得其解，明明我的字串就是utf-8，可是卻會出現這個錯誤訊息。查了&lt;a href="http://docs.python.org/howto/unicode.html"&gt;Python的Unicode How-To&lt;/a&gt;好幾次，覺得問題應該是出在檔案上，開檔案時應該要用codecs，那，會不會是logging開啟檔案時，沒有用codecs去開檔案然後處理encoding啊??發現好像也不是，因為使用FileHandler時有指定編碼啊。&lt;/p&gt;&lt;p&gt;上網找了之後，才發現logging的確已經使用codecs來開啟檔案了，那為什麼呢??又再找了幾篇當參考：&lt;a href="http://stackoverflow.com/questions/1545263/utf-8-in-python-logging-how"&gt;UTF-8 In Python logging, how?&lt;/a&gt;，&lt;a href="https://github.com/ask/celery/issues/427"&gt;UnicodeEncodeErrors with celery built-in console logging&lt;/a&gt;，也有人直接&lt;a href="http://tony.czechit.net/2009/02/unicode-support-for-pythons-logging-library/"&gt;自訂formatter&lt;/a&gt;來解決，看著看著，就想到，原來logging裡面已經有處理了啊，再次對utf-8字串作utf-8 encode的結果就是出錯，那就表示不必特別丟utf-8字串，只要丟給他unicode字串，logging就會自動幫我轉了啊~&lt;/p&gt;&lt;p&gt;於是我就不特別再作字串的轉換，直接使用unicode字串，這樣就解決這問題了。&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2425772464823126069?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2425772464823126069/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2425772464823126069' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2425772464823126069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2425772464823126069'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2012/01/unicodedecodeerror-when-logging-utf-8.html' title='UnicodeDecodeError when logging utf-8 string'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1927833981591094048</id><published>2011-12-29T10:35:00.001+08:00</published><updated>2011-12-29T10:35:21.154+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='liveconnect'/><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='oauth2'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>LiveConnect OAuth2</title><content type='html'>講的比較仔細的是這幾篇：&lt;a href="http://msdn.microsoft.com/en-us/windowslive/hh561319"&gt;Mobile and Windows desktop apps&lt;/a&gt;、&lt;a href="http://msdn.microsoft.com/en-us/library/hh243647.aspx"&gt;OAuth 2.0 (Live Connect)&lt;/a&gt;、&lt;a href="http://msdn.microsoft.com/en-us/library/hh243649.aspx"&gt;Server-side scenarios (Live Connect)&lt;/a&gt;、&lt;a href="http://windowsteamblog.com/windows_live/b/windowslive/archive/2011/07/20/developers-learn-how-to-bring-data-from-hotmail-messenger-and-skydrive-to-your-mobile-apps.aspx"&gt;Developers – Learn how to bring data from Hotmail, Messenger, and SkyDrive to your mobile apps&lt;/a&gt;，第1篇比較粗略，但夠簡單。第2篇是有仔細講解參數以及流程(含圖)，可以在遇到問題時做參考。看過以後，發現步驟的確是OAuth2，但就是沒辦法用 python oauth2 去套，就只能照步驟來硬刻了。&lt;br /&gt;有試過httplib2，看能不能parse HTML再去摹擬POST登入，結果會回一個400的錯誤，拿到錯的頁面。python內建的webbrowser，只會用browser開出畫面，但沒有提供方法可以取回在網址列的網址。看來在拿 access token/authorization code 的部份，就只能先組出sign in的url，把瀏覽器開出來，讓使用者先去登入，然後允許以後，再請使用者把網址複製下來，貼到程式的輸入，讓程式去擷取 access token/authorization code，再保存下來。就先這樣子做吧，以後有更好的方法再來修正。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1927833981591094048?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1927833981591094048/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1927833981591094048' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1927833981591094048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1927833981591094048'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/12/liveconnect-oauth2.html' title='LiveConnect OAuth2'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8159888571973750936</id><published>2011-12-28T17:32:00.001+08:00</published><updated>2011-12-28T17:32:55.002+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>pyskydrive/skydrive .net api client</title><content type='html'>&lt;p&gt;靈機一動用python+skydrive去找，有找到&lt;a href="http://code.google.com/p/pyskydrive/"&gt;pyskydrive&lt;/a&gt;這個project，試用結果，是不行。專案是去年釋出的，追蹤了一下，發現是因為Skydrive頁面HTML一整個改掉，已經不能用原來的方法去parse了。&lt;/p&gt;&lt;p&gt;改看SkyDrive.Net API Client的source code，看能不能fork出來改。可是看跟試驗的結果，發現也不行使用。他使用的方法也不是正規作法，因此認証那關都過不了。&lt;/p&gt;&lt;p&gt;看來只能自己刻了。在LiveAPI的網站上有看到是使用 OAuth 2，就先安裝了 python oauth2 的library，可是參考範例以後，發現怎麼樣也套不上微軟的LiveAPI OAuth。於是就只能看官方的介紹跟文章來實驗與重刻了。&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8159888571973750936?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8159888571973750936/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8159888571973750936' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8159888571973750936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8159888571973750936'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/12/pyskydriveskydrive-net-api-client.html' title='pyskydrive/skydrive .net api client'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-5696694945865497810</id><published>2011-12-27T14:30:00.001+08:00</published><updated>2011-12-27T14:30:31.865+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='fuse'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='skydrive'/><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>skydrive+fuse?</title><content type='html'>好像沒人寫，先找資料看看。&lt;br /&gt;收集資料：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://pysnippet.blogspot.com/2009/11/fuse-filesystem-in-userspace-part-1.html"&gt;FUSE - Filesystem in Userspace part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://pysnippet.blogspot.com/2009/11/fuse-filesystem-in-userspace-part-2.html"&gt;FUSE - Filesystem in Userspace part 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.slideshare.net/matteobertozzi/python-fuse" title="python-fuse"&gt;python-fuse slideshow&lt;/a&gt;&lt;/li&gt;&lt;li&gt;微軟有提供live SDK，是否可用，仍未知&lt;/li&gt;&lt;li&gt;&lt;a href="http://skydriveapiclient.codeplex.com/"&gt;SkyDrive .Net API Client&lt;/a&gt; 有非官方的API可以使用&lt;/li&gt;&lt;li&gt;&lt;a href="http://windowsteamblog.com/windows_live/b/windowslive/archive/2011/12/07/skydrive-apis-for-docs-and-photos-now-ready-to-cloud-enable-apps-on-windows-8-windows-phone-and-more.aspx" title="SkyDrive APIs for Docs and Photos"&gt;SkyDrive APIs for Docs and Photos&lt;/a&gt; 有稍稍提到底層的方法&lt;/li&gt;&lt;li&gt;&lt;a href="http://tirania.org/blog/archive/2006/Sep-01.html"&gt;Authoring File Systems with Mono on Linux&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="https://github.com/jonpryor/mono-fuse"&gt;mono-fuse&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.jprl.com/Projects/mono-fuse.html"&gt;Mono.Fuse&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;整體看起來，不要使用python，使用 mono+fuse+SkyDrive .Net API Client 似乎是比較好的解?!&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-5696694945865497810?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/5696694945865497810/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=5696694945865497810' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5696694945865497810'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5696694945865497810'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/12/skydrivefuse.html' title='skydrive+fuse?'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1929881561180581883</id><published>2011-12-24T04:22:00.000+08:00</published><updated>2011-12-24T04:22:28.531+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/11/21~2011/12/23)</title><content type='html'>轉眼2011年已經要到底了，今年比較沒有認真在看電影，一方面是忙，一方面是中午要跟同事一起吃飯，看電影的時間不夠，又想要休息，所以就斷斷續續的看。隨文附上輕熟女一枚，她是Lena Headey，The Brothers Grimms的女主角，根據IMDB上的資料，她才大我兩歲...&lt;br /&gt;&lt;a href="http://www.flickr.com/photos/gifake/4681427698/" title="Flickr 上 quicheisinsane 的 #05 Lena Headey (ENG)"&gt;&lt;img alt="#05 Lena Headey (ENG)" height="183" src="http://farm5.staticflickr.com/4001/4681427698_78775bf8a9_m.jpg" width="240" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The Brothers Grimm(&lt;a href="http://www.imdb.com/title/tt0355295/" title="The Brothers Grimms"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/The_Brothers_Grimm_%28film%29" title="The Brothers Grimm (film)"&gt;Wikipedia&lt;/a&gt;)，中譯：神鬼兄弟。這是在網樂通上看完的，相當好看的電影!!裏面有好多格林童話的梗，像是白雪公主、長髮公主、糖果屋、小紅帽...等等的，然後再把這些梗寫到電影的主軸故事裡，很精彩!!格林兄弟是一對靠裝神弄鬼過活的兄弟，但弟弟其實是個喜歡研究民間傳說的學者。統治者知道他們的名聲(惡名)，就抓來讓他們去某個真正有怪事的村落，看他們是否能解決。經過探查之後，發現真的是有怪事，然後認識了女主角Angelika，原來Angelika的妹妹是最先失蹤的，被村民當作是帶賽的人隔離在外。兄弟兩發現真的超級奇怪，監視他們的人覺得這兩個傢伙很怪，就又把他們帶回統治者那邊，統治者又再給他們一次機會。這次弟弟要進去塔裏面，發現了皇后被下了永生咒，而不是永保青春咒，整個皮囊都腐朽了，所以才會找人來幫他恢復青春，而那個人好死不死就是Angelika的爸爸。接著省略，因為兩個兄弟進出森林了幾次，都快讓我想不起來了。總之，最後就是藉著打破鏡子破除了皇后的魔法，救出了所有失蹤的小孩。&lt;/li&gt;&lt;li&gt;Harry Potter and the Deathly Hallows Part1(&lt;a href="http://www.imdb.com/title/tt0926084/"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Harry_Potter_and_the_Deathly_Hallows_%E2%80%93_Part_1" target="_blank"&gt;Wikipedia&lt;/a&gt;), Part2(&lt;a href="http://www.imdb.com/title/tt1201607/" target="_blank"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Harry_Potter_and_the_Deathly_Hallows_%E2%80%93_Part_2" target="_blank"&gt;Wikipedia&lt;/a&gt;)，中譯：哈利波特-死神的聖物。劇情跟書差不多，導演、編劇有認真，辛苦他們了，把兩本書的故事塞到4個小時的電影裡，個人覺得精彩度不如小說，不過真的算不錯了。哈利一開始就開始逃，以避免佛地魔的追殺。跟榮恩、妙麗一起流亡的日子，除了要找魂器之外，也面臨了三人感情惡化的問題。Part 1 在救出 Luna，小精靈死掉，佛地魔取得死神聖器裡的魔杖而告終。Part 2則是在佛地魔準備大舉進攻霍格華茲學院開始，三人進到學校找到並消滅魂器，最後跟佛地魔決戰。我個人覺得石內卜(Snape)真的是超級偉大的，尤其是他在向Dumbledore哀求那段，真的可以很深刻的感受到他對哈利媽媽的愛。好吧，真的，哈利波特系列電影終於結束了，一共八集。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1929881561180581883?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1929881561180581883/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1929881561180581883' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1929881561180581883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1929881561180581883'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/12/2011112120111223.html' title='電影流水帳(2011/11/21~2011/12/23)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7194415753297851268</id><published>2011-12-23T11:52:00.001+08:00</published><updated>2011-12-23T11:52:53.794+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ssl'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>SSL3_GET_SERVER_CERTIFICATE</title><content type='html'>&lt;p&gt;這是根據錯誤訊息找到的文：&lt;a href="http://ademar.name/blog/2006/04/curl-ssl-certificate-problem-v.html"&gt;Curl: SSL certificate problem, verify that the CA cert is OK - ademar@toronto&lt;/a&gt;，但很可惜，對我沒用。&lt;/p&gt;&lt;p&gt;我是用virtualenv去建出我所需的python環境的，我安裝了oauth2，oauth2連帶安裝了httplib2，試著寫一個小程式想試試看oauth2時，卻吐出了這樣的錯誤：[Errno 1] _ssl.c:480: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed。接下來的情況，就幾乎是鬼打牆，找了一堆，都是講要更新憑證。後來靈機一動，因為在某篇文看到說可以用curl_setopt跳過檢查認証，所以就跑去看httplib2的源碼，好死不死在 site-packages/httplib2 下被我看到 cacerts.txt，啊哈，應該就是你吧，就去這裡&lt;a href="http://curl.haxx.se/docs/caextract.html"&gt;cURL - Extract CA Certs from Mozilla&lt;/a&gt;下載了cacert.pem，然後拿這個檔案替換了cacerts.txt，就搞定了認証的問題。&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7194415753297851268?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7194415753297851268/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7194415753297851268' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7194415753297851268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7194415753297851268'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/12/ssl3getservercertificate.html' title='SSL3_GET_SERVER_CERTIFICATE'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2235687941369670459</id><published>2011-12-07T16:27:00.001+08:00</published><updated>2011-12-07T16:36:22.385+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Android 2.3.x 的 JavaScript Interface</title><content type='html'>星期天利用Google reader看文的時候，看到Fred大的這篇：&lt;a href="http://fred-zone.blogspot.com/2011/12/android-23x-javascript-interface.html"&gt;Android 問題百出之 2.3.x 的 JavaScript Interface&lt;/a&gt;，我就心想，完了，我踩到雷。因為最近正好在實驗WebView Javascript與Java部份，回家一試，果真如此，真的頭很大。&lt;br /&gt;再上網找了一下，發現很早以前就有人回報這個&lt;a href="http://code.google.com/p/android/issues/detail?id=12987"&gt;問題&lt;/a&gt;，喂，我說Google啊，那為什麼不修?!(怒)，這個&lt;a href="http://code.google.com/p/android/issues/detail?id=12987"&gt;討論串&lt;/a&gt;很長，連PhoneGap開發小組也都有回。結果沒辦法，只能參考Fred大的文去改了。可是改了以後，卻怎麼樣都不能動，連原來的會導向到LogCat的部份都失效了，試了好久，又去StackOverflow找，找了幾篇，像：&lt;a href="http://stackoverflow.com/questions/7424510/uncaught-typeerror-when-using-a-javascriptinterface"&gt;Uncaught TypeError when using a JavascriptInterface&lt;/a&gt;...等等，但還是不行，真的讓人摸不著頭緒。&lt;br /&gt;後來是發現 onConsoleMessage 應該是要加 @Override 的，現在卻不用了，上網去Android reference找，才發現我搞錯類別名稱了。一個是WebChromeClient，而Fred大文章裡用的是WebViewClient，搞清楚，修改程式以後，這才讓我有了log利器，能用這個來去找到Javascript修補程式的錯誤，並修正。&lt;br /&gt;為了要可以自動化為類別產生javascript修補程式的步驟，我運用了Annotation去標記需要產生Javascript代碼的函式，這樣就可以運用reflection的方式去找到這些函式，並產生程式，以注入到WebView裡面去。為了避免老是改程式，我也利用了Google瀏覽器，直接把產出的Javascript程式，放到Google瀏覽器的網址列去執行，這樣很快就知道哪裡有錯誤，並且修正。&lt;br /&gt;總之，大概就是這樣子，解決了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2235687941369670459?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2235687941369670459/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2235687941369670459' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2235687941369670459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2235687941369670459'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/12/android-23x-javascript-interface.html' title='Android 2.3.x 的 JavaScript Interface'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3244130113722137691</id><published>2011-12-05T17:39:00.001+08:00</published><updated>2011-12-05T17:39:46.285+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/11/21~2011/12/2)</title><content type='html'>&lt;ul&gt;&lt;li&gt;Johnny English(&lt;a href="http://www.imdb.com/title/tt0274166/"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Johnny_English"&gt;Wikipedia&lt;/a&gt;)，中譯：凸槌特派員。相當爆笑的故事啊，英國第一號情報員因為Johnny的失誤而掛掉，接著，一堆情報員又因為要幫第一號情報員送終而死光光，那就只剩下Johnny跟他的跟班了。過沒多久，他們接到保護英國王冠跟權杖的任務，不幸的是，保護不力，王冠跟權杖失蹤了，幸運的是認識了漂亮的女主角。於是他們展開調查，調查的過程裡，很顯然的，Johnny的跟班比Johnny本人更適合當情報員，後來搞了一堆烏龍，Johnny被首相開除，很失意的回家。女主角找到他，重燃起他的信心，讓他深信沒有他就無法阻止壞蛋登上王位，在阻止壞蛋登上王位的過程，又搞了一個超大的烏龍，但也讓壞蛋在公開的場合忍受不了，說出了不好的話，因此揭穿了陰謀。最後當然是皆大歡喜的解決了這個事件，和平落幕。&lt;/li&gt;&lt;li&gt;The Green Hornet(&lt;a href="http://www.imdb.com/title/tt0990407/"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/The_Green_Hornet_%282011_film%29"&gt;Wikipedia&lt;/a&gt;)，中譯：青蜂俠。我個人覺得不好看，劇情普普。特效的部份，在當年的科技或許那樣子是相當先進的，可是在今天看起來，卻顯得很拙，不合時宜，而且沒有交代年代，有種奇妙的時空背離感。唯一令人驚奇的是那個煮咖啡機，竟然可以瞬間加熱，炒好咖啡豆，然後研磨並立即有熱水去濾泡，這一台如果能量產，應該會有不少玩家買才是。&lt;/li&gt;&lt;li&gt;Fast Five(&lt;a href="http://www.imdb.com/title/tt1596343/"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Fast_Five"&gt;Wikipedia&lt;/a&gt;)，中譯：玩命關頭5。搞了四集之後，Dom、Brian、Mia聚在一起，再次偷車，卻發現了巴西最大犯罪公司的秘密，再加上美國中情局派出Luke來追捕他們，於是他們開始逃竄。但在逃的同時，決定用他們得到的秘密來幹一票，把最大犯罪公司的錢都偷光光。然後據說是前面幾集的人又再次聚在一次，開始演練計畫，並且施計讓犯罪公司的首腦把錢集中到警局，準備去偷。在正要下手的當天，Luke帶人衝了進來，抓住了Dom、Brian、Mia，並準備把他們移交到美國，移交的半路被犯罪公司襲擊，Luke的小組死光光，Dom、Brian、Mia被女警察鬆開，出手幫了Luke。Dom超火大，決定無論如何都要幹這票，Luke也加入了，說是要報仇。Luke首先衝到警局，把地下停車場清空，Dom跟Brian兩台車跟著進去把大大的保險櫃拖了出來，開始在街上跑，一狗票警車就在街上展開追逐，看著他們兩台車拖著大保險櫃跑來跑去真的很過癮。兩台車後來把保險櫃拖到了橋上，沒路跑了，Dom讓Brian先走，自己跟一堆警車對幹，然後利用慣性讓保險櫃撞到犯罪公司首腦開的車，犯罪首腦僥倖從車裡逃了出來，但卻沒逃過緊追而來的Luke的子彈。Luke最後還是以中情局的立場跟Dom與Brian說，錢你們不能拿走，兩人很瀟灑的離去。離去之後，Luke打開保險櫃一看，發現保險櫃早在跟警方追逐戰時就被調包了。一個皆大歡喜的結局，最後的最後，有埋了梗，看起來是Luke要挑起Fast 6大樑的樣子。相當好看的一部動作片，前面有點悶，雖然有些情節不是很合理，但後面相當精彩。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3244130113722137691?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3244130113722137691/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3244130113722137691' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3244130113722137691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3244130113722137691'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/12/201111212011122.html' title='電影流水帳(2011/11/21~2011/12/2)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7254267369243158137</id><published>2011-12-01T10:36:00.001+08:00</published><updated>2011-12-01T10:38:49.436+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>emulator無法啟動</title><content type='html'>這蠻奇怪的，但只要每次我在 AVD Manager 要啟動時，勾選 Wipe user data 以後，就都可以啟動。可是因為要手動指定 proxy 的關係，我必須用指令列的方式，但加上 -wipe-data 卻沒有用，上網搜了一下發現 &lt;a href="http://stackoverflow.com/questions/6641498/android-emulator-cant-start-cause-of-wrong-folder"&gt;Android Emulator can't start, 'cause of wrong folder&lt;/a&gt;裡面有提到要設定 ANDROID_SDK_HOME，於是在命令提示字元裡先設置 set "ANDROID_SDK_HOME=c:\Documents and Settings\your_name" 之後，就可以順利啟動 emulator 了。以後要省這麻煩的話，可以在"我的電腦"/"內容"/"進階"/"環境變數"裡去新增，就可以一勞永逸了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7254267369243158137?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7254267369243158137/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7254267369243158137' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7254267369243158137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7254267369243158137'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/12/emulator.html' title='emulator無法啟動'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-5005750206287646160</id><published>2011-11-30T14:32:00.001+08:00</published><updated>2011-11-30T14:32:41.008+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Android MapView - Failed to find provider info</title><content type='html'>這篇&lt;a href="http://stackoverflow.com/questions/1988078/android-failed-to-find-provider-info-for-com-google-settings-in-mapview-exampl"&gt;Failed to find provider info for com.google.settings in MapView Example&lt;/a&gt;講得很仔細，該說的都說了。我個人的經驗：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;有這個錯誤訊息，未必會看不到地圖。&lt;/li&gt;&lt;li&gt;當apiKey是對的時候，沒有網路，仍然會看不到地圖，會讓人懷疑apiKey有誤。&lt;/li&gt;&lt;li&gt;請務必讓網路暢通，如果公司裡面有proxy，可以試試在命令提示字元去啟動emulator：emulator -avd your_avd -http-proxy your_proxy_server:your_proxy_server_port -debug-proxy，這樣應該就可以了。(這指令是在&lt;a href="http://code.google.com/p/android/issues/detail?id=5508&amp;amp;q=emulator%20proxy&amp;amp;colspec=ID%20Type%20Status%20Owner%20Summary%20Stars"&gt;Android 2.0, 2.0.1 proxy problems&lt;/a&gt;撈到的)。&lt;/li&gt;&lt;/ul&gt;關於網路的部份，還可以參考：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/28380/proxy-with-android-emulator"&gt;Proxy with Android Emulator&lt;/a&gt;，這篇是直接去Settings/Wireless/APN那邊設定，之前我有用過，可以，但今天又不行了。&lt;/li&gt;&lt;li&gt;&lt;a href="http://forum.xda-developers.com/showthread.php?t=766569"&gt;http(s) proxy support (web, maps, etc)&lt;/a&gt;，這篇裡有一個.apk，看起來有支援NTLM之類的，也可以安裝看看，我是沒試過就是了&lt;/li&gt;&lt;li&gt;&lt;a href="http://developer.android.com/guide/developing/tools/emulator.html#proxy"&gt;Google對emulator proxy的說明&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-5005750206287646160?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/5005750206287646160/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=5005750206287646160' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5005750206287646160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5005750206287646160'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/android-mapview-failed-to-find-provider.html' title='Android MapView - Failed to find provider info'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7541539914327133355</id><published>2011-11-25T11:50:00.001+08:00</published><updated>2011-11-25T11:51:00.147+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='webview'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>WebView裡$.parseJSON() fail</title><content type='html'>查了好久。我是先用setWebChromeClient()去處理WebView的onConsoleMessage() callback，將console.log()的輸出導向到Android的LogCat以便於觀察。先懷疑jQuery是不是有問題，就先拿另外一個變數放確定可以的JSON字串丟進去parse，沒問題。那我就懷疑從addJavascriptInterface()那兒來的物件的傳回值了，直接複製傳回結果，放到JavaScript裡當作一個字串，parse的結果，是沒問題的。那?會是型態的問題嗎？用typeof()檢查了一下，發現是object，而非字串，真相大白。我先試著把一個空字串加到傳回值裡，然後就可以得到字串，也就可以正常parse了。再查了一下，JavaScript是有轉換函式的，叫String()，試了一下，也可以把型態是object的傳回值轉為字串。至此，就解決了parseJSON()的問題。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7541539914327133355?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7541539914327133355/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7541539914327133355' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7541539914327133355'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7541539914327133355'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/webviewparsejson-fail.html' title='WebView裡$.parseJSON() fail'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-544659216902617311</id><published>2011-11-24T16:48:00.001+08:00</published><updated>2011-11-24T17:20:08.833+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='webview'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>WebView</title><content type='html'>畫面如果用Android裡的xml，光想，就讓我頭痛。還是用HTML來的方便，而且現在有HTML5，Android也有WebView，再加上之前敗了這本&lt;a href="http://www.anobii.com/books/%E5%BB%BA%E6%A7%8BAndroid%E6%87%89%E7%94%A8%E7%A8%8B%E5%BC%8F/9789862761540/01559b2758c0e5b5f8/" title="More about 建構Android應用程式"&gt;建構Android應用程式&lt;/a&gt;，我想這樣應該會方便很多。可是用HTML，就得用JavaScript，也需要從Android程式那邊溝通，就研究了一下。&lt;br /&gt;&lt;a href="http://developer.android.com/resources/articles/using-webviews.html"&gt;Using WebViews&lt;/a&gt;裡提供的範例，就有講其中的關鍵了，就是使用WebView提供的addJavascriptInterface()，這可以把Java的物件加到JavaScript runtime裡去，這樣JavaScript就可以使用這個物件。可以呼叫之後，那麼資料該怎麼傳遞呢??這牽涉到轉換的問題，而且Android只允許傳遞int、String等一些基礎類別，而不允許使用自訂類別，這就糟了。還好，這篇&lt;a href="http://blog.johnmckerrell.com/2011/01/21/working-with-android-addjavascriptinterface/"&gt;Working with Android addJavascriptInterface&lt;/a&gt;就有討論到這個問題，他的結論是使用JSON字串，這看來是最簡便的方法。JavaScript可以使用jQuery提供的parseJSON()與toJSON()來從字串轉成物件，或從物件轉為字串，而Java則可以用&lt;a href="http://wiki.fasterxml.com/JacksonDocumentation"&gt;jackson&lt;/a&gt;來轉換。&lt;a href="http://mobile.tutsplus.com/tutorials/mobile-web-apps/build-a-contacts-application-with-jquery-mobile-the-android-sdk-part-1/"&gt;Build a Contacts Application With jQuery Mobile &amp;amp; the Android SDK&lt;/a&gt;這篇是更完整的使用範例。&lt;br /&gt;在&lt;a href="http://developer.android.com/resources/articles/using-webviews.html"&gt;Using WebViews&lt;/a&gt;裡另外有提到WebView的setWebViewClient，這個其實是WebView的callback，讓你可以在WebView遇到一些特定狀況的時候，作一些處理。詳細的說明要參照&lt;a href="http://developer.android.com/reference/android/webkit/WebViewClient.html"&gt;WebViewClient&lt;/a&gt;這邊。&lt;br /&gt;如果嫌麻煩的話，是參考&lt;a href="http://www.anobii.com/books/%E5%BB%BA%E6%A7%8BAndroid%E6%87%89%E7%94%A8%E7%A8%8B%E5%BC%8F/9789862761540/01559b2758c0e5b5f8/" title="More about 建構Android應用程式"&gt;書裡&lt;/a&gt;的PhoneGap就好，書上介紹的步驟就只要寫HTML+CSS+JavaScript就好，不用特別再寫Java的部份，也不用裝eclipse，最後就用ant，就可以build出apk。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-544659216902617311?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/544659216902617311/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=544659216902617311' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/544659216902617311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/544659216902617311'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/webview.html' title='WebView'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-9105178692426154531</id><published>2011-11-21T21:47:00.001+08:00</published><updated>2011-11-21T21:48:18.603+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/11/9~2011/11/20)</title><content type='html'>&lt;ul&gt;&lt;li&gt;Rat Race(&lt;a href="http://www.imdb.com/title/tt0250687/" title="Rat Race (2001) - IMDb"&gt;IMDB&lt;/a&gt;,&lt;a href="http://en.wikipedia.org/wiki/Rat_Race_(film)" title="Rat Race (film) - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：瘋狂世界。這在網樂通上面看的，蠻有趣的片子。就一堆人玩了角子老虎，然後拿到特別的珠子，說有特別的禮物，然後就到樓上去。到了樓上，賭場主人出來宣佈說，現在開始比賽，誰先到Silver鎮，就可以拿到兩百萬美金。一開始大家都用不可置信的心情，以為是騙人的。豈料到了門外，大部份人就開始衝了，有的人不屑一顧，有的人在樓下睡著。不過到了中間的時候，大家都卯起來往Silver鎮前進。中間就發生很多很妙的事情，也交代了為什麼賭場主人要辦這比賽，原來是他們賭到沒什麼可以賭，就亂找花樣來賭，這個比賽就是其中之一。到了最後，大家都趕到小鎮，結果在爭奪的過程裡，鈔票被掛到熱氣球上，開始飄啊飄，飄到了募款晚會會場。一群人從舞台後面衝了進去，大家手上都抓了幾把鈔票。到了台上，主持人跑了出來，陰錯陽差的對話之下，變成了捐款，這群人後來也大器地把錢捐了出去。然後律師看到了賭場主人也出現在舞台邊，就接過麥克風，開始說，我們會來到這裡捐款，都要謝謝這個賭場主人，然後就宣佈，賭場主人會捐出在大會募得金額的兩倍，片子就在賭場主人哭喪臉，眾人歡呼的情況下結束了。&lt;/li&gt;&lt;li&gt;劍雨(&lt;a href="http://www.imdb.com/title/tt1460743/" title="Jianyu (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://zh.wikipedia.org/wiki/%E5%8A%8D%E9%9B%A8" title="劍雨 - 维基百科，自由的百科全书"&gt;Wikipedia&lt;/a&gt;)。挺不錯的武俠片。片頭的動畫蠻精緻的，我很喜歡，把前因都交代挺清楚的。黑石是個暗殺組織，細雨是裏面頂尖的殺手，殺了張海瑞全家，奪得了羅磨遺體。後來她就帶著遺體逃走，途中遇到陸竹，這場相遇，陸竹死了，而她決定易容隱居。隱居的時候就遇到了阿生，並且被感動，結了婚。可是後來還是被發現了，黑石要脅她，幫忙從崆桐派手中搶回另一半遺體，沒辦法，為了阿生，只好幹了。後來搶到，黑石發生內鬨，細雨不想惹事，就把遺體留下，說今後再沒瓜葛，可是還是被轉輪王打傷。細雨勉勉強強逃了回去，叫阿生快逃，然後就昏了。阿生把細雨扶到床上以後，並沒有逃走，反而開始在地上挖洞。黑石的追兵雷彬跟綻青來了，準備要動手。阿生說，請等我一下，說完把劍拔了出來，開始磨劍。黑石的追兵從劍認出了阿生的真正身份，原來是張海瑞的兒子，他的心臟異位，所以並沒有被細雨殺死，還被神醫給救了，並易了容。黑石追兵在錯愕之下，佔了劣勢，後來雷彬受了重傷，綻青逃走。阿生把細雨帶去神醫那邊，然後跑去約轉輪王出來決戰。細雨沒多久就醒了，也跟著趕去，趕去前，神醫意味深長的說，這真是天意啊。最後就是阿生揭露了自己的身份，細雨知道了以後，很難過，但仍然決意由自己承擔一切，她先故意把阿生給刺傷，並讓他服下龜息散。跟轉輪王的決戰，靠著陸竹之前的指點，血戰之下贏的僥倖，自己也傷得很重。看似死亡但仍聽得到聲音的阿生也知道了一切，醒來以後，意想不到的抱著重傷的細雨離去。整個故事我還蠻喜歡的，特別是阿生跟細雨從相戀到背叛的那幾段，很讓人唏噓啊。看完才發現林熙蕾跟楊紫瓊還蠻像的，然後就是大S跟幻術師的那兩個角色不知道是戲份被抽掉了還是剪接的關係，感覺上挺雞肋的。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-9105178692426154531?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/9105178692426154531/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=9105178692426154531' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/9105178692426154531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/9105178692426154531'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/201111920111120.html' title='電影流水帳(2011/11/9~2011/11/20)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6830878199116366976</id><published>2011-11-16T15:48:00.001+08:00</published><updated>2011-11-16T15:50:51.318+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='greasemonkey'/><title type='text'>學校教材的下載</title><content type='html'>&lt;p&gt;有些科目的教材好多，用滑鼠可能會按到死。本想用 curl 來硬幹的，可是從登入頁面一路解析到教材下載頁面的時候，發現 ASP.NET 的頁面還真是難搞，後來選擇放棄。&lt;/p&gt;&lt;p&gt;於是想了一下看Firefox有沒有現成的AddOn可用，有，的確是有，那是DownthemAll，可是，教材下載頁面的"下載"是用javascript埋起來，所以必須解析div的onclick屬性，把真正的連結拿出來。這時候GreaseMonkey又再次派上用場，就是你啦!!於是就弄了這個userscript，他會在原來的下載圖形下方增加一個download連結，這樣DownthemAll就可以抓到。要用的話，可以直接到&lt;a href="http://userscripts.org/scripts/show/118214"&gt;userscripts.org這邊安裝&lt;/a&gt;，下面是原始碼：&lt;/p&gt;&lt;script type="text/javascript" src="https://gist.github.com/1369512.js?file=stdinfosys_meterial_download.user.js"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6830878199116366976?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6830878199116366976/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6830878199116366976' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6830878199116366976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6830878199116366976'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/blog-post_16.html' title='學校教材的下載'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3181154815934061609</id><published>2011-11-14T10:44:00.001+08:00</published><updated>2011-11-14T10:45:27.942+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='cups'/><category scheme='http://www.blogger.com/atom/ns#' term='centos'/><category scheme='http://www.blogger.com/atom/ns#' term='printer'/><category scheme='http://www.blogger.com/atom/ns#' term='canon'/><category scheme='http://www.blogger.com/atom/ns#' term='samba'/><title type='text'>Canon BJC-240+cups+SAMBA+CentOS</title><content type='html'>Canon BJC-240 以Parallel 轉 USB 接到電腦上，接上以後是在/dev/usb/lp0。&lt;br /&gt;&lt;br /&gt;先設置一下跟cups相關的部份，你要先確定自己在sys群組裡，因為cups會需要權限來寫入設定檔。&lt;br /&gt;&lt;br /&gt;cups，我是以web介面去安裝印表機，打開瀏覽器，在網址列輸入localhost:631，然後選新增印表機，首先會要求你輸入名稱以及描述，名稱裡不可以有空白。下一步之後，會要你選介面，這時候就選有偵測到的USB介面。接著會要選驅動程式，我試過raw了，不行，我改用了generic postscript。接著會要你選queue的部份，只有一個可以讓你選，就選吧。至此，cups會要你輸入帳號跟密碼，請輸入你的帳號跟密碼即可。&lt;br /&gt;&lt;br /&gt;接著是SAMBA。SAMBA的部份比較簡單，打開 /etc/samba/smb.conf，確定 printcap name = /etc/printcap 、 printing = cups，然後將 [printers] 下的 guest ok、writable、public、use client driver 都設為 yes 即可，如果沒看到就自己補上。接著重新啟動SAMBA。&lt;br /&gt;&lt;br /&gt;至此，Windows就可以連上，並且去新增印表機了。&lt;br /&gt;&lt;br /&gt;p.s. 這邊不多贅述SAMBA的權限控管，就看是用user或share或其他什麼的，總之要有權限可以存取server就是了。&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3181154815934061609?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3181154815934061609/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3181154815934061609' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3181154815934061609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3181154815934061609'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/canon-bjc-240cupssambacentos.html' title='Canon BJC-240+cups+SAMBA+CentOS'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-550421913737080395</id><published>2011-11-14T10:42:00.001+08:00</published><updated>2011-11-14T10:42:01.979+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wordpress'/><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='ssh'/><title type='text'>wordpress以SSH自動更新</title><content type='html'>考量到以後wordpress的更新問題，可是又不想開FTP的洞，所以研究了一下不使用FTP的方式，大致上就是照這一篇&lt;a href="http://kbeezie.com/view/wordpress-autoupdate-ssh/"&gt;Wordpress Automatic Update with SSH&lt;/a&gt;來操課即可。第一次更新失敗，在調整 wp-content/plugins 與 wp-content/themes 以後，就解決了。我把這兩個目錄的owner調整為apache:groupname，然後permission調整為0775。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-550421913737080395?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/550421913737080395/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=550421913737080395' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/550421913737080395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/550421913737080395'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/wordpressssh.html' title='wordpress以SSH自動更新'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1045948546695736246</id><published>2011-11-11T09:22:00.001+08:00</published><updated>2011-11-11T09:24:23.809+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wordpress'/><category scheme='http://www.blogger.com/atom/ns#' term='blog'/><title type='text'>wordpress開多站(blog)</title><content type='html'>好久沒用，印象中有WPMU，上去&lt;a href="http://wordpress.org/"&gt;wordpress&lt;/a&gt;看，發現已經被廢棄了，現在只有一套wordpress。&lt;br /&gt;一開始是找到&lt;a href="http://codex.wordpress.org/Installing_Multiple_Blogs"&gt;這篇Installing Multiple Blogs&lt;/a&gt;，但裏面介紹的方法，第1種是教你把wordpress放到多個目錄，然後用多個資料庫來切，第2種也是把wordpress放到多個目錄，然後以table的prefix來切。不管怎麼樣，這兩種方法都會讓維護變得麻煩。後來是看到&lt;a href="http://codex.wordpress.org/Create_A_Network"&gt;這篇Create A Network&lt;/a&gt;，這個是3.0以後才有的新功能，正是我要的。&lt;br /&gt;大致描述一下方法，我用的是分目錄的方法，而非分網域的方法：&lt;br /&gt;&lt;ol&gt;&lt;li&gt;先把wordpress裝好。看你是要放在根目錄還是建個wordpress的目錄來放都可以。&lt;/li&gt;&lt;li&gt;改wp-config.php，找到註解"Happy blogging!"，然後把 define('WP_ALLOW_MULTISITE', true); 放在該行上方。&lt;/li&gt;&lt;li&gt;重新登入，你可以在管理介面的左邊找到 Tools，裏面多了一個Network Setup，點選，然後填資料，Network Title填你要的名字，Admin E-Mail address填你的e-mail位址，點選Install。&lt;/li&gt;&lt;li&gt;依照畫面的顯示去修改wp-config.php、在wordpress目錄下建立.htaccess並且在wp-content/下建立blogs.dir目錄。這裡可能會遇到的陷阱，比較常發生的是.htaccess未生效，請檢查httpd.conf，看有無載入mod_rewrite，然後檢查AllowOverride，AllowOverride不能是None，應該填All。我個人是因為眼花，少貼了一行在wp-config.php裡，導致我重來了好幾次。第2塊說要改_SALT的那邊，我都沒改，這邊我要再查一下，看要怎麼產生，再填入。不過看起來對後面沒啥影響。&lt;/li&gt;&lt;li&gt;登出，再登入，到右上角的下拉選單，就可以發現有Network Admin，選了這個以後，就可以去管理站點了，像是建立新站、刪除站點...等等的。這樣就大功告成了。&lt;/li&gt;&lt;/ol&gt;&lt;a href="http://codex.wordpress.org/Create_A_Network"&gt;Create A Network&lt;/a&gt;的後面還有介紹一些plugin，讓你可以每個站點有自己的plugin，不需要透過Administrator來安裝。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1045948546695736246?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1045948546695736246/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1045948546695736246' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1045948546695736246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1045948546695736246'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/wordpressblog.html' title='wordpress開多站(blog)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2726085844984625906</id><published>2011-11-08T18:40:00.001+08:00</published><updated>2011-11-08T18:40:51.610+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/10/8~2011/11/8)</title><content type='html'>&lt;ul&gt;&lt;li&gt;Transformers: Dark of the moon(&lt;a href="http://www.imdb.com/title/tt1399103/" title="Transformers: Dark of the moon"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Transformers:_Dark_of_the_Moon"&gt;Wikipedia&lt;/a&gt;)，中譯：變形金剛3。故事很簡單，但加入了感情衝突的片段，一個是背叛，一個是嫉妒。背叛，是Autobot的前任領袖，原來很早以前他駕船逃出Cybertronian，是因為已經跟Decepticons談好條件，所以帶著Pillars飛走，可是卻墜落在月球的背面。之後，Decepticons故意讓Optimus Prime知道這個消息，讓他去把Sentinel Prime救回來。想不到Sentinel Prime被救回之後，搶走Pillars，打算把Cybertronian移動到地球，把地球人當作奴隸。第二個背叛則是人類，美國總統跟國會因為Deceptions的威脅，而決議把能幫助地球人的Autobots給遣返。而嫉妒，則是Sam嫉妒他女友的上司，想不到他女友的上司家族已經跟Deceptions狼狽為奸了好幾十年了。在一堆梗都交代以後，那就是開打了。Deceptions先開始打Chicago，打的亂七八糟，這裡我是很納悶，不是說要讓地球人當奴隸嗎?怎麼還亂殺?殺完是有人可以當奴隸嗎??然後Sentinel Prime就用Pillars準備開始傳送了。假裝離去的Optimus Prime回頭跟Sam的人一起殺入Chicago，一陣亂打之後，當然Autobots就贏了，故事結束。&lt;/li&gt;&lt;li&gt;武俠(&lt;a href="http://www.imdb.com/title/tt1718199/" title="武俠"&gt;IMDB&lt;/a&gt;, &lt;a href="http://zh.wikipedia.org/wiki/%E6%AD%A6%E4%BF%A0_%28%E9%9B%BB%E5%BD%B1%29"&gt;Wikipedia&lt;/a&gt;)。我覺得還蠻好看的。劉金喜一開始因為有強盜，被迫出手，但卻以偽裝的方法殺了他們。徐百九來查案，非常懷疑劉金喜，一陣試探之後，雖然金喜自白了一切，但徐百九還是覺得很擔心，後來發現他是七十二地煞的人，唐龍。這一段的試探相當好看，也很搶戲，前面的鋒頭都被他搶走了。於是徐百九回縣城找人來幫忙，好不容易跟前妻借了錢，找到人要去捉金喜，結果卻讓七十二地煞的人找上了劉金喜。惠英紅演的十三娘先出現在金喜的村子裡，大開殺戒，這段真的很莫名其妙的開始，然後莫名其妙地在十三娘掉到河裡結束。徐百九帶著人到了村子，發現村子被打的亂七八糟，村民也逃難去了，而他帶的人，也因為不想淌渾水，而想走避。然後他遇到金喜，他的仁慈之心又出現，決定幫金喜，所以他用針灸幫金喜假死，但只能假死15分鐘。在出村子的時候，遇到了七十二地煞，七十二地煞的領頭確定金喜死了，領著人唱悲歌。唱悲歌唱太久了，徐百九趕緊救人，金喜醒來，發現四周都是七十二地煞的人，他坐起身開始笑，他知道失敗了。然後他趁勢抽了七十二地煞領頭的刀，把自己的手砍斷，說明自己脫離七十二地煞的決心。七十二地煞知道他的決心以後，告訴他，你還有一關，是教主，他在你家裡。於是最後的大魔王出現了，他挾持著金喜的兒子跟妻子，在哈拉一陣以後，教主不肯放他走，說要一人換一人，想把小兒子帶走。金喜為了救妻兒而展開拼博，可是教主非常厲害，一身橫練的金鐘罩，刀槍不入，再加上拳勁驚人，斷了左手的金喜根本沒勝算。最後在徐百九跟老天的幫助下，終於把教主給殺了，可是徐百九也受了嚴重的內傷死去。徐百九看著即將死去的徐百九那一幕，有點像是死神的精準度裡的情節。金喜活了下來，成功地擺脫了唐龍的身份，繼續跟妻兒過著平淡的日子。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2726085844984625906?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2726085844984625906/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2726085844984625906' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2726085844984625906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2726085844984625906'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/20111082011118.html' title='電影流水帳(2011/10/8~2011/11/8)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6762201667916574458</id><published>2011-11-04T16:06:00.001+08:00</published><updated>2011-11-04T16:06:49.955+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c/c++'/><title type='text'>ANativeWindow::query = query</title><content type='html'>在FramebufferNativeWindow.cpp裡看到這樣的用法：ANativeWindow::query = query; 回頭看ANativeWindow的定義，query是一個函式指標，那照理來說應該不能這樣指定，應該要在ANativeWindow實體化以後才可以。好吧，我搞迷糊了。&lt;br /&gt;重新追蹤代碼：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;query 是一個在 FramebufferNativeWindow 裡的 static function&lt;/li&gt;&lt;li&gt;FramebufferNativeWindow其實繼承了ANativeWindow，所以在FramebufferNativeWindow裡使用ANativeWindow::query，就是指定父類別的query。&lt;/li&gt;&lt;/ul&gt;就這兩點看下來，可以使用ANativeWindow::query=query這點，就不會覺得奇怪了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6762201667916574458?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6762201667916574458/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6762201667916574458' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6762201667916574458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6762201667916574458'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/anativewindowquery-query.html' title='ANativeWindow::query = query'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-4098813743304561835</id><published>2011-11-02T18:43:00.001+08:00</published><updated>2011-11-02T18:45:43.363+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mmap'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='memory'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>記憶體配置</title><content type='html'>&lt;p&gt;在Android的gralloc那邊看到奇妙的記憶體配置方法，它是先開啟 /dev/zero，然後做 mmap，配出來的記憶體可以給其他process使用。上網查了一下，就可以找到詳細的說明，然後，之前買的 &lt;a href="http://www.man7.org/tlpi/"&gt;The Linux Programming Interface&lt;/a&gt;裏面就有寫，是說，這本書我才翻沒幾頁說...真是太偷懶了。&lt;/p&gt;&lt;p&gt;你可以參考這些連結：&lt;ul&gt;&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/4779188/how-to-use-mmap-to-allocate-a-memory-in-heap"&gt;How to use mmap to allocate a memory in heap?&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://man7.org/tlpi/code/online/dist/mmap/anon_mmap.c.html"&gt;mmap/anon_mmap.c&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-4098813743304561835?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/4098813743304561835/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=4098813743304561835' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4098813743304561835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4098813743304561835'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/11/blog-post.html' title='記憶體配置'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-522419741046720732</id><published>2011-10-31T17:34:00.001+08:00</published><updated>2011-10-31T17:34:46.215+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>UEFI secure boot impact on Linux閱讀小記</title><content type='html'>文章：&lt;a href="http://www.redhat.com/about/news/blog/red-hat-the-linux-foundation-and-canonical-publish-white-paper-on-unfied-extensible-firmware-interface"&gt;Red Hat, The Linux Foundation and Canonical Publish White Paper on Unified Extensible Firmware Interface&lt;/a&gt;的最後有個連結，點選以後可以下載一份PDF文件，標題是UEFI secure boot impact on Linux。文件的前面很仔細的分析了UEFI的種種好處跟壞處，然後分析了對Linux的影響。我有大略看過一遍，最主要的問題都是在於key，UEFI開機時會拿key去驗證bootloader，如果驗證失敗，就不再繼續開機。可是對Linux來說，不可能針對每個OEM製造的機器去簽署bootloader啊，因為這樣會要做很多份bootloader，太麻煩。如果要改那個key的話，又沒辦法。中間後段的時候還有提到一些有的沒的，我偷懶跳過去了，直接看最後的結論。最後就提出幾點建議：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;建議OEM可以提供很方便可以開關secure boot的介面&lt;/li&gt;&lt;li&gt;建議OEM(在BIOS廠商的協助下)可以在系統軔體裡提供標準機制去設置key&lt;/li&gt;&lt;li&gt;建議以setup模式賣出，讓作業系統去負責安裝初始key的動作&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-522419741046720732?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/522419741046720732/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=522419741046720732' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/522419741046720732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/522419741046720732'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/uefi-secure-boot-impact-on-linux.html' title='UEFI secure boot impact on Linux閱讀小記'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8215651322114861734</id><published>2011-10-31T16:58:00.001+08:00</published><updated>2011-10-31T16:58:16.073+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='http'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>BaseHTTPServer</title><content type='html'>模組的文件簡單到不行，而網路上查到的文件大多都是跟你講怎麼弄一個簡單的HTTP Server，真的要寫一個簡單的應用時，卻沒告訴你該怎麼去parse參數。這篇有答案：&lt;a href="http://blog.doughellmann.com/2007/12/pymotw-basehttpserver.html"&gt;PyMOTW: BaseHTTPServer&lt;/a&gt;&lt;br /&gt;基本上，do_GET時，要用 parsed_path = urlparse.urlparse(self.path) 。而 do_POST 時，要&lt;br /&gt;&lt;pre class="python" name="code"&gt;form = cgi.FieldStorage(&lt;br /&gt;  fp=self.rfile, &lt;br /&gt;  headers=self.headers,&lt;br /&gt;  environ={'REQUEST_METHOD':'POST',&lt;br /&gt;                 'CONTENT_TYPE':self.headers['Content-Type'],&lt;br /&gt;                 })&lt;br /&gt;&lt;/pre&gt;拿到的 form，可以用 form["your_key"] 去找到指定參數的值，但拿到的值，型態是MiniFieldStorage，要用 value 屬性去拿真正的值，也就是 form["your_key"].value 才是真正的值，&lt;a href="http://blog.doughellmann.com/2007/12/pymotw-basehttpserver.html"&gt;該文裡&lt;/a&gt;也有上傳檔案處理的範例。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8215651322114861734?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8215651322114861734/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8215651322114861734' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8215651322114861734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8215651322114861734'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/basehttpserver.html' title='BaseHTTPServer'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7614970985441582315</id><published>2011-10-28T15:22:00.003+08:00</published><updated>2011-10-28T15:22:29.137+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='twisted'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>twisted筆記</title><content type='html'>原本想用deferred搭subprocess去做的，想不到twisted已經有包這部份了，就呼叫reactor.spawnProcess就好，文件可以看&lt;a href="http://twistedmatrix.com/documents/current/core/howto/process.html"&gt;Twisted Documentation: Using Processes&lt;/a&gt;。主要要實作ProcessProtocol，這可以用來知道process狀態，或是拿process輸出做處理...等等的。&lt;br /&gt;作HTTP Server時，會要實作&lt;a href="http://twistedmatrix.com/documents/11.0.0/api/twisted.web.resource.Resource.html"&gt;twisted.web.resource.Resource&lt;/a&gt;，render_GET裡的request可以參考&lt;a href="http://twistedmatrix.com/documents/11.0.0/api/twisted.web.http.Request.html"&gt;twisted.web.http.Request : API documentation&lt;/a&gt;，引用參數，可以用args屬性，這是一個dictionary。除了render_GET，當然也可以用render_POST、request_HEAD...&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7614970985441582315?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7614970985441582315/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7614970985441582315' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7614970985441582315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7614970985441582315'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/twisted.html' title='twisted筆記'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-425610389633809494</id><published>2011-10-27T14:39:00.003+08:00</published><updated>2011-10-27T14:40:30.886+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='yahoo'/><category scheme='http://www.blogger.com/atom/ns#' term='woeid'/><category scheme='http://www.blogger.com/atom/ns#' term='twitter'/><title type='text'>woeid</title><content type='html'>&lt;p&gt;在Twitter API文件：&lt;a href="https://dev.twitter.com/docs/api/1/get/trends/%3Awoeid"&gt;GET trends/:woeid&lt;/a&gt;裡的woeid原來是&lt;a href="http://developer.yahoo.com/geo/geoplanet/"&gt;Yahoo! Where On Earth ID&lt;/a&gt;，由Yahoo提出的。&lt;/p&gt;&lt;p&gt;1 表示全球，要知道自己所在地區的trends，還得要先用Yahoo的Service去查到所在的woeid，才能再去問Twitter。&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-425610389633809494?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/425610389633809494/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=425610389633809494' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/425610389633809494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/425610389633809494'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/woeid.html' title='woeid'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-541673861283409704</id><published>2011-10-27T10:48:00.001+08:00</published><updated>2011-10-27T10:48:35.800+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='algorithm'/><title type='text'>Tail call</title><content type='html'>簡單的說是遞迴的特例，好處是可以避免call stack的損耗。Stack Overflow上的回答蠻清楚的，還附了python範例：&lt;a href="http://stackoverflow.com/questions/33923/what-is-tail-recursion"&gt;algorithm - What is tail-recursion?&lt;/a&gt;，英文維基百科上的說明：&lt;a href="http://en.wikipedia.org/wiki/Tail_call"&gt;Tail call&lt;/a&gt;比中文維基百科上的來的好。&lt;br /&gt;跟遞迴比較大的差別，目前我認知到的是會利用另外一個參數來傳遞結果，實際應用上應該只要是遞迴都可以改寫成Tail call吧，再想想可以怎麼應用。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-541673861283409704?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/541673861283409704/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=541673861283409704' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/541673861283409704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/541673861283409704'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/tail-call.html' title='Tail call'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-4033804301028507669</id><published>2011-10-26T15:45:00.001+08:00</published><updated>2011-10-26T15:45:28.278+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='twitter'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Mining the Social Web - Example 1-3</title><content type='html'>&lt;p&gt;實作這個範例時，出現錯誤：TwitterHTTPError: Twitter sent status 404 for URL: trends.json using parameters: () &lt;/p&gt;&lt;p&gt;有人回報給作者：&lt;a href="https://github.com/ptwobrussell/Mining-the-Social-Web/issues/3"&gt;Example 1-3 fails with 404 errors&lt;/a&gt;，也有人去 StackOverflow 上問：&lt;a href="http://stackoverflow.com/questions/5521848/problem-with-twitter-package-by-sixohsix"&gt;Problem with Twitter package by sixohsix&lt;/a&gt;，可是都沒有解決問題的答案。&lt;/p&gt;&lt;p&gt;答案在&lt;a href="https://dev.twitter.com/docs/api/1/get/trends"&gt;twitter API -GET trends&lt;/a&gt;上：因為deprecated了。要改用GET trends/:woeid，也就是像這樣的網址 http://api.twitter.com/1/trends/1.json  才可以取得。&lt;/p&gt;&lt;p&gt;換言之，程式要改為：&lt;pre name="code" class="python"&gt;import twitter&lt;br /&gt;t=twitter.Twitter(api_version='1')&lt;br /&gt;t.trends(id=1)&lt;/pre&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-4033804301028507669?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/4033804301028507669/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=4033804301028507669' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4033804301028507669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4033804301028507669'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/mining-social-web-example-1-3.html' title='Mining the Social Web - Example 1-3'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-5478502540843079074</id><published>2011-10-20T13:46:00.001+08:00</published><updated>2011-10-20T13:46:25.483+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='greasemonkey'/><title type='text'>Greasemonkey-輔助續借學校圖書</title><content type='html'>還是忍不住寫了，畢竟每次要為十幾本書打勾還是蠻累的。基本上就是多加兩個按鈕，一個幫我全打勾，一個幫我取消打勾。不過第二個按鈕好像永遠都用不到，這就是所謂的 over design 嗎? :-p&lt;script src="https://gist.github.com/1300501.js?file=idv.elleryq.library.continue.js"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-5478502540843079074?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/5478502540843079074/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=5478502540843079074' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5478502540843079074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5478502540843079074'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/greasemonkey.html' title='Greasemonkey-輔助續借學校圖書'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3930962052769337880</id><published>2011-10-19T11:54:00.000+08:00</published><updated>2011-10-19T11:54:10.919+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>"How to install Ubuntu on Android"觀後感</title><content type='html'>&lt;p&gt;看完還是順手紀錄一下，要不然就白花這25分鐘看了。&lt;/p&gt;&lt;p&gt;簡單的說，要先 root 並且裝上 busybox，接著下載 bootubuntu，這是預先編譯好的 ARM Ubuntu image，放到 SD Card 上的 ubuntu目錄下。然後用 adb shell 連上，執行 su，到 SD Card 的 ubuntu 目錄下，執行 bootubuntu，就進 ubuntu 環境了。有了 ubuntu 環境，就能執行 apt-get，立馬就可以裝上 openssh-server、tightvncserver，openssh-server 是為了有更好的終端機環境可用，因為 Windows 的命令提示字元不夠理想。tightvncserver 則是要給 market 上的 vnc client 用的，執行 vnc client 連到本機上的 vnc server，就有 Ubuntu 畫面跑出來了。&lt;/p&gt;&lt;iframe width="560" height="315" src="http://www.youtube.com/embed/YbunTRzEQCI" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3930962052769337880?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3930962052769337880/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3930962052769337880' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3930962052769337880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3930962052769337880'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/how-to-install-ubuntu-on-android.html' title='&quot;How to install Ubuntu on Android&quot;觀後感'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://img.youtube.com/vi/YbunTRzEQCI/default.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-4250078250294794361</id><published>2011-10-13T10:57:00.000+08:00</published><updated>2011-10-13T10:57:11.325+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='virtualenv'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='centos'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>CentOS 5裝Python 2.6</title><content type='html'>先確定有EPEL，然後:&lt;br /&gt;$sudo yum install python26&lt;br /&gt;再裝 python26-virtualenv python-pip:&lt;br /&gt;$yum install python26-virtualenv python-pip&lt;br /&gt;&lt;br /&gt;製作環境：&lt;br /&gt;$mkdir -p python-envs&lt;br /&gt;$cd python-envs&lt;br /&gt;$virtualenv-2.6 --no-site-packages --distribute myenv&lt;br /&gt;$pip-python install -E myenv yolk&lt;br /&gt;&lt;br /&gt;啟用:&lt;br /&gt;$source myenv/bin/activate&lt;br /&gt;$yolk -l&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-4250078250294794361?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/4250078250294794361/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=4250078250294794361' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4250078250294794361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4250078250294794361'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/centos-5python-26.html' title='CentOS 5裝Python 2.6'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8750253831940216398</id><published>2011-10-07T16:04:00.000+08:00</published><updated>2011-10-13T11:02:06.664+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/5/26~2011/10/7)</title><content type='html'>快年底了...&lt;br /&gt;&lt;ul&gt;&lt;li&gt;奶奶強盜團(&lt;a href="http://www.imdb.com/title/tt1832533/" title="Yukhyeolpo kangdodan (2010) - IMDb"&gt;IMDB&lt;/a&gt;)。3個奶奶好不容易攢了錢，要去夏威夷玩，很開心的去預約了行程，然後要付款，可是旅行社卻告訴她們要把錢存到戶頭去才可以。去到銀行存款，卻遇到搶案，存摺陰錯陽差地沒有刷到，銀行經理就跳出來說，不算，你們怎麼證明有拿八百萬來存款?於是，一番哭天搶地之後，還是沒能拿回錢。她們決心自己去找到搶匪，把錢要回來。很幸運，她們找到其中一個，不過這傢伙手上沒有錢，因為他被背叛了。這下絕望了，本想說再撐幾年繼續攢錢的，可是其中有一個人已經沒有時間了，她得了癌症。沒辦法，只能靠武力解決了，於是她們就要脅搶匪教她們搶銀行。經過一番訓練之後，她們要出擊了。第一次被呼弄，第二次真的就搶了，也順利搶到，可是來不及逃出，就被警察包圍了。她們跟人質訴說了她們遇到的情況後，人質深感同情，反過來幫她們逃出去(斯德哥爾摩症候群?!)。展開一段追逐之後，最後還是在機場被逮，瑯噹入獄。在獄中，得癌症的那個奶奶就病死了。後面真的很感人，眼淚差點就流下來，相當好看的片子。&lt;/li&gt;&lt;li&gt;Piranha 3D(&lt;a href="http://www.imdb.com/title/tt0464154/" title="Piranha (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Piranha_3D" title="Piranha 3D - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：3D食人魚。超簡單的劇情，可是看起來很爽，有辣妹、有裸體、有殺戮、有血也有肉。食人魚因為地震的關係從原本與世隔絕的洞窟中被放了出來，開始肆虐。在河邊發現片頭老人的屍體之後，下水探勘的生物學家也被幹掉，活著的人趕緊走人，然後運氣不錯，有逮到一隻魚，就去找魚類博士(這是演"回到未來"的那個怪博士!!)鑑定，說是遠古時代的超級食人魚。媽呀~太可怕了，警長就趕緊去疏散湖邊的人，沒人鳥...想當然爾，食人魚展開一場殺戮。警長的兒子情竇初開，不想幫警長媽媽(警長是女生，是好久沒出來演的伊莉莎白蘇)帶孩子，就用錢收買妹妹，叫弟弟妹妹們乖乖待在家裡，自己就跑出去看有料的了。弟弟妹妹不安份，也跟著跑出去，後來被困在島上。警長的兒子跟拍寫真的大叔與正妹們，後來也遇到食人魚了，就趕快逃走。路上遇到困在島上的弟弟妹妹，就要脅拍寫真的大叔說，我媽是警長，快過去救人~然後就救人，救完人，船就觸礁了。該死，食人魚也來了，又是一場殺戮。警長兒子的女友被困住，該死的人都死了，警長兒子趕緊向老媽求救，最後警長就救了她的兒女，炸死一堆魚。最後的最後，那個魚類博士又打電話來，說你們抓到的這隻還不是成魚喔，應該還有爸爸媽媽在活動，接著，我被嚇到從椅子上彈起來。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8750253831940216398?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8750253831940216398/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8750253831940216398' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8750253831940216398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8750253831940216398'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/20115262011107.html' title='電影流水帳(2011/5/26~2011/10/7)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6607199921282498603</id><published>2011-10-05T16:15:00.001+08:00</published><updated>2011-10-05T16:17:05.622+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='z4root'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><category scheme='http://www.blogger.com/atom/ns#' term='root'/><title type='text'>z4root</title><content type='html'>網路上可以找到很多文章，不過大多都是講怎麼用，而沒有提到原理，所以就想找找看。&lt;br /&gt;&lt;br /&gt;最初找到的是這篇：&lt;a href="http://blog.claudxiao.net/2011/04/android-adb-setuid/"&gt;Android adb setuid提权漏洞的分析&lt;/a&gt;，裡面就寫得很清楚了，他寫的不是 z4root，而是 RageAgainstTheCage，主要是靠著一直建 process，建到極限值，然後試著砍掉 adb，再靠 adb 程式沒有檢查 setuid 傳回值的漏洞來取得 root 權限。一般的 daemon 程式都是這樣子，一開始是 root，之後會用 setuid 切換身份，所以在 setuid 之前都是 root。而 setuid 通常不會失敗，但是因為可用的程序限制到了，才失敗 (參考 kernel/sys.c 裡的 set_user)。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;好，那跟 z4root 又有什麼關係？還好 z4root 有&lt;a href="http://code.google.com/p/z4root/"&gt;源碼&lt;/a&gt;。&lt;br /&gt;&lt;br /&gt;z4root 裡就有用到 RageAgainstTheCage，z4root.java 是主要的 Activity，當你 click root 按鈕值，會啟動 Phase1 Activity，這邊就會把包成 resource 的 RageAgainstTheCage 寫到z4root的應用程式目錄下，然後變更其權限並且執行。噹噹，執行完以後，當然 adb 就有 root 權限了。&lt;br /&gt;&lt;br /&gt;然後 Phase1 有 thread 去持續檢查執行 RageAgainstTheCage 的程序，如果成功了，會利用 Alarm 服務去啟動 Phase2。Phase2 這邊我有點不太明白，最後是將 su、busybox、SuperUser.apk 都搬到系統分割區了，然後就重開機，可是這個時候怎麼會有權限可以作這些事情呢? 如果照上面的 RageAgainstTheCage 來看，我猜想應該是在執行 RageAgainstTheCage 時，把程序數衝到最大限制，然後之後所執行的程序其實都是 root 啟動的，要切換使用者身份時失敗，所以之後的程序都是 root，也因此 Phase2 Activity 也有同等的 root 權限。這邊因為跟 java 的 thread 作法不是很熟，所以就不了了之。&lt;br /&gt;&lt;br /&gt;z4root 最後是重開機，此時已經有埋必要的 su 跟 SuperUser.apk 在系統裡，也就有了可以 root 的可能。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6607199921282498603?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6607199921282498603/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6607199921282498603' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6607199921282498603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6607199921282498603'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/10/z4root.html' title='z4root'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8370098273152093056</id><published>2011-09-30T10:48:00.001+08:00</published><updated>2011-09-30T10:48:21.305+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mindmap'/><category scheme='http://www.blogger.com/atom/ns#' term='note'/><title type='text'>心智圖練習-買Notebook</title><content type='html'>&lt;a href="http://www.flickr.com/photos/elleryq/6196971086/" title="Flickr 上 elleryq 的 SurveyNotebook1"&gt;&lt;img src="http://farm7.static.flickr.com/6163/6196971086_384cb9d578.jpg" width="500" height="164" alt="SurveyNotebook1"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8370098273152093056?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8370098273152093056/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8370098273152093056' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8370098273152093056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8370098273152093056'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/09/notebook.html' title='心智圖練習-買Notebook'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm7.static.flickr.com/6163/6196971086_384cb9d578_t.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7059163000389928907</id><published>2011-09-28T17:08:00.002+08:00</published><updated>2011-09-28T17:08:57.075+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><title type='text'>老師的喪禮</title><content type='html'>在教師節談老師的喪禮，好像不是很適合。不過我上周六(9/24)的的確確去參加了導師的喪禮。&lt;br /&gt;雖然相處只有一年，時間不是很長，但老師的笑聲跟爽朗讓我有很深的印象，另外，也因為導師的喪禮是以天主教/基督教(真的很抱歉，我實在搞不清楚)的形式來舉行，所以我就毅然決然地參加了。&lt;br /&gt;&lt;br /&gt;時間是在13:00，喪禮很準時的開始了。一開始是唱詩、福音，然後是師丈、老師的哥哥跟老師的好朋友出來講話，在邊講話的同時，後面還放著老師的生平照片投影片，從小時候到高中、大學學生時代，再到結婚、出國玩的照片，這邊真的很感人、很催淚，我眼淚都盈框了。等到講完，是證道，邀請了主任牧師來證道，這邊我要跟老師說抱歉，我差點就睡著，因為證道只有兩個重點，第一個是要把握現在，珍惜生命，第二個，就是講老師在神的引領下，到了天國，信了神，以後就可以再見到老師。再來，就又是唱詩，然後追思。最後可以再去看老師最後一面，我沒去看。&lt;br /&gt;&lt;br /&gt;這樣的喪禮我覺得除掉證道以外，我很能接受，所以我的喪禮以後就簡單舉行吧，沒有人上台講對我的懷念也沒關係，就大家看完投影片(投影片我看我自己在死前做好好了，才不會沒人做)，一起默哀個三分鐘，然後把遺體丟去火葬就好。總之，這次的喪禮對我來說是一個很特別的體驗。&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7059163000389928907?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7059163000389928907/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7059163000389928907' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7059163000389928907'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7059163000389928907'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/09/blog-post.html' title='老師的喪禮'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-4223426450796228974</id><published>2011-09-16T17:13:00.000+08:00</published><updated>2011-09-16T17:13:05.350+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='qrcode'/><category scheme='http://www.blogger.com/atom/ns#' term='barcode'/><category scheme='http://www.blogger.com/atom/ns#' term='zxing'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'></title><content type='html'>zxing的Android client 端，是直接不斷的進行自動對焦的動作，然後接 Camera 的 Preview，這時候接出來的影像是 YUV 格式的，然後就直接去做判讀。所以，我當下的想法是在這邊直接去讀取一個 YUV 格式的影像檔，讀完就給 zxing decoder 去判讀，但是失敗。我認為可能是我轉換出來的 YUV 有問題。我是這樣轉換的，先用 ImageMagick 的 convert 把 png 轉成 ppm，再用 ppmtoyuv 轉成 yuv。&lt;br /&gt;&lt;br /&gt;後來去看了 zxing 的 JavaSE client，他是用 awt 去做影像轉換，就想，可以把 awt 移植到 Android 去嗎? 上網找了一下，還真的有人做，只是後來專案就沒再開發了。&lt;br /&gt;&lt;br /&gt;最後還是 stackoverflow 的幫忙：&lt;a href="http://stackoverflow.com/questions/4854442/embed-zxing-library-without-using-barcode-scanner-app"&gt;android - Embed Zxing library without using Barcode Scanner app&lt;/a&gt;，原來 zxing 裡的 Android client 測試程式裡就已經有一個 import com.google.zxing.client.androidtest.RGBLuminanceSource 可以處理這件事情，所以就先用 BitmapFactory.decodeFile 把圖檔讀出，得到 Bitmap，再把 Bitmap 丟給 RGBLuminanceSource 裡，就可以再用 new BinaryBitmap(new HybridBinarizer(source)); 得到 BinaryBitmap，decode 就可以根據這個 BinaryBitmap 取到條碼了。詳細的程式可以參考&lt;a href="http://stackoverflow.com/questions/4854442/embed-zxing-library-without-using-barcode-scanner-app"&gt;Stack Overflow 文裡的程式碼。&lt;/a&gt;，這裡不再摘錄。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-4223426450796228974?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/4223426450796228974/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=4223426450796228974' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4223426450796228974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4223426450796228974'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/09/zxingandroid-client-camera-preview-yuv.html' title=''/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-4839575600870010739</id><published>2011-09-15T16:55:00.000+08:00</published><updated>2011-09-15T16:55:05.019+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='link2sd'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>link2sd</title><content type='html'>link2sd 是一個可以把應用程式從內部記憶體移到 SD Card 上的應用程式，你需要把 SD Card 切成兩個主要分割區(primary partition)，第一個分割區作為正常的 SD Card 使用，第二個分割區就拿來存放應用程式。&lt;br /&gt;&lt;br /&gt;之前用的時候，我是將第二個分割區格式化為 vfat，但用了一段時間以後，覺得效率不是很好，也為了 journaling filesystem，就想把 vfat 換為 ext3。研究了好一陣子，昨天決定下手了。&lt;br /&gt;&lt;br /&gt;首先先說明我對 link2sd 的了解，照理說，一般要額外掛載分割區是需要額外寫 script 的，link2sd 是寫在 /system/etc/install-recovery.sh 裏面。所以我就簡單修改這個 script，然後關機把 SD Card 拿出來將第二個分割區備份，再格式化為 ext3，再把備份出來的檔案回存回去。但很遺憾，不行。&lt;br /&gt;&lt;br /&gt;於是我去看 init.rc，裏面沒有啟動 /system/etc/install-recovery.sh 這一段，我知道編譯 android 源碼以後得出來的 init.rc 是有這段的。於是我修改 init.rc，加入這段，可是重開機以後，再去看 init.rc，我加的這段居然消失了。&lt;br /&gt;&lt;br /&gt;沒辦法，只好還原回 vfat，乖乖的使用。&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-4839575600870010739?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/4839575600870010739/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=4839575600870010739' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4839575600870010739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4839575600870010739'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/09/link2sd.html' title='link2sd'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2162564701206365745</id><published>2011-09-09T16:02:00.002+08:00</published><updated>2011-09-09T16:02:14.086+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scm'/><category scheme='http://www.blogger.com/atom/ns#' term='git'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>git support in Visual Studio 2010</title><content type='html'>因為用 git 管理源碼，在切換 Visual Studio 跟 Command Prompt 之間，頗為麻煩，就想說，應該是有人寫了 Visual Studio 的 git 擴充套件了吧~&lt;br /&gt;&lt;br /&gt;進 [Tools][Extension Manager] 一找，果然已經有人寫了，主要有兩個：Git source control provider 跟 Git Extensions。Git source control provider 主要是一個給 Visual studio 用的介面，你可以設定實際上以哪個軟體去作 git，例如：msysgit、git extension、tortoise git...等等，所以容量不大，小小的。試用結果還算可以，唯一的缺點就是更動較多檔案時，會導致 Visual studio 重啟動。&lt;br /&gt;&lt;br /&gt;Git extensions 我就沒安裝了，因為我已經裝了 msysgit。目前是以 Git source control provider 跟 Command prompt 交互使用中。&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2162564701206365745?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2162564701206365745/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2162564701206365745' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2162564701206365745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2162564701206365745'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/09/git-support-in-visual-studio-2010.html' title='git support in Visual Studio 2010'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8651057951204195902</id><published>2011-09-07T16:25:00.002+08:00</published><updated>2011-09-07T16:25:13.843+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><category scheme='http://www.blogger.com/atom/ns#' term='電子書'/><category scheme='http://www.blogger.com/atom/ns#' term='epub'/><title type='text'>Android上的電子書</title><content type='html'>昨天想起介紹 &lt;a href="https://market.android.com/details?id=com.kobobooks.android"&gt;Kobo eBooks&lt;/a&gt; 的那篇文章說 &lt;a href="https://market.android.com/details?id=com.kobobooks.android"&gt;Kobo eBooks&lt;/a&gt; 可以吃 epub 格式的電子書，可是一直都忘記試，今天早上上班時，就試了一下，發現閱讀的效果真的比 &lt;a href="https://market.android.com/details?id=org.geometerplus.zlibrary.ui.android"&gt;FBReader&lt;/a&gt; 好很多。fbreader用來對付一般的小說是綽綽有餘，但遇到有程式碼的epub，整個就爛給你看，而且是爛的可怕。&lt;a href="https://market.android.com/details?id=com.kobobooks.android"&gt;Kobo eBooks&lt;/a&gt; 的處理就好很多，網站上有提供免費電子書可下載，也有像類似 foursquare 的打怪機制，讓你讀書跟打怪一樣，讀的愈多，拿的勳章愈多。&lt;br /&gt;拿 &lt;a href="https://market.android.com/details?id=com.kobobooks.android"&gt;Kobo eBooks&lt;/a&gt; 跟 &lt;a href="https://market.android.com/details?id=com.amazon.kindle"&gt;Kindle&lt;/a&gt; 比的話，在記憶體少的機器上運行ok。每次開 &lt;a href="https://market.android.com/details?id=com.amazon.kindle"&gt;Kindle&lt;/a&gt;，就常讓我的Asus A50重開機，重開機之後再去開啟程式才能正常進入，常常讓我不知道該不該賭一下，我想這應該是Linux Kernel 發現記憶體不足而砍應用程式的關係。&lt;br /&gt;要說 &lt;a href="https://market.android.com/details?id=com.kobobooks.android"&gt;Kobo eBooks&lt;/a&gt; 缺點的話，大概就是沒辦法查字典，&lt;a href="https://market.android.com/details?id=com.amazon.kindle"&gt;Kindle&lt;/a&gt;是可以查的。&lt;a href="https://market.android.com/details?id=com.amazon.kindle"&gt;Kindle&lt;/a&gt; 在長按單字時，他會自動去查英英字典，第一次查的時候，程式會告訴你要額外送你一本英英字典，下載以後，就可以有自動查單字的功能，畫面是以 pop window 的方式呈現，再點選，會進到英英字典，顯示更多資訊。&lt;br /&gt;如果沒意外的話，我想我以後都會拿 &lt;a href="https://market.android.com/details?id=com.kobobooks.android"&gt;Kobo eBooks&lt;/a&gt; 來讀 epub。&lt;br /&gt;除了上面的3個電子書以外，我還有試過 &lt;a href="https://market.android.com/details?id=com.chaozh.iReaderFree"&gt;iReader&lt;/a&gt;，是同事推薦我的，Market 裡的評價不錯，但iReader網站上的書太多，一時不知道要下載什麼，大多都是簡體中文，又考慮到翻譯品質良莠不齊，所以乾脆就移除掉了。&lt;br /&gt;我還有額外下載獨立電子書的 app：&lt;a href="https://market.android.com/details?id=com.aimery.abook.mcdnxs"&gt;明朝的那些事儿-全集&lt;/a&gt;跟&lt;a href="https://market.android.com/details?id=com.aimery.abook.hhgg"&gt;黄河鬼棺-全集&lt;/a&gt;，這兩個也不錯，作者是同一個，作者有在積極改版，可是我覺得最早用的那版還不錯用，不太需要改。目前&lt;a href="https://market.android.com/details?id=com.aimery.abook.mcdnxs"&gt;明朝的那些事儿-全集&lt;/a&gt;還沒看完，才看到第五集，等看完才會看&lt;a href="https://market.android.com/details?id=com.aimery.abook.hhgg"&gt;黄河鬼棺-全集&lt;/a&gt;。這兩本雖說是免費，但實際上應該算是盜版吧~&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8651057951204195902?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8651057951204195902/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8651057951204195902' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8651057951204195902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8651057951204195902'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/09/android.html' title='Android上的電子書'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2647142400308035923</id><published>2011-09-02T11:11:00.001+08:00</published><updated>2011-09-02T11:11:47.060+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='語言治療'/><title type='text'>語言治療(8)</title><content type='html'>這次實際上是第十一次，下次一上課會有一個小測驗，老師會根據這個來決定是否要繼續上課，雖然老師已經有跟我們說過他應該不用來上課了。&lt;br /&gt;&lt;br /&gt;老師似乎忘記了上次上什麼，不過我也不知道，因為上次是太座帶大公子來的。反正將錯就錯，老師就繼續講，主要是拿出一組卡片，共兩張，一張是因，一張是果，讓大公子練習描述人事地物與前後的因果關係，這樣的圖片之後陸陸續續講了六組。簡單的說，主題就是加強他描述的能力以及教導他在遇到圖片時該怎麼去說裏面有什麼。&lt;br /&gt;&lt;br /&gt;圖片上有，但大公子不知道怎麼講的東西：滅火器、打火機、消防隊員、客廳。回去要記得再跟他加強描述，因為這幾次上課的關係，讓我明白到大公子對很多東西還是不知道該怎麼說。&lt;br /&gt;&lt;br /&gt;這次上課，老師有以畫圖輔助說明，跟他說這是什麼東西。&lt;br /&gt;&lt;br /&gt;發音問題還是老樣子，這些音還是不太能擺脫慣性：火，多，對，拼圖，風，戒掉用奶瓶喝奶會不會比較好呢? 有跟大公子講過用杯子喝奶，可是他很妙，他覺得牛奶就是要泡在奶瓶裡，所以我決定要買奶粉回來泡給他看，讓他知道也可以用杯子喝奶。&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2647142400308035923?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2647142400308035923/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2647142400308035923' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2647142400308035923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2647142400308035923'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/09/8.html' title='語言治療(8)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3277371572094711731</id><published>2011-09-02T10:54:00.000+08:00</published><updated>2011-09-02T10:54:15.637+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='virtualenv'/><category scheme='http://www.blogger.com/atom/ns#' term='django'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Windows 上的 python + virtualenv + django</title><content type='html'>安裝上並不難，只是最後有卡到一個問題，特別提出來分享一下。&lt;br /&gt;&lt;ol&gt;&lt;li&gt;下載python 2.7安裝檔，然後安裝&lt;/li&gt;&lt;li&gt;下載setuptools安裝檔，然後安裝&lt;/li&gt;&lt;li&gt;打開命令提示字元，先 cd /d c:\python27\scripts ，再 easy_install virtualenv，你公司有 proxy 的話，記得先 set http_proxy=http://your_proxy:port &lt;/li&gt;&lt;li&gt;安裝好 virtualenv 以後，就可以去創建環境了，假設你的環境都在 c:\envs，那就先 cd /d c:\envs ，再 virtualenv --no-site-packages myenv ，這樣就建好環境了&lt;/li&gt;&lt;li&gt;啟動你的環境，要先 cd /d c:\envs\myenv ，再輸入 scripts\activate 。Linux 下的activate 是放在 bin 下，這是比較大的不同。&lt;/li&gt;&lt;li&gt;安裝 django：scripts\pip install django &lt;/li&gt;&lt;li&gt;使用 django 指令：scripts\django-admin.py startproject myproject ，嗶嗶嗶，卡住了。&lt;/li&gt;&lt;/ol&gt;哈，我就卡在這裡。django-admin.py 會說找不到 django.core ，我苦思了好久，終於才想到，Windows 下是不鳥 python script 第1行的 sha-bang 的啊，所以雖然 django-admin.py 的第1行指定了說要用 c:\envs\myenv\scripts\python.exe 來處理，可是實際上卻是 .py 註冊在 registry 裡的 c:\python27\python.exe 在處理。因此會有找不到 django.core 的情況，改用 scripts\python scripts\django-admin.py 就可以順利找到 django.core 了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3277371572094711731?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3277371572094711731/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3277371572094711731' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3277371572094711731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3277371572094711731'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/09/windows-python-virtualenv-django.html' title='Windows 上的 python + virtualenv + django'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8079207825212155637</id><published>2011-08-17T14:34:00.000+08:00</published><updated>2011-09-02T11:12:33.508+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='語言治療'/><title type='text'>語言治療(7)</title><content type='html'>語言治療，這次實際上是第九次，上完還有三次。&lt;br /&gt;&lt;br /&gt;這次上課有點匆忙，父親載我跟大公子去慈濟醫院的途中，去市場買了葡萄，耽擱了一點時間。&lt;br /&gt;&lt;br /&gt;進慈濟醫院，打算走樓梯上去，可是門卻被鎖了起來，打不開，只好等電梯，一等之下，就等了快十分鐘，真是很讓人挫折。幸好，還是及時掛完號、上完廁所，並且準時上了課。&lt;br /&gt;&lt;br /&gt;一上課，我就跟老師說，我要拿東西上去一下再回來。上去是要拿葡萄給嬸婆，這一上去，就又花了十分鐘左右。等到回來，前面都沒有聽到。&lt;br /&gt;&lt;br /&gt;這次上課的內容是講小蛇散步的故事，就有一個晴天，小蛇覺得天氣很好就出去散步，散步的途中遇到了一個水坑，突然他聽到一個聲音說，可不可以搭橋讓我過去啊?他回頭一看，原來是螞蟻，於是他很好心的就搭了一座橋，讓螞蟻過去。沒想到，螞蟻過去了，老鼠過去了，獅子也過去了。更令人驚訝的在後頭，大象，他也過去了。小蛇這下可是累到暈倒了，等到它醒過來，它就一口氣把水坑的水給喝光了，繼續上路。&lt;br /&gt;&lt;br /&gt;基本上還是跟上次一樣，主要在於矯正發音，並且引導大公子說出故事。我發現大公子在上課到沒興趣的地方時，會開始東摸摸西摸摸，失去專注力，這邊之後要注意。&lt;br /&gt;&lt;br /&gt;老師說要去作聽知覺檢查，還沒去做。但有問了常去的診所，醫生表示診所沒有，需要去比較專門的耳鼻喉科做才行。&lt;br /&gt;&lt;br /&gt;下次換媽媽帶去，別忘了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8079207825212155637?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8079207825212155637/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8079207825212155637' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8079207825212155637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8079207825212155637'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/08/7.html' title='語言治療(7)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-4753161820834207068</id><published>2011-08-03T18:43:00.000+08:00</published><updated>2011-08-03T18:43:18.318+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='語言治療'/><title type='text'>語言治療(6)</title><content type='html'>語言治療，這次算第7次了。&lt;br /&gt;&lt;br /&gt;上次是太座帶大公子去的，是講貓咪的故事，就有一棟大樓，大樓的每一層都有貓咪隱藏在不同的場景裡，這次就是延續上次的故事。&lt;br /&gt;&lt;br /&gt;大公子這幾次下來已經可以表達的不錯了，要說有問題，一個就是發音，另一個就是比較沒自信。發音的話，實際上他有記住正確發音的，但就是講的時候常會忘記，然後他又不喜歡被更正的感覺。像是'蛋'念成'幹'、'對'念成'貴'、'花'念成'瓜'...，目前有注意到的是ㄌㄏㄉ這幾個音。沒自信可以從老師問他事情，講話小聲，或是盲從而看出來。&lt;br /&gt;&lt;br /&gt;老師在講故事的過程裡，常矯正大公子的發音，此外，也藉由小遊戲來讓他認識正確的發音，老師先念'蛋'跟'幹'，問他說這好不好聽，然後會顛倒'蛋'跟'幹'的順序，讓他來判斷，答對五次就有小饅頭。看的出來，大公子不是很樂意玩這遊戲，因為他分辨不太出來。除了小遊戲，也讓大公子看老師怎麼去發'蛋'的音，並且告訴他舌頭要伸出來。&lt;br /&gt;&lt;br /&gt;發音之外，也加強對句子意義的了解，像是"只要x，不要y或是相反"、"先找x再找y"、如果有x就y"等等的。再來就是空間與位置的表達，大公子太常用"這邊"、"那邊"，容易讓人不知道東西在哪裡，加強這部份，對於以後講東西在哪兒會很有用。&lt;br /&gt;&lt;br /&gt;老師最後說，他上完這期，也就是再五次，應該就不用再來上課。另外建議我們帶他去檢查聽知覺，看是否有問題。老師相當肯定他仿畫、組織空間的能力，我跟老師說，可能是上學期有上繪畫課，然後有教他看圖去組合積木有關係。&lt;br /&gt;&lt;br /&gt;好吧，等上完語言治療的課，接下來就是靠我們自己平常要多注意並且跟學校老師配合了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-4753161820834207068?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/4753161820834207068/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=4753161820834207068' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4753161820834207068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4753161820834207068'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/08/6.html' title='語言治療(6)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1899887672646941123</id><published>2011-07-29T10:42:00.000+08:00</published><updated>2011-07-29T10:42:48.618+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='math'/><title type='text'>速率即斜率</title><content type='html'>今天早上騎車的時候想到昨天在看的斜率，然後又想到速率，速率=距離/時間，這公式不就跟斜率是一樣的嗎? &lt;br /&gt;&lt;br /&gt;斜率 = (y2-y1)/(x2-x1)，假定 y 軸是距離，x軸是時間，以幾何圖形來表示，就很清楚。在愈短的時間裡，經過的距離愈長，表示速度愈快，在圖形上的表示，就是斜率愈陡峭，代表速度愈快。&lt;br /&gt;&lt;br /&gt;是說自己把觀念連通的時間也太晚了點，現在才發現。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1899887672646941123?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1899887672646941123/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1899887672646941123' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1899887672646941123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1899887672646941123'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/blog-post_29.html' title='速率即斜率'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6808316047019732456</id><published>2011-07-28T17:45:00.000+08:00</published><updated>2011-07-28T17:45:48.342+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><title type='text'>台哥大Catch上網費率試算</title><content type='html'>就試算一下，然後作圖。&lt;br /&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;tr&gt;&lt;td&gt;方案&lt;/td&gt;&lt;td&gt;Catch98&lt;/td&gt;&lt;td&gt;Catch198&lt;/td&gt;&lt;td&gt;Catch398&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;收費&lt;/td&gt;&lt;td&gt;98&lt;/td&gt;&lt;td&gt;198&lt;/td&gt;&lt;td&gt;398&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;傳輸量&lt;/td&gt;&lt;td&gt;15&lt;/td&gt;&lt;td&gt;50&lt;/td&gt;&lt;td&gt;150&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;超過以後費率(元/KB)&lt;/td&gt;&lt;td&gt;0.025&lt;/td&gt;&lt;td&gt;0.015&lt;/td&gt;&lt;td&gt;0.0048&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;費率&lt;/td&gt;&lt;td&gt;6.533333&lt;/td&gt;&lt;td&gt;3.96&lt;/td&gt;&lt;td&gt;2.653333&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Cost if over/MB&lt;/td&gt;&lt;td&gt;25.6&lt;/td&gt;&lt;td&gt;15.36&lt;/td&gt;&lt;td&gt;4.9152&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;img src="http://chart.apis.google.com/chart?chs=480x256&amp;cht=lc&amp;chtt=Live%20Preview&amp;chd=s:PHF,9lK&amp;chco=00ff00,ff0000&amp;chdl=Cost/MB|Cost%20if%20over/MB&amp;chxl=0:|solution|catch%2098|catch%20198|catch%20398|1:|2|4|6|8|10|12|14|16|18|20|22|24|26|28|30&amp;chxt=x,y&amp;chg=,1"/&gt;&lt;br /&gt;&lt;br /&gt;從 Catch 98 升到 Catch 198 時，看起來最划算，因為圖形上的斜率較陡峭，很明顯可以感覺到下降很多，從 6.53 下降到 3.96。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6808316047019732456?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6808316047019732456/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6808316047019732456' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6808316047019732456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6808316047019732456'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/catch.html' title='台哥大Catch上網費率試算'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3881311281177345866</id><published>2011-07-27T14:53:00.001+08:00</published><updated>2011-07-27T14:53:47.625+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='currying'/><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>currying</title><content type='html'>前兩天看&lt;a href="http://en.wikipedia.org/wiki/Currying"&gt;Wikipedia上的Currying&lt;/a&gt;時，突然頓悟了(可見之前都沒認真)。這個不看英文Wikipedia的說明，還真的是不容易看懂。簡單的說，假設有個 function 是 f( x, y, z )，currying 就是令 f1=f(1)，當呼叫 f1( 2, 3 ) 時，就等於是呼叫 f( 1, 2, 3 )。&lt;br/&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;目前想到可以應用在 c/c# 沒辦法帶預設參數的情況上，像：&lt;pre name="code" class="c"&gt;void func( int x, int y, int z ) { }&lt;br /&gt;void new_func1( int y, int z ) { return func( 1, y, z ); }&lt;br /&gt;void new_func2( int y, int z ) { return func( 2, y, z ); }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;你可以想像到，這是一項複製、貼上的體力活，用 currying 的話，可以很快創造出新函數：&lt;pre name="code" class="c"&gt;/* 以下為虛擬碼 */&lt;br /&gt;void func( int x, int y, int z ) { }&lt;br /&gt;new_func1 = func(1); /* new_func1 仍是函數 */&lt;br /&gt;new_func2 = func(2); /* new_func2 仍是函數 */&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;在 python 裡，透過 *arg、**kwargs 可以很容易實現，文章可以參考 &lt;a href="http://jonathanharrington.wordpress.com/2007/11/01/currying-and-python-a-practical-example/"&gt;Currying and Python, a practical example&lt;/a&gt;，裏面有點複雜，其實只要看 curry 類別的部份，下面就是直接摘錄出來的實例：&lt;pre name="code" class="python"&gt;class curry:&lt;br /&gt;  def __init__(self, fun, *args, **kwargs):&lt;br /&gt;    self.fun = fun&lt;br /&gt;    self.pending = args[:]&lt;br /&gt;    self.kwargs = kwargs.copy()&lt;br /&gt;&lt;br /&gt;  def __call__(self, *args, **kwargs):&lt;br /&gt;    if kwargs and self.kwargs:&lt;br /&gt;      kw = self.kwargs.copy()&lt;br /&gt;      kw.update(kwargs)&lt;br /&gt;    else:&lt;br /&gt;      kw = kwargs or self.kwargs&lt;br /&gt;    return self.fun(*(self.pending + args), **kw)&lt;br /&gt;&lt;br /&gt;def func( a, b, c ):&lt;br /&gt;    print( a, b, c )&lt;br /&gt;    return (a+b+c)&lt;br /&gt;&lt;br /&gt;func1 = curry( func, 1, 100 )&lt;br /&gt;func2 = curry( func, 2 )&lt;br /&gt;&lt;br /&gt;print( func1( 200 ), func2( 300, 400 ) )&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;原理就是利用類別的特殊方法 __call__ ，呼叫 func2=curry( func, 2 ) 時，實際上是得到 curry 類別的實體。curry 類別的 __init__ 裡去做參數的判斷跟預存，等到把 func2 當函數執行時，就會執行到 __call__，這裡再去呼叫真正的函數。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3881311281177345866?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3881311281177345866/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3881311281177345866' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3881311281177345866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3881311281177345866'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/currying.html' title='currying'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6139124321860935960</id><published>2011-07-25T14:43:00.000+08:00</published><updated>2011-07-25T14:43:04.331+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>Python 2 與 3 之字串與檔案</title><content type='html'>Python 3 裡，很多常用的 package 名稱都變更了，這個倒還好，在 python 2.x 的文件裡，都已經可以看到說 3 的時候，名稱會是什麼，以及要注意什麼，甚至也有 2to3 的工具來輔助轉換。&lt;br /&gt;&lt;br /&gt;最近遇到比較麻煩的是字串與檔案的處理，Python 3 裡的字串都是以 unicode 處理，好處當然是不用轉來轉去了，比較麻煩就是讀取檔案跟寫檔案的時候。我的程式有同時用到 subprocess、urllib/urllib2與一般檔案操作，以下是整理：&lt;ol&gt;&lt;li&gt;進行 subprocess pipe 操作時，讀出時，都是 bytes&lt;/li&gt;&lt;li&gt;使用 urllib/urllib2 讀取時，都是 bytes&lt;/li&gt;&lt;li&gt;使用一般檔案操作，沒特別指定的話，檔案編碼會以你當前的環境編碼來讀取，預定是讀取文字檔。&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;所以在讀取時，為了後續能用一樣的邏輯來讀取，我統一以 binary 來讀取，避掉 encoding 問題(對於 python 3 在 binary mode時，也能正確分行、tokenize這件事上，真的是深感佩服)。是說剛好之後也不需要做精確的內容判斷，所以也不用硬轉成 string(unicode)，在 python3 時，都以 bytes 存在。在 python 2，讀出來就都是一般的 string (無 unicode)，不是 bytes。&lt;br /&gt;&lt;br /&gt;寫入時，也儘量使用 bytes 去寫入，避免encoding轉來轉去的問題。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6139124321860935960?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6139124321860935960/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6139124321860935960' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6139124321860935960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6139124321860935960'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/python-2-3.html' title='Python 2 與 3 之字串與檔案'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8576832262147101687</id><published>2011-07-21T16:42:00.000+08:00</published><updated>2011-07-21T16:42:35.708+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>儲存空間即將不足(續)</title><content type='html'>&lt;ol&gt;&lt;li&gt;想用 statfs 去看 /data 到底是剩多少可用，結果要自己弄 jni，一整個懶惰，就...&lt;/li&gt;&lt;li&gt;SL4A的python應該可以用吧，查了 python 文件，得知要用 os.statvfs，但是 SL4A 的 os.statvfs 被閹割掉... 囧&lt;/li&gt;&lt;li&gt;查 threshold，這個應該是可以的，只是要把 Settings.Secure.SYS_STORAGE_THRESHOLD_PERCENTAGE 改成 "sys_storage_threshold_percentage"，這個沒真的下去寫程式驗證。&lt;/li&gt;&lt;li&gt;用 terminal+busybox df 去查 /data 的，total bytes 是 162529280，心一橫，就拿這數字設到 debug.freemem (sudo setprop debug.freemem 162529280)，真的，那個討厭的"儲存空間即將不足"的通知就消失了。&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;以上。但是要裝比較大的app的時候，還是沒辦法裝，可惡!!&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8576832262147101687?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8576832262147101687/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8576832262147101687' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8576832262147101687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8576832262147101687'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/blog-post_21.html' title='儲存空間即將不足(續)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7536662055407914335</id><published>2011-07-20T10:58:00.000+08:00</published><updated>2011-07-20T10:58:06.875+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>儲存空間即將不足</title><content type='html'>都上 SD Card，加裝 Link2SD 了，才裝幾個程式，Android 手機就開始唉唉叫，左上角老是出現"儲存空間即將不足"的訊息，真的是太令人生氣。本來不想挖程式出來看的，唉~&lt;br /&gt;&lt;br /&gt;Android 程式的文字多半是存在 xml 檔案，也就是 resource 檔，關鍵是在於對應所使用的變數名稱。在 mydroid 目錄下先用 source build/envsetup.sh ，再用 resgrep '儲存空間即將不足' 來找，出現這段文字的檔案有兩個，不過很明顯，變數名稱應該是 low_internal_storage_view_title。&lt;br /&gt;&lt;br /&gt;再用 jgrep 去找：jgrep low_internal_storage_view_title ，排除掉 R.java 之後，可以看到一個不一樣的：frameworks/base/services/ajva/com/android/server/DeviceStorageMonitorService.java&lt;br /&gt;&lt;br /&gt;看來關鍵就在這檔案裡了。從裏面可以看到在 sendNotification 裡，會把 low_internal_storage_view_title 當作訊息丟出去，於是上方的通知欄就有了'儲存空間即將不足的訊息'。那麼是在那邊去 sendNotification 的呢? 是同個檔案裡的 checkMemory()。&lt;br /&gt;&lt;br /&gt;checkMemory() 裡的檢查邏輯很簡單，先 getMemThreshold()，再用 mFreeMem 去做判斷，如果比取到的 threshold 值要小，mLowMemFlag 還沒設為true，就先試著清理 cache，再不行，就 sendNotification。&lt;br /&gt;&lt;br /&gt;getMemThreshold() 是怎麼取 threshold 的呢？是從 Content Resolver 裡找 "sys_storage_threshold_percentage" 來的，如果沒取到，則以 10 為預設值，然後乘上 mTotalMemory。&lt;br /&gt;&lt;br /&gt;好，上面有幾個關鍵的變數：mTotalMemory、mFreeMem，這兩個變數又是怎麼來的？checkMemory() 裡在檢查 mFreeMem 之前，有先呼叫 restatDataDir()，這個函數會呼叫到底層的 C 函數 - statfs 來取得 /data 的資訊，statfs 回傳一個結構體，主要會使用到裏面的 f_bavail、f_bsize、f_blocks。mFreeMem = f_bavail * f_bsize; mTotalMemory = f_blocks * f_bsize。&lt;br /&gt;&lt;br /&gt;從上面的資訊看來，如果要避免不足的問題，要不就是增加 /data 的可用空間，要不就是降低 threshold 的值。但原始碼裡透露了另外一個密技，restatDataDir() 裡，在使用 statfs 取得資訊以後，接著去取 System properties 裡的 debug.freemem，如果有取到，就拿這個當作 mFreeMem 的值來用。看來是可以利用的喔~搭配 setprop 可以設置 debug.freemem ，不過需要 root 嗎? 待驗證。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7536662055407914335?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7536662055407914335/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7536662055407914335' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7536662055407914335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7536662055407914335'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/blog-post.html' title='儲存空間即將不足'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3302842778677167558</id><published>2011-07-13T11:49:00.000+08:00</published><updated>2011-07-13T11:49:49.083+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='語言治療'/><title type='text'>語言治療(5)</title><content type='html'>轉眼就第五次上課了，這次上課前發生了請假風波。因為趕著出門，大公子以為是要去學校，所以就情緒激動地叫不要，於是我打電話給醫院老師，跟她請假。結果下了樓，大公子才又說是要去醫院，這下尷尬了，我趕上樓，再打一次電話給老師，說今天還是會去。&lt;br /&gt;&lt;br /&gt;今天是爸爸載大公子、媽、二公子跟我一起去的，爸跟媽要去耕莘醫院買醫療用品，二公子就順便一起去，而大公子跟我則到慈濟醫院。到了醫院，大公子喊說餓了，也是該餓的時候了，在家時叫他吃早餐，他死活都不要。就帶他到樓下全家買了蛋酥麵包跟養樂多給他吃，他很快就吃掉半個蛋酥麵包，然後喝完養樂多。&lt;br /&gt;&lt;br /&gt;這次上課一開始，老師先問他為什麼心情不好，因為我是以他心情不好的理由跟老師請假的。他沒說，老師就先拿出3個拼圖給他拼，邊拼圖的時候，邊請他講拼圖內的圖案，然後藉機會也問他說，綠色的水果有哪些，橘色的水果有哪些。綠色的水果他只講了芭樂，老師提醒他還有哈密瓜，可惜我們家真的很少吃哈密瓜，西瓜還比較常吃，橘色的水果只講了橘子。&lt;br /&gt;&lt;br /&gt;接著拿出三張左右對照的圖片，就左邊是不好的行為，右邊是好的行為，然後教他講跟請他講，有些部份，大公子已經講的不錯了。講到後面時，老師請他跟她講一樣的，大公子總是接著老師的話說，例如：老師說，"好寶寶要"，大公子就直接接話，而不是跟著念"好寶寶要"。老師花了一點時間，才讓他明白要跟著念。等講完這三張圖片，又再拼了3個拼圖。最後老師再請他說為什麼心情不好，大公子才說，"早上不來老師這裡啊"，所以才生氣，老師因此多給了他一張貼紙。&lt;br /&gt;&lt;br /&gt;這次講完，老師有跟我說，大公子從評估到現在進步很多，也比一般需要語言治療的孩子要來的好，像是ㄉㄨㄟ，大公子隔週還會記得，一般的孩子則是會忘記。我是說，可能因為從年初到現在，大公子好像正處在爆發期，所以感覺上很快，也跟評估時的情況不一樣。然後有提到回家跟他複習時，他會說"不要說"。老師說，接著會調整課程內容，只是她下週請假一週。&lt;br /&gt;&lt;br /&gt;附帶一提，晚上在看綠15路線圖時 (大公子很愛看地圖、路線圖)，我發現他已經有在認字了，像"七張"，他就已經可以直接看著念出來，不需要問我。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3302842778677167558?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3302842778677167558/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3302842778677167558' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3302842778677167558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3302842778677167558'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/5.html' title='語言治療(5)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8777950361930254280</id><published>2011-07-11T17:50:00.003+08:00</published><updated>2011-07-11T17:51:31.878+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>WIFI優先於3G?</title><content type='html'>蠻怕浪費錢的，所以還去挖code驗證了一下。NetworkStateTracker 用 NetworkUtils.setDefaultRoute() 設置routing。&lt;br /&gt;在ConnectiveService裡有定義優先權，但這邊的陣列值其實是在 framework/base/core/res/res/values/config.xml 中的 networkAttributes：&lt;table border='1'&gt;&lt;tr&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;Type&lt;/th&gt;&lt;th&gt;radio&lt;/th&gt;&lt;th&gt;priority&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;wifi&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;mobile&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;mobile_mms&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;mobile_supl&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;mobile_hipri&lt;/td&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;所以再依照程式裡的邏輯，應該是WIFI為優先... (好吧，我承認我沒認真去看懂程式邏輯，所以說"應該"...)&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8777950361930254280?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8777950361930254280/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8777950361930254280' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8777950361930254280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8777950361930254280'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/wifi3g.html' title='WIFI優先於3G?'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3126759245902348031</id><published>2011-07-05T18:24:00.002+08:00</published><updated>2011-07-05T18:24:53.702+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='語言治療'/><title type='text'>語言治療(4)</title><content type='html'>這次一開始，老師就拿了上次"雨傘"故事的圖卡，一張張的內容再帶過一次，然後請大公子來排出順序，邊排邊說。等到故事圖卡排列完，接著拿出一本大書，裏面有許多小小的方形磁鐵，上面貼著各種東西，像是葡萄、獅子、長頸鹿、外套...等等，總共5個大類。由於時間的關係，這次只做3個大類：水果、動物、衣服。老師一樣先帶過一次，確定大公子都知道了，然後把這些小方形磁鐵弄亂，請大公子分類。&lt;br /&gt;&lt;br /&gt;在整個過程裡，除了教導大公子講故事以外，也針對大公子某些字的發音跟慣用詞做矯正，例如："葡萄"的"葡"、"對"、"甜"、"嘟嘟"應該是"火車"...等等。&lt;br /&gt;&lt;br /&gt;最後老師說他7/19要請假，那天就暫停一次。&lt;br /&gt;&lt;br /&gt;從去醫院評估之後到現在，已經快四個月了，我個人是覺得大公子在這段期間進步很多，希望在年底前就可以不用再去上語言治療課程。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3126759245902348031?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3126759245902348031/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3126759245902348031' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3126759245902348031'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3126759245902348031'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/4.html' title='語言治療(4)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1933389725085694847</id><published>2011-07-03T01:05:00.002+08:00</published><updated>2011-07-03T01:05:57.752+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='語言治療'/><title type='text'>語言治療(3)</title><content type='html'>第三次上課。基本上每次上課就只有半個小時，但為了這半小時，不管是大人、小孩都需要請半天假。第一次上課時，是大人請半天，大公子請整天，第二次之後，就是都請半天了。&lt;br /&gt;&lt;br /&gt;這周是把上週的故事「雨傘」講完，除了講後半本的部份，也讓大公子重頭再講一次。邊講故事邊糾正大公子的某些發音，例如：「對」，大公子常念成「貴」，老師教他先念「ㄉㄨ」，再念「ㄟ」，合起來就是「ㄉㄨㄟˋ」。最後和大公子玩記憶卡片的遊戲 ，把兩兩一張的卡片共五組，洗牌後蓋起來，一人一次翻兩張牌，翻到一樣的牌就拿起來，算得分一次；翻到不一樣的牌就要再蓋回去，看誰拿到的牌組多。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1933389725085694847?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1933389725085694847/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1933389725085694847' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1933389725085694847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1933389725085694847'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/3.html' title='語言治療(3)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6960646420400373596</id><published>2011-07-03T00:54:00.002+08:00</published><updated>2011-07-03T00:54:47.442+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='語言治療'/><title type='text'>語言治療(2)</title><content type='html'>第二次上課。這次上課跟上次頗類似，但改用故事書「雨傘」，由於時間因素只講了半本。同樣的，在小朋友感到不耐煩時，有拿出拼圖之類的，讓小朋友先短暫的移開注意力，讓他喘息一下，一方面也是作為激勵因子。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6960646420400373596?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6960646420400373596/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6960646420400373596' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6960646420400373596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6960646420400373596'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/2.html' title='語言治療(2)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-866080816095799615</id><published>2011-07-03T00:50:00.002+08:00</published><updated>2011-07-03T00:50:58.132+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='語言治療'/><title type='text'>語言治療(1)</title><content type='html'>第一次上課。&lt;br /&gt;&lt;br /&gt;老師先拿出一個可以分拆成六片的六格連環圖畫，然後拆開。從第一張圖片去誘導小朋友說出裏面有什麼東西，並且做了什麼，如果說不出來，就說一遍，再請小朋友說一遍；小朋友厭煩了，就說看完三張，可以吹泡泡。最後六張都看完、說完了，就請小朋友從頭講一次。&lt;br /&gt;&lt;br /&gt;吹泡泡時也有技巧，老師會注意小朋友嘴型；大公子是牙齒咬住去吹，所以都不容易吹出大泡泡。老師會特別請他牙齒不要咬住去吹，這樣吹出大泡泡的機率就提高了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-866080816095799615?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/866080816095799615/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=866080816095799615' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/866080816095799615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/866080816095799615'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/07/1.html' title='語言治療(1)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8976106275650821950</id><published>2011-06-27T06:27:00.002+08:00</published><updated>2011-06-27T06:27:49.565+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><title type='text'>根據changelog取版號</title><content type='html'>以前上傳ppa之前，都是手動打指令，其實應該要自動化才對，今天跨出第一步。第一步當然就是取版號，deb的版號是從debian/changelog來的，所以要從這裡著手。&lt;br /&gt;&lt;br /&gt;當前的版號只會在第1行，一開始就想到用 head -n 1來取，用 awk 印出第2欄。可是第2欄前後有 () 呢?該怎麼拿掉呢?不會是要用 sed 吧? 去 GNU awk manual 翻閱了一會，發現有 match 函數，可以用 re 來取 group，所以用 match($2, /\((.*)\)/,arr); 就可以去掉 ()。&lt;br /&gt;&lt;br /&gt;去掉 () 之後，想到應該可以把 head 省掉，也用 awk 處理。NR 是一個特殊的變數，當處理一筆(行)時，這個值就會累加。把它限定為 1，就表示只處理第1行了。於是就可以湊出這麼一段script。&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;CHANGE=`awk 'NR==1 {match($2, /\((.*)\)/,arr);printf("gcin_%s_source.changes", arr[1]);}' debian/changelog`&lt;br /&gt;ls -l $CHANGE&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8976106275650821950?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8976106275650821950/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8976106275650821950' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8976106275650821950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8976106275650821950'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/06/changelog.html' title='根據changelog取版號'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2049851478076414372</id><published>2011-06-16T17:35:00.000+08:00</published><updated>2011-06-16T17:35:36.853+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>distutils bdist_rpm</title><content type='html'>CentOS 5.6 裡的MySQL-python是1.2.1，在用django的時候，它給我吐出需要MySQL-python-1.2.1p2 以後的版本才行。&lt;br /&gt;&lt;br /&gt;囧掉，這樣不就要抓MySQL-python新版來包，好像會很麻煩說。上MySQL-python官網去看，發現維護者很有意思，他在Amazon上的wish list裡都是大力水手的DVD，如果要贊助他的話，不妨幫他買DVD，Amazon會送到他家裡去。離題了，網站上最新的版本是1.2.3，就先抓下來吧。&lt;br /&gt;&lt;br /&gt;python的moodule照慣例都有 setup.py，就想說打 python setup.py --help-commands 來看看，結果喜出望外，裏面有 bdist_rpm 的指令，這表示我可以直接打 python setup.py bdist_rpm 就可以建出 rpm 了。&lt;br /&gt;&lt;br /&gt;於是馬上就來 build，首先裝上 mysql-devel，然後執行 python setup.py bdist_rpm，看起來很順利，但最後卻發現沒有 MANIFEST 檔案，而導致失敗。看了一下檔案，發現有 MANIFEST.in，再看一下裏面，沒有什麼要替換的字串 (一般來說，副檔名是 .in 的，都會需要用 sed 來替換一些字串)，就直接 cp MANIFEST.in MANIFEST 補上，再重新執行 python setup.py bdist_rpm 就大功告成了。rpm 會放在 dist 目錄下，收工。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2049851478076414372?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2049851478076414372/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2049851478076414372' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2049851478076414372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2049851478076414372'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/06/distutils-bdistrpm.html' title='distutils bdist_rpm'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1195847782925896327</id><published>2011-06-14T14:54:00.000+08:00</published><updated>2011-06-14T14:54:00.967+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><title type='text'>cpio的pass through</title><content type='html'>以前沒想過 cpio 的 pass through 可以做什麼，今天要不是有朋友問我，我大概也不會想到這個。是這樣子的，假定有個目錄 a，裏面有很多目錄跟檔案，可是只要複製 a/b/c/file.txt 跟 a/b/file2.txt 到目錄 t 下，可是沒辦法用 cp -r，因為 cp -r 會把整個 a 都複製過去，總不能先複製過去以後再一個一個刪除吧? 本想說這可能要寫 script 來做了，打了 cp，按了 tab，看有沒有什麼可能的指令可用，就看到 cpio，印象中，cpio 可能是可以。&lt;br /&gt;&lt;br /&gt;最初的想法是用兩個 cpio 來做，一個建 archive(cpio -o)，一個解到指定的目錄(cpio -i)，這樣就行了。用 info cpio 一查，發現 cpio -p 應該就可以做了。&lt;br /&gt;&lt;br /&gt;所以試了一下，這裡先建立一個 list 檔案，裏面有兩行：a/b/c/file.txt 跟 a/b/file2.txt，a 目錄下有很多目錄跟檔案，並且有 a/b/c/file.txt 跟 a/b/file2.txt。那麼這兩行指令就可以只把list裡指定的兩個檔案複製到 t 目錄下，並且建立必要的目錄：&lt;br /&gt;&lt;pre class="bash" name="code"&gt;mkdir -p t&lt;br /&gt;cat list | cpio -p --make-directories t&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1195847782925896327?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1195847782925896327/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1195847782925896327' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1195847782925896327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1195847782925896327'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/06/cpiopass-through.html' title='cpio的pass through'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3486503843218593340</id><published>2011-06-09T17:11:00.000+08:00</published><updated>2011-06-09T17:11:11.669+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><title type='text'>閒聊Windows7有感</title><content type='html'>前幾天服務於公家機關的H同學問我關於Windows 7的問題，主要是問軟體不相容以及盜版的問題，他抱怨說，有些軟體在Windows 7上無法使用，有些不能說的秘密的軟體也沒辦法用之前XX的方法來正常使用。我就跟他解釋了，說微軟是很有誠意，早就有緩衝期讓使用者/軟體開發公司能提早轉換到Windows 7，所以不是說一下子就突然要換Windows 7的。然後又跟他說，Windows 7裡好像有個XP相容模式的工具可以繼續讓軟體在XP上執行。邊跟他說明的時候就邊聊，才知道他這樣問(抱怨?)的原因。&lt;br /&gt;H同學服務的單位主要負責測量，所使用的軟體是之前已經離職的同事開發，用來輔助測量工作使用的，也就是說現在沒有人維護了。照理來說，公家機關的人流動率不高才是，但那個已經離職的同事是在業餘的時間自修去做軟體開發，可是卻沒有被適當的升遷，所以就離職，另作打算。至於其他的軟體，像委外開發或是有購買(如AutoCAD)等但沒有簽維護合約的軟體，軟體在Windows 7就有較高的機會遇到問題；那不能說的秘密的軟體多半都是以前可以順利在XP上運行，現在已經不知道更新到哪一版去了的，更不用說了。從這邊可以看出公家機關內部的軟體問題，在一般公司也是會遇到，只是一般公司都會簽訂維護合約以確保軟體可以運作。&lt;br /&gt;電腦大多都是運行XP，經過了這麼多年，總是會舊的，也慢慢被汰換。新的電腦現在都是安裝Windows 7出廠。在第1批安裝Windows 7的電腦來了之後，負責試用的人試用兩天，兩手一攤就說："我沒辦法適應"，當然辦公室裡的其他人在沒有適當的人教導的情況下，也不是很容易上手，再加上一些軟體都沒辦法用，就一致把Windows 7給隔離了，轉而好好保護執行XP的電腦或者是想把Windows 7降級為XP。電腦的硬體倒是沒什麼問題，有委外進行處理，換了就換，沒什麼好說的。&lt;br /&gt;從閒聊裡，我學到不少：&lt;ul&gt;&lt;li&gt;升級到新的作業系統前，要先試驗單位內的所有軟體都可以正常在新的作業系統上運作，如果不能運作，要儘快尋求協助或更新&lt;/li&gt;&lt;li&gt;單位內若有人有能力去開發、維護一個軟體，那麼這個人就值得留下，不要讓他走了，並且要讓他願意把軟體開源出來&lt;/li&gt;&lt;li&gt;要安排課程與時間讓不熟悉新作業系統的人去熟悉。&lt;/li&gt;&lt;li&gt;不想被軟體公司合約綁住，就要找適當的開放源碼軟體/作業系統來替代。&lt;/li&gt;&lt;/ul&gt;公家機關在電腦硬體上是可以委外，軟體也是可以，只是我認為應該要取得原始碼，並交給某個特定的單位來維護。這個特定的單位除了維護之外，也可以去開發一些比較偏向專業技術(只有公家機關在用)的系統，這樣應該會比較省錢吧~&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3486503843218593340?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3486503843218593340/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3486503843218593340' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3486503843218593340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3486503843218593340'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/06/windows7.html' title='閒聊Windows7有感'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-9036730234699672517</id><published>2011-06-09T12:54:00.000+08:00</published><updated>2011-06-09T12:54:05.500+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>django-nonrel之二</title><content type='html'>另外一個方法是直接參考這篇 &lt;a href="http://www.allbuttonspressed.com/blog/django/2010/02/4-things-to-know-for-NoSQL-Django-coders"&gt;4 things to know for NoSQL Django coders&lt;/a&gt;的Setting up the environment，裏面有提供一個 zip 連結，下載以後解開，基本上就可以了。這個 zip 提供的 django 是 1.3 beta1。&lt;br /&gt;&lt;br /&gt;我遇到的問題是在執行 python manage.py runserver 時所發生的，錯誤訊息說需要 sass，這個工具是一個輔助 css 撰寫的工具，但 10.04 裡所提供的 sass 是 2.x 版的，而 django 裡的 mediagenerator 需要 3.x 的版本。上網找了一下，果然有人遇到，解法是利用 rubygems 來安裝 (&lt;a href="http://www.dbuggr.com/simon-tite/install-sass-ubuntu-10-04/"&gt;Install SASS on Ubuntu 10.04&lt;/a&gt;)。&lt;br /&gt;&lt;br /&gt;我稍做了一點更動，因為我不想安裝到 user home 裡，所以使用的指令依序是：&lt;br /&gt;&lt;ol&gt;&lt;li&gt;sudo apt-get install rubygems1.8 ruby&lt;/li&gt;&lt;li&gt;sudo gem install haml-edge --no-user-install&lt;/li&gt;&lt;li&gt;sudo ln -s /var/lib/gems/1.8/gems/haml-edge-3.1.79/bin/sass /usr/local/bin/sass&lt;/li&gt;&lt;li&gt;sudo ln -s /var/lib/gems/1.8/gems/haml-edge-3.1.79/bin/sass-convert /usr/local/bin/sass-convert&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;後2個步驟是作 symbolic link，讓 sass 指令能在 PATH 裡找到。最後是預設網頁的問題，這個就請參考 django tutorial 去修改 urls.py 並在 templates 目錄補上預設網頁就可以了。&lt;br /&gt;&lt;br /&gt;有點混亂，我試著參考這個 zip 檔案去設定上一篇所開的專案，但 mediagenerator 就是跑不起來。另外就是試著用 tutorial 的 poll 例子去加 admin，可是卻吐 backend 不支援 max 這個方法，研判應該是 admin module內部處理問題。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-9036730234699672517?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/9036730234699672517/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=9036730234699672517' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/9036730234699672517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/9036730234699672517'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/06/django-nonrel_09.html' title='django-nonrel之二'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8309516338351607151</id><published>2011-06-08T15:22:00.000+08:00</published><updated>2011-06-08T15:22:25.413+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>django-nonrel</title><content type='html'>Google AppEngine(之後簡稱GAE)原本就有把django包進去，只是資料庫的使用上，需要自己處理，原本只支援relational database。後來就有人去補這一塊，名字就改稱django-nonrel。GAE官方的文件介紹django時，就直接介紹了這個project：&lt;a href="http://code.google.com/intl/nl/appengine/articles/django-nonrel.html"&gt;Running Pure Django Projects on Google App Engine&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;django-nonrel 的官方網頁在：&lt;a href="http://www.allbuttonspressed.com/projects/django-nonrel"&gt;Django-nonrel - NoSQL support for Django&lt;/a&gt;，坦白說，從官方網頁我沒找到很清楚的Installation說明，後來才在這一篇&lt;a href="http://www.allbuttonspressed.com/blog/django/2010/01/Native-Django-on-App-Engine"&gt;Native Django on App Engine&lt;/a&gt;裡看到。一般django建立網站的方法是使用django-admin.py startproject your_project來建立，接著再進入專案目錄，使用python manage.py 去做管理。但django-norel建立網站的方法稍微不一樣，是直接checkout一份空的專案骨架來用，而不是使用django-admin.py來建立。步驟如下：&lt;br /&gt;&lt;ol&gt;&lt;li&gt;使用mercurial(hg)去clone以下源碼，我統一都clone到~/hg 下：&lt;ul&gt;&lt;li&gt;hg clone https://bitbucket.org/wkornewald/djangoappengine&lt;/li&gt;&lt;li&gt;hg clone https://bitbucket.org/wkornewald/django-nonrel&lt;/li&gt;&lt;li&gt;hg clone https://bitbucket.org/wkornewald/django-testapp&lt;/li&gt;&lt;li&gt;hg clone https://bitbucket.org/wkornewald/djangotoolbox&lt;/li&gt;&lt;li&gt;hg clone https://bitbucket.org/wkornewald/django-dbindexer&lt;/li&gt;&lt;li&gt;hg clone https://bitbucket.org/twanschik/django-autoload&lt;/li&gt;&lt;li&gt;hg clone https://bitbucket.org/wkornewald/django-mediagenerator&lt;/li&gt;&lt;/ul&gt;，依序說明：djangoappengine、django-nonrel、djangotoolbox主要是針對GAE作補完，django-testapp是專案的骨架，dbindexer是實作資料庫處理的底層，autoload負責自動載入library，django-mediagenerator則是可以對css/js做壓縮、加速的library，可有可無。&lt;/li&gt;&lt;li&gt;複製django-testapp並更名，假設為mysite&lt;/li&gt;&lt;li&gt;進入mysite目錄下，然後去做symbolic link：&lt;ul&gt;&lt;li&gt;ln -s ~/hg/django-nonrel/django&lt;/li&gt;&lt;li&gt;ln -s ~/hg/djangoappengine&lt;/li&gt;&lt;li&gt;ln -s ~/hg/djangotoolbox/djangotoolbox&lt;/li&gt;&lt;li&gt;ln -s ~/hg/django-nonrel/django&lt;/li&gt;&lt;li&gt;ln -s ~/hg/django-dbindexer/dbindexer&lt;/li&gt;&lt;li&gt;ln -s ~/hg/django-autoload/autoload/&lt;/li&gt;&lt;li&gt;ln -s ~/hg/django-mediagenerator/mediagenerator&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;大功告成，輸入python manage.py runserver 就可以啟動web server，試著瀏覽 http://localhost:8000 看看吧。如果你想要改用別的 port，跟原來的django不太一樣的，你需要用 python manage.py runserver 0.0.0.0:10080 才可以，原來的 django 可以用 python manage.py runserver 10080 就搞定。&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;會想試試這個，主要還是因為GAEO後來的開發整個停掉，想說之後也想玩玩django，就乾脆用django-nonrel，以後也對django比較容易上手。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8309516338351607151?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8309516338351607151/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8309516338351607151' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8309516338351607151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8309516338351607151'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/06/django-nonrel.html' title='django-nonrel'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-689617674377329222</id><published>2011-06-03T17:44:00.002+08:00</published><updated>2011-06-03T17:44:42.424+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><title type='text'>石頭</title><content type='html'>昨天晚上S來我家檢查濾水器並送濾心過來給我，他是老何介紹給我的，幫我裝的濾水器已經用3年了，那時候大公子還不到一歲的樣子，時間真的很快。&lt;br /&gt;&lt;br /&gt;檢查完濾出來的水並確認沒有問題以後，他給我看一顆黑色的小石頭，叫我洗一洗，洗完放到裝了開水的杯子裡。&lt;br /&gt;S:"我們來做一個實驗喔~你手機在旁邊嗎?"&lt;br /&gt;我:"手機在旁邊"&lt;br /&gt;S接著用手機打了通電話到我的手機，旋即掛斷。&lt;br /&gt;S:"好~你單腳站好，兩手往左右伸直，和身體呈90度。"&lt;br /&gt;我照做了，左腳縮了起來，用右腳站。&lt;br /&gt;S:"我要按你的左手臂囉~準備好了嗎?"&lt;br /&gt;我:"好了"&lt;br /&gt;S輕輕一按，我就不平衡，身體往左傾，我趕緊把左腳放下站好。&lt;br /&gt;S:"好，你喝剛剛的水，喝完再用剛剛的姿勢站好。"&lt;br /&gt;我喝完水，站好以後，說:"好了"&lt;br /&gt;這次S按的比剛剛用力，可是我卻沒有像剛剛那麼的不平衡。&lt;br /&gt;很玄...&lt;br /&gt;S:"剛剛打手機的時候，手機的電磁波破壞了你的場，所以你會不平衡。這顆石頭泡過的水可以讓你恢復你的場，你喝完以後就不會不平衡了。"&lt;br /&gt;我心裡暗想，鬼扯，這怎麼可能!&lt;br /&gt;S:"我們再試一次，可以嗎?"&lt;br /&gt;可惡，這次實驗結果居然一樣，接了手機就會不平衡，喝完水，就不會。&lt;br /&gt;S:"這公司新產品，濾水器裡有這石頭，以後有機會，你再參考這產品看看。另外這小石頭就送給你吧~你可以放在杯子、水壺或熱水瓶裡，但要小心不要喝到肚子裡去囉~"&lt;br /&gt;跟他道別、送他出門之後，我在想這石頭真有這麼神奇嗎?&lt;br /&gt;&lt;br /&gt;隔天，就今天早上騎車的時候，我就在研究要怎麼驗證這個實驗的真實性。首先要排除人類心理因素，如果知道有這麼一顆石頭，就很難不受到它的影響，另外也要避免讓實驗者知道他正在做實驗，這很重要。根據組織行為課本裡介紹的一個實驗(好像是霍桑做的?)，當工廠工人知道他們在做實驗，就因為覺得自己受到重視，而表現的較好。然後，我想應該也要排除掉手機，要想辦法讓實驗者不知道手機的存在，請他等一下，在這個等一下的過程裡去打電話，等完之後，再讓他做那姿勢，並用手壓他的手臂。壓完之後，請他喝水(杯子裡不能有石頭，也不能讓他知道水哪裡來的)，再讓他做那姿勢，再壓一次。嗯~這樣應該就可以實驗出那顆石頭是否真的有功效了。&lt;br /&gt;&lt;br /&gt;我個人是覺得這跟那顆石頭或手機一點關係都沒有，等之後有空來試試看。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-689617674377329222?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/689617674377329222/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=689617674377329222' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/689617674377329222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/689617674377329222'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/06/blog-post.html' title='石頭'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-457301871326433674</id><published>2011-06-02T14:20:00.000+08:00</published><updated>2011-06-02T14:20:04.095+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><category scheme='http://www.blogger.com/atom/ns#' term='gae'/><title type='text'>GAE應用程式在哪裡執行</title><content type='html'>判斷Google Appengine應用程式是在GAE服務上或是本地端，可以這樣用：&lt;br /&gt;&lt;pre name="code" class="python"&gt;from google.appengine.api import conf&lt;br /&gt;app_version, current_config_version, development = conf._inspect_environment()&lt;br /&gt;if development:&lt;br /&gt;  print("development")&lt;br /&gt;else:&lt;br /&gt;  print("production")&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-457301871326433674?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/457301871326433674/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=457301871326433674' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/457301871326433674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/457301871326433674'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/06/gae.html' title='GAE應用程式在哪裡執行'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1701991566334170087</id><published>2011-05-27T18:29:00.002+08:00</published><updated>2011-05-27T18:29:57.825+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/4/27~2011/5/25)</title><content type='html'>整整一個月就這樣過去了...&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Love and other drugs(&lt;a href="http://www.imdb.com/title/tt0758752/" title="Love and Other Drugs (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Love_and_Other_Drugs" title="Love and Other Drugs - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：愛情藥不藥。這部片蠻感人的，雖然有點芭樂。Jamie出生於醫學世家，可是卻跑去當了藥廠的業務員，賣起藥來。賣藥的過程裡，遇見了Maggie，一見鍾情，也在床上一見如故，就像是遇見100%的女孩，並過了依段快樂的時光~可是，Maggie有帕金森氏症，他們因為這個而爭吵甚至分開，分開一陣子以後，Jamie發現他不能沒有Maggie，就趕緊去告白，然後復合。這部片子裡有不少裸露畫面，但很自然，Hathaway在這部片子裡看起來超有魅力的說~&lt;/li&gt;&lt;li&gt;Hero(&lt;a href="http://www.imdb.com/title/tt0104412/" title="Hero (1992) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Hero_(1992_film)" title="Hero (1992 film) - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)。上英文課時，老師讓我們看的，是一部批判媒體的片子，除了劇情不錯以外，飾演主角的演員也都是一時之選，相當好看。Bernie是一個自私自利的人，他離婚了，而且被法律訴訟給困住。某天下著雨的晚上，他正要帶兒子去看電影的路上，還沒接到兒子，就遇到飛機失事。飛機快要爆炸了，他幫忙打開機艙，機艙裡的乘客紛紛逃出，裏面有個小孩要求他幫忙救出他的父親，他看到這個小孩，動了惻隱之心，就進去救了好多人，之後就離去。救人的過程裡，他順手牽了女記者的皮包。當然，就跟他兒子爽約了，他想要跟他兒子解釋，可是被他前妻給轟了出去。女記者找到爆點，就趕緊大肆報導，想找到這個救人的人，後來有個流浪漢出來冒認了，想不到卻以假亂真。這個流浪漢心裡很掙扎，他想說只是出來冒充，卻一夕成名，媒體報導成這樣，想下台也很難下台。後來就想自殺，此時女記者已經找到Bernie，他以為Bernie是那個轉手流浪漢皮包然後威脅流浪漢的人，就帶去，結果Bernie卻跟要跳樓的流浪漢聊開了，並達成協議，讓流浪漢繼續行善，Bernie拿錢。女記者之後也認出了Bernie就是救她的人，之後也沒有再重新報導，就這樣各取所需，算是一個快樂的結局。&lt;/li&gt;&lt;li&gt;127 hours(&lt;a href="http://www.imdb.com/title/tt1542344/" title="127 Hours (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/127_Hours" title="127 Hours - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：127小時。這部片是一個獨自去爬山健行的人的故事，出發前都沒跟任何人講，結果途中失足，被石頭壓到手，獨自在荒郊野外過了127小時，後來自己把手給弄斷才脫困的故事。故事很簡單，看完以後覺得手真的是超痛的啊!!怎麼會有人能把自己手弄斷而不昏倒的，超厲害的。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1701991566334170087?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1701991566334170087/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1701991566334170087' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1701991566334170087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1701991566334170087'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/05/20114272011525.html' title='電影流水帳(2011/4/27~2011/5/25)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8098989721964641516</id><published>2011-05-25T16:46:00.001+08:00</published><updated>2011-05-25T17:33:37.474+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='jsonp'/><title type='text'>pixnetalbummaker(3)</title><content type='html'>承蒙&lt;a href="http://jnlin.org"&gt;jnlin&lt;/a&gt;跟&lt;a href="http://blog.gslin.org"&gt;gslin&lt;/a&gt;二位pixnet開發者的幫忙，現在連後端都不用刻了，只要搞定前台的javascript就可以去PIXNET album撈圖。就用jQuery.getScript()與PIXNET API 吐jsonp就可以達成。&lt;br /&gt;&lt;br /&gt;然後也參考這篇&lt;a href="http://blog.realmofzod.com/blog/2009/04/09/asynchronous-image-loading-with-jquery/"&gt;Asynchronous Image Loading with jQuery&lt;/a&gt;，為圖片加上了動態載入的效果。目前比較傷腦筋的問題就排版問題，發生的情況有以下幾個：一個是當圖寬高值過大時，一個是當圖片數目過多時。這再想辦法好了。&lt;br /&gt;&lt;br /&gt;之後可能會來看OAuth吧，看可不可以自動去 PIXNET blog 、blogger、facebook 貼文，就不用手動複製然後貼上了。&lt;br /&gt;&lt;br /&gt;對了，網址是&lt;a href="http://pixnetalbummaker.appspot.com"&gt;http://pixnetalbummaker.appspot.com&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8098989721964641516?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8098989721964641516/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8098989721964641516' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8098989721964641516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8098989721964641516'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/05/pixnetalbummaker3.html' title='pixnetalbummaker(3)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1666688482790750287</id><published>2011-05-23T15:49:00.000+08:00</published><updated>2011-05-23T15:49:29.490+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='json'/><category scheme='http://www.blogger.com/atom/ns#' term='jsonp'/><title type='text'>jsonp</title><content type='html'>前兩年有使用過，可是最近想起來時，卻發現什麼記憶都不剩，只記得好像是解決 cross domain 的方案。上網找了一下，終於讓我給想起來了，下面用我懂的話來寫，這樣下次又忘記時，可以很快想起來。&lt;br /&gt;&lt;br /&gt;在利用 xmlhttp(或form) post/get 時，目標的網址(action)跟目前網頁的網址必須是在同一個網域上，否則會無法post/get。該怎麼解決呢？就要利用所謂的 jsonp。jsonp 是利用動態安插 script tag 的方式來繞過 cross domain 的限制，script tag 裡的 src 不受 cross domain 的限制，一般來說，src 裡的網址會多加一個參數 callback (當然，不一定要叫作callback)，也就是說，後端收到這個 request 時，會去進行處理(一般會處理為json資料)，最後輸出時，會輸出 javascript ，並且將 json 資料傳入你指定的 callback並執行，這樣就完成了。&lt;br /&gt;&lt;br /&gt;本來以為 PIXNET API 可以直接利用 jsonp，就不需要另外刻後台來拉資料，結果今天去看時，發現沒有，大概是之前眼花了吧...&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1666688482790750287?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1666688482790750287/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1666688482790750287' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1666688482790750287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1666688482790750287'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/05/jsonp.html' title='jsonp'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2219725077523686145</id><published>2011-05-20T11:36:00.000+08:00</published><updated>2011-05-20T11:36:24.928+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>pixnetalbummaker(2)</title><content type='html'>GAEO 0.5 beta用的不順，再加上開發已經停止，所以還是用回文件相對比較多的0.3版。&lt;br /&gt;&lt;br /&gt;之前從&lt;a href="https://github.com/roymax/trunkly-python"&gt;trunkly-python&lt;/a&gt;抄來的代碼不太適用於PIXNET API，所以稍做了&lt;a href="https://github.com/elleryq/pypixnet/commit/7c100abc09d210e35b0cd1c6172a0053fc45894f"&gt;改動&lt;/a&gt;，原本是這樣使用的：&lt;pre name="code" class="python"&gt;print( pixnet.get_users_elleryq() )&lt;br /&gt;print( pixnet.get_album_sets( {'user': 'elleryq' }) )&lt;/pre&gt;現在得這樣用：&lt;pre name="code" class="python"&gt;print( pixnet.get_users( "elleryq", {} ) )&lt;br /&gt;print( pixnet.get_album_sets( parameters={'user': 'elleryq' }) )&lt;/pre&gt; &lt;br /&gt;是說，應該要好好來研究一下cross domain的xmlhttp，這樣根本就不用寫後台了，直接呼叫PIXNET API就好~&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2219725077523686145?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2219725077523686145/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2219725077523686145' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2219725077523686145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2219725077523686145'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/05/pixnetalbummaker2.html' title='pixnetalbummaker(2)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7762618941884508344</id><published>2011-05-11T09:52:00.000+08:00</published><updated>2011-05-11T09:52:02.354+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='statistics'/><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='math'/><title type='text'>歡樂智多星的機率隨想</title><content type='html'>歡樂智多星是胡瓜在衛視中文台主持的節目，遊戲的規則是，參加的人有30萬，每關有3個選擇，然後可以選擇全部押在一個答案上，或是分散，只要過了五關，剩下的錢就你的。&lt;br /&gt;&lt;br /&gt;先不考慮最低的押注是1萬的這個規則。最早的規則是可以把錢分散在3個答案上，所以這樣子的機率是 (1/3) ^ 5 = 1/243，最近看的時候，發現節目修改規則了，變成你只能把錢分散在兩個答案上，看起來過關機率降低了，但是實際上，只要排除掉不可能的那個答案，然後平均分散押注在另外兩個答案的話，這樣子機率是 (1/2) ^ 5 = 1/32，反而提高了!!&lt;br /&gt;&lt;br /&gt;現在在加上最低押注是一萬的規則。如果把錢分散在3個答案上，押注金額較多的又剛好過關，那麼，&lt;br /&gt;&lt;ol&gt;&lt;li&gt;10萬:10萬:10萬&lt;/li&gt;&lt;li&gt;4萬:3萬:3萬&lt;/li&gt;&lt;li&gt;2萬:1萬:1萬&lt;/li&gt;&lt;li&gt;孤注一擲&lt;/li&gt;&lt;li&gt;孤注一擲&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;同樣的情況，但只能把錢分散在兩個答案上，這邊再加上一個都會過關的假定：&lt;ol&gt;&lt;li&gt;15萬:15萬:0&lt;/li&gt;&lt;li&gt;8萬:7萬:0&lt;/li&gt;&lt;li&gt;4萬:4萬:0&lt;/li&gt;&lt;li&gt;2萬:2萬:0&lt;/li&gt;&lt;li&gt;1萬:1萬:0&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;從上面的分析看來，參賽者不再一定需要知道正確答案，也就是你可以什麼都不知道，在此情況時，嚴格執行排除最不可能的答案，並且把錢平均分散在其他兩個答案上，這樣最後至少可以得到一萬元。相較之前的規則，在第四次以後就只能孤注一擲的情況來說，節目的新規則把勝率提高許多。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7762618941884508344?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7762618941884508344/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7762618941884508344' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7762618941884508344'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7762618941884508344'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/05/blog-post.html' title='歡樂智多星的機率隨想'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1589331556714681942</id><published>2011-05-10T16:10:00.000+08:00</published><updated>2011-05-10T16:10:30.190+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>pixnetalbummaker(1)</title><content type='html'>我環境是ubuntu 10.04，依照GAEO文件，以easy_install安裝gaeo，可以順利安裝。&lt;br /&gt;&lt;br /&gt;但在產生專案時，卻會出現："OSError: [Errno 2] No such file or directory: '/usr/local/lib/python2.6/dist-packages/gaeo-0.5-py2.6.egg/oildrum/static'" 的錯誤。&lt;br /&gt;&lt;br /&gt;此錯誤應該與easy_install的EGG有關係，原因是因為少檔案，下載官方的 zip 檔案可以發現以 easy_install 安裝以後的 oildrum 跟 zip 裡的 oildrum 檔案數目並不一樣，也就是說少安裝了。解決方法也很簡單，就把 zip 檔案裡的 oildrum 複製過去即可。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1589331556714681942?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1589331556714681942/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1589331556714681942' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1589331556714681942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1589331556714681942'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/05/pixnetalbummaker1.html' title='pixnetalbummaker(1)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-4293037205539647300</id><published>2011-04-26T14:32:00.002+08:00</published><updated>2011-04-26T14:32:58.755+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/4/8~2011/4/26)</title><content type='html'>等後半年有特休的時候，看能不能消化掉比較多的電影債...最近啟動原始碼的片名source code蠻有梗的，例如：&lt;br /&gt;Dilbert: I watched source code yesterday. (我昨天看了source code)&lt;br /&gt;Dogbert: Linux kernel or Android? (是Linux kernel的還是Android的?)&lt;br /&gt;不過 watch 跟 read 在英文上的意思差很多，只要一亮出動詞，就又沒梗了...&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://disney.go.com/tron/"&gt;TRON&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt1104001/" title="TRON: Legacy (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Tron:_Legacy" title="Tron: Legacy - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：創：光速戰記。這是&lt;a href="http://en.wikipedia.org/wiki/Tron_(film)"&gt;1982年Tron&lt;/a&gt;的復刻板本，單就劇情來看，在1982年那個時候，真的是很創新的題材，很令人驚訝的，除了人能進到電腦世界以外，很多部份都還蠻寫實的。但是同樣的劇情放到現在，除了特效之外，好像就沒什麼了...劇情是小男孩的父親在小男孩小時候消失了，一直都沒回來。長大以後去老爸工作的地方看，才知道他真的到電腦世界裡去了，於是就進去看看。進去以後才知道他的父親沒有晃點他，只是因為他創造的程式反叛了他才沒辦法回來，一待之下就待了十幾年。要出來，就要改變，故事就是在講這個，最後當然是出來了，還多帶了一個女人出來，真的是很神奇，讓我想到桂正和的電影少女啊...&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.bvi.com.tw/movies/Detective/"&gt;Detective Dee and the Mystery of the Phantom Flame&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt1123373/" title="Di Renjie zhi tongtian diguo (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://zh.wikipedia.org/wiki/%E7%8B%84%E4%BB%81%E5%82%91%E4%B9%8B%E9%80%9A%E5%A4%A9%E5%B8%9D%E5%9C%8B" title="狄仁傑之通天帝國 - 维基百科，自由的百科全书"&gt;Wikipedia&lt;/a&gt;)，中譯：通天神探狄仁傑。放中譯的原因是因為大陸那邊的譯名跟台灣不一樣，然後英文片名也頗有趣味。其實故事比較像是推理小說，跟當時的時代背景什麼的，沒什麼太大關係，有應用到的梗，一個就是武則天跟李唐的一些糾葛，一個就是人名。故事編的還蠻好看的，國師真的是跟武則天有很奇妙的關係，兇手竟然是自己的好朋友，最後頗有柳暗花明的感覺，不錯看的電影。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-4293037205539647300?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/4293037205539647300/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=4293037205539647300' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4293037205539647300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/4293037205539647300'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/04/2011482011426.html' title='電影流水帳(2011/4/8~2011/4/26)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7488346874987007287</id><published>2011-04-08T15:02:00.000+08:00</published><updated>2011-04-08T15:02:25.396+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>編譯DLR debug version</title><content type='html'>因為 Pro DLR 有介紹編譯&lt;a href="http://dlr.codeplex.com/"&gt;Dynamic Language Runtime&lt;/a&gt; debug version的部份，如此一來就可以利用Visual studio來追蹤DLR內部的運作。&lt;br /&gt;&lt;br /&gt;下載位置在&lt;a href="http://dlr.codeplex.com/"&gt;這兒&lt;/a&gt;，目前是1.0版。&lt;br /&gt;&lt;br /&gt;假設你是用 Visual studio 2010/Visual studio express 2010的話：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;如果要在 .Net 4 下debug，開啟 Src 下的 Codeplex-DLR-Dev10.sln。&lt;/li&gt;&lt;li&gt;如果要在 .Net 2 (3.5也算)下debug，開啟 Src 下的Codeplex-DLR.sln 或 Codeplex-DLR-VSExpress.sln，開啟以後，會說要轉換。&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;編譯以後，就可以在 Bin 目錄下找到檔案。&lt;br /&gt;&lt;br /&gt;本來想說真不妙，竟然得一個個Project去改Target framework，還去找了人家寫好的Visual studio macro來做，可以是後來發現reference也要改，就暈了。幸好早就有提供.Net 2.0版本的solution檔案了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7488346874987007287?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7488346874987007287/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7488346874987007287' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7488346874987007287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7488346874987007287'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/04/dlr-debug-version.html' title='編譯DLR debug version'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8830555472411582716</id><published>2011-04-07T17:14:00.000+08:00</published><updated>2011-04-07T17:14:18.009+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/2/23~2011/4/7)</title><content type='html'>脫逃出現在的世界吧...follow this &lt;a href="http://www.lantis.jp/js/ligbox/jsprint.html"&gt;link&lt;/a&gt;...&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://adisney.go.com/disneypictures/sorcerersapprentice/"&gt;Sorcerer's apprentice&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt0963966/" title="The Sorcerer's Apprentice (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/The_Sorcerer%27s_Apprentice_%282010_film%29" title="The Sorcerer's Apprentice (2010 film) - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：魔法師的學徒。不難看的電影。一開始就交代了魔法師的故事，一切從梅林開始。梅林在死後，大弟子勾結外面的惡魔法師要搶奪一個咒語，與梅林另外兩個徒弟打起來，後來兩個趁著惡魔法師沒注意，將她封了起來。封起來的代價就是大家都變成俄羅斯娃娃，只剩下尼可演的魔法師。在攸長的歲月裡，俄羅斯娃娃外面因為又封印了許多魔法師的緣故，陸續套上愈來愈多的娃娃。時間很快就到了現代，主角在小時候不小心遇到了魔法師，被梅林的遺物選為繼承者。他不小心放出了大弟子，導致魔法師為了阻止他，自我封印，兩人都到了瓶子裡。時間很快，過了十年，主角長大了，魔法師也因為咒語失效陸續被放出來，然後就展開了訓練、打鬥的過程，最後當然是主角變得很powerful，將壞蛋都收拾掉。主角是一整個弱掉，因為演魔法師的都是大咖，太搶眼了。&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.prowaremovie.com/suzumiya/"&gt;涼宮ハルヒの消失&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt1572781/" title="Suzumiya Haruhi no shôshitsu (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://ja.wikipedia.org/wiki/%E6%B6%BC%E5%AE%AE%E3%83%8F%E3%83%AB%E3%83%92%E3%81%AE%E6%B6%88%E5%A4%B1" title="涼宮ハルヒの消失 - Wikipedia"&gt;Wikipedia&lt;/a&gt;)，中譯：&lt;a href="http://zh.wikipedia.org/wiki/%E6%B6%BC%E5%AE%AE%E6%98%A5%E6%97%A5%E7%9A%84%E6%B6%88%E5%A4%B1"&gt;涼宮春日的消失&lt;/a&gt;。我是先看過小說才來看電影。電影的節奏有點悶，不過整個氛圍相當微妙，帶有淡淡的愛情感覺，還不錯。故事大致就是照著小說來演，這裡就不破梗了。總之，時間機器的設定真的是很好用啊!!(咦?這樣算破梗嗎?)&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8830555472411582716?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8830555472411582716/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8830555472411582716' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8830555472411582716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8830555472411582716'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/04/2011223201147.html' title='電影流水帳(2011/2/23~2011/4/7)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7349417290797275051</id><published>2011-03-21T17:41:00.000+08:00</published><updated>2011-03-21T17:45:07.727+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='c/c++'/><title type='text'>gcin筆記(2)</title><content type='html'>看了 gcin 的程式，覺得頗亂，命名跟檔名是有其規則，例如 pp 是指詞音、pho 是注音、gtab 是亂倉打鳥、倉頡...等，不過，對於要新增輸入法，並沒有 interface讓人知道說該實作些什麼。看到這裡有點想放棄了說~&lt;br /&gt;&lt;br /&gt;連線的部份是 socket，但 event 的處理則是用 glib 的 &lt;a href="http://www.linuxjournal.com/article/8545" title="async I/O with IO Channels"&gt;io_channel&lt;/a&gt; (g_io_add_watch)。&lt;br /&gt;&lt;br /&gt;當 client 第一次跟 server 建立連線，是在 cb_new_gcin_clients()，gcin_clients 在 cb_new_gcin_client() 被配置出來，這邊是在超過預先配置好的 gcin_clients 的時候，才以 trealloc() 去重配置。在一開始如果有太頻繁的client過來(仔細想想，好像不太可能)，每次都重新配置，是不太有利的。但是如果改用  g_list 或 g_array 來做，感覺上又不是很划算。&lt;br /&gt;&lt;br /&gt;server 收到 client request 的點是在 im-srv.cpp 裡的 cb_read_gcin_client()，裏面會去執行 process_client_req()。process_client_req() 在 im-dispatch.cpp 裡，拿到 fd，直接用之前在 cb_new_gcin_client() 預配置的陣列 gcin_clients 去做判斷、處理。裏面會根據 req_no 再去看要呼叫 ProcessKeyPress()/ProcessKeyRelease()...等函數 (在 eve.cpp 裡)。&lt;br /&gt;&lt;br /&gt;參考 anthy 日文輸入法，好像比較好，因為同樣也是外部的library&lt;br /&gt;下面是掃過 eve.cpp 以後，得到的一些東西：&lt;ul&gt;&lt;li&gt;feedkey_anthy()&lt;/li&gt;&lt;li&gt;feedkey_anthy_release()&lt;/li&gt;&lt;li&gt;hide_win_anthy()&lt;/li&gt;&lt;li&gt;show_win_anthy()  =&amp;gt; init_in_method() 會用到&lt;/li&gt;&lt;li&gt;move_win_anthy()&lt;/li&gt;&lt;li&gt;get_win_anthy_geom()&lt;/li&gt;&lt;li&gt;anthy_visible() =&amp;gt; 給 win_is_visible() 用&lt;/li&gt;&lt;li&gt;init_win_anthy() =&amp;gt; init_in_method() 會用到&lt;/li&gt;&lt;li&gt;anthy_get_preedit()&lt;/li&gt;&lt;li&gt;gcin_anthy_reset() =&amp;gt; 給 gcin_reset() 用&lt;/li&gt;&lt;li&gt;flush_anthy_input =&amp;gt; 給 flush_edit_buffer 用&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;看起來是要實作這些部份。&lt;br /&gt;&lt;br /&gt;init_win_anthy(): anthy 是用 dlopen 的方式載入，這樣也對，可以省掉一開始不必要的配置。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7349417290797275051?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7349417290797275051/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7349417290797275051' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7349417290797275051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7349417290797275051'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/03/gcin2.html' title='gcin筆記(2)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1194643060200389156</id><published>2011-03-18T11:15:00.000+08:00</published><updated>2011-03-18T11:18:47.341+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c/c++'/><category scheme='http://www.blogger.com/atom/ns#' term='gcin'/><title type='text'>gcin筆記</title><content type='html'>gcin輸入法以 INMD 定義，在 gtab-list.cpp 裡載入，從 gtab.list 載入，裏面決定了檔名、方法...&lt;br /&gt;&lt;br /&gt;如果要加新酷音，&lt;ul&gt;&lt;li&gt;在 method_codes[] 裡增加一個項目， !CHEWING&lt;/li&gt;&lt;li&gt;gtab.list 裡增加一個新的項目，新酷音 ] !CHEWING chewing.png&lt;/li&gt;&lt;li&gt;MAX_GTAB_NUM_KEY 也要再加1&lt;/li&gt;&lt;li&gt;load_gtab_list 一開頭把 method_type 寫死了，所以這邊也要加，inmd[16].method_type=method_type_CHEWING&lt;/li&gt;&lt;li&gt;加 method_type_CHEWING&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;以上從 gcin-setup.cpp 的 cb_default_input_method() 開始追&lt;br /&gt;callback 裡呼叫了 create_gtablist_window()，然後再呼叫 create_model()。從裏面的 add_items() 再看到 load_gtab_list() 而推導的。&lt;br /&gt;&lt;br /&gt;從 GtkIMContextClass 的 filter_keypress 開始看: gtk_im_context_gcin_filter_keypress&lt;br /&gt;&lt;br /&gt;大致上的架構是這樣子：&lt;br /&gt;gtk_im_context -&amp;gt; gcin client &amp;lt;-&amp;gt; gcin server&lt;br /&gt;&lt;br /&gt;eve.cpp 裡的 ProcessKeyPress 是處理 Key 的部份，所以這邊可以看到輸入法的切換、暫時切換為英文、選phrase...等等的處理。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1194643060200389156?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1194643060200389156/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1194643060200389156' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1194643060200389156'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1194643060200389156'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/03/gcin.html' title='gcin筆記'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-877164553917898671</id><published>2011-03-16T14:25:00.000+08:00</published><updated>2011-03-16T14:26:48.404+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><title type='text'>好久沒用Vimana之gundo</title><content type='html'>因為看到了&lt;a href="http://blog.othree.net/log/2011/02/27/gundovim/"&gt;Gundo.vim&lt;/a&gt;，就想說來試用看看。&lt;br /&gt;&lt;br /&gt;要安裝 vim 插件，當然就是用 vimana，於是就更新許久未用的vimana。依照vimana的readme，以cpanm來進行重安裝。但是卻無法安裝，cpanm告訴我有 "Can't locate inc/Module/Install.pm"&lt;br /&gt;&lt;br /&gt;太鳥了，去年有碰到此問題，但沒解決，果然有報應，該找出原因的還是該找出來，否則以後一直會遇到。亂找了一下，發現要安裝 libmodule-install-perl 才行，於是就立馬執行了 sudo apt-get install libmodule-install-perl。&lt;br /&gt;&lt;br /&gt;接著再來安裝，是說，不知道為什麼，會有Test fail的情況，所以就省略掉測試，改用 cpanm --sudo --reinstall -n "Vimana的目錄" 這樣就大功告成了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-877164553917898671?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/877164553917898671/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=877164553917898671' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/877164553917898671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/877164553917898671'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/03/vimanagundo.html' title='好久沒用Vimana之gundo'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-5119853425029450109</id><published>2011-03-11T17:34:00.000+08:00</published><updated>2011-03-11T17:41:14.028+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>sis162u與ndiswrapper</title><content type='html'>原本以為linux的硬體相容性很高，至少好幾年前買的Asus USB無線網卡應該是要可以用的，結果，並不是我想的。不支援，就是不支援。&lt;br /&gt;&lt;br /&gt;還好知道這支無線網卡的晶片是SiS162U，就上網Google了一下，發現大家都是用ndiswrapper來裝上Windows的驅動程式，然後讓它運作。&lt;br /&gt;&lt;br /&gt;我裝的是ndisgtk這個GUI程式，安裝以後，執行ndisgtk，然後安裝sis162的windows驅動程式，就...大功告成了嗎?&lt;br /&gt;&lt;br /&gt;不是，因為我用的sis162 windows驅動程式不知道有問題還是太舊，查了好久，後來我是去SiS官方網站抓了最新的105版的驅動程式下來裝，就沒問題了!!&lt;br /&gt;&lt;br /&gt;所以碰到只有Windows驅動程式而Linux不支援的時候，可以用ndiswrapper + ndisgtk 試試看，也許就起死回生。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-5119853425029450109?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/5119853425029450109/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=5119853425029450109' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5119853425029450109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/5119853425029450109'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/03/sis162undiswrapper.html' title='sis162u與ndiswrapper'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1627415552321578760</id><published>2011-03-10T17:56:00.000+08:00</published><updated>2011-03-10T18:00:28.512+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c/c++'/><title type='text'>libchewing小記</title><content type='html'>libchewing的用法挺簡單的，我是先試 python 目錄下的範例，可是即便我把 Init() 裡的目錄改成對的了，還是不行。這邊要傳進去的目錄，要用 libchewing3-data 的安裝路徑，否則Init會出錯。&lt;br /&gt;&lt;br /&gt;對照 test/testchewing.c 裡的程式以後，發現沒什麼太大的不同，可是就是不行，反正以後沒有要用 python 來寫，所以就算了。&lt;br /&gt;&lt;br /&gt;最後是對照 test/testchewing.c 去寫一個小的程式，就可以運作了，test/testchewing.c 是一個很好的進入點。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1627415552321578760?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1627415552321578760/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1627415552321578760' title='3 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1627415552321578760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1627415552321578760'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/03/libchewing.html' title='libchewing小記'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1882876839146019311</id><published>2011-03-09T15:30:00.001+08:00</published><updated>2011-03-09T15:33:00.903+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>讀Debian新維護人員手冊</title><content type='html'>讀&lt;a href="http://www.debian.org/doc/maint-guide/index.zh-tw.html"&gt;Debian新維護人員手冊&lt;/a&gt;記下的：&lt;br /&gt;&lt;ul&gt;&lt;li&gt;比較版本：dpkg --compare-versions ver1 op ver2 &lt;/li&gt;&lt;li&gt;添加環境變數到 .bashrc 以供識別：&lt;pre&gt;DEBEMAIL=your.email.address@example.org&lt;br /&gt;DEBFULLNAME="Firstname Lastname"&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;dh_make 可以快速的從一個 tarball 產生出 tarball 副本跟 debian 目錄，如：dh_make -f ../gentoo-0.9.12.tar.gz&lt;/li&gt;&lt;li&gt;control裡的內容，如分類、權重...等可參考 &lt;a href="http://www.debian.org/doc/debian-policy/ch-controlfields.html"&gt;Debian Policy Manual&lt;/a&gt;&lt;/li&gt;&lt;li&gt;可以用 dpkg-depcheck -d ./configure去檢查相依性，或者用 objdump -p foo | grep NEEDED 去看用了哪些 library&lt;/li&gt;&lt;li&gt;changelog 可以參考&lt;a href="http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog"&gt;Debian Policy Manual, 4.4&lt;/a&gt;，是主要定版號的地方。&lt;/li&gt;&lt;li&gt;rules 可以用 fakeroot debian/rules target 來執行裏面的特定 target&lt;/li&gt;&lt;li&gt;可以用 debuild 來自動化，在 .devscripts 裡添加&lt;ul&gt;&lt;li&gt;DEBSIGN_KEYID="keyID"&lt;/li&gt;&lt;li&gt;DEBUILD_LINTIAN=yes&lt;/li&gt;&lt;li&gt;DEBUILD_LINTIAN_OPTS="-i -I --show-overrides"&lt;/li&gt;&lt;/ul&gt;，然後 debuild -sa、debuild clean&lt;/li&gt;&lt;li&gt;檢查套件：&lt;ul&gt;&lt;li&gt;debi xxxx_i386.changes &lt;/li&gt;&lt;li&gt;lintian -i -I --show-overrides xxx_i386.changes&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1882876839146019311?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1882876839146019311/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1882876839146019311' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1882876839146019311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1882876839146019311'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/03/debian.html' title='讀Debian新維護人員手冊'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7239911623601040061</id><published>2011-03-02T17:10:00.000+08:00</published><updated>2011-03-02T17:17:48.759+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='j2me'/><category scheme='http://www.blogger.com/atom/ns#' term='epub'/><title type='text'>AlbiteReader後續修正</title><content type='html'>J2ME裡的英文字型寬度不是固定的，所以顯示英文字的時候會怪怪的。利用 HashTable 去存英文字的寬度，至於中文字型還是固定，這樣英文顯示就比較漂亮一點了。&lt;br /&gt;&lt;br /&gt;大致上就這樣，更新以後的檔案放在&lt;a href="http://dl.dropbox.com/u/2226918/AlbiteREADERX/AlbiteReaderLight.jar"&gt;同一個地方&lt;/a&gt;，需要的人自己下載。&lt;br /&gt;&lt;br /&gt;另記用 Sigil 的心得，儘量使用 p、blockquote 來做編排，段落的呈獻會比較漂亮，避免使用 br 來做斷行。簡單說，大致的編排就是儘量使用 html 搭配 css，而不要用硬幹的方式。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7239911623601040061?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7239911623601040061/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7239911623601040061' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7239911623601040061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7239911623601040061'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/03/albitereader.html' title='AlbiteReader後續修正'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8585682865898996936</id><published>2011-02-25T17:36:00.000+08:00</published><updated>2011-02-25T17:58:14.992+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='j2me'/><title type='text'>AlbiteReader的後續紀錄</title><content type='html'>AlbiteReader是一個可以在手機上閱讀 epub 電子書的軟體，原來只能看英文，下面是我改成可以看中文的紀錄。&lt;br /&gt;&lt;br /&gt;原本很擔心怎麼build的問題，想不到下載 netbean 6.9.1 + J2ME 3.0 的版本就迎刃而解，先從&lt;a href="https://github.com/dumbledore/AlbiteREADER/"&gt;AlbiteREADER&lt;/a&gt;的github網頁上把原始碼拉下來，接著用 netbean 開就行了，除了可以 build 也可以 debug (有emulator)，這在後續追蹤問題上，給了我很大的協助。&lt;br /&gt;&lt;br /&gt;netbean 這邊比較大的問題是在編輯主要畫面，就編輯 .midlet 檔時，如果選 flow 會整個當掉，我後來是根本沒機會看到，好在也不需要用到，其他的頁籤就都可以點，所以我就順手把主選單給中文化了。&lt;br /&gt;&lt;br /&gt;之前有提到 Font 的問題，後來是整個翻掉，改成使用系統的中文字型，所以 AlbiteFont 類別其實是 J2ME Font 的 Adapter，作為一個中間的轉換，對原來的 AlbiteReader 來說，介面幾乎是一樣，只是底層顯示的方式改變了。&lt;br /&gt;&lt;br /&gt;改了以後，根本沒辦法顯示，去 debug，才知道 Font.drawChar跟 netbean 給的提示不一樣，drawChar 的最後一個參數並不是 color，必須要給 Graphics.TOP、Graphics.LEFT...這些定位的參數才行，我後來是用 Graphics.TOP | Graphics.LEFT，簡單說，就是一個是上下的定位，一個是左右的定位，我就是固定靠左上角。&lt;br /&gt;&lt;br /&gt;可以顯示之後，發現最右邊總是會出現半個字。原本以為是斷字出現的問題，大致追到TextPage，確定這裡是主要處理多少字為一頁的地方。再次利用了 debug，發現程式的思維跟我想的不一樣，程式的作法是根本不斷字，每行其實是一個 XXXRegion 的類別，Region 裡放的字串是好長一串，顯示的時候其實是這樣畫：12345678, 45678, 78...，所以根本跟斷字無關，一定會畫出半個字。我的處理方式是在 Font.drawChars 增加一個參數，在邊畫字的時候，就邊檢查，如果超出了這個值，就不畫了，這樣就避免了畫出半個字的問題。&lt;br /&gt;&lt;br /&gt;整個改到這邊的時候，是很高興的，但是放到手機上，卻發現慢到一個不行。想了一個晚上，才想到，可能是取字寬度的問題，在看 TextPage 時，發現程式裡大量使用了取字寬度函數。因為我是呼叫 J2ME Font.charWidth()，每個字都去呼叫，而原來的處理，這些值都是固定的，而且字了不起也才 26 個英文字母 + 數字 + 標點符號，不會對程式有太大的負荷。但對中文字來說，如果每個字都去查，那肯定是很慢。這邊我的處理方法是在 initialize Font 的時候，就先把一個中文字的寬度記下來，假定每個中文字的寬度都一樣 (好在也都一樣)，之後就用這個值去計算，這樣就恢復到原來的速度了。&lt;br /&gt;&lt;br /&gt;回憶錄大概就記到這裡，如果有需要參考我的 code，可以到&lt;a href=" https://github.com/elleryq/AlbiteREADER"&gt;我 fork 出來的 github repository&lt;/a&gt;去拉。&lt;br /&gt;要直接下載 .jar 的話，可以直接從&lt;a href="http://dl.dropbox.com/u/2226918/AlbiteREADERX/AlbiteReaderLight.jar"&gt;這裡&lt;/a&gt;下載。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8585682865898996936?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8585682865898996936/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8585682865898996936' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8585682865898996936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8585682865898996936'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/02/albitereader_25.html' title='AlbiteReader的後續紀錄'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3365680268472556874</id><published>2011-02-22T14:38:00.000+08:00</published><updated>2011-02-22T14:39:20.037+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/2/14~2011/2/22)</title><content type='html'>也是托網樂通的福。對遙控器的 play/pause 按鍵感到很火大，到底是為什麼在快轉/倒退時會那麼難按呢??&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.howtotrainyourdragon.com/"&gt;How to train your dragon&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt0892769/" title="How to Train Your Dragon (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/How_to_Train_Your_Dragon_(film)" title="How to Train Your Dragon (film) - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：馴龍高手。維京男孩並不像一般的維京人，他打下了一條龍，並且發現了危害維京人的龍並不是單純因為想殘害他們而來搶食物，這個發現，不僅改變了部落的命運，也改變了龍的命運。我覺得很好看的動畫片，除了提醒自己當爸爸的要仔細聽懂兒子的話，也提醒自己要勇往直前，不要畏縮。&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.thesocialnetwork-movie.com/"&gt;The Social Network&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt1285016/" title="Shequnwang zhan (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/The_Social_Network" title="The Social Network - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：社群網戰。facebook網站創辦的經過，同時涉及了兩件訴訟案。被那兩個兄弟告，我覺得idea真的是先做先贏，這是有點沒道理，也不容易證明。但是被自己共同創辦人&lt;a href="http://en.wikipedia.org/wiki/Eduardo_Saverin"&gt;Eduardo Saverin&lt;/a&gt;告的那件訴訟，我就覺得Eduardo有點可憐了。不過最後都是以和解收場，算是皆大歡喜? 我覺得演那兩個兄弟的演員真的很帥又很壯，同事表示演Eduardo也很帥，只有主角比較不帥，不知道是不是導演故意的。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3365680268472556874?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3365680268472556874/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3365680268472556874' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3365680268472556874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3365680268472556874'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/02/20112142011222.html' title='電影流水帳(2011/2/14~2011/2/22)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-1247832648769295161</id><published>2011-02-16T13:55:00.000+08:00</published><updated>2011-02-16T13:56:52.076+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='瀏覽器(browser)'/><title type='text'>chromium/chrome 裡的flash收不到space key</title><content type='html'>就不要用internal 的 flash。&lt;br /&gt;&lt;br /&gt;啟動 chromium/chrome 時，加上 --disable-internal-flash 參數。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-1247832648769295161?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/1247832648769295161/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=1247832648769295161' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1247832648769295161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/1247832648769295161'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/02/chromiumchrome-flashspace-key.html' title='chromium/chrome 裡的flash收不到space key'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-7035081841022098259</id><published>2011-02-15T12:27:00.000+08:00</published><updated>2011-02-15T12:29:13.995+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>make recoveryimage後什麼事都沒有發生</title><content type='html'>make recoveryimage無法建出recovery image，追蹤build/core/Makefile以後，就可以發現，如果有定義TARGET_NO_KERNEL、TARGET_NO_RECOVERY或BUILD_TINY_ANDROID任一個為true的話，就不會建出來。&lt;br /&gt;&lt;br /&gt;而我拿到的SDK的BoardConfig.mk裡，正好就有這麼一行：TARGET_NO_KERNEL:=true&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-7035081841022098259?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/7035081841022098259/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=7035081841022098259' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7035081841022098259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/7035081841022098259'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/02/make-recoveryimage.html' title='make recoveryimage後什麼事都沒有發生'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6594009416706857589</id><published>2011-02-14T13:11:00.002+08:00</published><updated>2011-02-14T13:13:11.806+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/2/8~2011/2/13)</title><content type='html'>真要說網樂通的缺點，就是沒有bookmark，以後如果要推包租電影的服務，我覺得這是相當重要的特色。不用到說有選單讓我設定bookmark，只要當我按停止或離開時能自動存下那個當下的點，之後當我再回來繼續看時，能自動繼續就好。每次因為小朋友要停下，之後要回去接著看時，就很累，64x的快轉才差不多跳一分鐘而已，而這樣的動作差不多要一秒，所以如果你是在最後的一小時三十分鐘離開不看，之後要回來接著看，就要按快轉64x，等約一分三十秒才能從停掉的地方開始看。之後會再看看收費服務合不合理，如果不是很ok的話，大概就會收起來供了吧...&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.sonywonder.com/openseason3/"&gt;Open Season 3&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt1646926/"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Open_Season_3"&gt;Wikipedia&lt;/a&gt;)，中譯：打獵季節3。這部片子印象中台灣好像沒上。故事很簡單，春天到了，應該是要去男生旅行的季節，可是卻沒人要跟大灰熊布穀去。布穀只好自己去亂逛，亂逛的時候遇到了馬戲團的大灰熊阿德，於是他們交換身份，最後，布穀的好朋友一起來找他，而布穀走的時候還帶了一個女友一起走，可謂是皆大歡喜。這一集除了以前的好朋友以外，還多了駱馬，算是大團圓的片，故事普普。這部片老婆跟我被兩個公子強迫看了十幾遍了，所以說，對小朋友應該是相當有吸引力....囧&lt;/li&gt;&lt;li&gt;Knight and Day(&lt;a href="http://www.imdb.com/title/tt1013743/" title="Knight and Day (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Knight_and_Day"&gt;Wikipedia&lt;/a&gt;)，中譯：騎士出任務。很歡樂又有動作的片子，相當適合用來打發時間。就女主角其實算是宅女，出去找汽車零件的時候遇上了男主角，一開始並不知道他是特務，後來慢慢知道了整個事情的始末然後展開一連串的冒險，最後當然是順利解決事件。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6594009416706857589?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6594009416706857589/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6594009416706857589' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6594009416706857589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6594009416706857589'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/02/2011282011213.html' title='電影流水帳(2011/2/8~2011/2/13)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2308535408764229815</id><published>2011-02-11T12:48:00.000+08:00</published><updated>2011-02-11T12:49:39.277+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='epub'/><title type='text'>AlbiteReader的字型處理</title><content type='html'>org.albite.font.AlbiteFont&lt;br /&gt;&lt;ol&gt;&lt;li&gt;ctor 開啟字型檔以後，就開始處理 (這邊是開 .alf)&lt;/li&gt;&lt;li&gt;格式&lt;ul&gt;&lt;li&gt;byte 1: line spacing&lt;/li&gt;&lt;li&gt;byte 2: line height&lt;/li&gt;&lt;li&gt;byte 3-6: glyphs (character range)&lt;/li&gt;&lt;li&gt;byte 7-8: maxium width&lt;/li&gt;&lt;li&gt;byte 9-12: character count&lt;/li&gt;&lt;li&gt;接下來就是循序讀出各字元的 x, y, w, h, xo, yo, xa&lt;ul&gt;&lt;li&gt;byte 1-2: character&lt;/li&gt;&lt;li&gt;byte 3-4: x&lt;/li&gt;&lt;li&gt;byte 5-6: y&lt;/li&gt;&lt;li&gt;byte 7-8: width&lt;/li&gt;&lt;li&gt;byte 9-10: height&lt;/li&gt;&lt;li&gt;byte 11-12: xoffset&lt;/li&gt;&lt;li&gt;byte 13-14: yoffset&lt;/li&gt;&lt;li&gt;byte 15-16: xadvance 下一個字元跟目前字元的間隔&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;再放到對應 character 的 glyphs 陣列裡 (glyphs[character]=new Glyph(x, y, w, h, xo, yo, xa)&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;讀完 .alf(字型資訊)，接著開啟 .ali，這邊是真正的字型資料，先把整個 .ali 讀取到記憶體裡 (由 AlbiteImageMono 處理，同樣也有檔頭，但較簡單，前4個bytes是magic number，接著的兩個bytes是width，然後再來的兩個bytes是height)&lt;/li&gt;&lt;li&gt;把必要的字元先處理起來，像是 ' ', '?', '-'&lt;/li&gt;&lt;li&gt;其他的字元都是畫的時候，依據 glyphs 資訊去存取記憶體裡的 buffer&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;照這樣看起來，如果要依樣畫葫蘆，將中文字型製作成 .ali 的話，會遇到的問題是記憶體問題。AlbiteFont 會將整個 .ali 載入到記憶體裡，製作出來的 .ali 會有多大呢? 假設字的大小是12x12，要完整收文泉驛的20932個字，那大約是3MB左右。依照 SE T700 的規格，內部記憶體只有 25MB。未知的是可用記憶體，所以必須考慮最壞的情況，記憶體會不足!!&lt;br /&gt;&lt;br /&gt;會使用自己的字型，我想應該是考慮到平台相容的問題。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2308535408764229815?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2308535408764229815/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2308535408764229815' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2308535408764229815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2308535408764229815'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/02/albitereader.html' title='AlbiteReader的字型處理'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6638770466683970927</id><published>2011-02-10T15:34:00.001+08:00</published><updated>2011-02-10T15:37:26.199+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='note'/><category scheme='http://www.blogger.com/atom/ns#' term='epub'/><title type='text'>epub二三事</title><content type='html'>今天剛好看到這個&lt;a href="http://wp.1000ebooks.tw/"&gt;百年千書&lt;/a&gt;計劃，裏面提供了一堆epub，於是就想說，可不可以放到我的手機SE T700上看呢?&lt;br /&gt;&lt;br /&gt;就上&lt;a href="http://www.getjar.com" title="getjar"&gt;getjar&lt;/a&gt;上找，就找到了&lt;a href="http://albite.vlexofree.com/reader"&gt;Albite Reader&lt;/a&gt;。很高興地下載程式跟epub下來放到手機上，可以執行，但是結果卻都是一堆 ?&lt;br /&gt;&lt;br /&gt;這到底怎麼回事，首先我試了軟體的編碼設置功能，沒有用。我懷疑 epub 裡的編碼是big5，而軟體的編碼選項裡卻沒有 big5，所以就上網找了一下，看要怎麼編輯 epub。看到這篇：&lt;a href="http://www.howtogeek.com/howto/19268/edit-epub-ebooks-with-your-favorite-html-editor/"&gt;Edit ePub eBooks with Your Favorite HTML Editor&lt;/a&gt;，才知道原來 epub 其實是個 zip 檔案，將副檔名更名為 zip 以後，就可以解開去看了。然後也發現了不錯的編輯工具：&lt;a href="http://code.google.com/p/sigil/"&gt;sigil&lt;/a&gt;。不過都沒有用，epub 裡的編碼是正確的。&lt;br /&gt;&lt;br /&gt;那麼問題就出在軟體本身了，幸好軟體有開放原始碼而官方網站也有說明。大致看了官方網站的說明以後，才明白，問題出在字型上。軟體本身沒有包中文字!!!!這就麻煩了。官方網站也有說怎麼製作字型，不過他所使用的 &lt;a href="http://www.angelcode.com/products/bmfont/"&gt;Bitmap font generator&lt;/a&gt; 卻沒有支援中文字，因此無法產生出必要的 .png 跟 .xml 檔案，也沒辦法繼續後面的步驟，將 .png, .xml 轉成 .alf, .ali 了。&lt;br /&gt;&lt;br /&gt;傷腦筋，看來如果要能用，一個方法就是寫程式去做出 &lt;a href="http://www.angelcode.com/products/bmfont/"&gt;Bitmap font generator&lt;/a&gt; 的功能，將字型轉成 .png, .xml，另外一個方法就是改寫 Reader 裡處理字型的部份了。&lt;br /&gt;&lt;br /&gt;我想寫工具來轉字型應該是比較快的方法，在 &lt;a href="https://github.com/dumbledore/AlbiteFontBuilder"&gt;AlbiteFontBuilder&lt;/a&gt;網頁裡有提到 .xml 的格式，看起來是將字型都顯示在 .png 以後，.xml 則是描述字(glyph)在 .png 裡的位置跟寬高。得到這個以後，應該就可以接著用 AlbiteFontBuilder 做出 .alf 與 .ali 了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6638770466683970927?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6638770466683970927/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6638770466683970927' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6638770466683970927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6638770466683970927'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/02/epub.html' title='epub二三事'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-233219079532570173</id><published>2011-02-08T15:06:00.001+08:00</published><updated>2011-02-08T15:09:10.237+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='movie'/><title type='text'>電影流水帳(2011/1/1~2011/2/7)</title><content type='html'>最近裝了網樂通，3月底前看電影不用收費，就趁過年期間看了幾部。&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.shrek.com/"&gt;Shrek Forever After&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt0892791/" title="Shrek Forever After (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Shrek_Forever_After" title="Shrek Forever After - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：史瑞克快樂4神仙。看完以後有不少感觸，心裡想這根本就是給已婚者看的啊~的確是常常會覺得自己時間都被剝奪掉了，可是從另外一方面來看，的確，太太與小孩也給自己帶來不同的視野與責任，中間的平衡點怎麼去拿捏就是一門學問...可是，這很常是一個離婚的原因...好吧，言歸正傳，簡單說就是Shrek想偷閒回去過一天以前的生活，卻沒想到合約裡的陷阱，導致現在與未來的生活陷入危機，當然最後是皆大歡喜，破除了合約裡限制，重回原來的生活。相當好看的片，我個人推薦給已經結婚的人看，不過這並不代表看了以後，就會知道結婚不只是愛。&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.despicableme.com/"&gt;Despicable Me&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt1323594/" title="Despicable Me (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Despicable_Me" title="Despicable Me - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：神偷奶爸。看了時候正在吃飯，一片混亂，所以沒什麼太大的感想，基本上是走溫情路線。主角是個不太成功的科技小偷，因為童年以及現實的種種因素，他決定去偷月亮。為了偷月，他需要準備許多道具，其中包括了縮小燈。在偷縮小燈的過程裡，他認識了3個女娃，並收養了她們，於是溫情從此展開。最後他收養了3個女娃，月亮偷成了，但縮小燈有缺陷，又還回原位了。&lt;/li&gt;&lt;li&gt;&lt;a href="http://inceptionmovie.warnerbros.com"&gt;Inception&lt;/a&gt;(&lt;a href="http://www.imdb.com/title/tt1375666/" title="Inception (2010) - IMDb"&gt;IMDB&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Inception_(film)" title="Inception (film) - Wikipedia, the free encyclopedia"&gt;Wikipedia&lt;/a&gt;)，中譯：全面啟動。這部片很好看，網路上應該有很多人分享了，這裡就不多說。&lt;ul&gt;&lt;li&gt;現實的五分鐘等於夢境裡的一小時。這裡我照著推算了一下，飛機上的十小時一共600分鐘，在夢境裡應該是五天才對，而不是一星期。&lt;/li&gt;&lt;li&gt;第1層夢境裡，Fischer潛意識持續在追殺他們，那他們從水裡脫逃以後，應該是繼續被追殺才對吧?那將近五天怎麼渡過?&lt;/li&gt;&lt;li&gt;最後老婆跟我還倒帶看了那個圖謄陀螺好幾次，看到底有沒有倒下。我是跟她說沒有，因為這部電影從一開始就是一個夢。&lt;/li&gt;&lt;/ul&gt;其他還有一些可能要反覆再多看幾次才會明白的細節，真是太玄了。&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-233219079532570173?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/233219079532570173/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=233219079532570173' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/233219079532570173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/233219079532570173'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/02/201111201127.html' title='電影流水帳(2011/1/1~2011/2/7)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-3611684878312772309</id><published>2011-01-27T11:03:00.001+08:00</published><updated>2011-01-27T11:04:40.528+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='wine'/><title type='text'>Run MiPony on Linux(wine)</title><content type='html'>因為看到MiPony可以快速下載freakshare.net的檔案，所以就想裝來試試看~&lt;br /&gt;&lt;br /&gt;在Linux下，只能用wine，我用的版本是1.3。你得先安裝winetricks(sudo apt-get install winetricks)，然後用winetricks裝上 gdiplus, fontfix, dotnet20, ie6(winetricks gdiplus fontfix dotnet20 ie6)。接著再用wine裝上MiPony，就可以了。&lt;br /&gt;&lt;br /&gt;目前下載了十幾個檔案，都沒問題，真是太好了!!&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-3611684878312772309?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/3611684878312772309/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=3611684878312772309' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3611684878312772309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/3611684878312772309'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/01/run-mipony-on-linuxwine.html' title='Run MiPony on Linux(wine)'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-2811015248502049881</id><published>2011-01-26T12:57:00.001+08:00</published><updated>2011-01-26T12:59:11.984+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='瀏覽器(browser)'/><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='note'/><title type='text'>Google reader expanded/list hack</title><content type='html'>最近把Google reader的tag都設到書籤裡去，想說這樣會比較快。&lt;br /&gt;可是卻遇到一個問題，某些tag要看的時候想用Expanded，但某些tag卻想用List。本想說Google reader是不是可以藉著設URL Parameter的方式來解決這問題，查了&lt;a href="http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI"&gt;Unofficial 的 Google reader API&lt;/a&gt;，卻沒找到答案。&lt;br /&gt;&lt;br /&gt;只能手動 Hack 了。&lt;br /&gt;&lt;br /&gt;啟用神兵 Firebug 查看以後，Google reader要show Expanded/List，是送 POST 到 https://www.google.com/reader/api/0/preference/set?client=scroll ，然後帶上3個參數：T、k、v ，T 用途不明，k 總是 is-card-view，v 在 Expanded 時是 true，List 時則是 false。&lt;br /&gt;&lt;br /&gt;所以，看來是沒辦法，除非是書籤改用 javascript，寫成 bookmarklet 的方式才能達成。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-2811015248502049881?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/2811015248502049881/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=2811015248502049881' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2811015248502049881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/2811015248502049881'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/01/google-reader-expandedlist-hack.html' title='Google reader expanded/list hack'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-8217963794350727228</id><published>2011-01-25T14:51:00.001+08:00</published><updated>2011-01-25T14:54:26.823+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='瀏覽器(browser)'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>GNU IceCat Privacy extension安裝總是失敗</title><content type='html'>之前都沒注意，直到GreaseMonkey升級，跑不起來，才發現這事情的嚴重性。&lt;br /&gt;&lt;br /&gt;上網找了一下，果然已經有人跳腳：&lt;a href="http://osdir.com/ml/bug-gnuzilla-gnu/2010-12/msg00057.html"&gt;http://osdir.com/ml/bug-gnuzilla-gnu/2010-12/msg00057.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;就follow裏面的提供的網址：&lt;a href="http://kb.mozillazine.org/Installing_extensions#Global_installation"&gt;http://kb.mozillazine.org/Installing_extensions#Global_installation&lt;/a&gt; ，照裏面的指示去手動解壓縮 /usr/lib/icecat/extensions/privacy_ext.xpi 到 /usr/lib/icecat/extensions/privacy_features@gnuzilla.gnu.org 就行了。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-8217963794350727228?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/8217963794350727228/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=8217963794350727228' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8217963794350727228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/8217963794350727228'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/01/gnu-icecat-privacy-extension.html' title='GNU IceCat Privacy extension安裝總是失敗'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6061280271010400475</id><published>2011-01-25T02:13:00.001+08:00</published><updated>2011-01-25T02:15:01.579+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>DDMS抓圖</title><content type='html'>會看這個，是因為抓圖失敗...&lt;br /&gt;&lt;br /&gt;ddms 會開啟本地的port 5037，這是由host端的adbd所listen的。接著寫入"framebuffer:" (AdbHelper.getFrameBuffer)。&lt;br /&gt;&lt;br /&gt;target端的adbd收到以後，會建立一個thread，thread跑的是framebuffer_service.c裡的code。裏面很簡單，就開啟/dev/graphics/fb0，然後取 fb_var_screeninfo 的值，再根據得到的值來決定要讀多少bytes，寫回去到host端，最後寫完就關閉。&lt;br /&gt;&lt;br /&gt;為什麼會抓不到圖呢?不知道，還找不到原因。&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6061280271010400475?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6061280271010400475/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6061280271010400475' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6061280271010400475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6061280271010400475'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/01/ddms.html' title='DDMS抓圖'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-564176856811147662</id><published>2011-01-17T11:52:00.001+08:00</published><updated>2011-01-17T11:52:52.664+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>加快linux開機速度</title><content type='html'>在 &lt;a href="http://www.embedded-bits.co.uk/2011/1-second-linux-boot-to-qt/"&gt;1 second Linux boot to Qt!&lt;/a&gt; 看到的，標題超聳動，不過實際看到影片，真的是很嚇人，根本就是瞬間就開好了。投影片在這裡：&lt;a href="http://www.slideshare.net/andrewmurraympc/elce-the"&gt;The Right Approach to Minimal Boot Times&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;這個 topic 前兩年很熱門，當然啦，現在因為 Android 的關係，應該會更熱。下面是我看完的一些紀錄跟想法：&lt;ul&gt;&lt;li&gt;使用 Arjan van de Ven 對 kernel aync 的 patch&lt;/li&gt;&lt;li&gt;把不重要的 module 改成 loadable&lt;/li&gt;&lt;li&gt;修改init/do_mounts.c以提早mount root&lt;/li&gt;&lt;li&gt;修改init/main.c裡的init_post，看了以後，我想應該是避免掉open /dev/console還有移掉不必要的步驟以提速。&lt;/li&gt;&lt;li&gt;improve memcpy (這我不知道是哪裡的，要再查看看)&lt;/li&gt;&lt;li&gt;reduce kernel size：這可以加快 u-boot 載入時間。一般手段就移掉不必要的driver/module。&lt;/li&gt;&lt;li&gt;reduce u-boot delay time：u-boot 預設有 delay time，這可以改掉&lt;/li&gt;&lt;li&gt;kernel 壓縮或不壓縮：用zImage的話可以減少kernel大小，可是要評估解壓縮時間跟載入時間的平衡來決定壓縮或不壓縮。&lt;/li&gt;&lt;li&gt;利用 gcc 的 --finstrument-functions --function-sections 去 profile function 的時間 (簡報說加了這兩個 argument，就可以在 __cyg_profile_func_enter/__cyg_profile_func_exit 裡放 code，這個要鑽研 gcc 試試看。)&lt;/li&gt;&lt;li&gt;利用ubootchart/bootchart.org工具來測時間。&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;參考資料：&lt;ul&gt;&lt;li&gt;&lt;a href="http://elinux.org/Technology_Watch_List"&gt;Technology Watch List&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://lwn.net/Articles/299483/"&gt;LPC: Booting Linux in five seconds [LWN.net]&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-564176856811147662?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/564176856811147662/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=564176856811147662' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/564176856811147662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/564176856811147662'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/01/linux.html' title='加快linux開機速度'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9140489.post-6814855269594585970</id><published>2011-01-13T13:06:00.001+08:00</published><updated>2011-01-13T13:08:33.942+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='glib'/><category scheme='http://www.blogger.com/atom/ns#' term='c/c++'/><category scheme='http://www.blogger.com/atom/ns#' term='lex'/><title type='text'>Lex 練習</title><content type='html'>看 lex &amp;amp; yacc 第一章的練習，然後改用 glib 的 GList 來做：&lt;pre name="code" class="c"&gt;%{&lt;br /&gt;#include &amp;lt;glib.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;/* token recognizer */&lt;br /&gt;enum {&lt;br /&gt;    LOOKUP = 0, /* default is lookup, not add */&lt;br /&gt;    VERB,&lt;br /&gt;    ADJ,&lt;br /&gt;    ADV,&lt;br /&gt;    NOUN,&lt;br /&gt;    PREP,&lt;br /&gt;    PRON,&lt;br /&gt;    CONJ&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int state;&lt;br /&gt;&lt;br /&gt;int add_word( int type, char* word );&lt;br /&gt;int lookup_word( char* word );&lt;br /&gt;int print_word( gpointer data, gpointer userdata );&lt;br /&gt;%}&lt;br /&gt;&lt;br /&gt;%%&lt;br /&gt;\n        {state=LOOKUP;} /* go back to default */&lt;br /&gt;^verb     {state=VERB;}&lt;br /&gt;^adj      {state=ADJ; }&lt;br /&gt;^adv      {state=ADV; }&lt;br /&gt;^noun     {state=NOUN; }&lt;br /&gt;^prep     {state=PREP; }&lt;br /&gt;^pron     {state=PRON; }&lt;br /&gt;^conj     {state=CONJ; }&lt;br /&gt;[a-zA-Z]+ {&lt;br /&gt;    if( state!=LOOKUP ) {&lt;br /&gt;        add_word( state, yytext );&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;        switch( lookup_word( yytext ) ) {&lt;br /&gt;            case VERB:&lt;br /&gt;                printf("%s: verb\n", yytext);&lt;br /&gt;                break;&lt;br /&gt;            case ADJ:&lt;br /&gt;                printf("%s: adjective\n", yytext);&lt;br /&gt;                break;&lt;br /&gt;            case ADV:&lt;br /&gt;                printf("%s: adverb\n", yytext);&lt;br /&gt;                break;&lt;br /&gt;            case NOUN:&lt;br /&gt;                printf("%s: noun\n", yytext);&lt;br /&gt;                break;&lt;br /&gt;            case PREP:&lt;br /&gt;                printf("%s: preposition\n", yytext);&lt;br /&gt;                break;&lt;br /&gt;            case PRON:&lt;br /&gt;                printf("%s: pronoun\n", yytext);&lt;br /&gt;                break;&lt;br /&gt;            case CONJ:&lt;br /&gt;                printf("%s: conjuction\n", yytext);&lt;br /&gt;                break;&lt;br /&gt;            default:&lt;br /&gt;                printf("%s: don't recognize\n", yytext );&lt;br /&gt;                break;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;. /* ignore other characters. */&lt;br /&gt;%%&lt;br /&gt;&lt;br /&gt;GList* list=NULL;&lt;br /&gt;&lt;br /&gt;int main( int argc, char* argv[] )&lt;br /&gt;{&lt;br /&gt;    yylex();&lt;br /&gt;    g_list_foreach(list, (GFunc)print_word, NULL);&lt;br /&gt;    g_list_free(list);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;struct word {&lt;br /&gt;    GString* word_name;&lt;br /&gt;    gint word_type;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int print_word( gpointer data, gpointer userdata ) {&lt;br /&gt;    struct word* word=(struct word*)data;&lt;br /&gt;    g_printf( "word=%s type=%d\n", word-&amp;gt;word_name-&amp;gt;str, word-&amp;gt;word_type );&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int add_word( int type, char* word) {&lt;br /&gt;    struct word* wp;&lt;br /&gt;    if( lookup_word( word )!=LOOKUP ) {&lt;br /&gt;        printf("!!! Warning: word %s already defined.\n", word );&lt;br /&gt;        return 0;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    wp = g_new0(struct word, 1);&lt;br /&gt;    wp-&amp;gt;word_name=g_string_new( word );&lt;br /&gt;    wp-&amp;gt;word_type=type;&lt;br /&gt;    list = g_list_append(list, wp);&lt;br /&gt;    return 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;gint compare_word( gconstpointer a, gconstpointer b) {&lt;br /&gt;    struct word *p1=(struct word*)a;&lt;br /&gt;    GString* s=g_string_new( (char*)b );&lt;br /&gt;    int ret=0;&lt;br /&gt;    if( !g_string_equal( p1-&amp;gt;word_name, s ) )&lt;br /&gt;        ret=1;&lt;br /&gt;    g_string_free(s, FALSE);&lt;br /&gt;    return ret;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int lookup_word( char* word ) {&lt;br /&gt;    GList* found=g_list_find_custom( list, word, compare_word );&lt;br /&gt;    if( found )&lt;br /&gt;        return ((struct word*)found-&amp;gt;data)-&amp;gt;word_type;&lt;br /&gt;    return LOOKUP;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Lex 是用來 tokenize 輸入用的，也就是用來辨識說輸入裡有哪些東西是你要的。這個例子書上沒針對怎麼使用做解說，乍看之下，不容易懂。其實使用上就是打 verb is，表明說 is 是 verb，你可以一直輸入 verb read、verb write、noun book、noun dog....程式就會把你輸入的這些內容分類、放到list裏面去，之後你輸入 read、write、book 時，程式就會告訴你 read、write 是 verb，book 是 noun 。&lt;br/&gt;&lt;br/&gt;改用 glib，是因為想練習 glib。g_list_find_custom令人意外地沒範例，不過用法挺簡單，主要變化在第二個參數，第二個參數是一個 function。該 function 第一個參數是 list 裡的元素，第二個參數就是 g_list_find_custom 裡的第二個參數，你可以參考 compare_word，應該是不難懂。&lt;br /&gt;&lt;br /&gt;參考資料：&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.ibm.com/developerworks/linux/tutorials/l-glib/section4.html"&gt;Manage C data using the GLib collections&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://library.gnome.org/devel/glib/stable/glib-Doubly-Linked-Lists.html"&gt;Doubly-Linked List&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://library.gnome.org/devel/glib/stable/glib-Strings.html"&gt;Strings&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://javaworld.com.tw/roller/caterpillar/entry/glibabc"&gt;良葛格的blog-GLib入門&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6887110089906023";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-05-15: Thinking more, ArticleBottom
google_ad_channel = "6814537209+4257381310";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9140489-6814855269594585970?l=blog.elleryq.idv.tw' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.elleryq.idv.tw/feeds/6814855269594585970/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9140489&amp;postID=6814855269594585970' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6814855269594585970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9140489/posts/default/6814855269594585970'/><link rel='alternate' type='text/html' href='http://blog.elleryq.idv.tw/2011/01/lex.html' title='Lex 練習'/><author><name>elleryq</name><uri>http://www.blogger.com/profile/08617365240813299251</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_Wes9bokzDjQ/S86FVI6jV9I/AAAAAAAAAaE/nIcaMO00TMM/s1600-R/3952647376_dcac87c974_s.jpg'/></author><thr:total>0</thr:total></entry></feed>
