2009/06/16

感覺怪怪的

P3194092 (by plateaukao)
Annecy.France

最近都在瞎忙,感覺怪怪的。

****
IMAG0481.jpg (by plateaukao)
景美舊橋.Taipei
想睡著,隨便畫。

IMAG0514.jpg (by plateaukao)
家後面的土地公廟的重新上漆的石獅

2009/06/15

Unofficial Plurk API in Python : A Plurk client in wxpython - Plurkao

PB124783 (by plateaukao)
Des feuilles.Annecy

Originally, I wanna study how to write a small plug-in for Windows Live Messenger, so that every time a plurk alert comes, I can easily input the plurk id and username to reply the message. However, it turns out it's a hard work to do and there's no high-level wrappers for this task (please refer to CodeProject: Windows Live Messenger Plug-in Development Bible. Free source code and programming help). Moreover, I don't even have Visual Studio installed on my home computers. How can I compile my codes without a compiler.

After searching for a while, I gave up the idea of tweaking with Windows Live Messenger. Instead, I turned to search for plurk clients for desktop. Still, in vain. What I can only find is some air clients that use plurk mobile link internally, which I can already find a firefox extension for it. That interface is not intuitive enough for me. I need something more user friendly and not so error-prone as msn plurk alerts.

Well, the unofficial Plurk API in Python is what I found so far. On its website, the demo only shows how to display user's karma value and how to list your plurks. Hm.... it's not so attractive isn't it? But!!! indeed, the module does more than these two simple not so useful demonstrations!! You can send plurks, respond to existing plurks, get plurk permemant links, and etc. That's powerful enough to let me write my own plurk client. Yeah. You bet. I am gonna write one for myself if I have enough time.

Currently, there's only one API to get plurks which is called getPlurks( ). This API will get plurks no matter they are already read or not. I did a little modification now so that it can let you choose if you only want to list unread messages only.

Update (20090617)
I wrote a small app with this python library. Currently it can merely work. The speed is slow, but it works somehow.

And~~ the screenshots!

1. Login UI: well, that's almost you need to login your account
plurkao_login (by plateaukao)

2. Main Window: you can click on RealAll or UnRead to see the plurks. Send button allows you to post a new plurk. There's no auto update mechanism so far; you have to manually click on them when you want to see updates. And...the data fetch is done in the same thread so the UI will be a bit lagged when the button is pressed.
plurkao_plurks (by plateaukao)

plurkao_plurks2 (by plateaukao)

3. Response Window:You can click on Inside to open up a new window which shows you the responses of the plurk. Refresh button will refresh the plurk for you (cause there's no auto update now); and the Send button will post a response to this plurk.
plurk_responses (by plateaukao)

The UI is done by wxpython, so you have to install wxpython on your system if you want to test this program. And thanks for python's portability, I think it can run well under Linux too.

DOWNLOAD:
http://daniel.kao.googlepages.com/plurkao.zip

REF:
David - The Unofficial Plurk API in Python
Boa Constructor Download
http://plurkapi.com/http/methods

2010/02/17 補充:
既然有官方版的plurk api了,照例隨便玩玩看:

2009/06/14

Python再起,誰與爭鋒:無名小站相簿備份軟體

PB124784 (by plateaukao)
Autumn.Annecy

這篇雖然是電腦文,不過因為國外連進來的,可能對這篇也不會感興趣,所以破例用中文寫囉。無名小站前陣子因為取消一些服務,搞得民怨四起(好像不是一直都這樣?),鬧得很多人都要出走。要搬家的話,問題就來了:經年累月留下來的文章和照片,要怎樣搬到其他部落格去呢?關於文章、留言的部分,各家部落格其實都有提出類似的服務,可以讓使用者無痛搬家;但是對於相簿這塊,目前網路上找得到的軟體大都是專門設計來下載正妹照片用的,對於相簿中的標題和詳細描述,都沒有另外處理。也就是說,你搬得了照片,搬不了照片的字。

所以,昨晚我研究了一下網路上關於無名小站相簿原始檔格式的說明和網頁間的關連,寫了一小支程式可以把單一個相簿的相片抓下來,並且把照片和文字同時放進一個html檔。這麼一來,至少自己可以有一份相片和說明在一起的備份,就算不行匯到別的部落格去,也可以在自己的電腦上看爽的。等哪天有哪個部落格支援匯入照片和文字說明時,要再匯入也不會是件難事。

接下來是在寫這支python script時,需要注意的一些問題,和特別查到的資詢:
1. URL request時的Referer:無名小站從以前就一直被人垢病相簿不行外連,因為在抓圖時,它會檢查這個request是從哪發來的。為了要順利抓到照片,在程式裡必須塞一個假的,可以通過它檢查的網址給它。如此一來,就不行用單純的urllib完成,而得改用urllib2才行。

def GetURLContent(u):
req=urllib2.Request(url=u)
#req.add_header('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113')
req.add_header('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.9.0.11) Gecko/2009060215')
req.add_header('Referer','http://www.wretch.cc')
return urllib2.urlopen(req)

如上,先在request中加上Referer的header就可以了。

2. 在網頁的原始碼中,主要有三個tag是我們要抓的:DisplayTitle, DisplayImage, DisplayDesc;然後還有一個id="next"要抓。DisplayTitle是使用者設定的照片標題;DisplayImage該行有照片的真正路徑;DisplayDesc就是使用者可以寫得落落長的照片描述;id="next"則是用來檢查還有沒有下一張圖片,有的話,程式得要一路再抓下去,直到沒有下一張。

3. 抓的時候,記得要設一下sleep,不然抓太頻繁好像會被擋掉。所以每抓一張就加個sleep(10)或sleep(20)讓它休息一下。

4. 原本有打算把描述和標題塞到jpeg的exif裡頭的,可是編碼問題一直搞不定,所以算了。因為加了,一般的image viewer也看不到。

5. 用urllib2抓下image後,可以用read()讀出image的內容;存檔時記得開檔要用"wb"的flag,這樣子存出來的照片才能看。

6. 沒了。就這麼簡單。真想不通我怎麼搞了那麼久才寫好。

下載 DOWNLOAD:
http://daniel.kao.googlepages.com/WretchGrabPhoto.py

使用方式:
0. 先在電腦上裝好Python。
1. 把WretchGrabPhoto.py下載下來,放在隨便一個目錄
2. 用cmd開啟一個Dos視窗,進到該目錄,然後執行下面這行 (python執行檔的位置要看你灌的是哪一版而定)
c:\Python24\python.exe WretchGrabPhoto.py "the_url_to_the_first_photo_in_the_album" html_to_be_saved.html
3. 等它執行完,用IE或Firefox開啟你自己設定的html檔就行了

參考:
Read & Write JPEG COM and EXIF metadata [jpeg] [python] [image] [metadata] [exif]
fetidcascade.com - Python Exif Utilities
Team Programming Dragon.編程龍 » Blog Archive » 用 wget 抓無名單一相簿
下載無名Blog文章裡的圖片 | 無為閣

破解無名小站下載相簿照片作者: 井民全前言



New Skype UI

下午出門騎好久沒有騎的腳踏車,
不然肚子愈來愈大了。

IMAG0469 (by plateaukao)IMAG0465 (by plateaukao) IMAG0467 (by plateaukao)

才騎沒多久,就開始下雨了。
在下狂風暴雨的前一刻,我躲進了某家7-11還是全家的騎樓,
在它外頭的桌椅旁看著大雨直直下,大風猛吹。
一旁一樣是在躲雨的路人,都在討論說,這跟颱風來了沒有什麼兩樣。

IMAG0474 (by plateaukao)
回程時經過景美舊橋。
目前舊橋好像要拆了 (廢話,都剩下不到一半長了)。
摩托車可以走一旁的便道。
汽車的話就得要繞道而行了。

回家後,很廢,什麼事都沒做。
週六就這麼結束了。

IMAG0477 (by plateaukao)
晚上吃了碗辛拉麵。

****

New Skype UI is not as intuitive as I thought. And I hate its new copy message feature. Why the hell you keep adding user name and posted time in the copied message for me. Fortunately, I found that this feature (big flaw, from my point of view) can be turned off in the options.

Also, now it has a new window style that aligns conversation window to the user list. By this way, user only has to deal with one window at a time. You can switch to other conversations by selecting from the current ongoing conversation list.

The wierd thing is: I can't find documents or any help files that describe all these changes... Are they expecting every user knows how to use these strange UI once they get the updates?

2009/06/13

食記

IMAG0444.jpg (by plateaukao)
Taipei.Taiwan

鋒面應該走了吧。天氣變得很晴朗。

IMAG0452.jpg (by plateaukao)

IMAG0450.jpg (by plateaukao) IMAG0453.jpg (by plateaukao)
上次吃羊肉麵時,用magic拍的照片真是差。
所以今天去吃鴨血時,就特地帶了畫質應該比較好的機子去。
順便把上次忘了拍的冰棒也拍一拍。

IMAG0455.jpg (by plateaukao)
今天傍晚的天空很棒。
原本很想請假的,不過不知道為什麼後來沒有請。
可能是因為太熱了吧。在外面閒逛是會中暑的。

A small utility to customize Manila Program Tab on HTC Windows Mobile devices

2009-06-13_005711 (by plateaukao)
ManilaProgramSetting

Because I constantly re-install my devices with different ROM builds, I used to installing softwares into my SD card. Although I don't have to reinstall all these softwares, every time I want to launch them, I have to launch File Explorer first; go to that directoy on SD card. And finally luanch it manually. It's so tiresome that I wanna configure these apps in my Manila Program Tab, so that I can launch them by no more than two clicks.

Current Manil Program Tab design only allows you to add programs which are listed in \windows\Start Menu\Programs. In official way, it's not possible to do so. As a consequence, I decided to write a small utility to help myself on this boring task, and by the way, I can practice my poor C# coding skills a bit.


It's very easy to create UI layouts with C# (though it's usually very ugly). As you can see on the screenshot, there are two buttons on the top, so that user can easily switch to other program icon settings. File Path and Display Name is what we need to fill in the registry keys. When you switch to a program icon, current setting will be brought out. And then, you can press "Select File" button to any other exe files on the device (or SD card). Before switching to other program icon, remember to press LSK: Update, to write the modification back to registry key.

Finally, you can exit the program and go to Manila Program Tab and take a loot. What? it's not as what you modified? oh, because Manila does not know you changed its registry keys. You need to do something to let it reresh the UI. this is very easy too: just press RSK: Remove and then press Done again. Your modification will be shown now.

Programming Tips:
1. MS built-in OpenFileDialog really sucks!!! It will teat "My Documents" as root, and only lists files under it and one more subdirectory. It's not useful for most of the applications!! Anyway, I don't wanna write one by myself; so I found some simple classes written by others on the internet. It's from Reference 1. With his efforts, I can get my exe file name on sd cards now.

2. In order to read registry key, Microsoft.Win32 should be used. Here's how I use it:
RegistryKey regManilaSetting = Registry.LocalMachine;
regManilaSetting = regManilaSetting.OpenSubKey(@"Software\HTC\Manila\ProgramLauncher\" + (string)comboBox1.SelectedItem,true);
textBoxPath.Text = (string)regManilaSetting.GetValue(@"Path");



REF:
1. MobilePractices

Download:
http://daniel.kao.googlepages.com/ManilaProgramSetting.exe

2009/06/12

食記

IMAG0442 (by plateaukao)
Annecy.France

Ca me souvient un petit magasin a Annecy, qui vend des oeuvres artificielles.
Je les ai trouvees plusieurs fois a Taipei aussi, mais en taille plus petite.

IMAG0432 (by plateaukao)
Taipei.Taiwan

Cette photo est prise dans un batiment plubic a Taipei.
Quand il fait beau, la vue d'ici est magnifique.
Regard, on peut meme voir la montagne de guanyin!!
Quel beau temps!

IMAG0294 (by plateaukao)
Leiden.Netherlands

Quand je me suis promene au bord du lac pres de la ville de lyde aux pays-bas,
j'ai vu un homme qui etait assis sur le banc en lisant un livre.
C'etait tres tranquille.

IMAGE_001 (by plateaukao)
Grenouille

C'est un appareil de FM radio.
Mais il ne marche pas depuis longtemps.

****

IMAG0435 (by plateaukao)

晚餐,拖到九點多才吃,不太像我。
跑到景美夜市吃蚵仔麵線。
雖然大腸不多,但蚵仔可是滿滿一碗,而且吃起來沒有砂。

IMAG0439 (by plateaukao)

吃完蚵仔麵線,再來盤冰吧。
這家冰店從我國小有印象開始,就已經存在了。
當初店裡幫忙招呼客人的兩個小女孩,現在也已經長大成人。
今天在店裡的,應該就是其中一個吧。
離題了。
下次應該點一下新的牛奶雪花冰的。

乩童警探 一二集

接連看了兩集。第一集還算新鮮,到了第二集就看得比較慢了。一來,劇情雖然常會提到乩童,但真的跟乩童又沒有什麼關係。第二集後半大概就猜出是怎麼一回事了,但還是很享受在作者解釋的過程。只是前面舖陳有點久,而且人物有點多,再加上我是斷斷續續的看,看到後來都快忘了誰是誰,或是誰曾經出過什麼...