</script> </ …">

Octopress 部落格

一個靜態網站的部落格框架

Ajax Suggest 建議的範例

Ajax Suggest 建議的範例: 1. HTML Code(clienthint.htm):
1
2
3
4
5
6
7
8
9
10
11
12
13
<html>
  <head>
    <script src="clienthint.js"></script>
  </head>
  <body>
    <h3><a href="http://www.w3school.com.cn/php/php_ajax_suggest.asp">Ajax Suggest</a></h3>
    <form>
      First Name: <input type="text" id="txt1" onkeyup="showHint(this.value)">
    </form>
    <p>Suggestions: <span id="txtHint" /></p>
    <a href="index.htm">Home</a>
  </body>
</html>
2. Javascript Code(clienthint.js):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var xmlHttp;
function showHint(str) {
  if (str.length==0) {
    document.getElementById("txtHint").innerHTML="";
    return;
  }
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null) {
    alert ("Browser does not support HTTP Request");
    return;
  }
  var url="clienthint.php";
  url=url+"?q="+str;
  url=url+"&sid="+Math.random();
  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function stateChanged() {
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
    document.getElementById("txtHint").innerHTML=xmlHttp.responseText
  }
}

function GetXmlHttpObject() {
  var xmlHttp=null;
  try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  } catch (e) {
    // Internet Explorer
    try {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}
3. PHP Code(clienthint.php):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php

// Fill up array with names
$a[]="Anna";
$a[]="Brittany";
$a[]="Cinderella";
$a[]="Diana";
$a[]="Eva";
$a[]="Eric";
$a[]="Fiona";
$a[]="Gunda";
$a[]="Hege";
$a[]="Inga";
$a[]="Johanna";
$a[]="Kitty";
$a[]="Linda";
$a[]="Nina";
$a[]="Ophelia";
$a[]="Petunia";
$a[]="Amanda";
$a[]="Raquel";
$a[]="Cindy";
$a[]="Doris";
$a[]="Eve";
$a[]="Evita";
$a[]="Sunniva";
$a[]="Tove";
$a[]="Unni";
$a[]="Violet";
$a[]="Liza";
$a[]="Elizabeth";
$a[]="Ellen";
$a[]="Wenche";
$a[]="Vicky";

//get the q parameter from URL
$q=$_GET["q"];

//lookup all hints from array if length of q>0
if (strlen($q) > 0) {
  $hint="";
  for($i=0; $i<count($a); $i++) {
    if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) {
      if ($hint=="") {
        $hint=$a[$i];
      } else {
        $hint=$hint." , ".$a[$i];
      }
    }
  }
}

//Set output to "no suggestion" if no hint were found
//or to the correct values
if ($hint == "") {
  $response="no suggestion";
} else {
  $response=$hint;
}

//output the response
echo $response;
?>
4. 寫好後, 執行 clienthint.htm , 完成!

20111101 常用軟體列表

1. HeidiSQL_6.0 - MySQL Client
2. ToYcon 0.9 - Picture change Icon
3. dbvis_windows_7_1_5 - MySQL Client
4. MWSnap300 - Capture Screen
5. httpwatch_Professional_5.2.14 - IE Debug
6. ClickKey.exe - Click Sound
7. MemCleaner - Memory Clean
8. DateEdit - File Date Editer
9. ZoomIt - Zoom.Pen….
10. navicat091_lite_en.exe - MySQL Client
11. Convertz802 - 簡繁轉換
12. FileZilla-3.5.0 - SFTP
13. TeamViewer - TeamViewer
14. NTPClock - 時間校正
15. PStartSetup211 - 軟體捷徑功能
16. RocketDock-v1.3.5 - 仿 Mac
17. vncviewer - VNC
18. win32-chewing-0.3.4.8 - 新酷音輸入法 for Windows
19. CmdHerePowertoySetup - 右鍵 Open Command Prompt Here
20. UnxUtils.zip - Unix 指令
21. pointofix - 在螢幕上畫畫
22. SQLyog407 - MySQL Client
23. SynergyInstaller-1.3.1 - KVM多台電腦遙控
24. Universal-USB-Installer-1.8.6.7 - Linux 安裝在 USB 工具
25. WinScp - SFTP
26. TreeSizeFree - 觀看資料夾容量大小
27. FastStone Capture v5.3 cht - 螢幕擷取
28. Hinedo - 聽廣播
29. jruler - 螢幕尺
30. Vim - 文字編輯器
31. PDFX_vwr_Port - 看 PDF
32. FirefoxPortable - Firefox瀏覽器
33. HiRadio - 聽廣播
34. TimeRadioV5.5 - 聽廣播
35. portaputty - putty
36. VMware - 虛擬器
37. ColorPix - 顏色擷取器
38. Notepad++ - 程式編輯器
39. Dropbox - 免費空間 Client
40. Avira AntiVir - 小紅傘防毒軟體

由 Github 將 Dotfile 專案抓回來

先安裝 git core (在 ubuntu 底下):
#sudo apt-get install git-core

將專案 clone 回來(https的網址, 請參考專案的網址)
# git clone https://userproject@github.com/userproject/dotfile.git

將 dotfile 內的資料, 指到指定的資料夾內
#cd ~/dotfile
#ln -fs `pwd`/vim ~/.vim
#ln -fs `pwd`/vimrc ~/.vimrc

參考網站:
http://huan-lin.blogspot.com/2011/05/git-basic-workflow.html
http://c9s.blogspot.com/2009/11/git-dotfiles.html
http://gavaee.wordpress.com/2011/10/11/git-安裝及使用/

http://help.github.com/linux-set-up-git/
http://antbsd.twbbs.org/~ant/wordpress/?p=3044

===========================================================

如果在電腦上新增一個專案, 可用以下方式:
mkdir ~/dotfile
cd ~/dotfile
以下是要放入的檔案
mv ~/.vim vim
mv ~/.vimrc vimrc
git config –global user.name “user real name”
git config –global user.email “user email”
git init
touch README
git add README   # 如果只有幾個檔案, 可以此方式
git add .  #如果此資料夾下檔案都要, 使用此方式
git commit -m “commit description …”
(https的網址, 請參考專案網址)
git push https://userproject@github.com/userproject/dotfile.git







Vim Tab Tips

:tab ball –>將所有在 buffer 內的檔案,都放到 tab 上去

gt –> 下個 tab

gT –> 上個 tab

Ctrl-PgDn –> 下個 tab

Ctrl-PgUp –> 上個 tab


HiRadio

[LiveUpdate]
Version=1

[HiRadioUrl]
RadioUrl=http://b1.mediayou.net/cgi-bin/mmsurl_hinet?id=

[HiRadio]
RadioList=77
Title1=NEWS98 新聞網
Files1=187
Title2=中廣新聞網
Files2=207
Title3=ASIAFM 衛星音樂台
Files3=321
Title4=Apple line 蘋果線上
Files4=248
Title5=BestRadio 台中好事 903
Files5=211
Title6=BestRadio 台北好事 989
Files6=212
Title7=BestRadio 花蓮好事 935
Files7=303
Title8=BestRadio 高雄港都 983
Files8=213
Title9=HitFm 聯播網 台中 91.5
Files9=88
Title10=HitFm 聯播網 高雄 90.1
Files10=90
Title11=HitFm 聯播網台北 91.7
Files11=222
Title12=Kiss Radio 南投廣播
Files12=258
Title13=Kiss Radio 台南知音廣播
Files13=255
Title14=Kiss Radio 大苗栗廣播
Files14=256
Title15=Kiss Radio 大眾廣播電台
Files15=156
Title16=Kiss Radio 網路音樂台
Files16=308
Title17=中廣古典網
Files17=162
Title18=中廣流行網
Files18=205
Title19=中廣音樂網 I Radio
Files19=206
Title20=台北之音經典音樂台
Files20=222
Title21=台北愛樂
Files21=228
Title22=台灣之音-音樂
Files22=313
Title23=太陽電台
Files23=289
Title24=奇美古典音樂網
Files24=294
Title25=寶島新聲廣播電台
Files25=259
Title26=台灣之音-華語
Files26=315
Title27=復興廣播電台 短波網
Files27=288
Title28=復興廣播電台 第一網
Files28=286
Title29=復興廣播電台 第二網
Files29=287
Title30=正聲台北調幅台
Files30=317
Title31=正聲台北調頻台
Files31=198
Title32=漢聲光華網-中波
Files32=281
Title33=漢聲光華網-短波
Files33=309
Title34=漢聲廣播電台
Files34=215
Title35=漢聲廣播電台全國調頻網
Files35=216
Title36=綠色和平台灣文化廣播電台
Files36=327
Title37=ICRT
Files37=177
Title38=台灣之音-FM
Files38=312
Title39=台灣之音-亞洲
Files39=311
Title40=台灣之音-歐美及方言
Files40=314
Title41=ASIA FM92.3亞太電台
Files41=295
Title42=ASIA FM92.7亞州電台
Files42=210
Title43=GOLD FM-台中城市廣播
Files43=226
Title44=GOLD FM-台北健康電台
Files44=229
Title45=IC 之音
Files45=148
Title46=佳音廣播電台
Files46=201
Title47=佳音電台2台
Files47=250
Title48=全國廣播
Files48=202
Title49=台中廣播
Files49=230
Title50=台北廣播電台- 都會資訊頻道
Files50=208
Title51=台北廣播電台喔海洋頻道
Files51=238
Title52=真心之音廣播電台
Files52=217
Title53=大千電台
Files53=109
Title54=大愛網路電台
Files54=325
Title55=宜蘭中山電台
Files55=301
Title56=環宇廣播
Files56=282
Title57=警廣長青網
Files57=271
Title58=飛碟電台
Files58=232
Title59=中廣客家頻道
Files59=160
Title60=大漢之音
Files60=300
Title61=寶島客家
Files61=241
Title62=新客家廣播電台
Files62=254
Title63=高屏溪客家電台
Files63=298
Title64=警廣全國交通網
Files64=269
Title65=警廣台中台
Files65=260
Title66=警廣台北台
Files66=261
Title67=警廣台南台
Files67=263
Title68=警廣宜蘭台
Files68=265
Title69=警廣新竹台
Files69=268
Title70=警廣花蓮台
Files70=266
Title71=警廣高雄台
Files71=267
Title72=警廣台東台
Files72=358
Title73=Flyradio飛揚調頻895
Files73=357
Title74=佳音CCM
Files74=340
Title75=全國廣播音樂網
Files75=338
Title76=嘉義之音
Files76=368
Title77=青春線上
Files77=356

MySQL刪除重複的資料,只留下一筆資料

MYSQL語法 ALTER IGNORE TABLE 資料表 ADD UNIQUE INDEX(欄位1,欄位2); 假設我這Table name 是songlist,欄位1是tt,欄位2是tp,SQL語法組合起來如下… ALTER IGNORE TABLE songlist ADD UNIQUE INDEX(tt,tp);
1sndttttp
212008-02-26 17:01:00香蕉加樂福
322008-02-26 17:01:00西瓜金銀倒
432008-02-26 17:01:00香蕉加樂福
542008-02-26 17:01:00西瓜金銀倒
652008-02-26 17:02:00蘋果加樂福
762008-02-26 17:02:00牛奶金銀倒
872008-02-26 17:02:00蘋果加樂福
982008-02-26 17:02:00牛奶金銀倒
資料來源: http://www.dotblogs.com.tw/doremi.miredo/archive/2008/12/20/6464.aspx

MySQL 升級

(PS:此文章從Web上的PDF檔案中擷取出來的)
如果你有安裝MySQL
而且MySQL 版本是5.X 的,請注意囉
因為從MySQL 4.1 開始,密碼格式很像變得不同囉
詳情請看此篇:http://dev.mysql.com/doc/refman/4.1/en/old-client.html
MySQL 4.1 and up uses an authentication protocol based on a password hashing algorithm that is
incompatible with that used by older clients. If you upgrade the server to 4.1, attempts to connect to
it with an older client may fail with the following message:
shell> mysql
Client does not support authentication protocol requested
by server; consider upgrading MySQL client
簡單的   , 說 MySQL 4.1跟更新的版本使用一個以密碼雜湊演算法為基礎的驗證協定
而且跟舊版的不一樣,不適用於舊版的 Client端.
如果你的 MySQL升級到 4.1(或者更新的,像是 5.X)
你連線到 MySQL時應該會出現以下訊息(請往上看 XD)
解決方法很多
•    升級Client 端的MySQL 函式庫
•    連線到4.1 以上版本的MySQL 時,使用4.1 以上版本的帳號密碼來進行連線
•    啟動MySQL 時,多加個–old-passwords 引數
•    登入MySQL,使用old_password 函式(待會說明)
OK,我們先來學第四個方法吧.. 也是我最習慣使用的方法(因為簡單拉@@”)
請你先登入mysql(請用有權限更改mysql 的帳戶,例如:root)
然後↓
mysql> set password for ‘帳號’@’主機’ = old_password(‘密碼’);
Query OK, 0 rows affected (0.00 sec)
用好之後,請update 跟flush privileges
mysql> update mysql.user set password = old_password(‘密碼’) where host = ‘主機’ and user = ‘帳
號’;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
OK,這樣一來就更改好了!可以連線看看囉!
另外一種方法,也就是第三種方法可以自行參考MySQL 函式庫說明囉^^

PHP印出陣列中被包在StdClass內的Value

 假設今天收到的資料的是
Array (
   [0] => stdClass Object (
   [name] => “AAA”
   [code] =>123
   )
[1] => stdClass Object (
   [name] => “BBB”
   [code] =>456
  )
[2] => stdClass Object (
   [name] => “CCC”
   [code] =>789
  )
)

要印出資料只要設定一個變數指到那個Array Object 就好了…
//先把資料存到某個變數 , 假設上面那筆資料是 $a
$b = $a;
//接著逐一印出的話
foreach ($b as $value) {
    $name = $value->name;
    $code = $value->code;
    echo “$name , $code \n”;
}

出處: http://note.ajneok.org/programing_note/php/php-print-array-value-in-stdclass/comment-page-1/#comment-1231

Comments

Yien_Huang
因為您這樣寫會讓人覺的你只要看裡面的資料

我記得我寫的php很多都是這樣的方式,因為要跟javascript溝通,必需把array換成object,轉換成json資料格式才可以跟js使用。(上架程式裡面有一堆都是這個!)
~我的筆記園地~
如果你要擷取裡面的值, 就得要回圈跑~~
目前很多套裝軟體都會用到~~
Yien_Huang
我不懂~ print_r() & var_dump() 不是就可以印出來了嗎?~怎麼要用回圈跑出來呢?!

CentOS 的提示顯示修改與檔案顯示將深藍改成淺藍

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions
# 修改此兩個值, 括號是預設值 di=01;36(01;34), ln=02;36(01;36)
declare -x LS_COLORS=”no=00:fi=00:di=01;34:ln=02;35:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:”

# 原設定 PS1=”[\u@\h \W]\$”
PS1=”\h[\[\033[1;34m\]\w\[\033[0m\]]$ \[\033[0m\]”

# ===========================================================================
PS1=’[\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\W\[\033[00m\]]$ ’

\33[0m 关闭所有属性
\33[1m 设置高亮度
\33[4m 下划线
\33[5m 闪烁
\33[7m 反显
\33[8m 消隐
\33[30m – \33[37m 设置前景色
\33[40m – \33[47m 设置背景色
\33[nA 光标上移n行
\33[nB 光标下移n行
\33[nC 光标右移n行
\33[nD 光标左移n行
\33[y;xH设置光标位置
\33[2J 清屏
\33[K 清除从光标到行尾的内容
\33[s 保存光标位置
\33[u 恢复光标位置
\33[?25l 隐藏光标
\33[?25h 显示光标
所有的转移字符表:
\a ASCII 响铃字符(也可以键入 \007)
\d “Wed Sep 06” 格式的日期
\e ASCII 转义字符(也可以键入 \033)
\h 主机名的第一部分(如 “mybox”)
\H 主机的全称(如 “mybox.mydomain.com”)
\j 在此 shell 中通过按 ^Z 挂起的进程数
\l 此 shell 的终端设备名(如 “ttyp4”)
\n 换行符
\r 回车符
\s shell 的名称(如 “bash”)
\t 24 小时制时间(如 “23:01:01”)
\T 12 小时制时间(如 “11:01:01”)
\@ 带有 am/pm 的 12 小时制时间
\u 用户名
\v bash 的版本(如 2.04)
\V Bash 版本(包括补丁级别) ?/td>
\w 当前工作目录(如 “/home/drobbins”)
\W 当前工作目录的“基名 (basename)”(如 “drobbins”)
\! 当前命令在历史缓冲区中的位置
\# 命令编号(只要您键入内容,它就会在每次提示时累加)
\$ 如果您不是超级用户 (root),则插入一个 “$”;如果您是超级用户,则显示一个 “#”
\xxx 插入一个用三位数 xxx(用零代替未使用的数字,如 “\007”)表示的 ASCII 字符
\ 反斜杠
\[ 这个序列应该出现在不移动光标的字符序列(如颜色转义序列)之前。它使 bash 能够正确计算自动换行。
\] 这个序列应该出现在非打印字符序列之后。


特殊格式 含義 字體顏色值 背景顏色值 顏色
0 默認值 30 40 黑色
1 粗體 31 41 紅色
22 非粗體 32 42 綠色
4 下劃線 33 43 黃色
24 非下劃線 34 44 藍色
閃爍 35 45 洋紅
25 非閃爍 36 46 青色
7 反顯 37 47 白色
27 非反顯

參考網站:
http://blog.csdn.net/gausszhch/archive/2010/05/27/5628009.aspx
http://blogold.chinaunix.net/u/10679/showart_114949.html

MySQL 紀錄 SQL 語法

MySQL大約有3種方法, 加入 /etc/my.cnf後, 再 service mysqld restart !!

1. 查詢 Slow query 的 SQL 語法:
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 2 (超過 2秒的 SQL 語法記錄起來)

2. 設 MySQL Replication 用 binlog:
log_bin = /var/log/mysql/mysql-bin.log (此檔要用 mysqlbinlog 解來看)
mysql 會將所有 INSERT/UPDATE/DELETE 語法記於此(但是語法可能跟你想的不同), 這是要寫給 SLAVE 用的 log 檔

3. 將 MySQL 執行的每行指令全都記錄起來(作者推薦):
log = /tmp/mysql.log
restart mysql 後, tail -f /tmp/mysql.log 就可以看到囉!

參考網址:
http://blog.longwin.com.tw/2007/06/mysql_record_any_sql_command_2007/