Thursday, September 24, 2009

壞男人怎麼來的…

十歲以前,就不說了,無非是淘氣和不懂事。

十三、四歲的時候,開始對女孩有好感,但是那時候他離女孩遠遠的,並且以討厭女孩自居,生怕被同伴嘲笑。

十五歲的時候,聽到大人們說某某男人好花,把女朋友甩了,女孩自殺了。
他覺得這人真狠毒,自己將來一定要做個痴情的男人,一定要一生只愛一個人。

十六歲的時候,他喜歡上了一個女孩,但是他不敢和她說。
仍然和往常一樣,髒兮兮的 在灰土飛揚的操場上踢球。
只在女孩走出校門的時候,躲在二層的窗戶上看她的背影,他覺得她一定是個天使。

十七歲的時候,有個女孩喜歡上了他,但是他離她很遠,他心里面只有自己愛的那個女孩,他覺得看別的女孩都是對她的不忠。

十八歲的時候,看了一個MTV,感動得想哭,他想,如果自己的女孩失去了雙眼,他一定會像男主角會毫不猶豫的把自己的眼睛給她,讓她能看到光明。

十九歲的時候,高考了。
終於和自己暗戀的女孩分別,坐火車去學校的時候,感覺自己離她越來越遠,心像被掏空了一樣。
還在想自己一定不會忘記她,等到自己成功以后一定要去找她。

二十歲的時候,聽到有人講黃色笑話,覺得這人真可恥。

二十一歲的時候,她的回信中告訴他,自己有了男朋友。
偷偷的哭了一個晚上。

二十二歲的時候,他向一個女孩表白,女孩說「你是個好人,可是我還小。」
他想,我的確是個好人,他說「沒關系,我可以等你。」
心想「我不會像那些花心的人一樣,三年五年我也能等。」

二十三歲的時候,說自己還小的女孩和一個帥哥戀愛了。
他很納悶,長大原來可以這樣快。

二十四歲的時候,他又向一個女孩表白,女孩說「你是個好人,可是我並不適合你。」
他納悶很久,我是好人你怎麼還不適合我呢?

二十五歲的時候,他又追求一個女孩,女孩接受了他。
他開始很幸福的為未來拼搏,他想「一時的開心只是暫時的,只有努力拼搏,他和她才能有快樂的未來。」
但是,半年以后,女孩和他分手了。
只是因為另外一個男孩會說讓她開心的話。
女孩說「你是個好人 ,是我對不起你。」
他似乎明白問題所在,他是個好人。

二十六歲的時候,他開始墮落,交網友。
打扮得時尚而酷,而且漸漸的學習著討好女孩 的話。不
久,他有了個女朋友,雖然他對她也很好,可是,他心里知道,自己並不愛她。

二十七歲的時候,他和女孩分手了。
他對女孩說「你是個好女孩,是我對不起你。」

二十八歲的時候,他嘗試了一夜情,發現別人能做的,自己也一樣。

二十九歲的時候,他學會了講黃色笑話,並且以看旁邊的女孩子臉紅為樂趣。

三十歲的時候,他忽然發現自己變得很有能力追求到女孩,但是卻沒有了愛的能力。


於是他在自己QQ上寫下了如下的話




其實每個男孩,本來都是想做一個感情專一的好男人的。
其實每個男孩,本來看女孩子都是看臉而不是胸部的。
其實每個男孩,本來都是不會講黃色笑話的。
其實每個男孩,本來都是渴望愛一個人直到永遠的。
只是,沒有任何女孩愛這樣的男孩,她們覺得這樣的男孩太幼稚,太古板,沒有情趣。




於是男孩開始改變,變成女孩喜歡的那種。
嘴角掛著壞壞的笑。
玩世不恭或者幽默。
開始學會說甜言蜜語而不是心裡想說的話。
開始學會假裝關心。
學會給女孩送小飾物討好她。
學會如何追求,如何把握愛情。
或者看破紅塵,遊戲情場,成為女人很恨的那種男人。
他們可以很容易俘獲女孩子的心。
但是他們也會在黑的夜裡叼著煙流淚。
心裡有愛的時候,沒有女孩 有了女孩,卻永遠沒有了愛的感覺。
在聽到女人抱怨世上沒有一個好男人的時候,他們不會再去努力做個好男人,只是微笑著擦肩而過。

---------------------------

老文了,但很有感觸。 希望我能達到任意遊走於兩邊的地步吧…

Tuesday, June 30, 2009

Handling CString in C++

Once I had encountered problems when CStrings were declared in a C++ project without MFC. The solution found on the net was to include , but then Visual C++ suggests including instead, which did solve the problem. Just a note.

Thursday, May 07, 2009

單個


curl_setopt($ch, CURLOPT_HTTPHEADER, array("Range: Bytes=0-50\n"));


多個

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Range: Bytes=0-50\nOtherheader: stuff\n"));

Thursday, April 16, 2009

欲在Symphony(PDO使用Propel)下從DB拿多列的資料,目前看到這是唯一可行的方法:



$connection = Propel::getConnection();
$query = 'SELECT MAX(%s) AS max FROM %s'; //写你要查询的sql
$query = sprintf($query, ArticlePeer::CREATED_AT, ArticlePeer::TABLE_NAME);
$statement = $connection->prepare($query);
$statement->execute();
$resultset = $statement->fetchAll(PDO::FETCH_OBJ);

最後一行如果用fetch就是只拿一列,fetchAll就拿所有列。 $resultset是個array,裡面有所有列的資料。

但這是Propel裡的東西,而非Symfony本身的。 Symfony本身的doSelect()只能拿到第一筆的資料,但列的數目又是對的。 我查了好久的文件還是找不到為什麼會這樣。 doSelectstmt()也懶得試了… Symfony真的很鳥啊!

Edit:
用了doSelect

$c = new Criteria();
$c->add(ListsPeer::MAC_ADDRESS, $mac, Criteria::EQUAL);
$stmt = ListsPeer::doSelectStmt($c);
$ids = array();
while($res = $stmt->fetchColumn(1)) {
echo $res;
}

還是可以用的啦… 算了。

Tuesday, April 14, 2009

Using Propel ORM. My step-by-step walkthrough to create a working model:

There are several commands concerning the ORM which ultimately works toward building a Model.

The schema.yml, which represents the schema for a Model, can be either typed by hand, or imported and built directly from a database. To do so, type:


symfony propel:build-schema


Or if there is no corresponding database in the db, you may enter the schema by hand. After doing so, type


symfony propel:build-sql


to convert the schema into SQL commands. The actual SQL commands are stored in the lib.model.schema.sql inside the data/sql/ directory of the project folder. You can actually skip the build-sql step by editting this file directly...

After the build-sql command, you can insert the SQL commands into the db, provided that you have already configured the connection to your db. Use either


symfony configure:database "mysql:host=localhost;dbname=db_name"


or edit your /config/databases.yml and /config/propel.ini

Once the connection to the db server are set, insert the SQL by typing:


symfony propel:insert-sql


This step will remove tables with the same names defined in the SQL in the db. Clearing Symfony cache is recommended after this step:


symfony cc



Then it's finally time to build Model so that we can use the ORM to access db:


symfony propel:build-model


Note: Actually, you MAY build Model directly from schema.yml, but it'd be pretty pointless without making sure your Model has a working db connection, right?

Wednesday, April 01, 2009

為了某個不足為外人道之原因,在下做了這件感覺起來很蹩腳很挫的事… >_< 真的要拿出去討論的話,可能我還得好一陣子的心理建設才敢拿出去曝光… 但如果有幸有哪位前輩高手不幸在blogger看到這篇的話,還不吝留下您的意見; 像是更好的做法… 等等。 小弟感激不盡。m(_ _)m

以下這一段是要達到效果的描述:
一個母網頁頁面,必須將其cookie丟到其所包含之一個iframe裡所指到的一個不同domain的網頁(姑且稱此網頁為子網頁)。 而子網頁必須要能拿到母網頁的cookie來做一些… 見不得人的事兒。 在開啟母網頁同時,即需可看到母網頁下iframe裡的子網頁根據母網頁的cookie所做出的頁面。


為了做這件事,在擦股溝擦了好一會兒後,所做出的解答如下:

母頁面就只是一個html,除了一些讀寫刪cookie的Javascript functions外,還包括兩個iframe:


<iframe id="test1" src ="http://howard.com/cookiecutter.php?cooke_name=cookie_value" width="300px" height="100px" >


cookiecutter.php:



<?php
header("P3P: CP=CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR");
$keys = array_keys($_GET);
header("Set-Cookie: ".$keys[0] ."=" . $_GET[$keys[0]]. "; domain=.howard.com; path=/"); ?>

cookiecutter.php較特別的是那一行header P3P的code。 P3P全名為:「The Platform for Privacy Preferences」。 基本上就是跟網頁瀏覽器說,我知道我現在要做的事不合規定或不安全,但你就讓我做就是了。 然後下一行header set-Cookie就在howard.com上設一個名字和值為cooke_name和cookie_value的cookie。


值得注意的是,如果拿掉P3P那一行,剛剛設的這個cookie在母頁上將拿不到。


如此,雖然是達成了目標,但是不管怎麼看,都應該只能算是很粗糙的解決方案,並不是真正的cookie passing。 小弟在此拋磚引玉,還希望各位先進們指教一下。

Monday, March 30, 2009

A fragment identifier is defined by RFC 3986 as an optional component of a URI reference, and it must conform to a certain syntax. The syntax requires that the fragment identifier be separated from the rest of the URI reference by a # (number sign) character. The separator is not considered part of the fragment identifier.

Basically it looks like http://www.foo.org/foo.html#fragment-identifier.

To use it in Javascript, it is simply "window.location.hash"

This is an imitation of PHP $_GET, in pure Javascript.

From http://www.11tmr.com/11tmr.nsf/D6Plinks/MWHE-695L9Z




function getURLParam(strParamName){
     var strReturn = "";
     var strHref = window.location.href;
     if ( strHref.indexOf("?") > -1 )
    {
         var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
        var aQueryString = strQueryString.split("&");
        for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
                if (
                aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break;
            }
        }
    }
     return unescape(strReturn);
}