夕口技術錄
專業上的小常識,備而用之~
Monthly Archives: 三月 2009
[Linux][clientmqueue] – /var/spool/clientmqueue 量超大?
2009/03/27
Posted by 於 /var/spool/clientmqueue 這個檔案夾為何會產生超大的檔案呢?
原因在於當 sendmail process stop 時,
linux 就會將紀錄更改到這個目錄下,
且系統不會自動清除。
而當要使用
# rm -rf *
確因量大到無法刪除…
那該怎辦呢 ><!!!
請來這篇看看吧!!!
[Linux] – 檔案數太多,如何大量刪除[Linux][awk] – 轉小寫
2009/03/27
Posted by 於 將 file 中的第七欄位值 轉小寫後導出 newfile
# awk ‘{$7=tolower($7);print}’ “file" > newfile
[ PHP ]#!/usr/local/locker_agent/foundation/bin/php -q
<?PHP`awk ‘{\$1=tolower(\$1);print}’ redomain.sym > redomain_lower.sym`
[PHP][&、~] – 位元運算子(bitwise operator)
2009/03/22
Posted by 於 “位元運算子" 大家平常是非常用的到東西,
但今天我才知道它的另外的用法,
下面就來舉個例吧!!!
echo(5&6); //結果為4
?為何呢…
因位元運算子是提供二進位的位元運算,計算過和如下…
運算子 範例 運算過程 說明
& 11&13 11(1011) & 13(1101) = 9(1001) 將每個位元做 and 運算
| 11|13 11(1011) | 13(1101) = 15(1111) 將每個位元做 or運算
^ 11^13 11(1011) ^ 13(1101) = 6(0110) 將每個位元做 xor 運算
>> 11>>2 11(1011) >> 2 = 2(0010) 將位元向右移動,例右移兩位元
<< 11<<2 11(001011) << 2 = 44(101100) 將位元向左移動,例左移兩位元
~ 11~ ~11 = -12 將所有位元做反相運算,相當於將十進位數值乘一個負號再減1
[PHP][xor] – 邏輯運算元(Logical Operators)
2009/03/22
Posted by 於 對於 xor 這個 邏輯運算元很少用到,
所以對於它的用處及定義也一直處於似懂非懂的狀態…
因此重新再針對這方面的基礎進重新學習。
運算元 用法 說明
and $a and $b 二個同時為真
&& $a && $b 同上
or $a or $b 其一為真
|| $a || $b 同上
xor $a xor $b 任一者為真,且只能一個為真
! !$a 不為真時
[PHP][image map] – 接收影像地圖點選座標
2009/03/22
Posted by 於 基本語法
Image 不是一個獨立的元件,它是 Input 元件的一種使用型態。其基本語法如下:
<input type="Image" src="圖片來源" name="名稱">
參數說明
name 係指該元件的名稱,例如:ImageButton。在事件處理程序中,您可以用 document.FormName.ImageButton 來稱呼它。
src 則是用來指定圖片檔的來源路徑,例:imgbutton.gif。
其他參數的使用請自行參閱 HTML Specification。
使用範例
Image 與 Submit 功能相同,都可以用來送出 form 中的資料。不過,使用 Image 時,同時會將滑鼠指標點在該圖時的 X、Y 座標也一併傳回,這就可以產生類似 Image Map 的效果了。
使用者端:
<form action="act.php" name="DemoForm" onsubmit="return Final_Check( );">
……
<input type="image" name="ImageButton" src="media/logo_s.gif">
</form>
伺服器端:
在伺服器端,我們可以用元件名稱分別加上「_x」與「_y」,來取得點選位置的 X、Y 座標。
<?
echo “您點的位置是";
echo " X:" . $ImageButton_x;
echo " Y:" . $ImageButton_y;
?>
若 register_globals 被設定為 off 時,您必須視資料傳送所使用的 method(GET/POST),改用 $_GET[‘變數名稱’]、$_POST[‘變數名稱’] 或 $_REQUEST[‘變數名稱’] 來取得變數內容。
[Linux][export] – 更改環境變數 值
2009/03/20
Posted by 於 [root@dywHome2 ~]# export declare -x DISPLAY=":0" declare -x ENV="/root/.bashrc" declare -x GCONF_TMPDIR="/tmp" declare -x G_FILENAME_ENCODING="@locale" declare -x HISTCONTROL="ignoredups" declare -x HISTSIZE="1000" declare -x HOME="/root" declare -x HOSTNAME="dywHome2" declare -x INPUTRC="/etc/inputrc" declare -x LANG="en_US.UTF-8" 中間省略 declare -x USER="root" declare -x USERNAME="root" declare -x XAUTHORITY="/home/dywang/.Xauthority" 舉例如何更改 LANG 的值呢? 其實只要直接在 commend 下把當行覆制後更改送出即可 # declare -x LANG="en_US" 當然也有另外的方式, 就舉 LANG 這個例子 # LANG="en_US" 延申閱讀..
[Linux] – 檔案數太多,如何大量刪除
2009/03/12
Posted by 於 當檔案數太多, 砍不掉的時後該怎麼辦(錯誤訊息: rm: too many arguments 或 rm: Argument list too long)
- 先轉成 file owner 的身份去下指令(不然就轉成 root 吧!)
- ls -l | awk ‘{print $9}’ | xargs rm # 再來這樣子就可以砍掉
- ls -l *.jpg | awk ‘{print $9}’ | xargs rm # 如果只要砍那目錄下的所有 jpg 檔
不過使用前請小心確認一下, 最後 xargs rm 先拿掉, 改成 less, 先確定一下是自己要砍的, 再下此指令吧
另外的方式 :
- find /path -name ‘*.jpg’ -depth 1 -delete
- ls *.jpg | xargs rm
- ls|xargs rm -f
[Linux][cache] – 手動釋放記憶體暫存Cache
2009/03/11
Posted by 於 # echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
# echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation and dirty objects are not freeable, the user should run “sync" first!
# sync –help
Usage: sync [OPTION]
Force changed blocks to disk, update the super block.
# free -m
view memory status
[MySQL] – 忘記 MySQL 密碼的處理方法
2009/03/09
Posted by 於 Mysql 的 root 帳號如忘記了,
要怎麼辦呢?
以下提供一個方法,
但這個方法前提之下必需將所有創建的帳號刪除…
1、找尋 mysql_install_db 的位置
[root@CentOS mysql]# locate mysql_install_db
/usr/bin/mysql_install_db
2、砍掉原有的帳號表格
[root@CentOS mysql]# rm -rf /var/lib/mysql/mysql
3、重新創建一個新的 mysql 表格
[root@CentOS mysql]# ./mysql_install_db –user=mysql
4、重啟 mysql
[root@CentOS mysql]# /etc/rc.d/init.d/mysqld start
5、重新設定 root 密碼
[root@CentOS mysql]# /usr/bin/mysqladmin -u root password ‘rootpassword’
6、登入 mysql commend 修改 root 密碼
[root@CentOS mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.1.12
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> set password for root@"localhost"=old_password(‘rootpassword’);
Query OK, 0 rows affected (0.00 sec)
7、大功完成,離開
mysql> exit
Bye
[Javascript][array]:Array以字串為key的值
2009/03/07
Posted by 於 //宣告 var url_arr={'software':'software.sopili.net','dev':'dev.sopili.net'}; //讀取 for(var key in url_arr){ //這裡面的key值,就真的是字串了! document.write(url_arr[key]+'<br>'); } More ....
近期迴響