2010/03/31
霞光, 火天之城
Riverside.Taipei.Taiwan
原來五十公里比我想像中的還要長。
不過時速平均不到十公里,也太誇張了。
====
火天之城。沒有字幕,每到重點必聽不懂。
不過,電影畢竟是電影,光看畫面也可以猜出個七八成。
2010/03/22
onlinedict線上版小改進
lac d'Anncey.France
在這邊看到,透過點小設定,可以讓Chrome的網址列充當搜尋引擎,自訂想要的搜尋。之前用Google App Enginen包裝出來的OnlineDict,只有吃由form餵入的資料,也就是只支援post的方式。為了要讓它也可以做為Chrome搜尋用的引擎,就得要為它做點小改變,讓它也支援get方式的查詢才可以。
所以,我改了一下程式碼。有多簡單呢?就copy paste一行程式碼而已。
原本def get(self)底下是直接呼叫OutputHtml(),現在改成呼叫post(self),就可以跟post做一模一樣的處理了。
#/usr/bin/env python
import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import os
from google.appengine.ext.webapp import template
import Dict
class OnlineDic(webapp.RequestHandler):
def __init__(self):
self.fren_dic = Dict.collins_fren_dict()
self.ench_dic = Dict.yahoo_dict()
self.eijiro_dic = Dict.eijiro_dict()
def get(self):
self.post()
def post(self):
word = self.request.get('word')
dic = self.request.get('dic')
if dic == 'Fr-En':
content = self.fren_dic.doSearch(word)
content = content // handling
elif dic == 'Ja-En':
content = self.eijiro_dic.doSearch(word)
else:
content = self.ench_dic.doSearch(word)
self.OutputHtml(content,dic)
def OutputHtml(self, content="", dic=""):
template_values = { 'content': content,
'dic': dic,
}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
application = webapp.WSGIApplication(
[('/', OnlineDic)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
# vim:set nu et ts=4 sw=4 cino=>4:
網站在此:http://onlinedict.appspot.com/
目前支援法翻英,範例如下:
http://onlinedict.appspot.com/?dic=Fr-En&word=%s
英翻中
http://onlinedict.appspot.com/?dic=En-Ch&word=%s
日翻英
http://onlinedict.appspot.com/?dic=Ja-En&word=%s
為了貼上面的程式碼,特別去找了一個透過javascript的syntax highlighter,路徑如下:
http://alexgorbatchev.com/wiki/SyntaxHighlighter
使用方式可以參考下面這個網址:
http://www.craftyfella.com/2010/01/syntax-highlighting-with-blogger-engine.html
2010/03/21
高速鐵路新時代 -- 蘇昭旭
2010/03/20
Vimium
Seattle.US
No chance to visit Mountain Ranier and Mountain Baker in Seattle.
However, a casual view on the road side is already attractive enough.
====
Vimium is another Chrome extension that tries to simulate the key behaviors of Vi editor. Comparing to Vrome, it allows you to customize(map/unmap) its default key mappings, which is quite useful if you are used to other key mappings.
For example, I like to use H/L for going backward/forward among the tabs with vimperator on firefox. Instead of using the default J/K with Vimium on Chrome, I can change it back to the way I like.
Link: Vimium
Link: Vimium
2010/03/18
龍紋身的女孩
2010/03/15
2010/03/14
Did you hear about the Morgans 名牌冤家
忠犬小八
等一個人咖啡 -- 九把刀
2010/03/11
追尋現代中國 -- 最後的王朝 史景遷
2010/03/10
2010/03/09
Bouquet Final (Final Arrangements)
2010/03/07
電影
2010/03/05
onlinedict by google app engine
Central Station.NYC.US
I posted an article about using Google App Engine in last June, and the experiment target is the onlinedict. Everything goes well and since onlinedict is originally written in python, the porting task is without any efforts.
However, there's one limitation of using Google App Engine: You can get your codes back from the server. You have to keep your codes somewhere. That's quite strange as a policy. I know it may be easier to control the whole system on google side, but as a user, it's troublesome ofr me because I am too lazy to my stuff in another source control website.
As a consequence, I lost my codes after re-installing OS on my nb for several times. Although my original work still runs well, it looks bad on all mobile devices. The words are too small to read. However, I don't have original codes anymore! no way to improve it at all!
Finally, I decided to rewrite it again,since this website should help me most on mobile devices. If the outlook on devices are bad, then it is somehow useless to me. Well, the first thing to do is study again how to apply the google app engine framework into my dictionaries. With the help of the tutorial, I quickly achieved what I have done last time: a working fr-en, ch-en dictionary, and, plus eijiro dictionary!
The most difficult part (not really difficult at all, I just don't know how to do) is to adopt some css style to make it look great on mobile devices. Well, I found a good refernce site: http://building-iphone-apps.labs.oreilly.com/. And, it's free!
Okay, after several hours of work, I am happy with my new dictionary now. The font size is good, the input control is at the right position, with some hints in the box. Three online dictionaries are available. It's time to go to sleep again~~
2010/03/04
訂閱:
文章 (Atom)
乩童警探 一二集
接連看了兩集。第一集還算新鮮,到了第二集就看得比較慢了。一來,劇情雖然常會提到乩童,但真的跟乩童又沒有什麼關係。第二集後半大概就猜出是怎麼一回事了,但還是很享受在作者解釋的過程。只是前面舖陳有點久,而且人物有點多,再加上我是斷斷續續的看,看到後來都快忘了誰是誰,或是誰曾經出過什麼...