
Annecy.France
看了點文件,想說就來寫寫東西吧,從最簡單的開始。
= = =
另外,沒想到有人替eblib包了個python wrapper!!
Link: http://code.google.com/p/pyeb/

Marbourg.Allemagne
又在亂寫東西了。
目前的噗浪,可能是為了有效地節省傳輸的頻寬,提高使用者操作時的response,
雖然它會定期的檢查是不是有新的回應,
但是使用者還是要再按一下才可以切到最新回應的模式。
時間軸的方式在大部分情況下很方便,
但是在看回應時,就顯得不是那麼重要了,
因為,這時使用者在意的是別人的回覆,
而不是這條噗是在什麼時候發出的,或是跟其他噗的前後關係。
所以,如果在看最新回應時,所有的噗可以更集中的話,
應該會更一目瞭然才是。
於是乎,自己寫了一個小小的script,
讓我可以在不開browser或是不開plurk website的情況下,
可以知道目前是不是有新的回應,而這些回應又是屬於哪些使用者的噗。
畢竟,有些時候,並不是所有最新回應自己都有興趣,
但又懶得一一去關成靜音。
= = = =
為了怕自己會一直改來改去,所以去google code開了個project
方便之後的source code control。
網址在:https://code.google.com/p/plurkmonitor/
系統需求:python + wxpython

Des feuilles.Annecy
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




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

Autumn.Annecy
接下來是在寫這支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就可以了。
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文章裡的圖片 | 無為閣
破解無名小站下載相簿照片作者: 井民全前言
https://developer.skype.com/wiki/Skype4Py
http://www.kolmann.at/philipp/linux/skysentials/
http://www.oberle.org/skype_linux_tools/

Ricoh GRD
Semnoz.France
2008.03.08
滑雪還有個好處,看的景跟平常看到的都不大一樣。
右邊是一群小朋友在學習滑雪。
很慶幸自己學習得還算快,不用交大錢或是和一堆人跟著教練的屁股走。
當然,得付出不少跌倒的代價。
****
看片名可能不知道這是怎樣的一部日劇,
不過提到“千物女”的話,相信聽過的人就比較多了。
在上班時,打扮的光鮮亮麗;
可是下了班,卻喜歡一個人窩在家裡,
穿著破舊的運動服,頭髮紮到一束沖天炮,
躺在地板上喝啤酒看漫畫,享受屬於一個人的時間。
綾賴遙在這部片中的表現,個人覺得比鹿男那部挑戰性要高些,
因為形象的犧牲比較大。
至於藤木直人的演出,沒想到現在他已經老到飾演主管的角色。
看了一兩集後,就會有股衝動想要一次看到完。
下次,還是別在非週末的時候看日劇才好。
***
之前寫的pyFlickrRandomImage最近操作時覺得怪怪的。
明明是要產生十張隨機的照片出來,
怎麼老是會有五六張以上是同一張。
今天晚上花了點時間做小測試,
發現flickr的API flickr.photos.search 只支援參數page = 最多到10000
原本的作法是,每個page一張。
目前我有5萬多張照片,所以總共有5萬多個page,
我每次隨機挑十個page出來。
不過flickr不知道做了什麼更新,目前page設定超過10000的話,
都會被自動改為10000。
也就是說我有4萬多張照片是不會被選到的。
這樣子的話還得了!
所以我只好改一下script,讓它每個page有10張照片,
這樣子page數目前可以控制在6000以內。
等選好page後,我再產生一個亂數去從10張照片中選一張。
雖然多了一個步驟,不過好歹可以暫時解決目前的問題。
random_page = random.randint(1,self.count/10+1)
random_image = random.randint(0,9)
try:
photo = self.flickr.photos_search = self.my_user_id, per_page=10, page = random_page).photos[0].photo[random_image]

Canon S30
2004.04.15
Keukenhof tuin
荷蘭的庫肯霍夫花園,除了有各式各樣的鬱金香外,
其實還有許多特別的花可以欣賞。
****
Added features:
****
The launch look-up in the web browser function in onlinedic is broken for a while. Since I don't use this feature often, I did not care about it. The other day, I found that there's a good module in emesene just for the purpose as I want! It's called desktop.py. emesene uses it to determine the current system and choose the right web browser for you. With this module, what I need to do is nothing but copy the desktop.py and call a method!
import desktop
desktop.open('url_name')

Olympus E510
Florence, Italy
Flowers
米開朗基羅廣場繞一圈,發現到的。
****
Originally, Gimp only supports script-fu plugins which are written in lisp. From some day that I don't know exactly, Gimp started to support plugins written in python. As a python programmer, I can easily write something for my own purpose. By reading the instructions of the following links, a simple plugin can be written within minutes. However, I do not find many useful examples on the internet. If there's a place on internet to store all the plugins, that would be wonderful.
HOW TO WRITE YOUR OWN PYTHON-FU PLUGIN
1. copy one script from the second link
2. modify the contents as you want, by following the API documentation
3. try out in Gimp
4. add more stuff by referencing PDB browser
REF:
Basi Python-fu API Documentation
Templates

(坪林,台灣 2006.10.21)
剛寫好的python script有兩個缺點:
1. 只能看到public的照片。我有很多沒整理的照片都是private的,如果連自己也不行看,那不是白費工。
2. 執行程式之後,firefox會開啟網頁,如果想要再來一次,就要手動關掉已經開啟的畫面,來來回回的很麻煩。
趁還沒睡覺,又趕出了一版。這一版依照Python Flickr API Documentation中關於Authentication的部分做了加強,讓它可以取得token。這麼一來,第一個問題就解決了。不論是公開還是隱藏起來的照片,都列在隨機選取的範圍內。
另外,還利用wxpython加了視窗。視窗很簡單,只有一個按鈕和一個html視窗。只要按一下按鈕,照片就會更新,顯示新取得的照片。如果有看中意的照片,可以點選它,這時才會開啟firefox網頁,帶你到fickr的網站去。
以後閒閒沒事,也可以開著這支程式隨意瀏覽自己的照片了。
***
將下面兩個檔拷到同樣的目錄中,然後照前一篇文章做修改。最後執行wxGUI.py就行了。
REF:
myflickr2.py
wxGUI.py

(Wakkanai, Hokkaido, Japan 2006.01.01)
2006年一月一日,我在日本北海道的最北端-稚內-迎接初日。照片中的大石頭不是藝術品,而是化石。牌子上寫著:
干貝化石群
發現地點:中頓別鐘乳洞附近
石齡:新生代第三期(約四千萬年前)
重量:約40噸
****
今天晚上手癢,決定自己寫一個可以根據使用者隨機選出照片的小程式。這麼一來,我只要呼叫一下自己寫的程式,就可以看到亂數為我選出來的照片。如果不喜歡的話,再執行一次就行了。這麼一來,就不用花時間想說要進哪個set,只要呆呆地等電腦幫我選就行了,我自己再做最後的決定。而且沒有建立set或tag的照片,也跟其他照片一樣,有機會被選出來。
set list我就直接跳過了,因為我並不想透過set來取得照片資訊。取得照片list的api如下:
self.flickr.photos_search(user_id, per_page, page)
這個API可能還有其他的參數,不過我只列出我有用得到的。
user_id: flickr為你產生的id,這在profile或是哪裡應該找得到。
per_page: 一次要取出多少張照片。
page: 從第幾頁開始取。
有需要的人可以拿回去,然後改一下第9行的API_KEY(上Flickr去申請);第10行,MY_USER_ID的值,和修改一下74行,啟動哪個browser來顯示該網頁。
REF:
Beej's Python Flickr API
myflickr original sample
Flickr Services: Official Site
下面這是我改過的:
myflickr.py

(Wakkanai, Hokkaido, Japan 2006.01.01)
2006年一月一日,我在日本北海道的最北端-稚內-迎接初日。照片中的大石頭不是藝術品,而是化石。牌子上寫著:
干貝化石群
發現地點:中頓別鐘乳洞附近
石齡:新生代第三期(約四千萬年前)
重量:約40噸
****
今天晚上手癢,決定自己寫一個可以根據使用者隨機選出照片的小程式。這麼一來,我只要呼叫一下自己寫的程式,就可以看到亂數為我選出來的照片。如果不喜歡的話,再執行一次就行了。這麼一來,就不用花時間想說要進哪個set,只要呆呆地等電腦幫我選就行了,我自己再做最後的決定。而且沒有建立set或tag的照片,也跟其他照片一樣,有機會被選出來。
set list我就直接跳過了,因為我並不想透過set來取得照片資訊。取得照片list的api如下:
self.flickr.photos_search(user_id, per_page, page)
這個API可能還有其他的參數,不過我只列出我有用得到的。
user_id: flickr為你產生的id,這在profile或是哪裡應該找得到。
per_page: 一次要取出多少張照片。
page: 從第幾頁開始取。
有需要的人可以拿回去,然後改一下第10行,MY_USER_ID的值,
和修改一下74行,啟動哪個browser來顯示該網頁。
REF:
Beej's Python Flickr API
myflickr original sample
Flickr Services: Official Site
下面這是我改過的:
myflickr.py

(Ricoh GRD Morbihan Tour 2008, Annecy du 21 au 24 mai)
一連好幾天,在Courrier和學校中間的大廣場有法國西北部旅遊推廣活動。除了很普通的旅遊簡介、講解和美食品嚐外;還有三十場的免費concert可以聽。這種好事法國人自然不會錯過。週六下午在臨時搭起的表演台前,坐滿也站滿了觀眾。有沒有發現?表演台看起來很像是台灣廟會搭的台子。
****
Last time, I said that ebmodule is not compatible with current eb library, so I turned to modify the sample code of eb library and use a separate execution file for both linux and windows. Though it works smoothly for me, putting an extra program in the package is not what I really want it to be. Several days ago, I thought: since ebmodule couldn't work with current eb library, why not try using the old eb library with which it says it compiles.
I downloaded eb library 0.3.1 from internet and compiled it. And then, I spent some time figuring out where to put eb headers / library in order to compile ebmodule module; and I modified ebmodule.c too because there're some errors about the static char arrays. Finally, the native python ebmodule module is GENERATED!! Well, what a success!! The README says it compiles with Python 1.5.2; however with Python 2.5, it can be compiled too.
After some simple tests of the ebmodule, I am quite happy with it. From now on, I think I can provide more support for EPWING files (to start with, maybe I can put in "strict match", "prefix match", and "postfix"; and ... word list too).

(Ricoh GRD Cannes, France. 坎城小火車)
南部每個鎮都會有逛市區的小火車,帶著你穿街過巷,在較短的時間內一覽當地名勝和景點。價錢大都落在5歐到10歐之間。車上一般會提供英文和法文的解說,可以帶上耳機或是由司機直接口頭介紹景點。行程則大概是二十分鐘到三十分鐘之間。
我只有在馬賽突然心血來潮坐了一次,登上了馬賽著名的教堂,俯看整個馬賽港。一路上車子緩縱上坡,和兩旁的行人擦肩而過,吹著微風。
****
Psyco,一個號稱可以加速python程式執行速度的module。只要加個兩行code就可以見效。雖然我看不大出來效果,不過還是在onlinedic中加入了這個功能。Psyco需要從其官網另外下載套件才行,目前支援linux和Windows。
REF:
IBM網站上的介紹
Psyco官網

(Ricoh GRD Marseille, France. ile d'if)
到馬賽沒上伊芙島,大概算不上是到過馬賽吧。不過伊芙島卻一點兒也不吸引我。來回的船票要十歐,上了島,還得一定要再交五歐參觀Chateau d'if才行。(如果有買馬賽一日周遊券的話,會比較划算,因為20歐裡面便包含了來回船票,城堡門票,還可以參觀很多市區內的博物館,一日的交通票,Tram,地鐵,巴士坐到爽,還可以坐上山的市區觀光小火車)。可惜我發現有一日券的時間太晚了,所以沒來得及買。
從伊芙島往陸上看去,海的顏色是漸層的,很夢幻。很多家庭拿著食物,就在城堡四周野餐起來,完全不介意這曾經是個關犯人的地方。小時候看過的"基度山恩仇記"早就忘光了,所以不大體會得到被關在這兒的痛苦。
****
from long time ago, I've kept trying to add supports of global hotkeys for onlinedic; however, it's always in vain. Tonight, I finally found a way to achieve it!!! (though it only works for Windows platform) Why didn't I find the API earlier, I keep wondering....
This feature is supported by wxWidgets. As consequences, it's been ported to wxPython too. Actually it's quite easy. All I need to do is to invoke RegisterHotKey provided by Frame.
self.RegisterHotKey(
self.hotKeyIdToggleScan, #a unique ID for this hotkey
MOD_WIN, #the modifier key
VK_F3) #the key to watch for
The usage of the parameters are rather obvious. The last two parameters should be filled in by definitions from win32con. If you don't have installed win32 extension, you can just find out the right definitions you want to used by the second following references.
Once you want to quit the program, you have to unregister the hotkey:
self.UnregisterHotKey(self.hotKeyIdToggleScan)
REF:
Sample of RegisterHotKey for wxpython
Virtual Key Definition in win32con

(Ricoh GRD Annecy.Fleur Lampe)
GRD在經過我亂搖之後,裡頭的灰塵已經快要看不見了。
所以,現在又一條活龍(雖然成像好像還是不大好)。
這幾天,有太陽,有雲,也有下雨。
所以,出門要挑時間才行。
****
J'ai essayé un noveau logiciel pour communiquer aver mes amis par msn protocol, qui s'appelle emesene. Il est fait par python et python-gtk, donc il marche sur linux et aussi sur windows. Grâce à son codage Python + Gtk, je peux le modifier facilement.
site de reference:
http://www.emesene.org/
http://doc.ubuntu-fr.org/emesene

(Olympus E300 France.Chamonix)
週日有到夏慕尼滑雪的活動,光是車錢就要18歐。
如果再加上一整天的forfait的話,大概總共要50歐。
還在考慮中…
****
今天在網上找資料時,看到有人說wordreference的解釋比較精確。
我去找了幾個最近在學的les mots familiers,它裡頭大都有明確的英文解釋。
所以,早上花了點時間把它也加到onlinedic裡頭。
跟其他網站不一樣的地方是,wordreference會檢查request的header,
看user-agent是不是一般常用的browser,如果不是的話會擋掉該request。
這麼一來,python提供的最基本的
urllib.urlopen
就派不上用場了。
上網看了一下,要改掉預設的user-agent,得要改用urllib2才行。
大致上的code如下:
import urllib2
req=urllib2.Request(url=url_line,headers={'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113'})
f = urllib2.urlopen(req)
source = f.read()
嗯~又多了一個好字典 :)
相關連結:
WordReference

When I read Harry Potter III, I used three instances of onlinedic: one in Chambers Francais Anglais; one with XMLittre, Francais-Francais Dictionnaire; one in woaifayu-fc 我愛法語法漢字庫.
Most of the time I used the third one, because I can quickly grab the idea of the word, and move on to the following details of the plots.
However, the content of woaifayu-fc (a dictionary file from stardict website) is not well orgnized. All the explanations are crammed together. It's hard to find the meannings that I want.
So, I did a little modifications for the display of woaifayu-fc. As you can see in the screenshot, explanations are separated out with green colored font.
It'll work better when I export them out to text file and read by my ReviewVocab on PocketPC.
:-)











