目前日期文章:200806 (14)

瀏覽方式: 標題列表 簡短摘要
Static: 所有由同一個 class 所產生的 objects 共用同一記憶體位置
Single-Colon (:): 用來初始化 class 中被宣告為 const 的 data members

wenching520 發表在 痞客邦 留言(0) 人氣()

http://dev.mysql.com/doc/refman/5.0/en/blob.html

10.4.3. The BLOB and TEXT Types
A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold.

BLOB columns are treated as binary strings (byte strings). TEXT columns are treated as non-binary strings (character strings). BLOB columns have no character set, and sorting and comparison are based on the numeric values of the bytes in column values. TEXT columns have a character set, and values are sorted and compared based on the collation of the character set.

http://www.icewalkers.com/Perl/5.8.0/lib/DBI/FAQ.html#5.2%20How%20do%20I%20handle%20BLOB%20data%20with%20DBI%3f 

5.2 How do I handle BLOB data with DBI?
XX

wenching520 發表在 痞客邦 留言(0) 人氣()

Problems occurred after upgrading from 7.10 to 8.04

Q: locate: can not open '/var/lib/mlocate/mlocate.db': No such file or directory
A: sudo updatedb [https://bugs.launchpad.net/ubuntu/+source/mlocate/+bug/204357]

Q: Using perl script to connect mysql: Can't connect to MySQL server on 'mysql_server_ip' (111) at DBI.pl line X
A: comment out ''bind-address = 127.0.0.1'' in /etc/mysql/my.cnf [https://bugs.launchpad.net/ubuntu/+source/mysql-admin/+bug/155274], and then /etc/init.d/mysql restart (restart mysql)

wenching520 發表在 痞客邦 留言(0) 人氣()

E.g.,
By using repeat operator 'x', you could initialize multiple variables at one time.

my ( $iX, $iY, $iZ ) = (1) x 3;

my ($sX, $sY, $sZ ) = (undef) x 3; or
my ($sX, $sY, $sZ ) = "test" x 3;

wenching520 發表在 痞客邦 留言(0) 人氣()

http://www.itworld.com/nl/perl/09202001/

Repeating Yourself: The X Operator
Andrew Johnson

The x operator can return repeated lists if used in list context and if the left operand is a literal list (i.e., wrapped in parentheses):

my @array = (1,2,3) x 2;
print "@array" # prints: 1 2 3 1 2 3

You need to be careful to put the left operand in parentheses for list repetition --- using a plain array will not behave as desired:

my @array = (1,12,42);
@array = @array x 2; print "@array\n"; # prints: 33

In this case, because the left operand is not in parentheses it is evaluated as a scalar, and an array in scalar context returns the number of elements in the array --- in this case 3 --- thus the x operator has returned the string '3' repeated twice.

Is this operator practical? Consider a case where you want to define a ten-element array and initialize each element to 1:

my @array = (1) x 10; # my @array = (1,1,1,1,1,1,1,1,1,1);

Another useful case is initializing a hash when we've read in (or otherwise obtained) a list of keys we wish to initialize to 1:

my @keys = qw(a b c d);
my %hash; @hash{@keys} = (1) x @keys;

Lastly, a minor cautionary note --- remember that 'x' is not the multiplication operator:

my $value = 15 x 2 / 3;
print "$value\n"; # prints: 505

Here the number 15 is treated as a string and repeated twice to get 1515 which is then treated as a number and divided by 3 to get 505 (rather than the result of 10 you might have wanted). This is one case where Perl's natural conversion between numbers and strings without warning can mean that a simple typo ('x' instead of '*') can lead to strange results and is difficult to track down. So, if you have calculations in your code and you are getting bizarre results you might want to check for this particular typo.

wenching520 發表在 痞客邦 留言(0) 人氣()

話說,兩個星期前搭公車要去陽明上課時,
看到 BeeTV? 介紹 '鮮芋仙' 的 鮮芋仙招牌(仙草凍+仙草沙+芋圓+鮮奶油)。
想說只吃過 黑糖沙 的冰還沒有試過 仙草沙。
吃完後卻懷念起水龜伯 "大碗又實在" 的八寶冰。
一直拖到昨天才又去體驗了水龜伯的冰,
且還是新推出的 "雙仙鬧奶"。

 

真是 '料好實在又大碗",

且這碗冰是 "黑郎君 (仙草) + 白郎君 (杏仁) + 仙草沙 + 兩種芋圓 (一種只有紅白的大粉圓,一種是其他多種顏色且較 Q 的芋圓)"
最好玩的是 "鬧" 這個字,
不知道,各位客官有沒有在小時候吃過一種汽水糖,他遇到口水會 "滋滋叫",好像在口中跳舞的那種,
這碗冰最後上桌前就是灑上那種糖粉。(圖片中右下角杏仁豆腐上面黃黃的顆粒)

而我這個貪吃鬼來水龜伯也是必吃他們的 "黑糖燒麻糬" 一份兩粒,


黑糖麻糬在鍋內煮的樣子,最後要上桌前再伴一下花生粉與黑芝麻。


這是店裡的產品與價格。


店裡有很多古早味的東西 ~


但來這裡吃東西要有心理準備

幾乎每次都嘛大排長龍 ~

而且,最近他們好像除了賣冰以外,還賣熱食囉 ~

其實,就是就是將煮好的小火鍋放到一個小甕中啦

wenching520 發表在 痞客邦 留言(0) 人氣()

1.$sCmd = ~YOUR_COMMANDS~ . " >/dev/null 2>&1 & echo \$!";

Here, '>/dev/null 2>&1' means whatever stdout or stderr are piped into /dev/null.

Reference: http://blog.daviesliu.net/2005/08/31/200811/
Linux Shell 環境中支持輸入輸出重定向,用符號<和>來表示。0、1和2分別表示標準輸入、標準輸出和標準錯誤信息輸出。
同時,還可以在這三個標準輸入輸出之間實現重定向,比如將錯誤信息重定向到標準輸出,可以用 2>&1來實現。
Linux下還有一個特殊的文件/dev/null,它就像一個無底洞,所有重定向到它的信息都會消失得無影無蹤。
如果想要正常輸出和錯誤信息都不顯示,則要把標準輸出和標準錯誤都重定向到/dev/null, 例如:
# ls >/dev/null 2>&1
注意:此處的順序不能更改,否則達不到想要的效果,此時先將標準輸出重定向到 /dev/null,然後將標準錯誤重定向到標準輸出,由於標準輸出已經重定向到了/dev/null,因此標準錯誤也會重定向到/dev/null,於是一切靜悄悄:-)

2.exec( $sCmd );

3.echo "<meta http-equiv=\"refresh\" content=\"~DELAY_in_SEC~;url=~Redirect_Location~\">";

wenching520 發表在 痞客邦 留言(0) 人氣()

Reference: http://mamchenkov.net/wordpress/2005/07/06/analysis-of-two-perl-lines/

Usage:
test_statement ? true_event : false_event

wenching520 發表在 痞客邦 留言(1) 人氣()

Source: http://www.bioperl.org/wiki/HOWTO:SearchIO
use strict;
use Bio::SearchIO;
my $usage = "Bio_SearchIO_blast.pl infile\n";
my $sInFile = shift or die $usage;
my $in = new Bio::SearchIO(-format => 'blast', -file   => $sInFile);

while( my $result = $in->next_result ) {
        print "result_algorithm: " . $result->algorithm() . " \n";
        print "result_algorithm_version: " . $result->algorithm_version() . " \n";
        print "result_query_name: " . $result->query_name() . " \n";
        print "result_query_accession: " . $result->query_accession() . " \n";
        print "result_query_length: " . $result->query_length() . " \n";
        print "result_query_description: " . $result->query_description() . " \n";
        print "result_database_name: " . $result->database_name() . " \n";
        print "result_database_letters: " . $result->database_letters() . " \n";
        print "result_database_entries: " . $result->database_entries() . " \n";
        print "result_available_statistics: " . $result->available_statistics() . " \n";
        print "result_available_parameters: " . $result->available_parameters() . " \n";
        print "result_num_hits: " . $result->num_hits() . " \n";

        while( my $hit = $result->next_hit ) {
                print "\n";
                print "hit_name: " . $hit->name() . " \n";
                print "hit_Length of the Hit sequence: " . $hit->length() . " \n";
                print "hit_accession: " . $hit->accession() . " \n";
                print "hit_hit description: " . $hit->description() . " \n";
                print "hit_algorithm: " . $hit->algorithm() . " \n";
                print "hit_hit raw score: " . $hit->raw_score() . " \n";
                print "hit_hit significance: " . $hit->significance() . " \n";
                print "hit_hit bits: " . $hit->bits() . " \n";
                print "hit_number of HSPs in hit: " . $hit->num_hsps() . " \n";
                print "hit_locus name: " . $hit->locus() . " \n";

                while( my $hsp = $hit->next_hsp ) {
                        print "\n";
                        print "hsp_algorithm: " . $hsp->algorithm() . " \n";
                        print "hsp_evalue: " . $hsp->evalue() . " \n";
                        print "hsp_alias for evalue(): " . $hsp->expect() . " \n";
                        print "hsp_frac_identical: " . $hsp->frac_identical() . " \n";
                        print "hsp_frac_conserved: " . $hsp->frac_conserved() . " \n";
                        print "hsp_number of gaps: " . $hsp->gaps() . " \n";
                        print "hsp_query string from alignment: " . $hsp->query_string() . " \n";
                        print "hsp_hit string from alignment: " . $hsp->hit_string() . " \n";
                        print "hsp_string from alignment: " . $hsp->homology_string() . " \n";
                        print "hsp_length of HSP (including gaps) : " . $hsp->length('total') . " \n";
                        print "hsp_length of hit participating in alignment minus gaps: " . $hsp->length('hit') . " \n";
                        print "hsp_length of query participating in alignment minus gaps: " . $hsp->length('query') . " \n";
                        print "hsp_Length of the HSP (including gaps) alias for length('total'): " . $hsp->hsp_length() . " \n";
                        print "hsp_frame: " . $hsp->frame() . " \n";
                        print "hsp_number of conserved residues: " . $hsp->num_conserved() . " \n";
                        print "hsp_number of identical residues: " . $hsp->num_identical() . " \n";
                        print "hsp_rank: " . $hsp->rank() . " \n";
                        print "hsp_identical positions as array: " . $hsp->seq_inds('query','identical') . " \n";
                        print "hsp_conserved, but not identical positions as array: " . $hsp->seq_inds('query','conserved-not-identical') . " \n";
                        print "hsp_conserved or identical positions as array: " . $hsp->seq_inds('query','conserved') . " \n";
                        print "hsp_identical positions as array: " . $hsp->seq_inds('hit','identical') . " \n";
                        print "hsp_conserved not identical positions as array: " . $hsp->seq_inds('hit','conserved-not-identical') . " \n";
                        print "hsp_conserved or identical positions as array, with runs of consecutive numbers compressed: " . $hsp->seq_inds('hit','conserved',1) . " \n";
                        print "hsp_score: " . $hsp->score() . " \n";
                        print "hsp_score in bits: " . $hsp->bits() . " \n";
                        print "hsp_start and end as array of query: " . $hsp->range('query') . " \n";
                        print "hsp_start and end as array of hit: " . $hsp->range('hit') . " \n";
                        print "hsp_% identical: " . $hsp->percent_identity() . " \n";
                        print "hsp_strand of the hit: " . $hsp->strand('hit') . " \n";
                        print "hsp_strand of the query: " . $hsp->strand('query') . " \n";
                        print "hsp_start position from alignment of query: " . $hsp->start('query') . " \n";
                        print "hsp_end position from alignment of query: " . $hsp->end('query') . " \n";
                        print "hsp_start position from alignment of hit: " . $hsp->start('hit') . " \n";
                        print "hsp_end position from alignment of hit: " . $hsp->end('hit') . " \n";
                        print "hsp_number of identical and conserved as array of hit: " . $hsp->matches('hit') . " \n";
                        print "hsp_number of identical and conserved as array of query: " . $hsp->matches('query') . " \n";
                }
        }
}

wenching520 發表在 痞客邦 留言(0) 人氣()

Source: http://www.orafaq.com/wiki/SQL_FAQ

The DELETE command is used to remove some or all rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. Note that this operation will cause all DELETE triggers on the table to fire.

SQL> SELECT COUNT(*) FROM emp;
COUNT(*)
----------
14

SQL> DELETE FROM emp WHERE job = 'CLERK';
4 rows deleted.

SQL> COMMIT;
Commit complete.

SQL> SELECT COUNT(*) FROM emp;
COUNT(*)
----------
10

TRUNCATE removes all rows from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUNCATE is faster and doesn't use as much undo space as a DELETE.

SQL> TRUNCATE TABLE emp;
Table truncated.

SQL> SELECT COUNT(*) FROM emp;

COUNT(*)
----------
0

The DROP command removes a table from the database. All the tables' rows, indexes and privileges will also be removed. No DML triggers will be fired. The operation cannot be rolled back.

SQL> DROP TABLE emp;
Table dropped.

SQL> SELECT * FROM emp;
SELECT * FROM emp
*
ERROR at line 1:
ORA-00942: table or view does not exist

DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. Therefore DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.

From Oracle 10g a table can be "undropped". Example:

SQL> FLASHBACK TABLE emp TO BEFORE DROP;
Flashback complete.

PS: DELETE will not free up used space within a table. This means that repeated DELETE commands will severely fragment the table and queries will have to navigate this "free space" in order to retrieve rows.

wenching520 發表在 痞客邦 留言(0) 人氣()

This night, Berdhard held a farewell party (actually, just Sean will leave us for one year to Chicago Unvi.) for Sean and himself.

Berdhard flew back to his country, Germany, to recruit for our program in the next day.
Actually, Berdhard is also the only German in TIGP program.



It's a quite different experience to have a foreign student in our class.
Cause Berdhard likes to drink , and he thinks that the taste of beers in Taiwan is quite good .
But I envy him that he has a Taiwanese girl friend, that I also met my girl friend in America but she is Taiwanese too .
I always think that i could have good experiences of dating with foreign girls, especially Japanese.

Whatever, see u guys, I know we will get together again after this one year.

Elsa, Sean, ??, Gopi, Berdhard, Peishan(B's GF), Mirrian

Oh, my. I almost forgot Gupi had come to join us at that night.
He is an indian and is also a TIGP student.

And forgive me that I don't know your names for ??.

wenching520 發表在 痞客邦 留言(0) 人氣()

Create a Project folder in /var/www and put all php files into that folder, and remember to use 'sudo chmod 777 /var/www/ProjectDir -R'.

Q1. When using 'mkdir', we occur "Warning: mkdir() [function.mkdir]: Permission denied in index.php on line 23"
A1. sudo chmod 777

Q2. replace new line '\n' in textarea into '
\n' in HTML
A2.
$message = ereg_replace("\n", "
\n", $sContent );
echo "

$sContent

";
or
echo nl2br( $sContent );

Q3. When using 'rmdir', we occur "Warning: rmdir(/tmp/664838dcfc993201ce07af5bae3ef0da) [function.rmdir]: Directory not empty in index.php on line 54"
A3.
function rmdir_recurse( $file ) {
if( is_dir( $file ) && !is_link( $file ) ) {
foreach( glob( $file . '/*' ) as $sf ) {
if( !rmdir_recurse( $sf ) ) {
echo( "Failed to remove $sf\n" );
return false;
}
}
return rmdir( $file );
}
else {
return unlink( $file );
}
}
and call 'rmdir_recurse( $sJobDir ) or die( "Could not remove $sJobDir.
\n" );'

Q4. Difference btw empty() and isset()
A4.
Example #1 A simple empty() / isset() comparison.
$var = 0;
// Evaluates to true because $var is empty
if (empty($var)) {
echo '$var is either 0, empty, or not set at all';
}
// Evaluates as true because $var is set
if (isset($var)) {
echo '$var is set even though it is empty';
}
?>
Empty():
Returns FALSE if var has a non-empty and non-zero value.
The following things are considered to be empty:
"" (an empty string)
0 (0 as an integer)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)

Q5. Error Messages Explained
A5.
http://ca.php.net/features.file-upload.errors
http://php.chinaunix.net/manual/zh/features.file-upload.errors.php
從 PHP 4.2.0 開始,PHP 將隨文件信息數組一起返回一個對應的錯誤代碼。該代碼可以在文件上傳時生成的文件數組中的 error 字段中被找到,也就是 $_FILES['userfile']['error']。
UPLOAD_ERR_OK
其值為 0,沒有錯誤發生,文件上傳成功。
UPLOAD_ERR_INI_SIZE
其值為 1,上傳的文件超過了 php.ini 中 upload_max_filesize 選項限制的值。
UPLOAD_ERR_FORM_SIZE
其值為 2,上傳文件的大小超過了 HTML 表單中 MAX_FILE_SIZE 選項指定的值。
UPLOAD_ERR_PARTIAL
其值為 3,文件只有部分被上傳。
UPLOAD_ERR_NO_FILE
其值為 4,沒有文件被上傳。
UPLOAD_ERR_NO_TMP_DIR
其值為 6,找不到臨時文件夾。PHP 4.3.10 和 PHP 5.0.3 引進。
UPLOAD_ERR_CANT_WRITE
其值為 7,文件寫入失敗。PHP 5.1.0 引進。
Note: 以上值在 PHP 4.3.0 之後變成了 PHP 常量。

If a new error constant would be introduced, your script would ignore it and assume that the upload went OK.
Anonymous has included a better version below:
$uploadErrors = array(
UPLOAD_ERR_OK => 'There is no error, the file uploaded with success.',
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded.',
UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder.',
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk.',
UPLOAD_ERR_EXTENSION => 'File upload stopped by extension.',
);

$errorCode = $_FILES['myUpload']['error'];

if($errorCode !== UPLOAD_ERR_OK && isset($uploadErrors[$errorCode]))
{
throw new Exception($uploadErrors[$errorCode]);
}
?>

For a multifile upload try this:
foreach($_FILES as $file)
{
if($file['error'] == 0 && $file['size'] > 0)
{
move_uploaded_file($file['tmp_name'], $targetdir.$file['name']);
}
}
?>

wenching520 發表在 痞客邦 留言(0) 人氣()

本來看到這篇介紹時就想去試試看了
http://www.wretch.cc/blog/bajenny/11733407

但是上次自己一個人去,到的時候是 8:32 pm. 已經不供餐了 ~

沒想到今天去看看,活動已經結束了 (殘念 ~~~)

但,都已經帶爸媽和大妹來了就吃吧 ~

瑞典烤肉丸(20粒) 179 我後來想想應該點兩盤 10粒 的,這樣有比較多的薯條


拉普蘭風味燉雞 99


德國豬腳 200


其實大妹還點了一道義大利麵,但真的太誇張了 ~
連拍的意願都沒有 ~

我想下次會更有經驗的 ~
記得拿個餐包或是好像也有白飯。

不然就得像我們一樣又到一樓去吃豬肉餡餅 (現在五個豬肉餡餅加兩杯飲料 75元/份,很划算)
當然,來 IKEA 必吃的霜淇淋 (10元/隻) 也不會放過的啦 ~


好像各家分店賣的餐點不太一樣,下次去試試其他三家分店
IKEA環亞店: 台北市105松山區敦化北路100號B1(環亞購物廣場)
http://www.ikea.com.tw/chi/locator/shatin.html
台北: http://blog.yam.com/linda5101/article/10322449

IKEA桃園店: 桃園市中山路958號 (武陵高中對面)
http://www.ikea.com.tw/chi/locator/taoyuan.html
桃園: http://www.wretch.cc/blog/JoyceLee41/8075066

IKEA高雄店: 高雄市中華五路1201號
高雄: http://www.wretch.cc/blog/finzaghi/9561204
高雄: http://blog.pixnet.net/suzukihiro/post/3132152

wenching520 發表在 痞客邦 留言(0) 人氣()

想說找個休息站好好享受經過甲仙時買的 大腸 & 香腸


(在甲仙三冠王芋冰城也買了爸爸最喜歡的芋頭糕)


就選了東山服務區,這也是我第一次到這 (印象中)


這是東山服務區的導覽


我並沒有進入休息站內,只在外面拍拍
STARBUCKS


還可以玩水歐 ~


東山休息站有名的百年大榕樹 (用左下角休息的人群可知有多大) 和我在成大榕園看到的有得比。




有好幾個荷花池




wenching520 發表在 痞客邦 留言(0) 人氣()