<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-8581772664691091802</atom:id><lastBuildDate>Sun, 01 Sep 2024 13:51:23 +0000</lastBuildDate><category>Linux</category><category>Emacs</category><category>PHP</category><category>WindowsCE</category><category>MySQL</category><category>Python</category><category>Debian</category><category>DirectShow</category><category>JavaScript</category><category>Tips</category><category>VisualC++</category><category>openSUSE</category><category>Flask</category><category>Opera</category><category>Apache</category><category>C/C++</category><category>Container</category><category>Django</category><category>SQLAlchemy</category><category>shell</category><category>software</category><category>ssh</category><category>unicode</category><category>Codecs.AAC</category><category>Human Interface Device</category><category>Multimedia</category><category>Regular Expression</category><category>Tools</category><category>blogger</category><category>error</category><category>git</category><category>graphviz</category><category>grub</category><category>network</category><category>windowsXP</category><category>Action Script</category><category>Android</category><category>Audio</category><category>Compare</category><category>Drupal</category><category>File Format</category><category>HTML</category><category>Lisp</category><category>Mac</category><category>Microsoft.API</category><category>N900</category><category>OpenMAX</category><category>Slides</category><category>Streaming</category><category>SystemAdmin</category><category>Vim</category><category>WTForms</category><category>WebDesign</category><category>boot</category><category>compiler</category><category>domain</category><category>facebook</category><category>goodies</category><category>hash</category><category>jQuery</category><category>maemo</category><category>nginx</category><category>note</category><category>security</category><title>MooGoo&#39;s Blog</title><description></description><link>http://moogoo78.blogspot.com/</link><managingEditor>noreply@blogger.com (shl)</managingEditor><generator>Blogger</generator><openSearch:totalResults>135</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-178725544360784823</guid><pubDate>Thu, 03 Jan 2013 09:54:00 +0000</pubDate><atom:updated>2013-01-03T02:35:48.469-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQLAlchemy</category><title>SQLAlchemy的count很慢</title><description>http://docs.sqlalchemy.org/en/rel_0_8/orm/tutorial.html#counting&lt;br /&gt;
&lt;br /&gt;
uall = User.query.count()&lt;br /&gt;
很慢 (subquery的關係?)&lt;br /&gt;
&lt;br /&gt;
session.query(func.count(User.id)).scalar()&lt;br /&gt;
快多了&lt;br /&gt;
&lt;br /&gt;
232,053的資料,&amp;nbsp;用time.time() 算&lt;br /&gt;
&lt;br /&gt;
count(): 4.53022193909 sec&lt;br /&gt;
func.count: 0.17828607559 sec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://moogoo78.blogspot.com/2013/01/sqlalchemycount.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-7365481342320717717</guid><pubDate>Fri, 23 Nov 2012 04:32:00 +0000</pubDate><atom:updated>2012-11-22T20:32:45.201-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">facebook</category><category domain="http://www.blogger.com/atom/ns#">nginx</category><title>[nginx] facebook canvas連nginx時出現 HTTP 405 Not allowed</title><description>&lt;br /&gt;
Facebook是用POST去抓canvas/iFrame,&lt;br /&gt;
但是nginx處理static file預設不給POST,&lt;br /&gt;
workaround如下:&lt;br /&gt;
&lt;br /&gt;
location / {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; error_page 405 =200 $uri;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; root /var/www/html/yoursite.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
比較好的處理如下:&lt;/div&gt;
&lt;div&gt;
http://invalidlogic.com/2011/04/12/serving-static-content-via-post-from-nginx/&lt;/div&gt;
</description><link>http://moogoo78.blogspot.com/2012/11/nginx-facebook-canvasnginx-http-405-not.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-9215556763444322207</guid><pubDate>Mon, 19 Nov 2012 09:41:00 +0000</pubDate><atom:updated>2012-11-19T01:59:33.468-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQLAlchemy</category><title>[SQLAlchemy] 不用primary key的table</title><description>table沒有設pirmary key會出現這個錯誤:&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
sqlalchemy.exc.ArgumentError: Mapper Mapper|FooTable|foo_table could not assemble any primary key columns for mapped table &#39;foo_table&#39;&lt;br /&gt;
&lt;br /&gt;
mapper要設:&lt;br /&gt;
&lt;br /&gt;
&quot;primary_key&quot;:(col1, col2)}&lt;/div&gt;
</description><link>http://moogoo78.blogspot.com/2012/11/sqlalchemy-primary-keytable.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-3784897785913122147</guid><pubDate>Fri, 16 Nov 2012 04:03:00 +0000</pubDate><atom:updated>2012-11-15T20:16:58.412-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">git</category><category domain="http://www.blogger.com/atom/ns#">Mac</category><title>[Mac][git] git diff in Mac</title><description>&lt;br /&gt;如果有裝GitX的話，設定選&quot;Enable Terminal Usage&quot;，然後&lt;br /&gt;&lt;br /&gt;git diff | gitx&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;或是XCode的FileMerge/opendiff也很好用，&lt;br /&gt;&lt;br /&gt;git difftool -t opendiff -y&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
可以寫到.gitconfig的&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
[alias]&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;df = difftool -t opendiff -y&lt;/div&gt;
</description><link>http://moogoo78.blogspot.com/2012/11/macgit-git-diff-in-mac.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-3100183989481931199</guid><pubDate>Thu, 15 Nov 2012 04:13:00 +0000</pubDate><atom:updated>2012-11-14T20:14:06.142-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><category domain="http://www.blogger.com/atom/ns#">SQLAlchemy</category><title>[SQLAlchemy] foreign key constraint 問題</title><description>&lt;br /&gt;
以不delete, SET NULL為例:&lt;br /&gt;
&lt;br /&gt;
1. database level&lt;br /&gt;
db.Column(db.Integer, ForeignKey(db.ForeignKey(&#39;category.id&#39;,ondelete=&#39;SET NULL&#39;)))&lt;br /&gt;
&lt;br /&gt;
2.&amp;nbsp;pythen level&lt;br /&gt;
db.relationship(passive_deletes=True)</description><link>http://moogoo78.blogspot.com/2012/11/sqlalchemy-foreign-key-constraint.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-7686250288420284852</guid><pubDate>Sun, 11 Nov 2012 01:42:00 +0000</pubDate><atom:updated>2012-11-10T17:42:42.096-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>[Tools] 方便產生server response的Deployd </title><description>&lt;br /&gt;
&lt;br /&gt;
http://www.deployd.com/</description><link>http://moogoo78.blogspot.com/2012/11/tools-server-responsedeployd.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-4517294075646236135</guid><pubDate>Tue, 16 Oct 2012 09:45:00 +0000</pubDate><atom:updated>2012-10-16T02:45:21.402-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Emacs</category><title>Emacs 24 color theme 錯誤</title><description>是因為Emacs有內建color theme，語法改一下就好了。&lt;br /&gt;
&lt;br /&gt;
參考:&lt;br /&gt;
http://batsov.com/articles/2012/02/19/color-theming-in-emacs-reloaded/</description><link>http://moogoo78.blogspot.com/2012/10/emacs-24-color-theme.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-2277619686623641077</guid><pubDate>Tue, 03 Jul 2012 09:27:00 +0000</pubDate><atom:updated>2012-07-03T02:28:35.374-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">network</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>[tools] 找domain有無被用走的方便工具</title><description>https://github.com/zachwill/dom&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
$ pip install dom&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;#&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;安裝&lt;/span&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;$ dom foo # 列出相關domain有無被註冊&lt;/span&gt;&lt;/blockquote&gt;</description><link>http://moogoo78.blogspot.com/2012/07/tools-domain.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-4526594072103024784</guid><pubDate>Wed, 27 Jun 2012 06:04:00 +0000</pubDate><atom:updated>2012-06-26T23:04:53.328-07:00</atom:updated><title>[note] 2012 GDC Taipei - Aaron Pulkka (Rabbx) 利用AAA電腦/遊戲機遊戲開發經驗來獲得智慧手機/平板電腦遊戲的成功</title><description>&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;AAA&lt;/span&gt;&lt;br /&gt;
------&lt;br /&gt;
&amp;nbsp; - big buget&lt;br /&gt;
&amp;nbsp; - large item&lt;br /&gt;
&amp;nbsp; - long development schedule&lt;br /&gt;
&amp;nbsp; - &amp;nbsp;requirement:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; * large scope,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; * broad feature set&lt;br /&gt;
&amp;nbsp; - long play time&lt;br /&gt;
&amp;nbsp; - high quality/ polish&lt;br /&gt;
&amp;nbsp; - innovation?&lt;br /&gt;
&amp;nbsp; - no middle in game market&lt;br /&gt;
&amp;nbsp; - marketing costs &amp;gt;= development costs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.. note:: core gamers bring high expectations but are willing to pay&lt;br /&gt;
.. note:: late adopters form new casual audience, but want to pay less&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. High Quality User Experiance&lt;br /&gt;
&amp;nbsp; &amp;nbsp;- responsive&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;- 0.1s good&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;- 0.5s slow&lt;br /&gt;
&amp;nbsp; &amp;nbsp;- consistent&lt;br /&gt;
&amp;nbsp; &amp;nbsp;- clear/obvious&lt;br /&gt;
&amp;nbsp; &amp;nbsp;- forgiving&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; * Lasting Appeal&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - Ramping difficulty + Random Chance + Increasing Rewards = Replayability&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - Rollercoaster Excitement Curve&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; * Quality Assurance&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - Start QA early, ramp-up from alpha through launch&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - 100 little bugs worse than 1 big bug&lt;br /&gt;
&lt;br /&gt;
2. Launch Multiplatform&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; * cross-platform social play allowed on mobile and can increase audience growth dramatically&lt;br /&gt;
&amp;nbsp; * Amortize Development &amp;amp; Marketing&lt;br /&gt;
&amp;nbsp; * Build game as native to each platform&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - meet &#39;cultural&#39; expectations&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - tune for platform specific features&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; * xbox live! rich presence&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; * apple game center &amp;amp; retena display&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; * android &#39;back&#39;&lt;br /&gt;
3. Connect with yurr audience&lt;br /&gt;
&amp;nbsp; * Most AAA gamers target core gamers (young males)&lt;br /&gt;
&amp;nbsp; * konwing your audience&lt;br /&gt;
&amp;nbsp; &amp;nbsp; * mobile has potential for broader audience&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - casual audience spends less per user&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - broader audience can increase costs&lt;br /&gt;
&amp;nbsp; * community anagement&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - best marketing: word-of-mouth&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - metric tracking can help filter noise&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - press is not magic entity but part of your community&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; * bioware &amp;amp; blizzard provide great example&lt;br /&gt;
&amp;nbsp; * App store&lt;br /&gt;
&amp;nbsp; &amp;nbsp; understanding how each app store search function works is key&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; * Plannang&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - launch of game is just the beginning&lt;br /&gt;
&amp;nbsp; &amp;nbsp; * plan for updates&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - DLC for AAA games usually in development before game launches&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; - post-launch, be ready to modify update plan based on users&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; * tools&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - metric tracking (flurry, bitpollen)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - project management (Hansoft)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; - Feedback (Forum)&lt;br /&gt;
&lt;br /&gt;
Naughty Dog (AAA developer with no project managers)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* clones copy a proven base set of features, without adding much new.&lt;br /&gt;
* experimental games focus more on innovation, generally at the expense of scope and polish&lt;br /&gt;
* AAA games focus on evolution and polish on proven features&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
smartphone&lt;br /&gt;
* short session&lt;br /&gt;
* always connected to Internet&lt;br /&gt;
tablate&lt;br /&gt;
* longer session&lt;br /&gt;
* often disconnected from Internet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
AAA to mobile&lt;br /&gt;
* smaller scope&lt;br /&gt;
- app store&lt;br /&gt;
- more qualtiy&lt;br /&gt;
- more budget&lt;br /&gt;
+ larger possible audience&lt;br /&gt;
+ core gamers willing to pay to play&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
New Territory&lt;br /&gt;
---------------&lt;br /&gt;
TV + Mobile:&lt;br /&gt;
* Google TV&lt;br /&gt;
* Apple TV&lt;br /&gt;
* Transmedia&lt;br /&gt;
TV + Console + Mobile:&lt;br /&gt;
* MS Smart Glass&lt;br /&gt;
Tactile Controls:&lt;br /&gt;
* joysticks and buttons on mobile? (we missed buttons)&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</description><link>http://moogoo78.blogspot.com/2012/06/note-2012-gdc-taipei-aaron-pulkka-rabbx.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-351595146242482455</guid><pubDate>Wed, 27 Jun 2012 02:15:00 +0000</pubDate><atom:updated>2012-06-26T19:15:29.482-07:00</atom:updated><title>[note] 2012 GDC Taipei - Metro Style Game for Windows 8</title><description>&lt;div&gt;
Metro App min resolution: 1024x768&lt;/div&gt;
&lt;div&gt;
如果Metro App resolution大於1366x768+會在前景另外開一個APp (Snap View?)&lt;/div&gt;
&lt;div&gt;
Tile 動態磚, 每個是不同Entry Point, 同一個遊戲可有不同進入點 (從不同關卡進去)&lt;/div&gt;
&lt;div&gt;
Data sync:&lt;/div&gt;
&lt;div&gt;
* App Data(setting...)&lt;/div&gt;
&lt;div&gt;
* User Data (music, library...) - &amp;nbsp;live.com 帳號&lt;/div&gt;
&lt;div&gt;
Game可在任意時間(電動打一半)分享, 分享給個social service, 或&quot;另一個App&quot; (puzzle...)&lt;/div&gt;
&lt;div&gt;
統一Settings (Setting的framework?), 統一使用者體驗&lt;/div&gt;
&lt;div&gt;
http://ie.microsoft.com/testdrive/&lt;/div&gt;</description><link>http://moogoo78.blogspot.com/2012/06/note-2012-gdc-taipei-metro-style-game.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-5549686713974532109</guid><pubDate>Sun, 10 Jun 2012 12:05:00 +0000</pubDate><atom:updated>2012-06-10T05:09:48.086-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">shell</category><title>好fish shell, 不用嗎</title><description>shell很多了: bash, ksh, dash, zsh...
在&lt;a href=&quot;http://tw.pycon.org/2012/&quot;&gt;PyCon Taiwan 2012&lt;/a&gt;聽到這個很好用的&lt;a href=&quot;http://fishshell.com/&quot;&gt;fish shell&lt;/a&gt;，目前我只能發現自動補齊和指令顏色顯示很方便，不用很複雜的設定，就很好用了。&lt;br /&gt;
&lt;br /&gt;
1. 在Mac OSX用brew安裝:&lt;br /&gt;
&lt;blockquote&gt;
brew install fish&lt;/blockquote&gt;
2. 設定檔在: ~/.config/fish/config.fish (自己新增)
顯示git branch,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 參考: https://wiki.archlinux.org/index.php/Fish#Configuration_Suggestions&lt;br /&gt;
&lt;br /&gt;
3. 換預設shell: &lt;br /&gt;
&lt;blockquote&gt;
chsh -s /usr/local/bin/fish&lt;/blockquote&gt;
4. 以上出現&quot;non-standard shell&quot;錯誤, 到/etc/shells加&quot;/usr/local/bin/fish&quot;&lt;br /&gt;
&lt;br /&gt;
但是指令和bash/zsh不太合。</description><link>http://moogoo78.blogspot.com/2012/06/fish-shell.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-7917994757175524160</guid><pubDate>Mon, 07 May 2012 10:40:00 +0000</pubDate><atom:updated>2012-05-07T03:42:35.185-07:00</atom:updated><title>Git 強制pull</title><description>git pull時出現

&lt;b&gt;error: Untracked working tree file &#39;foo.bar&#39; would be overwritten by merge.  Aborting
&lt;/b&gt;

&lt;pre&gt;git fetch --all
git reset --hard origin/master&lt;/pre&gt;

ref: http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull</description><link>http://moogoo78.blogspot.com/2012/05/git-pull.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-7342680296684064958</guid><pubDate>Thu, 03 May 2012 04:28:00 +0000</pubDate><atom:updated>2012-05-02T21:31:30.300-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Python</category><title>[Python][Javascript] Python抓Javascript產生的頁面 (phantomJs)</title><description>一向都是用Python的&lt;a href=&quot;http://www.crummy.com/software/BeautifulSoup/bs4/doc/&quot;&gt;Beautiful Soup&lt;/a&gt;來parse網頁，現在出到第四版，更好用文件也好看多了。

&lt;pre&gt;
from BeautifulSoup import BeautifulSoup
&lt;/pre&gt;
改成
&lt;pre&gt;
from bs4 import BeautifulSoup
&lt;/pre&gt;
method name也有改，&lt;a href=&quot;http://www.crummy.com/software/BeautifulSoup/bs4/doc/#porting-code-to-bs4&quot;&gt;參考&lt;/a&gt;。


不過這次遇到的是內容是javascript產生的，如play.google.com，以前可能看一下js的code，學他送http request出去就可抓回來，現在的js越來越複雜，不好搞。

&lt;br&gt;

幸好有&lt;a href=&quot;http://phantomjs.org/&quot;&gt;PhantomJS&lt;/a&gt;這種東西(headless WebKit with JavaScript API)，就可以很方便的用webkit把網頁內容全開出來(跑完javascript)。

既然是javascript，DOM的selector就用jquery吧(&lt;i&gt;page.injectJs(&quot;jquery.min.js&quot;)&lt;/i&gt;)。

&lt;pre&gt;
var page = require(&#39;webpage&#39;).create(),
    t, address;

if (phantom.args.length === 0) {
    //console.log(&#39;Usage: loadspeed.js &lt;some URL&gt;&#39;);
    phantom.exit();
} else {
    address = phantom.args[0];
    page.open(address, function (status) {
        if (status !== &#39;success&#39;) {
            //console.log(&#39;FAIL to load the address&#39;);
        } else {
          
           if (page.injectJs(&quot;jquery.min.js&quot;)) {
                //console.log(&quot;jQuery loaded...&quot;);
            }

            var get_data = page.evaluate(function () {
              var data = {}
              data[&#39;title&#39;] = $(&#39;h1.doc-banner-title&#39;).text();
              data[&#39;content&#39;] = $(&#39;#doc-original-text&#39;).text();
              data[&#39;icon&#39;] = $(&#39;.doc-banner-icon img&#39;).attr(&#39;src&#39;);
              var img_list = []
              $(&#39;.screenshot-carousel-content-container img&#39;).each(function(){ img_list.push($(this).attr(&#39;src&#39;)) });
              data[&#39;images&#39;] = img_list

              return JSON.stringify(data);
            });
          console.log(get_data);
          phantom.exit();
        }

    });
}
&lt;/pre&gt;

command line執行$ phantomjs my_scrapy.js my_url 
console.log裡的資料就回跑出來了。

Python裡用commands.getoutput，再json.loads把JSON拆成dict，大改就這樣吧。
&lt;pre&gt;
import commands
import json

out = commands.getoutput(my_cmd)
data = json.loads(out)
&lt;/pre&gt;</description><link>http://moogoo78.blogspot.com/2012/05/pythonjavascript-pythonjavascript.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-6649320472811357297</guid><pubDate>Wed, 02 May 2012 18:12:00 +0000</pubDate><atom:updated>2012-05-02T12:00:25.031-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Flask</category><title>[Flask] multiple file input 上傳多檔案</title><description>這個害我傷腦筋好久，&lt;a href=&quot;http://flask.pocoo.org/&quot;&gt;Flask&lt;/a&gt;處裡form的post，透過&lt;a href=&quot;http://werkzeug.pocoo.org/&quot;&gt;Werkzeug&lt;/a&gt;處理，如果是單一name，用&lt;i&gt;request.values()&lt;/i&gt;(串列list)或&lt;i&gt;request.form&lt;/i&gt;(dict)，就可以抓到。如過是多重name，如：
&lt;br /&gt;
&lt;pre class=&quot;brush: html&quot;&gt;&amp;lt;input name=&quot;animal&quot; type=&quot;checkbox&quot; value=&quot;lion&quot; /&amp;gt;
&amp;lt;input name=&quot;animal&quot; type=&quot;checkbox&quot; value=&quot;tiger&quot; /&amp;gt;&lt;/pre&gt;
就要用&lt;i&gt;request.form.getlist(&#39;animal&#39;)&lt;/i&gt;取的list。


&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;檔案上傳&lt;/b&gt;:&lt;br /&gt;
&lt;pre&gt;&amp;lt;input name=&quot;icon[]&quot; type=&quot;file&quot; /&amp;gt;&lt;/pre&gt;
就要用&lt;i&gt;request.files&lt;/i&gt;，是一個werkzeug自定的&lt;a href=&quot;http://werkzeug.pocoo.org/docs/datastructures/?highlight=immutablemultidict#werkzeug.datastructures.ImmutableMultiDict&quot;&gt;ImmutableMultiDict&lt;/a&gt;。

如果是同一個name的多檔案(input array)&lt;br /&gt;
&lt;pre&gt;&amp;lt;input name=&quot;image[]&quot; type=&quot;file&quot; /&amp;gt;
&amp;lt;input name=&quot;image[]&quot; type=&quot;file&quot; /&amp;gt;&lt;/pre&gt;
&lt;i&gt;request.files&lt;/i&gt;裡有值，但是用&lt;i&gt;for j in request.files:&lt;/i&gt;同一個input name只能抓第一個出來，&lt;a href=&quot;https://github.com/rduplain/flask-wtf/issues/10&quot;&gt;有人說&lt;/a&gt;：&lt;a href=&quot;http://packages.python.org/Flask-WTF/&quot;&gt;Flask-WTF&lt;/a&gt;的FileField可以解決(沒試過)。後來去看了&lt;a href=&quot;https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/datastructures.py&quot;&gt;Werkzeug的原始碼&lt;/a&gt;:&lt;br /&gt;
&lt;pre&gt;class MultiDict
...
def iteritems
...&lt;/pre&gt;
學他用&lt;br /&gt;
&lt;pre&gt;for key, values in dict.iteritems(request.files):
     for value in values:
         print key, value&lt;/pre&gt;
就可以了。</description><link>http://moogoo78.blogspot.com/2012/05/flask-multiple-file-input.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-5589853132674315905</guid><pubDate>Tue, 24 Apr 2012 03:38:00 +0000</pubDate><atom:updated>2012-04-23T20:38:35.196-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Flask</category><title>[Flask][Flask-WTF]</title><description>Flask-WTF升級到0.6，{{ form.csrf }}要改成{{ form.csrf_token }}</description><link>http://moogoo78.blogspot.com/2012/04/flaskflask-wtf.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-1822489294871636674</guid><pubDate>Tue, 17 Apr 2012 01:43:00 +0000</pubDate><atom:updated>2012-04-16T18:55:58.558-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Django</category><title>[Django] 圖片上傳錯誤</title><description>換了新的VPS後上傳圖片出現錯誤:&lt;br /&gt;(jpg才會出現)&lt;br /&gt;&lt;br /&gt;&quot;上傳一個有效的圖片。你上傳的檔案不是圖片，否則就是壞掉的圖。&quot;&lt;br /&gt;英文:&lt;br /&gt;&quot;Upload a valid image. The file you uploaded was either not an image or a corrupted image.&quot; &lt;br /&gt;&lt;br /&gt;果然是PIL的問題，找不到libjpeg吧，用pip或apt重裝/upgrade PIL, libjpeg等都沒用。&lt;br /&gt;&lt;br /&gt;懶得自己重編，最後是以下順序成功了:&lt;br /&gt;&lt;blockquote&gt;sudo pip uninstall PIL&lt;br /&gt;sudo apt-get install libjpeg-dev&lt;br /&gt;sudo pip install PIL&lt;/blockquote&gt;</description><link>http://moogoo78.blogspot.com/2012/04/django.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-2019992550656539592</guid><pubDate>Sat, 14 Apr 2012 10:58:00 +0000</pubDate><atom:updated>2012-04-14T04:51:05.116-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">WebDesign</category><title>[WebDesign] 10 things every designer needs to know about forms (心得文摘)</title><description>via: &lt;a href=&quot;http://www.netmagazine.com/features/10-things-every-designer-needs-know-about-forms&quot;&gt;10 things every designer needs to know about forms&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;其實很多都是「常識」了，不過再實作時還是會常常忘記。&lt;br /&gt;&lt;br /&gt;1. 不用特別標示「必填欄位」，使用者通常只會直接按送出，然後再看有什麼沒填完的。&lt;br /&gt;2. 不要用HTML5的&quot;spinner&quot;，按鈕小不好按，用普通的TextField或Select就好了&lt;br /&gt;spinner: http://www.html5tutorial.info/html5-number.php &lt;br /&gt;3. 表單有很多按鈕時，要把最重要的「送出」特別標出，不然容易迷失自我。&lt;br /&gt;4. 欄位多可以分區塊，人是視覺的動物&lt;br /&gt;5. 表單的用詞遣字可多用心，讓使用者覺的填這資料是有意義的，而不是冷冰冰格子。（想一下例子）&lt;br /&gt;6. 日期欄位用動態跳出的月曆來選很酷，但是要考慮各地風水民情不同，年月日順序等（用Select簡單又方便）&lt;br /&gt;7. Server端檢查不容易，但還是一定要做好 （工程師的事）&lt;br /&gt;8. 不要設橫向欄位，或是用tab，從上到下就好了&lt;br /&gt;9. 簡化欄位，如地址不要用xx路xx巷xx號、電話不要分區碼，直接用一格就好了&lt;br /&gt;10. 別用機掰語氣做錯誤檢查，如:出生選成2028年，不要寫「你是未來出生的嗎」</description><link>http://moogoo78.blogspot.com/2012/04/webdesign-10-things-every-designer.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-4383661779205262985</guid><pubDate>Fri, 30 Mar 2012 05:48:00 +0000</pubDate><atom:updated>2012-03-29T23:04:59.530-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Flask</category><category domain="http://www.blogger.com/atom/ns#">WTForms</category><title>[Flask][WTForms] 要在HTML的Select tag, 新增一個&quot;空&quot;的預設選項</title><description>本來想用jQuery來後製，但其實不用那麽麻煩，WTForms果然都想好了：&lt;br /&gt;QuerySelectField的話，加上&lt;blockquote&gt;allow_blank=True, blank_text=u&#39;-- please choose --&#39;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://wtforms.simplecodes.com/docs/0.6.1/ext.html#module-wtforms.ext.sqlalchemy&quot;&gt;wtforms doc&lt;/a&gt;</description><link>http://moogoo78.blogspot.com/2012/03/flaskwtforms-htmlselect-tag.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-1043208626655144311</guid><pubDate>Thu, 08 Mar 2012 10:01:00 +0000</pubDate><atom:updated>2012-03-08T02:21:17.119-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Apache</category><category domain="http://www.blogger.com/atom/ns#">SystemAdmin</category><title>時常出現HTTP 403 Forbidden</title><description>&lt;blockquote&gt;Forbidden&lt;br /&gt;&lt;br /&gt;You don&#39;t have permission to access xxx on this server.&lt;/blockquote&gt;&lt;br /&gt;通常發生在圖很多的頁面，兇手是Apache防DOS的&lt;span style=&quot;font-weight:bold;&quot;&gt;mod_evasive&lt;/span&gt;&lt;br /&gt;果然是被保護機制擋掉了...</description><link>http://moogoo78.blogspot.com/2012/03/http-403-forbidden.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-3921167206997645391</guid><pubDate>Fri, 17 Feb 2012 12:47:00 +0000</pubDate><atom:updated>2012-02-17T04:54:40.940-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>[Python] 像PHP的associate array一樣初始Dict</title><description>Python的dict不能像PHP的associate array一樣&quot;任意給值&quot;，當不知道dict有幾維時很麻煩。&lt;br /&gt;有一個defaultdict可以用，只是不好看，哈哈!&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;cat = {} # 先初始一個dict&lt;br /&gt;for k, v in foo_list:&lt;br /&gt;   cat.setdefault(k, []).append(v)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;ref: &lt;a href=&quot;http://docs.python.org/library/collections.html#collections.defaultdict&quot;&gt;collections&lt;/a&gt;</description><link>http://moogoo78.blogspot.com/2012/02/python.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-2866703325638288298</guid><pubDate>Thu, 16 Feb 2012 03:33:00 +0000</pubDate><atom:updated>2012-02-15T19:34:40.702-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ssh</category><title>[ssh][error] Could not open a connection to your authentication agent.</title><description>ssh-agent沒有跑,&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;exec ssh-agent bash&lt;/blockquote&gt;</description><link>http://moogoo78.blogspot.com/2012/02/ssherror-could-not-open-connection-to.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-4632067323401877843</guid><pubDate>Thu, 09 Feb 2012 01:14:00 +0000</pubDate><atom:updated>2012-02-08T17:27:01.342-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">domain</category><title>domain transfer</title><description>Godaddy -&gt; Namecheap&lt;br /&gt;&lt;br /&gt;1. 登入Godaddy,Domain Manager左邊Domain Information的Authorization Code:按Send by Email,&lt;br /&gt;就會寄一封EPP Code的信來&lt;br /&gt;2. 到Namecheap申請domain transfer, 付完錢後會寄一封信來, 給你一個認證網址, 再輸入剛才godaddy寄來的EPP code. 輸入後再等一封transfer認證信(不會馬上).&lt;br /&gt;3. 收到認證信後, 點一個&quot;terms and conditions of the Agreement&quot;的連結, 看完按Approval, 等結果</description><link>http://moogoo78.blogspot.com/2012/02/domain-transfer.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-4975530992234216456</guid><pubDate>Sun, 23 Oct 2011 18:14:00 +0000</pubDate><atom:updated>2011-10-23T11:17:28.977-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Compare</category><category domain="http://www.blogger.com/atom/ns#">Flask</category><category domain="http://www.blogger.com/atom/ns#">PHP</category><category domain="http://www.blogger.com/atom/ns#">Python</category><category domain="http://www.blogger.com/atom/ns#">Slides</category><title>[Slides] PHP之惡, Flask (Python)之優</title><description>滿主觀的, 不過可姒參考&lt;br /&gt;&lt;br /&gt;http://zakx.de/phprant-en.pdf</description><link>http://moogoo78.blogspot.com/2011/10/slides-php-flask-python.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-5366042224275494331</guid><pubDate>Thu, 20 Oct 2011 14:31:00 +0000</pubDate><atom:updated>2011-10-20T08:23:43.388-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Debian</category><title>Google earth在Debian squeeze 32bit 中文出不來</title><description>Google附的Qt4函式庫的問題，改用系統內建的就好了。&lt;br /&gt;&lt;br /&gt;先把Google附的砍掉&lt;br /&gt;&lt;br /&gt;Google附的Qt4lib裝在 /opt/google/earth/free/目錄下, 有四個檔:&lt;br /&gt;libQtCore.so.4, libQtGui.so.4, libQtNetwork.so.4, libQtWebKit.so.4&lt;br /&gt;全砍掉, 然後再改 /opt/google/earth/free/googleearth&lt;br /&gt;找到以下這行:&lt;br /&gt;LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./googleearth-bin “$@”&lt;br /&gt;再之前加上這行&lt;br /&gt;export LD_PRELOAD=/usr/lib/libfreeimage.so.3&lt;br /&gt;就好了。&lt;br /&gt;&lt;br /&gt;(註: 要安裝sudo aptitude install libfreeimage3)&lt;br /&gt;&lt;br /&gt;via: http://blog.slps.tp.edu.tw/00086/?p=275</description><link>http://moogoo78.blogspot.com/2011/10/google-earthdebian-squeeze-32bit.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8581772664691091802.post-6038291234416852770</guid><pubDate>Sat, 15 Oct 2011 04:31:00 +0000</pubDate><atom:updated>2011-10-14T21:36:37.608-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Debian</category><category domain="http://www.blogger.com/atom/ns#">Python</category><title>[Python] PyPI實在太常連不到了</title><description>pip 0.8.1之後:&lt;br /&gt;&lt;blockquote&gt;pip install --use-mirrors $PACKAGE&lt;/blockquote&gt;&lt;br /&gt;舊版pip (Debian 6用的是0.7.2)&lt;br /&gt;&lt;blockquote&gt;pip install -i http://d.pypi.python.org/simple $PACKAGE&lt;/blockquote&gt;&lt;br /&gt;或是把mirror資料寫在&quot;~/.pip/pip.conf&quot;裡&lt;br /&gt;&lt;blockquote&gt;[global]&lt;br /&gt;index-url = http://d.pypi.python.org/simple&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;via: http://jacobian.org/writing/when-pypi-goes-down/</description><link>http://moogoo78.blogspot.com/2011/10/python-pypi.html</link><author>noreply@blogger.com (shl)</author><thr:total>0</thr:total></item></channel></rss>