VirtualBox客戶端抓不到USB?


在Linux下VirtualBox安裝完畢後,會出現客戶端抓不到USB的問題。
其實,這是安裝的時候沒有把目前的使用者加入到特定的群組當中,不知道這算不算是bug?


Linux: Mint 11
VirtualBox: 4.1.8


解決方法:
1. sudo groupadd usbfs
2. sudo adduser {current_user} usbfs
3. sudo adduser {current_user} vboxusers

Reference:
* 怎样将当前使用用户添加到vboxusers组中

RealTek 8111/8168


換了主機板後,RealTek 8111E的晶片不知為何被核心識別為8169,造成網路常常會莫名其妙斷線。

解決方法:
1. 從RealTek下載驅動
2. sudo ./autorun.sh

Reference:
* No network detected, Realtek 8111/8168 issue
* Realtek RTL8111B / RTL8168B NIC

大家都要贏在起跑點上

家長要公平的考試制度,又要自己的孩子「贏」在起跑點上。

不知道參與明年選舉的候選人中,是否能提供這樣的教育政策? 保證每個孩子都是「贏」在起跑點上。 能提出的話應該可以贏得不少家長的選票吧。

另外,坊間的文理補習班只要能保證來這裡補習的孩子都是「贏」在起跑點上,並化為白紙黑字的成績單的話 不也是財源滾滾而來吗?
參見新聞:
至於,那些沒有贏在起跑點上的孩子們,跟失敗者的傳記一樣是個賣不出去的新聞故事。

非大陸地區怎麼看土豆網與優酷網的影片


土豆網跟優酷網最近都在封鎖大陸以外地區的觀看, 試過了轉用大陸匿名Proxy, 沒用。
後來找到了這個方法暫時可以看土豆網跟優酷網的影片, 不曉得可以用多久, 只要下面兩者其中之一發生的話,就沒戲唱了:
  • 後端的存放影片的主機也跟著封鎖大陸以外地區的IP的話
  • 土豆網與優酷網封鎖FLVCD這類網站的話
用FLVCD到不是多喜歡用這服務只是:
  1. FLVCD的主機在大陸
  2. 有些視頻解析網站可能因為主機不再大陸就宣佈之後不支援土豆網或優酷網了

步驟:
  1. FLVCD 之類網站解析出影片網址
  2. 再將常用的下載工具或者是影片播放器加上user-agent, 偽裝成Firefox之類的瀏覽器就可以下載或觀看了
  • curl/wget之類的工具下載
    wget --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20100101 Firefox/6.0" {video_url}
    curl -L -A "Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20100101 Firefox/6.0" {video_url}
  • 用mplayer之類的播放器播放
    mplayer -user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20100101 Firefox/6.0" {video_url}
  • 如果Firefox有裝mplayer之類的plugin的話,就可以直接用瀏覽器播放解析完畢後的網址


  • 土豆網比較簡單,因為影片沒有被切割。優酷網因為將影片切割成了許多段,簡單的作法是產生播放清單, 再用-playlist選項丟給mplayer播放。


Example:
順便用Python寫了個很簡單的FLVCD warpper




Reference:

果然是拼經濟啊


看完下面的新聞, 終於可以理解為什麽,財政部長說:「中華民國財政是最好的」

原來政府要開發土地還不需要地主同意就可以預標售所有權人所擁有的土地。真的是讓我開了眼界, 長了見識。
更絕的是, 預標售制度完全沒有法源依據, 政府就可以進行土地開發了。

若依照這種土地預標售模式, 政府怎麽會缺錢呢? GDP數字的成長怎麽會難看呢? 只要:

圈塊地, 畫個餅, 加上預標售就有錢可以搞開發了,順道又提升一下GDP的數字
至於土地徵收的合理性與必要性,官員只要一句:「開發的合理性與必要性已審慎的評估」

最後如果有爭議就是,官員:「我們都是依法行政」
Reference:

土豆網影片所在地區不能播放的問題


轉貼自:怎么国外不能看土豆网的视频了_百度知道
目前我国主流的的视频网站“优酷”、“土豆”等用“日剧”等关键词检索可获得不下10万条相关结果,并设有专门网页,热门电视剧常常是从头至尾整部 上传。 比特网(Chinabyte)12月31日消息(李群) 据星岛环球网报道,针对我国视频网站大量引用“非法播放”的日剧及动画等视频现象,日本的电视台等相关产业正在加紧制定对策予以应对。报道称,在中国这类 网站上,用户可以收看到刚刚放映的日本作品,并配有中文字幕,且每集无时间限制,整部电视剧或电影都能收看,“严重侵害了作品的著作权”。
据报道,目前我国主流的的视频网站“优酷”、“土豆”等用“日剧”等关键词检索可获得不下10万条相关结果,并设有专门网页,热门电视剧常常是从头 至尾整部上传。日本的电视剧及制作公司等对此颇为头疼,NHK公司今年的推出的《笃姬》等电视剧在中国很受欢迎,但是,无视非法视频泛滥将直接威胁到收费 服务的运作。为此,该公司与主要视频网站交涉,并同部分网站签署了协议,目前每月向网站提出数次删除要求,涉及数百个视频,中方基本都进行了删除,对中方 的应对给予肯定。
除NHK公司外,由民间电视台组成的日本民间放送联盟也正对该问题进行研究,计划今后采取相应对策。为此,我国部分视频网站最近限制了来自日本域名的链接。
日本经济产业省相关团体针对中国的非法视频现象该机构指出,“用户希望今后也能收看喜欢的作品,理应向作者支付相应报酬”,希望中方采取相应措施。
原來是這樣啊, 不過這樣頂多只是關起門來, 不讓外面的人看到而已 侵權的問題還是一樣無解啊

這樣,變成要弄個跳板跳進牆裡面嗎? XD
Reference:

土豆網雜記

之前網路上有看到擷取土豆下載網址的網站,現在我連不進去了
http://www.flvxz.com/
# 0827今天又可以進去了, 但不能網址似乎抓不出來

Step:

  1. GET http://www.tudou.com/programs/view/...../
    • iid -> 數字(後面查下載網址時會用到)
    • iid_code -> [0-9a-zA-Z]+
    • time 播放時間
    • thumbnail = pic = 影片圖片
    • kw = title = 影片標題
    • ishd = hd = 影片畫質參數
    • isMusic = true/false
    • http://www.tudou.com/v/{iid}/v.swf # 無廣告版本
    • http://www.tudou.com/v/{iid_code}/v.swf # 無廣告版本
  2. GET http://v2.tudou.com/v?.... -> XML # 影片下載網址
    • it = iid
    • refurl = urllib.urlquote(http://www.tudou.com/programs/view/...../) # 選擇性
    • hd=0,1,2 #影響影片來源的排序
    • st=1,2,3,99 #影響影片畫質
    • 如果完全不管畫質的話, 只要給個it參數就可以得到下載網址的XML資料
    • 加上st, hd參數可以得到比較高畫質的下載網址
    • error <e errno="6" error="ip is forbidden"/> #(由於....因素不能播放.....)
    • Example: http://v2.tudou.com/v?it=94078712 # 神的筆記本第一集
  3. GET http://....
    • 用curl之類工具要加 user-agent header
    • user-agent = "Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20100101 Firefox/6.0"

無廣告版

可以用Firefox addons Redirector 來達成
  1. 是給一般影片用的
  2. 主要是豆單中的影片
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxtmuzD947L94NAmGM_Vlxxsh44gJAA115Ruwl-1jF3jE_ZCrkvtjPZrytLugSUevu2R3W89SzgFpPhmrNSV0KsKSbXx_V0RdpY_TcADM4cIYVDRZ_qQM-kOtMNGUH2yICMgK3ph2zjwNI/s800/Redirector_002.png
碎碎唸一下,越來越多東西不能再土豆上看了=_=
Reference:

新增nautilus工具列按鈕按鈕


Add Nautilus toolbar buttons
File: /usr/share/nautilus/ui/nautilus-navigation-window-ui.xml
<toolbar>
+<toolitem ....>
  • <toolitem name="Cut" action="Cut"/>
  • <toolitem name="Copy" action="Copy"/>
  • <toolitem name="Paste" action="Paste"/>
  • <toolitem name="Delete" action="Delete"/>
  • <toolitem name="Properties" action="Properties"/>
  • <toolitem name="New Folder" action="New Folder"/>
Reference:

NTFS-3G的幾點雜記


幾點雜記:
  • setfattr -n user.field -v 'non-ASCII' 時, 會將value以Bae64編碼編碼編碼,前面會多個0s, 或0x ,而說明是在getfattr找到的=_=|||
    可以用用getfattr -e text -n user.field path來存取
    -e en, --encoding=en
    Encode values after retrieving them. Valid values of en are "text", "hex", and "base64". Values encoded as text strings are enclosed in double quotes ("), while strings encoded as hexidecimal and base64 are prefixed with 0x and 0s, respectively.
  • ntfs-3g的掛載選項 streams_intferface
    streams_interface=value
    This option controls how the user can access Alternate Data Streams (ADS) or in other words, named data streams. It can be set to, one of none, windows or xattr. If the option is set to none, the user will have no access to the named data streams. If it's set to windows, then the user can access them just like in Windows (eg. cat file:stream). If it's set to xattr, then the named data streams are mapped to xattrs and user can manipulate them using {get,set}fattr utilities. The default is xattr.
    user_xattr
    Same as streams_interface=xattr.
    掛載選項streams_interface=windows:
    • 可以使用 cat file:stream 之類的語法來存取ADS,缺點是不能用serfattr來更新與刪除ADS
    • 只能用getfattr -n ntfs.streams.list file 來取得ADS屬性清單(說明是這樣說,但是列出的部份不完全)
    掛載選項streams_interface=xattr:
    • 無法設置超過4K(這看系統block size決定)的屬性值
    • non-ASCII屬性值會以Base64編碼
    • 無法以 cat file:stream 之類語法來存取ADS

這算是種kuso嗎?


對照著以前發生過的新聞:
  • 大埔農地爭議
  • 新竹璞玉計畫
  • 搶救高鐵封井
在對照著下面的新聞報導(取自Google News)
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9cBePBXNlJ2e717D1uuBXkBU0rX7wtyjVY0pf9FRzZ-mggXLRWHEE4GXLYNhj1m6O_cAplIB6SrcR8I6Bx1REFhdySYsQugMzpRULtXdjHdHkMNrKGKlLViGfX2lOy0rj1kvARTuXrT9G/s800/%2525E7%2525B3%2525A7%2525E5%2525AE%252589%252520%2525E7%2525B7%25258A%2525E6%252580%2525A5%2525E5%252584%2525B2%2525E5%252582%252599%2525E6%2525A9%25259F%2525E5%252588%2525B6%252520%2525E5%252590%2525B3%2525E6%25258F%252586%2525E5%2525BF%2525B5%2525E8%25258C%2525B2%2525E5%25259C%2525A8%2525E8%25258C%2525B2%252520-%252520Google%252520%2525E6%252596%2525B0%2525E8%252581%25259E.png

這種邏輯我的確看不懂=_=
再看看, 考試院長關中說:「公務員不是一般人,錄取率只有三趴。」 嗯~ 套句食神的台詞:我真的搞不懂你啊

Wine雜記


wine 環境變數

  • WINEPREFIX - wine設定
  • WINEDLLOVERRIDES - DLL設定
可以配合 env LANG="ja_JP.UTF8" WINEPREFIX="absPath" wine ..... 來執行特定的程式

wine 相關程式

  • wine/wineconsole(GUI/Console)
  • winecfg - wine設定程式
  • regedit
  • msiexec - 安裝*.msi
  • regsvr - register DLL

wine install application:

  • app-setup.exe type:
    wine app-settup.exe
    
  • *.msi:
    wine start "D:\setup.msi"
    or
    msiexec /i foo.msi
    or
    wine start /Unix /mnt/cdrom/setup.msi
    
有時為了保險起見, 安裝前最好還是下個 env WINEPREFIX="/home/{user}/.wine" wine "setup.exe" 免得不知道裝到哪裡去了

不讓wine執行的安裝程式建立桌面連結或是改變檔案關聯

  1. winecfg中將winemenubulider.exe設為disable
  2. regedit disable::
    將下列存成disable-menubuilder.reg [HKEY_CURRENT_USERSoftwareWineDllOverrides] "winemenubuilder.exe"=""
    # 使用regedit匯入設定 regedit disable-menubuilder.reg
  3. 設定環境變數::
    WINEDLLOVERRIDES=winemenubuilder.exe=d wine setup.exe

使用apt-build重新編譯wine

ubuntu 11.04 code name: natty
參考 http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?viewmode=compact&topic_id=12836&forum=2
  1. sudo apt-get install apt-build
  2. 增加 /etc/apt/sources.list(針對ubuntu 11.04)
    deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu natty main
    deb-src http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu natty main
  3. sudo apt-build update
  4. suod apt-get build-dep wine# 設定wine編譯環境
  5. sudo apt-build install wine --reinstall # 我的機器上 AMD X945 + 8G RAM 大約要跑一個小時多
  6. sudo apt-get autoremove
  7. sudo apt-build clean-sources
  8. sudo apt-build clean-build
效果沒有預期的好,有比較快一點但沒有到達飛快的程度

重新生成一個新的wine環境

  1. rm -rf ~/.wine # 預設路徑(如果有設定WINEPREFIX的話則依WINEPREFIX)
  2. winecfg (會在 ~/.wine生成一個新的wine環境)
如果有多個wine環境的話就要配合使用env WINEPREFIX="..."

修改winecfg桌面整合中的字型

  • Message Box Text
  • 功能表文字
  • 提示區文字
  • 當前標題欄文字
對一般程式來說夠用了, 不用那麼麻煩去弄字型對應 MangaMeeya修改完上面4個字型設定之後就ok!
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNuWQPF9muW3pjWrJIaJLxJWY6abVMCndY8EmAM9j7Rf11BTDiYxI2ghyphenhyphenU9xccsF_CQMy80cGRZeJCSjcSMnlQXC8s1e7wrA4vb1dqK7f1FgpIFFbrHw6NMacTlTrFsk98K_yX46MZ2E19/s800/%2525E3%252583%25259E%2525E3%252583%2525B3%2525E3%252582%2525AC%2525E3%252583%25259F%2525E3%252583%2525BC%2525E3%252583%2525A4%252520v7.4_021.png

winetricsks

  • wintricks的GUI不算好用, 很多app安裝選項在GUI中沒出現
  • 參考 http://wiki.winehq.org/winetricks_cn 裡面有比較完整的安裝套件
  • 安裝DirectX9:
    1. winetricks corefonts
    2. winetricks fontfix # 主要是為了後面的.Net Framework的安裝不會出現錯誤訊息
    3. winetricks dotnet11
    4. winetricks directx9
  • winetricks會把下載的東西放在 ~/.cache/winetricks

ubuntu 11.04 新增語系


#列出所有所有可用的語系:
locale -a
#新增ja_JP.SJIS, ja_JP.EUC-JP:
sudo vim /var/lib/locales/supported.d/ja
ja_JP.SJIS SJIS
ja_JP.EUC-JP EUC-JP
#reconfigure installed package:
sudo dpkg-reconfigure
#加入語系:
sudo locale-gen
Reference:

SD Gundam GX cheats

修改.bst

Start: 0x6F65(我方大將MS x-aix
下一個MS/WS: +16bytes

Act/Level: 一個byte要拆成2 部份來看

  • 前半部是Act/若未行動則會小於128, 不同地形的未行動會有所不同
    4-> 艦艇中未行動
    8-> 已行動
  • 後半部是Level(0-> Lv1, 3->Lv Ace)




這是惡搞(結果我把敵我雙方的MS都改成X Gundam, AI竟然都把MS集合在一起.....= =|||

視覺震撼效果一流
實質作戰力:0 分





何為因, 何為果?

全球股災 紅酒指數早就預警

真是好標題,讓兩個看似相關,卻難以證明因果之論證,硬是扯成了篇報導

, 要是我以後看不到了怎麼辦?


Reference:

在ubuntu下編譯bsnes

編譯bsnes要裝很多東西>"< 
 * build-essential 
 * libqt4-dev 
 * libqt4-opengl-dev
 * libsdl1.2-dev
 * libpulse-dev 
 * libopenal-dev 
 * libao-dev 
 * libxv-dev 
 * gcc-4.6 # 0.83版之後都需要 

在Linux下玩SD Gundam GX

Reference:


Extended Attributes

使用者自訂的extended attributes要放在user這個namespaces下面
對於NTFS分割區一樣可以使用setfattr, getfattr來存取NTFS ADS

使用上的一些限制:

  • ext2/3/4 分割區需要在fstab額外下 user_xattr option
  • extended attributes size are limited to fit on a block size
  • block size 可以用下面來查詢
    sudo blockdev --getbsz /dev/partition   

我查到的block size是4096(4K) 對於純文字來說很夠用, 不過若要把extended attributes
拿來放影片的screenshots的話,就要切割了~XD~

# 安裝setfattr, getfattr
sudo apt-get install attr

Example:
# Create new file
echo Hello World! > 1.txt

# Add extended attributes
setfattr -n user.URL -v http://www.google.com.tw 1.txt
setfattr -n user.Metadata.MIME -v "text/plain text" 1.txt

# Update extended attributes
setfattr -n user.URL -v http://tw.yahoo.com 1.txt

# Delete extended attributes
setfattr -x user.URL 1.txt

# Get all extened attributes
getfattr -d 1.txt

檔案從ext4複製到NTFS, extended attributes也會被一併複製過去過去

Reference:

Nautilus-actions

What is it ?
Nautilus-Actions is a Nautilus extension whose principal function is to allow the user to add arbitrary actions to the file manager context menus. These actions may be organized in menus and submenus, exported and shared with other desktop environments.

 nautilus-actions

* 設定工具
nautilus-actions-config-tool
或者是Menu -> 控制台 -> Nautilus-Actions Configuration

-Action標籤頁:
這裡比較重要的是設定
  • context label (設定選單名稱)
  • Icon 可設可不設, 若沒有設定的話會用gtk-execute當預設的icon
  • Tooltip 設定提示說明

-Command標籤頁:
  • Path: 設定執行檔路徑
  • Parameters: 設定執行檔參數
  • Working directory: 設定工作目錄 
需要把結果輸出的時候,卻因為在command path不能這樣寫md5sum .. | zenity ....
所以只好用變通的方式,透過bash -c 來執行指令
  • Path: bash
  • Parameters: -c "md5sum %F | zenity --text-info --title='MD5 digest for selected files' --width=640"


-Basenmae標籤頁:
設定匹配的檔名
  • *.* 匹配 abc.def
  • * 匹配 abc(沒有副檔名)

-Mimetype標籤頁:
設定匹配的檔案MIME類型
  • */* for all MIME types
  • image/* 匹配所有圖檔

-Folder標籤頁
設定執行的目錄
  • * for any directory

-Schemes標籤頁
  • file 套用在檔案上
  • folder 套用在目錄上

-Capabilities標籤頁
設定匹配檔案的權限

-Enviroment標籤頁
這邊最重要的是設定是設定count,當選取的item數目到達指定的條件的時候就會出現選單

-Properties標籤頁
這邊可以設定Enable/Disable Action

Reference:

用curl下載Wupload/Fileserve/Filesonic付費帳號

這三個檔案空間的付費帳號下載方式大同小異, 只差在一開始的login form & login url而已
使用curl下載的重點則在於:

  • --cookie-jar 將登入的cookie保存到硬碟
  • --cookie 將登入cookie資訊回傳給serve
  • -L 重導下載網址
  • -O 看看就好, curl的remote-name 用的是未重導的網址, 猜猜樂時間?




Form field
Value
Filesonic
http://www.filesonic.tw/user/login(*)
email 登入email
password 登入密碼
redirect %2F
Wupload
http://www.wupload.com/account/login
email 登入email
password 登入密碼
redirect %2F
rememberMe 1
Fileserve
http://www.fileserve.com/login.php
loginUserName 登入帳號
loginUserPassword 登入密碼
autoLogin on
recaptcha_response_field

recaptcha_challenge_field

recaptcha_challenge_field

loginFormSubmit Login

* 一般的登入網址是http://www.filesonic.com/user/login
filesonic會依據IP 的地區作重導, 在這裡遇到了一個curl的小問題
使用-L/--location選項時:


-L/--location
...........前略..................
              When  curl follows a redirect and the request is not a plain GET (for example POST or PUT), it
              will do the following request with a GET if the HTTP response was 301, 302,  or  303.  If  the
              response  code  was any other 3xx code, curl will re-send the following request using the same
              unmodified method.
response code in (301, 302, 303)就只會用GET重發request, 就變成沒有登入....,只好把位址改成.tw了


Tellico

我之前寫了一個Python script可以抓出Getchu當月的動畫/遊戲清單,
清單的格式是XML,我遇到的問題不在於XML的建構怎麼寫,
而是有沒有好用的XML資料檢視程式?

可以透過簡單的定義就可以有一個圖形化的檢視程式。

Tellico is a KDE application for organizing your collections.
在Tellico中:
  • collection是資料樣板,類似於OOP中的class
  • entry是資料,類似於OOP中的instance



先定義collection fields







entry圖形化編輯視窗就出現了








產生的tellico.xml如下


有幾個要注意的地方:

  • Tellico會在每個collection fields中自動加入cdate, mdate這兩個element,在collection fields中看不到,也不能刪除,所以用script產生XML要記得每個entry都要包含cdate, mdate這兩個element
  • field type = image的話會在collection加入subelement <images>
  • 修改已經存在的collection會有個小問題, 如果之前的圖片都是以連結的方式儲存,那修改collection後可能會把圖片從外部
    包裹進*.tc檔案裡,這個要看Tellico的設定



*.tc檔案格式:
  • 是一個ZIP壓縮的檔案
  • 裡面會有一個tellico.xml的檔案
  • 如果圖片是選擇Store images in date file的話,會多個images目錄


目前看起來都還不錯,不過缺點是:

  • 遇到大量資料可能就不行了= =|||(沒辦法底層是XML)
  • 只能在Linux下跑


Reference:



[Python] 改變預設編碼

改變預設編碼
Win32
C:\Python27\Lib\site-packages\sitecustomize.py
Linux Mint 11
/etc/python2.7/sitecustomize.py 
import sys
sys.setdefaultencoding('utf-8') 
 

Reference:

從XP到7

昨天終於把用了多年了XP丟到硬碟角落裡變成救急用的系統了。

停用服務或功能:
  • Superfetch(有了SSD還需要嗎?)
  • Windows Defender
  • Windows Search
  • Windows Live ID Sign-in Assistant
  • Windows Backup
  • Windows Presentation Foundation Font Cache 3.0.0.0
  • Theme
  • Easeus Agent(做完備份就可以調整為手動了,可以省下約20MB左右的記憶體)
  • 硬碟重整
  • 系統還原
  • UAC(只有我在用,亂搞也還有備份系統跟備份檔案,關了省心啊)

Firefox userChrome.css(改Menubar字型與大小,要不然真的很小很難看)
/*
 * Do not remove the @namespace line -- it's required for correct functioning
 */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */


*{font-size: 12pt !important}
*{font-family:"メイリオ", "メイリオ", "メイリオ";} 
其他參閱:

自動登入參閱:

自動撥接參閱:

關閉休眠功能(桌機用不到休眠,可以省下等同於記憶體大小的空間):

  1. 建立高效率的電源計畫
  2. 關閉休眠功能 powercfg -h OFF



重新調整分頁檔大小: 4G太多了,1G就很夠用了

接著把可攜版的程式加入右鍵選單就搞定了

一次抓取多個分頁面

看小說時遇到個問題,很多都是依照章節分頁,看的時候用Autopager很方便就可以自動載入下一頁的內容。不過遇到要存檔的時候,常常只有存到第一頁的內容。

找到可以用Re-pagination解決這問題,一次就可以把全部章節都存成單一的網頁檔案。
不過這種解決方法也不是每個網站都能適用,小說網站ok
但是像夜蝴蝶館就沒用了。




Reference:

BT代抓

網路上看到介紹主要是這兩種:

Fetch.io免費帳號不提供BT代抓,付費帳號的空間跟頻寬如下(單位: USD/month)


4.95/m9.95/m19.95/m
Storage10G50G100G
Bandwith20G100G200


付費帳號的頻寬這個月沒用完可以累計到次月,算是好事,不過空間還是一樣大啊。
不曉得這個付費帳號抓的速度有沒有比torrific穩定?


Torrific目前在alpha測試階段,而在使用上比較麻煩的是:
  • 沒有上傳torrent檔案的選項,變成要找空間來放torrent檔案
  • 已經排入序列的torrent有時候會莫名其妙的被標示成"removed"
    要自己手動再把torrent加入序列中
  • 同時下載數目還是個謎啊? 有些torrent已經掛了兩三天了剩餘時間還是40小時?
    同一檔案用utorrent測試,是有seeder而且數量還不只一個,所以???????
  • 官網上對於使用上的限制沒有詳細說明,只好大家來玩猜一猜!!!

熱門檔案瞬間完檔真是最大的賣點啊,偏偏我找來測試檔案的好像都不熱門@@!

The Dark Side of NTFS

我真的很喜歡這種標題~XD~,扯遠了。

抓回來的一堆ACG檔案,有些額外的資料想要跟檔案『綁』在一起。
之前用XML檔案的方式,遇到改檔名就破功。所以,才想到要把資料塞到Filesystem裡面。

在NTFS裡面有兩種儲存metadata的方式:
  1. COM Structured Storage
  2. ADS(Alternate Data Streams)
下面有幾篇文章介紹ADS:
ADS commandline tools
上面是用notepad檢視ADS內容,更簡單的檢視方式是用:
more < filename:stream

目前看來ADS有趣的多(?)。ADS新增很容易,也很好修改,不過刪除有點麻煩。
'Create File
echo Hello World! > 1.txt

'Add data stream 
echo http://www.google.com.tw > 1.txt:URL

'Edit data stream
echo http://tw.yahoo.com > 1.txt:URL

'Delete data stream
more < 1.txt > 1.txt.new
del 1.txt
ren 1.txt.new 1.txt



10 Things to know about ADS
  1. There is no limit on the size of streams and there can be more than one stream linked to a normal file. ADS are not visible in explorer or via command prompt. In fact, their size is also not reported by Windows!
  2. Streams can be attached not only to files but also to folders and drives!
  3. The content of an ADS should not be considered limited to simply text data. Any stream of binary information can constitute a file which includes executables, Mpeg files, Jpeg files etc.
  4. ADS have no attributes of their own. The access rights assigned to the default unnamed stream are the rights that control any operation on ADSs such as creation, deletion or modification. This means if a user cannot write to a file, that user cannot add an ADS to that file. A user with guest privileges can also create such streams in every file where he has write access.
  5. Some Browser helper Objects (BHOs) have started storing their malicious files inside ADS and very few anti-spyware/malware actually detect it.
  6. Windows File Protection prevents the replacement of protected system files; it does not prevent a user with the appropriate permissions from adding ADS to those system files. The System File Checker (sfc.exe) will verify that protected
    system files have not been overwritten, but will not detect ADS.
  7. Microsoft Windows provides no tools or utilities either within the operating system software distribution or the Resource Kits for detecting the presence of ADS.
  8. The stream can only be executed if called directly by a program with the full path to the file given. It is impossible to accidentally execute a stream.
  9. None of the Internet protocols enabling file transfer such as SMTP, FTP etc. support streams. This means that ADS can't be sent via Internet. However, files containing ADS can be sent across a local LAN provided the target drive is in the NTFS format.
  10. In certain cases, streams have been used to remotely exploit a web server. Some web servers are susceptible to having their file source read via the: $DATA stream. If a server side script such as PHP or ASP is running on a web server which is not patched properly, instead of getting output as a result of processing the script, the source code of the ASP/PHP file could be viewed by using a URL like this:

    http://www.abcd.com/index.asp::$DATA

    This is a critical vulnerability as the server-side source code could reveal sensitive information including how the site has been coded and how the information is flowing. This information could be used by the attacker to launch a specific attack on the server. 

銷售量大增,但毛利率是多少? 營利率又是多少? 淨利率又是多少?

馬總統表示,政府協助漁民發展養殖、近海、遠洋漁業,希望永續發展,「以台灣為主,對漁民有利」。
他舉石斑魚為例,他上任前外銷量僅一百多公噸,金額兩千七百多萬元,去年則成長到廿四億元,成長達八十七倍。目前石斑魚養殖面積已超過兩千公頃,漁業署準備在兩年內將石斑魚產值翻倍,達到七十六億元,漁業絕對有很多發展機會。
重點是漁民賺到多少錢?

Reference:

[Python] 全角 → 半角

之前在抓Kattachi網站的漫畫資料的時候遇到個問題,他的文字大半都是全角文字。
對於之後的搜尋上面有點麻煩,本來想找全角→半角的module來處理。
不過,現在有內建的unicodedata可以處理這個問題。

print unicodedata.normalize("NFKC", u"iPod")

Reference:

[Python] Using mediainfo.dll to get file's metadata

程式碼參考了MediaInfo.DLL壓縮檔案內的MediaInfoDLL.py。
MediaInfoDLL.py已經把mediainfo.dll包好了,不過我只需要取得全部的資訊,class有太多東西都用不到,所以就自己寫了一個簡易版本的。

from ctypes import *

_mlib = windll.LoadLibrary("mediainfo.dll")

def getAllInform(filename):
    handle = c_void_p(_mlib.MediaInfo_New())
    _mlib.MediaInfo_Open(handle, c_wchar_p(filename))
    info = c_wchar_p(_mlib.MediaInfo_Inform(handle, c_size_t(0)))    
    return info.value

Reference:

Zotero Standalone

今天才看到有standalone版。稍微測試了一下:

  1. 消耗的記憶體不算少,空白資料庫要70MB+ (XULRunner 貢獻不少啊~)
  2. 速度比Firefox addon版快上不少
哪天才有stable release,Evernote免費版的限制不少。

Reference:

Everything SDK

在實驗Everything ETP的時候竟然發現,ETP Server當了= =|||。
好吧,我只是同時送了4個query過去,就當了>"<。找替代方案。

替代方案就是Everything SDK。
稍微測試一下,速度快很多。SDK是用IPC的方式跟Everything主程式溝通。所以Everything一定要開著,這點ETP也是一樣。

程式碼是參考(原创)在gvim中实现基于Everything SDK的极速搜索,稍作修改變成傳回list
from ctypes import *

def query(term):
    SE = windll.LoadLibrary("./SDK/everything.dll")

    strBuff=create_unicode_buffer(1024)
    SE.Everything_SetSearchW(c_wchar_p(term))

    try:
        SE.Everything_QueryW()
    except:
        SE.Everything_QueryW(0)

    results = []
    rcount = SE.Everything_GetNumResults()

    if rcount == 0:
        return results

    for x in range(0, rcount):
        SE.Everything_GetResultFullPathNameW(x, byref(strBuff), len(strBuff))
        results.append(strBuff.value)
    del strBuff, SE
    return results

Reference:

Baker - 簡化命令列選項的coding

以前要在script上增加命令列選項不外乎用optparse,或者是用新的argparse
Baker比上面那兩個更簡單。只需要:
  1. 在function的前面加一行@baker.command,該function就會成為command
  2. 在if __name__ == "__main__"區塊中加入baker.run()
Example:
import baker
# Add command
@baker.command
def foo():
    "foo is test command"


# Add parameter help
@baker.command(params={"force": "Delete even if the file exists"})
def delete(filename, force=False):
    "Delete a file."

@baker.command
def delete2(filename, force=False):
    """Deletes a file.
    :param force: Delete even if the file exists.
    """
    pass


# Short options
@baker.command(shortopts={"verbose": "v"}, params={"verbose": "Spew lots"})
def test(verbose=False):
    "test command"

#Run script
if __name__ == "__main__":
    baker.run()

Output:
python test.py 
Usage: X:\test.py COMMAND <options>

Available commands:

 delete   Delete a file.
 delete2  Deletes a file.
 foo      foo is test command
 test

Use "X:\test.py <command> --help" for individual command help.
python test2.py delete2 --help
Usage: X:\test.py delete2 <filename>

Deletes a file.

Options:

 --force  Delete even if the file exists.

(specifying a single hyphen (-) in the argument list means all
subsequent arguments are treated as bare arguments, not options)

Reference:

Search Everything via ETP

ETP簡單來說就是FTP+延伸指令。所以,外部程式若要利用ETP來搜尋檔案的話,需要基本的FTP支援。

  • 預設port: 5485
  • mode: PASV

Query syntax

QUERY <SP> <offset> <SP> <max> <SP> <match_case> <SP> <match_whole_word> <SP> <match_path> <SP> <search_string> <CRLF>
  • offset is the scroll bar offset (use 0 for all items)
  • max is the maximum number of visible items in the list. (use 0xffffffff for all items)
  • match_case can be non-zero for enabled, zero for disabled.
  • match_wholeword can be non-zero for enabled, zero for disabled.
  • match_path can be non-zero for enabled, zero for disabled.
  • search_string can be any number of parameters. 
Query reply
200 <SP> <offset> <SP> <count> <SP> <numfolders> <SP> <numfiles> <CRLF>
  • offset is the index offset of the first result.
  • count is the number of results that follow
  • numfolders is the total number of folders.
  • numfiles is the total number of files.
"count" results follow:
<full_path_name> <CRLF>
  • full path and file name of folder or file 

Python Example Code
def search(q, maxResult=1000, match_case=False, match_whole_word=False, match_path=True):
    # Query
    cmd = "QUERY 0 %d %d %d %d %s"%(maxResult, match_case, match_whole_word, match_path, q)

    # Query response offset control
    resp = ftp.sendcmd(cmd)
    code, offset, count, numfolders, numfiles = resp.split()

    results = []
    for i in range(int(count)):
        line = ftp.getmultiline().decode("UTF-8")
        results.append(line)

    return int(numfolders), int(numfiles), results


Reference:

Browser web scraping tools

BrowserAddonsNote
IEData Toolbar免費版有100筆資料上限
Google ChromeScraper

Yahoo Japan Web Search API

  1. 免費版有同時存取使用者上限,上限多少倒是沒提到。
  2. 免費版一個Application ID,24小時內不能超過1000個Request
  3. 這兩天測試的結果在台灣時間的晚上比較不容易遇到同時存取使用者上限的問題
Yahoo!検索Web APIについて、2011年3月31日(木)よりサービス内容を以下のように変更いたします。
【対象API】
(ウェブ検索API)
http://developer.yahoo.co.jp/webapi/search/websearch/v2/websearch.html
(画像検索API)
http://developer.yahoo.co.jp/webapi/search/imagesearch/v2/imagesearch.html


【変更内容】
1.同時にアクセス可能なユーザー数に制限を設けます(数セッションを上限とします)。超過した場合にはYahoo! JAPAN Web APIに共通のエラーメッセージおよびコードを返します。
2.24時間中、1つのアプリケーションIDにつき1,000件までのリクエストを上限とします。超過した場合にはYahoo! JAPAN Web APIに共通のエラーメッセージおよびコードを返します。

Reference:

orbitdm.exe (Orbit Downloader)

orbitdm.exe [/i/e/c] url:
  • /i - information
  • /e - HTTP Referer
  • /c - Cookie

Orbit downloader 讓我又愛又怕

優點:
  • 體積小
  • 速度快
  • 耗用記憶體少
缺點:

  • 更新若不注意常常會被改首頁
  • 更新若不注意會裝到不知道是什麼的軟體
  • Downloader怎麼管電腦裡安裝的程式= =?














它的優點符合我心目中理想工具程式的樣貌。不過缺點就讓人怕怕的,更新程式就要很小心不能Next一路點到底。有幾點覺得怪怪的:
  • 怎麼會去檢查電腦中安裝的程式? 
  • orbitdm.exe有命令列選項,不過官網卻說不支援命令列模式? 不希望被其他程式當成工具來使用嗎?

    [Mediawiki] full text search

    list=search (sr) *
      Perform a full text search
    
    This module requires read rights
    Parameters:
      srsearch       - Search for all page titles (or content) that has this value
                       This parameter is required
      srnamespace    - The namespace(s) to enumerate
                       Values (separate with '|'): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 101, 108, 109
                       Maximum number of values 50 (500 for bots)
                       Default: 0
      srwhat         - Search inside the text or titles
                       One value: title, text, nearmatch
      srinfo         - What metadata to return
                       Values (separate with '|'): totalhits, suggestion
                       Default: totalhits|suggestion
      srprop         - What properties to return
                        size             - Adds the size of the page in bytes
                        wordcount        - Adds the word count of the page
                        timestamp        - Adds the timestamp of when the page was last edited
                        score            - Adds the score (if any) from the search engine
                        snippet          - Adds a parsed snippet of the page
                        titlesnippet     - Adds a parsed snippet of the page title
                        redirectsnippet  - Adds a parsed snippet of the redirect
                        redirecttitle    - Adds a parsed snippet of the redirect title
                        sectionsnippet   - Adds a parsed snippet of the matching section
                        sectiontitle     - Adds a parsed snippet of the matching section title
                        hasrelated       - Indicates whether a related search is available
                       Values (separate with '|'): size, wordcount, timestamp, score, snippet, titlesnippet, redirecttitle, redirectsnippet, sectiontitle, sectionsnippet, hasrelated
                       Default: size|wordcount|timestamp|snippet
      srredirects    - Include redirect pages in the search
      sroffset       - Use this value to continue paging (return by query)
                       Default: 0
      srlimit        - How many total pages to return
                       No more than 50 (500 for bots) allowed
                       Default: 10
    Example:
    http://ja.wikipedia.org/w/api.php?action=query&list=search&srprop=score&srsearch=%E3%83%89%E3%83%A9%E3%82%B4%E3%83%B3%E3%83%9C%E3%83%BC%E3%83%AB%E6%94%B9%20%E4%BA%BA%E9%80%A0%E4%BA%BA%E9%96%93%20%E3%82%BB%E3%83%AB%E7%B7%A8%2014%20
    Reference:

    Google Web Search API return 403 ...

    在這篇Why does Google Search return HTTP Error 403? 有說明關於Error 403的原因。

    我就是因為這條吃了403 = =|||
    We received automated requests, such as scraping and prefetching. Automated requests are prohibited; all requests must be made as a result of an end-user action.

    API Key可以重新再登錄申請過就可以了,不過依照上面的限制,Web Search API的實用性就大打折扣了。原因不難理解,畢竟Google是靠廣告吃飯的。

    要用Web Search API做Data mining難了...
    Usually not a problem if you are just providing web users with a search box, but not helpful if you're trying to use Google to go data mining. I guess they don't want you to go data mining using their API.

    另外,要模擬瀏覽器送出搜尋的話只需要在HTTP Request中增加"User-Agent"欄位,把Firefox的user-agent填上去就可以了。不過這種做法,速度沒有Web Search API快。

    Reference:

    Gethcu & Google Reader





    基本上是從Getchu.com抓Game/Anime資料再丟給Google Reader去找出相關的文章。
    接著再把相關條目丟給Google Web Search API搜尋:
    • Wikipeida的相關的條目網址(以en, jp, zh三種語言為主)
    • Moeimouto的相關的tag URL
    Wikipedia跟Moeimouto都有內建搜尋,不過Getchu抓出的資料當中有蠻多無用的詞彙在其中。所以,搜尋的結果不太好,當然無用的詞彙可以自己過濾,不過要花時間去建立對應表,倒不如直接用Google Web Search去充當過濾器比較快。

    另外,我也想過是否要把某些Game/Anime的標題用Google Translate/J-Talk.com將之翻譯成英文或羅馬拼音,近一兩年的Anime/Game都可以用日文標題直接找,某些年代久遠的未必能用日文標題搜尋就可以找出滿意的結果。


    怎麼不全用Google Web Search API做?

    1. Web Search API沒有全文輸出,要找內容還是需要自己去抓網頁資料。
    2. 我的Reader大約有300左右的訂閱,只需要2個HTTP Request就可以搜尋約300個左右的訂閱,是比Web Search來的快。
    3. Reader可以指定傳回搜尋結果的數量。預設是20個。相較之下Web Search是8個,要取得20個搜尋結果, Web Search需要做3次HTTP Request。
    4. Web Search API有查詢限額
    Anime/Game這部分用Google Reader取得的搜尋結果比我測試Manga的結果好多了,上面右邊的圖是搜尋300訂閱的結果,我想如果把Anime/Game相關的訂閱都放在一個folder之下,結果應該會蠻不錯的。但這也很難完全避免SEO所帶來的雜訊。

    Google Web Search API

    在2013/11/1前都還可以用啊,不過還是希望Custom Search API的額度可以拉高一點。

    Note: The Google Web Search API has been officially deprecated as of November 1, 2010. It will continue to work as per our deprecation policy, but the number of requests you may make per day will be limited. Therefore, we encourage you to move to the new Custom Search API.

    Reference:

    Google Reader & Custom Search

    網路上可以找到如何將Google Reader的訂閱匯出成OPML,再導入Custom Search
    建立搜尋。看完後本想用Custom Search API來取代自己寫的Google Reader Client,
    問題是看到下面時就放棄了。Custom Search API一天的限額只有100 queries/day.......
    還是乖乖用自己寫的code吧。

    計費方式:
    However, you will be billed for all additional requests at the rate of 
    $5 per 1000 queries, for up to 10,000 queries per day.


    [Mediawiki API] 取得其他不同語言的網址

    http://en.wikipedia.org/w/api.php?action=query&prop=langlinks&redirects=&format=json&llurl=&lllimit=100&titles={titles}
    • title, 文章標題要用application/x-www-form-urlencoded編碼
    • format=josn|jsonfm|xml|xmlfm(傳回格式,其中...fm代表pretty-print
    • llimit=100(傳回語言連結的數量,最多500)
    • llurl= (傳回語言連結的完整網址)
    Test:

    Google Reader API for Search

    Get SID

    POST https://www.google.com/accounts/ClientLoginResponse
    FORM:
    • service=reader
    • Email={loginEmail}
    • Passwd={loginPassowrd}
    HTTP Resonse:
    • SID=…\n
    • LSID=…\n
    • Auth=…\n

    Get Token for later operations

    GET http://www.google.com/reader/api/0/token
        Add Extra HTTP Header for getting Token and other operations
            1. Cookie: SID={SID from ClientLogin}
            2. Authorization: GoogleLogin auth={Auth from ClientLogin}  

    All {keyword} are encoded in UTF-8 with application/x-www-form-urlencoded format

    Search Reader with <keyword>

    # Get search result item index
    GET  http://www.google.com/reader/api/0/search/items/ids?q={keyword}&num=1000&output=json&ck={timestamp}&client=scroll

    HTTP Response:
    JSON ["results"] -> [{"id":item index}, {"id":item index}, .....]

    # Get search result item content
    POST http://www.google.com /reader/api/0/stream/items/contents?ck={timestamp}&client=scroll
    POST FORM:
    • i=item index
    • it=0
    • T=Token 

    Search Reader with <keywords> <Feed>

    GET /reader/api/0/search/items/ids?q={keyword}&num=1000&s=feed/{feed url}&output=json&ck={timestamp}&client=scroll

    POST /reader/api/0/stream/items/contents?ck={timestamp}&client=scroll


    Search Reader with <keywords> <folder>

    GET http://www.google.com/reader/api/0/search/items/ids?q={keyword}&num=1000&s={folder}&output=json&ck={timestamp}&client=scroll

    POST http://www.google.com /reader/api/0/stream/items/contents?ck={timestamp}&client=scroll


    Feed listing

    GET http://www.google.com/reader/api/0/stream/contents/feed/{feed url}?

    • ot=[unix timestamp] : The time from which you want to retrieve items. Only items that have been crawled by Google Reader after this time will be returned.
    • r=[d|n|o] : Sort order of item results. d or n gives items in descending date order, o in ascending order.
    • xt=[exclude target] : Used to exclude certain items from the feed. For example, using xt=user/-/state/com.google/read will exclude items that the current user has marked as read, or xt=feed/[feedurl] will exclude items from a particular feed (obviously not useful in this request, but xt appears in other listing requests).
    • n=[integer] : The maximum number of results to return.
    • ck=[unix timestamp] : Use the current Unix time here, helps Google with caching.
    • client=[your client] : You can use the default Google client (scroll), but it doesn't seem to make a difference. Google probably uses this field to gather data on who is accessing the API, so I'd advise using your own unique string to identify your software.

    Reference:

    蚊子館與塌塌橋

    難怪有網友在塌陷事故發生後,提議拆了趙州橋——這座坐落在河北省趙縣洨河上、建於隋代大業年間的橋太“招惹是非”了,匠師李春建造後愣是1400餘年不倒,這讓那些塌了再修、修了再塌的路橋情何以堪?一座豆腐渣工程,對GDP的貢獻其實是很大的:修建的時候拉動經濟,回頭天天打補丁,還是拉動就業、提升總量,就算真倒了,哪怕人命關天,也是再建新功的好契機。至於問責呢?誰也別較真,自有痴狂的專家準時跳出來“和稀泥”。這就是公共基建問題不斷、卻又病 程不決的根源。

    與台灣的蚊子館、蚊子工業區異曲同工啊。
    那路平專案呢?

    資料來源:
    錢塘三橋,垮塌的偶然與必然

    SiteShoter 補遺

    如果要每五分鐘對該網站做一次screenshot,
    用Siteshoter /RunConfig "cfgFile" 只做一次screenshot,之後程式就結束了。

    解決方法是:
    siteshoter /LoadConfig "cfgFile" /Start
    這樣就會每隔一段時間做一次screenshot,直到使用者關閉程式為止。

    或者是用命令列下的taskkill
    taskkill /F /IM siteshoter.exe 

    客戶的遊艇在哪裡?

    吳敦義劉憶如 拜託銀行幫幫忙
    行政院長吳敦義和經建會主委劉憶如今天向銀行喊話,「拜託銀行幫幫忙!」一方面希望銀行以服務財富管理客戶的精神,和管理客戶資產的專業,把政府當成財管客戶,集思廣益、提供意見,讓財務艱困的政府,財政健全、走上健康的道路。
    另一方面,也希望銀行協助改善國內的貧富差距問題,劉憶如並建議,銀行承作的財富管理,可透過手續費收入打折等誘因,多開發年收入在110萬元、120萬元左右的基層客戶,讓這些族群的小錢變大錢,而不要只是服務有錢人。
    【2011/07/13 聯合報】@ http://udn.com/

    看完上面的新聞,讓我想到一個故事:
    有一本經典的書叫《顧客的遊艇在哪裡?》(Where Are the Customers' Yachts?),一位住在美國中西部的農人,退休之後到各地去遊覽,有一次參加到紐約觀光的旅行團,由於紐約的華爾街是全世界的金融重鎮,當然也在行程之列,農人對於華爾街能夠有如此繁榮的景象驚異不已,心想這裡一定創造出不少大富翁。果不其然,接著導遊領著他們到紐約長島(Long Island)的碼頭,一一為他們介紹,這是某某銀行家的豪華遊艇,那是某某名股票經紀人的私人遊艇,令農人欽羡不已,但是他突然納悶的問了一句:「那客戶的遊艇停在那裡呢?」。

    資料來源:
    聯合新聞網: 吳敦義劉憶如 拜託銀行幫幫忙
    投資基本法: 股市預測 (十二) 基本分析-騙人的投資專家(經紀佬)