總網頁瀏覽量

咕狗大神

顯示具有 自我修煉 標籤的文章。 顯示所有文章
顯示具有 自我修煉 標籤的文章。 顯示所有文章

2012年8月18日 星期六

Regular Expression

摘錄 wikipedia 正規(常規)表示式: http://zh.wikipedia.org/wiki/Regular_Expression

最近剛好要用到文字的 parsing ,所以複習一下,也順便作個筆記,以免再度失憶。

幾個比較常用的如下:


符號 意義 範例
. 任意字元 regex =@"^thank."; regex.match("thank u"); regex.match("thankx");
? 出現零次或一次 regex =@"^thankx?"; regex.match("thank u"); regex.match("thankx");
* 重複出現任意次數(含不出現) regex =@"^thankx*"; regex.match("thank u"); regex.match("thankxxxxxx");
+ 至少重複出現一次 regex =@"^thankx+"; regex.match("thankx"); regex.match("thankx");
{n} 必須重複出現n次 regex =@"^thankx{3}"; regex.match("thankxxx");
{n,} 至少重複出現n次 regex =@"^thankx{3,}"; regex.match("thankxxx"); regex.match("thankxxxxxx");
{n,m} 至少重複出現n次,但不超過m次 regex =@"^thankx{3, 5}"; regex.match("thankxxx"); regex.match("thankxxxxx");
[^...] 中括弧裡面的字元以外 regex =@"^th[^iou]nk"; regex.match("thank"); regex.match("thenk");
其他的有用到再寫。

2012年4月19日 星期四

qt 4.8.1 播放 mp4

以下是我一個很佩服的高手 leo 的步驟, po 出來跟大家分享:

1. Download "qt-everywhere-opensource-src-4.8.1.zip" from official website.
2. Unzip it and then enter the installation location, e.g. C:\Qt\4.8.1
3. Type "configure -opensource -debug-and-release", "nmake"

PS. What if there's a error happened in this file, "DefaultLocalizationStrategy.cpp",
   just go to the error line (line 327) and fix it by modifying the capital character error from " to \".
   (This error will just happen in a XP system.)

4. Add this value inside the user variable of environment variables, QTDIR, which its value is "C:\Qt\4.8.1",
  and then append this value into system variable, Path, value is "C:\Qt\4.8.1\bin".
5. Download "qt-mobility-opensource-src-1.2.0.zip" from official website.
6. Unzip it and then enter the installation location, e.g. C:\QtMobility\qt-mobility-opensource-src-1.2.0
7. Type "configure -prefix C:\QtMobility -modules sensors" and then "nmake", "nmake install"
8. Type "configure -prefix C:\QtMobility -modules multimedia" and then "nmake", "nmake install"
9. Copy the files "QtMultimediaKit1.dll" and "QtSensors1.dll" just were made by step 7 & 8,
  into this location "C:\Qt\4.8.1\qt-everywhere-opensource-src-4.8.1\demos\browser\release".
10. run browser.exe and throw a html file containing <video> tag of html5 to it. It should play it successfully,
   by the way, you should be able to see a play/pause button, the seeking bar and audio volume control button, that is
   because your qtwebkit can recognize the video tag finanlly.
11. What if it can't be played, maybe your pc hasn't been installed the correct codec well,
   check your pc whether your pc has been installed the correct codec or not, maybe you can
   go the website "http://www.free-codecs.com/" to download a suitable codec for directshow to play.

2012年4月3日 星期二

QT 4.8.1 出來了

等了很久,Qt 4.8.1 總算出來了,第一個要測試的,就是到底有沒有把 audio 跟 video 給改回來。

結果...無言

2012年3月30日 星期五

OSX 4.3.1 + cmake 2.8.7 + Lion

xcode-select -switch /Applications/Xcode.app/Contents/Developer 


cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++


cmake -DCMAKE_OSX_SYSROOT:PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/ 


CMAKE_OSX_ARCHITECTURES = x86_64


ps. Lion 只有支援 64 位元程式碼,所以如果加上 i386 就會錯誤,謹記謹記

2012年1月11日 星期三

在 Mac 上build Qt

./configure -sdk /Developer/SDKs/MacOSX10.6.sdk -opensource -universal

2011年11月24日 星期四

Sigil 0.3.4.3 釋出了

從前幾天知道 0.3.4.2 有蟲以後,就開始惶惶不知終日,每天只想趕快抓蟲,其他事情都沒什麼心思。蟲是很快就發現了,問題是要想個方法,把蟲抓掉又不會影響到 0.3.4.2 的功能,這可真是頭痛。

昨天實在是沒招了,狠下心來決定對 HTMLTidy 這一大包進行拆解。不過這種東西拆完可能已經明年了,所以只好用絕招了,就是猜想他的架構,然後賭賭看我猜的對不對。

運氣不錯猜中了,所以我就把 audio, video 都加入了,這下子這兩個標籤就不會被洗掉了。測試完沒什麼問題,就打包囉~

這次也順便開放一個新功能,就是當儲存為 EPUB 3.0 格式,會跳出詢問框問你要不要檢視套裝文件內容,如果選擇要,就會出現編輯視窗,裡面有 package document 的內容可以修改。

以上~接下來可能要忙好一陣子的工作了,Sigil 暫時不會做功能新增。

2011年11月23日 星期三

你知道 Sigil 要增加一個標籤有多困難?


後記:2011-12-12
---------------------------
試了很久才發現,必須對 tidy-html 作修改,不然無法產生 xhtml1.1 以及 xhtml5 的 DOCTYPE

但是這個問題解決了,卻跑出一個 multi-thread 的 memory leak
繼續努力中







後記:2011-12-08
---------------------------
找到 W3C 後續發展的 HTML5-tidy ,正在試著裝上去
希望成功,那就徹底解決這個問題了


---------------------------
先寫步驟吧,以 audio 做例子:

1. tags.h
#define nodeIsAUDIO( node )      TagIsId( node, TidyTag_AUDIO )

2. tags.c
#define VERS_ELEM_AUDIO      (xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10)

static const Dict tag_defs[] =
{ /**增加下面這行 */
    { TidyTag_AUDIO,      "audio",      VERS_ELEM_AUDIO,      &TY_(W3CAttrsFor_AUDIO)[0],      (CM_BLOCK|CM_EMPTY),                           TY_(ParseEmpty),    NULL           },

3. tidynum.h
enum { /** 增加下面這行 */
    TidyTag_AUDIO,    /**< AUDIO */
} TidyTagId;


4. attrdict.h
extern const AttrVersion TY_(W3CAttrsFor_AUDIO)[];

5. attrdict.c

const AttrVersion TY_(W3CAttrsFor_AUDIO)[] =
{
  { TidyAttr_ACCESSKEY,      xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_AUTOPLAY,       xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10 },
  { TidyAttr_CLASS,          xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10 },
  { TidyAttr_CONTROLS,       xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10 },
  { TidyAttr_DIR,            xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|xxxx|xxxx },
  { TidyAttr_ID,             xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10 },
  { TidyAttr_LANG,           xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|xxxx|xxxx },
  { TidyAttr_LOOP,           xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10 },
  { TidyAttr_OnCLICK,        xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_OnDBLCLICK,     xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_OnKEYDOWN,      xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_OnKEYPRESS,     xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_OnKEYUP,        xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_OnMOUSEDOWN,    xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_OnMOUSEMOVE,    xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_OnMOUSEOUT,     xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_OnMOUSEOVER,    xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_OnMOUSEUP,      xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_PRELOAD,        xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10 },
  { TidyAttr_SDAPREF,        HT20|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx },
  { TidyAttr_SRC,            HT20|HT32|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10 },
  { TidyAttr_STYLE,          xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_TABINDEX,       xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|xxxx },
  { TidyAttr_TITLE,          xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10 },
  { TidyAttr_XML_LANG,       xxxx|xxxx|xxxx|xxxx|X10T|xxxx|xxxx|X10F|xxxx|xxxx|X10S|XH11|XB10 },
  { TidyAttr_XMLNS,          xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|XH11|XB10 },
  { TidyAttr_UNKNOWN,        0                                                                },
};

6. 凡是沒有定義過的 attributes ,一律回到 tidynum.h 去增加
TidyAttr_PRELOAD,           /**< PRELOAD= */

大概就這樣~有夠麻煩

2011年11月22日 星期二

Sigil 0.3.4.2 有蟲

今天跑去逛電子書跑去逛電子書研究基地,發現不少人下載了 Sigil 0.3.4.2 來試驗,而且很多人反應有蟲,只要切章節就會當掉,這可真是嚇死人了,因為本來好好的被我改壞了~真是遜啊!

第一個反應就是因為我拿掉稽核的程式碼,由於原作者把稽核的程式碼包裝得很緊密,所以不只是稽核,還會順便洗標籤、縮排等,這部份我目前幾乎沒辦法拆解,所以之前釋出版本時,就直接把整包給取消掉,現在出問題,應該就表示某些補標籤、補內容的部份也包在這包裡面,真是好大一包喔~

所以唯一的辦法,就是把切章節的部份,加回那一大包,當然這也表示,如果原本的內容使用了 HTML5 專有的標籤,如: audio, video 等,那麼這些標籤會被洗掉。

我在這裡必須聲明,這並不是原作者功力不好,如果現在的時代還是 HTML4 + CSS 2.0 + EPUB 2.0.1,那麼我也會用這種一大包的方式,因為完全沒理由要把這包拆開。

也許有人會說,預留彈性不是很好嗎?說真的,寫了十幾年的程式,預留彈性往往等同於過度設計,幾乎不會用到那個彈性啦~

所以呢?未來有很長一段路要走,因為我必須把接近七八成的程式碼置換,同時必須調整整個架構,這真是龐大的工程。另外,這個編輯器有他的限制,所以不管怎麼努力,其實都會碰到頂,再也上不去。

但是這可是我自己選擇的,我只能堅持往前走囉~

2011年11月18日 星期五

Sigil 0.3.4.2 釋出了

經過了好一陣子的 trace code 以及新增功能, Sigil-0.3.4.2 終於可以釋出了。我把它放到 Source Forge ,網址: http://sourceforge.net/p/sigil4epub3

說真的,釋出這個版本其實非常陽春,號稱支援 epub 3.0 也僅止於 OCF 3.0 以及部份的 Publications 3.0 ,所以我想應該會有一堆人咒罵吧~

比較有用的大概是繁體中文的語言包,這次不像上次硬改掉 source code,而是採用 i18n 的作法,算是比較像樣的部分。

以後就靠我自己了,我希望強迫自己,每個月可以多一點功能,或者改善一些 bug,當然最好的狀況是有人願意一起討論與開發,但這只能隨緣了。

2011年9月18日 星期日

書籍清單

資訊相關書籍

已經看完
  • Effective C - Meyers
  • Effective C++ - Meyers
  • More Effective C++ - Meyers
  • The C++ Programming Language - Stroustrup
  • Extreme Programming Explained: Embrace Change - Kent Beck <極限編程>
  • Refactoring: Improving the Design of Existing Code - Kent Beck <重構>
  • The Mythical Man Month: Essays on Software Engineering <人月神話>
  • Design Patterns: Elements of Reusable Object-Oriented Software - Gang of Four <設計模式>
  • Apprenticeship Patterns: Guidance for the Aspiring Software Craftsman - Dave & Ade <學徒模式>
  • Enterprise JavaBeans 3.0 - Richard Monson-Haefel
  • UML Distilled 3th Edition - Fowler
還沒看完
  • Effective STL - Meyers
  • Refactoring to Patterns - Kerievsky
  • Advanced Qt Programming: Creating Great Software with C++ and Qt 4 (Hardcover) - Mark Summerfield
  • Analysis Patterns - Fowler
打算要看
  • Code Complete - Steve McConnell <軟體建構之道>
  • JQuery Cookbook - Cody Lindley


中醫相關書籍

已經看完
  • 圓運動的古中醫學(上) - 彭子益
  • 傷寒論新義 - 余無言
  • 傷寒發微 - 曹穎甫
  • 金匱發微 - 曹穎甫
  • 胡希恕越辨越明釋傷寒 - 胡希恕
  • 金匱要略新義淺注 - 陳修園
  • 經方實驗錄 - 曹穎甫
  • 自己開藥方(上)(下) - 張步桃
  • 人體陽氣與疾病 - 李可
  • 胡希恕讀傷寒雜病論 - 胡希恕
還沒看完
  • 圓運動的古中醫學(下) - 彭子益
  • 鄭欽安醫學三書 - 鄭欽安
  • 血證論 - 唐容川
  • 李可老中醫急難重症疑難病經驗專輯 - 李可
  • 傷寒卒病論台灣本 - 陳淼和
打算要看
  • 醫林改錯 - 王清任