發表文章

目前顯示的是 2011的文章

[java] static

reference: http://www.inote.tw/2007/12/java-static.html

[c] fork

fork will return 0 when it is child process and a random positive number when it is parent.

[c] error: ‘exit’ was not declared in this scope

error: ‘exit’ was not declared in this scope it will be compiled without errors if you include in your code the statement: #include <cstdlib> error: ‘fork’ was not declared in this scope it will be compiled without errors if you include in your code the statement: #include <unistd.h>

[c++] size_t

Unsigned integral type size_t corresponds to the integral data type returned by the language operator sizeof and is defined in the header file (among others) as an unsigned integral type. In , it is used as the type of the parameter num in the functions memchr, memcmp, memcpy, memmove, memset, strncat, strncmp, strncpy and strxfrm, which in all cases it is used to specify the maximum number of bytes or characters the function has to affect. It is also used as the return type for strcspn, strlen, strspn and strxfrm to return sizes and lengths.

[c++] static 的意義

1.用作變數: 1-1:放在函數內 Ex: void MyFun() { static int i=0; } 說明:"i"為"static,i"的生命週期會到程式結束,但是他的scope 還是在MyFun()中,每次呼叫MyFun(),函數中"i"的值會保留上次呼叫最後一次設定的值。 1-2:放在函數外 Ex:檔案 abc.c 中寫了如下 static int s_i=0; int myfun() {} 說明:此時"s_i"只能在檔案"abc.c"中使用,她可以讓"abc.c"中所有的"function"看到,他的生命週期也是到程式結束,但是別的.c 檔是無法使用到"abc.c"檔中的"s_i"。 2.在function 前面加上"static" Ex:檔案 123.c 中寫了如下 static void MyFun() {return;} 說明:此時"MyFun()"只能給這個123.c 這個檔案中的其他function 呼叫。 (簡單的說,就是"MyFun()"這個function不會被linker 參考到) 資料來源:http://flykof.pixnet.net/blog/post/23583952

[web design] alt vs title

ALT is a required element for images and can only be used for image tags because its specific purpose is to describe images. and title can use to describe all structural HTML elements. you can use the TITLE attribute for just about any page element.

[web design] 自動轉址

a,b 轉載自 : Openwebmail FAQ a. ---------------------------------------- <html><head> <meta http-equiv="Refresh" content="0;URL=http://your_server/cgi-bin/openwebmail/openwebmail.pl"> </head></html> ---------------------------------------- b. --------------------------------------- <html> <body onload= "window.open('http://your_server/cgi-bin/openwebmail/openwebmail.pl','_top')"> </body> </html> ---------------------------------------- 以下是其它寫法 (非Html) ---------------------------------------- c. PHP header 寫法 --------------------------------------- header("Location: https://fgps.tcc.edu.tw/cgi-bin/openwebmail/openwebmail.pl"); --------------------------------------- d. JavaScript 寫法 --------------------------------------- <script language="Javascript"> <!-- if (screen.width == "800") { location="fgps/800/index.php?link=index" } else { location...

[php] post重複傳送

弄了幾小時... 無法接受為什麼 unset($_POST) 還是無法消除POST內容 最後靠別人那偷來的程式碼搞定QQ < ? php session_start(); /** * 检查表单是否被重复提交 * 相同内容的表单在设定时间内只能提交1次 * @param int $iTimeOffset * @return bool */ function checkFormSubmit($iTimeOffset=60){ // 取得表单的标识 $idForm = md5(serialize($_POST)); // 是否需要表单提交检察 $iFormCheck = true; if (isset($_SESSION['formSubmitCheck'])){ // 删除过期的表单标识 foreach (array_keys($_SESSION['formSubmitCheck']) as $val){ if (time() > $val){ unset($_SESSION['formSubmitCheck'][$val]); } } }else { $_SESSION['formSubmitCheck'] = array(); $iFormCheck = false; } if ($iFormCheck == true){ // 检查是否有重复标识的提交记录 foreach ($_SESSION['formSubmitCheck'] as $val){ ...

[Ubuntu] some instructions

ps -l report a snapshot of the current precesses. pstree -Aup display a tree of processes. fg call job to run in font mode. bg call job to run in background mode. jobs list all jobs. & add this after an instruction, and job will run in background.

[Ubuntu]安裝Apache2 + PHP5 + MySQL + phpMyAdmin 【Ubuntu】安裝Apache2 + PHP5 + MySQL + phpMyAdmin

安裝MySQL-Server $ sudo apt-get install mysql-server 安裝Apache HTTP Server $ sudo apt-get install apache2 安裝PHP for Apache HTTP Server $ sudo apt-get install php5 安裝MySQL for Apache HTTP Server $ sudo apt-get install libapache2-mod-auth-mysql $ sudo apt-get install php5-mysql 安裝phpMyAdmin$ sudo apt-get install phpmyadmin裝完後必須先新增一個mysql的帳號$ mysqladmin -u root password [密碼] PS. 這裡新增的root跟系統的root是不同的,如果遺漏第二個步驟會發生錯誤 => #1045 - Access denied for user 'root'@'localhost' (using password: YES) 安裝完畢後套件會自動在/var/www下建立連結,網址列輸入http://127.0.0.1/phpmyadmin即可進入 資料庫預設目錄:/var/lib/mysql 網頁預設目錄:/var/www Apache設定檔:/etc/apache2/apache2.conf -- 後紀: when I going this step : {安裝phpMyAdmin$ sudo apt-get install phpmyadmin裝完後必須先新增一個mysql的帳號$ mysqladmin -u root password [密碼]} it's occur false...{Access denied balabala..} so google and find ... { Q: Ubuntu 下安装phpmyadmin 却无法使用 A: 安装phpmyadmin命 令:sudo apt-get install phpmyadmin 默认安装在 /usr/share/phpmyadmin 作个链接到 /var/www/ 目录下,命令为:sudo ln -s /usr/...

[HTML] shortcut icon

http://www.dotblogs.com.tw/puma/archive/2008/08/24/5188.aspx

[php] use recursice to read all file in directory

<? function open_dir($dir){ $d = dir($dir); while($row = $d->read()){ if($row != '.' && $row != '..'){ $path = $dir.'/'.$row; echo $path."\n"; if(is_dir($path)){ open_dir($path); } } } } $dir = getcwd(); open_dir($dir); ?>

[php] trim() 去掉 \r \n 等不必要字元

This function returns a string with whitespace stripped from the beginning and end of str. Without the second parameter, trim() will strip these characters: * " " (ASCII 32 (0x20)), an ordinary space. * "\t" (ASCII 9 (0x09)), a tab. * "\n" (ASCII 10 (0x0A)), a new line (line feed). * "\r" (ASCII 13 (0x0D)), a carriage return. * "\0" (ASCII 0 (0x00)), the NUL-byte. * "\x0B" (ASCII 11 (0x0B)), a vertical tab. reference: http://php.net/manual/en/function.trim.php

[php] Maximum execution time of 30 seconds exceeded

error: Maximum execution time of 30 seconds exceeded 解: 修改php.ini max_execution_time(time) //單位秒 or 在code加上 set_time_limit(時間) //0為無限制 以上

[php] 網頁即時更新php運算

在前方加上 ob_end_clean(); 在echo 之後加上 flush(); ex: echo "good"; flush(); 即可

[php] 記憶體超出限制

solution : ini_set('memory_limit', '-1'); OR ini_set('memory_limit', '128M');