發表文章

Change font in web pages

圖片
參加過三次Google I/O, 但都沒有去過它的codelab, 現在回頭看一下他的教材, 還真是好物... 一個是用appengine把pipeline, log, google storage, big query, bootstrap, channel api全部串起來, 做一個log分析程式. 那個很有趣, 之後再另外寫心得. 另外一個是教CSS,  http://io12-css-codelab.appspot.com/lessons/index.html . 也不是頂難的東西, 但是一步一步這樣教, 好有FU喔. 其中換字型原來這麼簡單. 1. 去 http://www.google.com/webfonts/ 挑字型. 它已經有很多工具可以讓你看不同大小的字型, 或是該字型當標題或內文時的感覺. 2. 選定後可以按該字型下面的Quick-use, 它還會跟你說因為用了這個字型, 造成網頁loading overhead的高低. 如果是綠色的應該影響就很小吧... 3. 再往下面看有兩個簡單的code要copy & paste. 只要把 <link href='http://fonts.googleapis.com/css?family=Quando' rel='stylesheet' type='text/css'> 放在html的header裡. 然後就可以在後續的css style裡用font-family: 'Quando', serif;來指定該字型囉... 真是想不到的簡單.

OAuth in GAE

因為需要用到Google的某個service, 而那個service需要用OAuth認證, 最近研究了一下OAuth2要如何在GAE上用. 身為OAuth2推手之一的Google, 在推廣OAuth2及提供對應的Tools來說, 盡了很大的心力. 以python來說, 它就提供了 google-api-python-client 這個library, 可以很容易的使用OAuth. 我參考了這份 文件 實驗成功使用OAuth2了, 特別記錄一下. 安裝 在Linux與MacOS下十分簡單, 只要'sudo easy_install --upgrade google-api-python-client'即可安裝完成. Windows下就哭哭了, 但是最後的成果是可以在Windows下的dev_appserver.py裡執行的. 在 Google APIs Console 裡註冊你的AP 在左邊的下拉選單裡新增一個Project. 在Service那欄裡找出對應的API, 把它切換成On. 點API Access. 點Create on OAuth 2.0 client ID. 因為是GAE, 選Web application. Hostname可以先打localhost. 點Create後, 會產生三個像密碼一樣的東西, 兩個link. 把它們抄寫到一個叫settings.py的檔裡. 等等會用到. CLIENT_ID='把那串密碼裡的Client ID填在這' CLIENT_SECRET='把那串密碼裡的Client secret填在這' SCOPE='' #這是要使用的API應該會提供的資訊, 從API的文件取得. 在安裝完 google-api-python-client 後, 會在/usr/local/bin裡裝一個enable-app-engine-project的script. 如果已經有把/usr/local/bin加入PATH的話, 直接執行後面加project目錄即可. e.g. enable-app-engine-project ./ 上面那段command會複製一大堆目錄檔案過來, 把你的目錄搞的亂七八糟, 不過就將就著用吧. ...

Unix scripts (sed & bash for)

圖片
今天工作上有個小任務, 一個目錄裡有47張圖, 巧合的是他們只有兩種解析度, 分別是480x84及480x720. 需要把它們分別放到兩個目錄裡. 大概記錄一下怎麼做的, 不然永遠記不得... 用file取得檔案的解析度, 先不要480x84的. file *.png | grep -v "x 84" | sed 's/\(.*\):.*/\1/' > list 再在bash cmdline寫一行的script for i in `cat list`; do `mv $i 720`; done 再把剩下的搬去84目錄下. mv *.png 84 收工

How to use FTP over TLS?

Filezilla Site Manager->New Site->Encryption->Require explicit FTP over TLS. lftp lftp id@ip set ftp:ssl-protect-data true get filename

Revamp my blog

圖片
My blog template didn't change for a while. Blogger has added many new features and I chose my template before that. So that template wasn't too flexible. Now I changed to use another template, removed most of the Ads and add SyntaxHighlighter 3.x. Now the web site would look neater.

Microsoft isn't doing right job...

I paid a visit to a  Apple store  on 3/16 to experience the new iPad. And I found there wasn't too much difference and innovation there. It got heavier and thicker for the higher resolution. I don't appreciate the higher resolution now because most of the apps do not support this resolution, they looked awful. There are still blurred icon there including the system UI. Can't imagine it before Jobs' leave. Things may change when time flows. There would be more and more app support it in the future. One tip, you shouldn't buy 16GB version anymore, the app grows a lot in size in such resolution. 16GB won't be enough. Anyway, the intention of this post is complaining about MS. When I visited Apple store, I also visit Microsoft store. I can feel they are desperate. A girl in the front door to pass free T-shirt which shows "I'm a PC" and I got one too. And another Latino was promoting a "call for duty" game tournament. As far as I can tell,...

Python gflags

Google有一個叫 python-gflags 的project, 可以很方便地幫助讀取參數. 使用方法如下. 安裝方法 sudo easy_install --upgrade python-gflags 參數種類 string: 將參數解讀為字串 bool/boolean: 值可以是0/1, false/true, f/t float: 將參數解釋為floating point number. 有兩個optional參數, 可以指定上下限 integer: 將參數解釋為integer. 有兩個optional參數, 可以指定上下限 enum: 如果輸入參數在預先設好的這個list裡, 為合法輸入, 否則會發出exception. list: 以逗號隔開的一組輸入字串 spaceseplist: 以space隔開的一組輸入字串 multistring: 還看不太懂怎麼用. multi_int: 還看不太懂怎麼用. 使用方法 import gflags FLAGS = gflags.FLAGS # string, 參數意義為"參數名", 預設值, 說明 gflags.DEFINE_string('client_id', None, 'Client Id for authentication.') gflags.DEFINE_string('client_secret', None, 'Client secret for authentication.') gflags.DEFINE_integer('age', None, 'your age in years', lower_bound=0) gflags.DEFINE_boolean('debug', False, 'produces debugging output') gflags.DEFINE_enum('gender', 'male', ['male', 'female'], 'your gender') # 設為required ...