Monday, December 05, 2011

Pencil 無法安裝新圖集(collection)

Evolus Pencil ver.1.3.2
安裝新圖集時最下方出現一句: SYSTEM ERROR! * uncaught exception:[Exception... "Component return-------chrome://pencil/content/definition/collecionManger.js::-----
google 結果 http://code.google.com/p/evoluspencil/issues/detail?id=373 按psychol...@gmail.comNov 23, 2011
"...change "resource:app" to "CurProcD".

So inside of exportTemplateManager.js, collectionManager.js and privateCollectionManager.js (inside /app/content/pencil/definition) replace "resource:app" with "CurProcD".

After that it seems to work normally"
修改C:\Program Files\Evolus\Pencil\app\content\pencil\definition\collectionManger.js
第46行stencilDir = properties.get("resource:app", Components.interfaces.nsIFile); 為"CurProcD".

Monday, November 21, 2011

原來是DNS 拖慢SimpleXML讀取外部網站速度

在測試用PHP 的SimpleXML時出現嚴重延遲。
在virtual server 中行
$xml = new SimpleXmlElement($url, 0, true);
到外部網站讀取一個ashx (xml?)的檔案。
觀看apache access.log及 firebug 系統會出現一段几十秒的等待,然後很短時間內即顯示結果。
若直接用瀏覽器取$url就没有這問題但在服務器用命令行curl 要等很長時間。將script 搬至外部雲server, 速度提升到只要8秒多。
未知SimpleXmlElement內部運作,今日試用wget $url 運行時停在Resolving....然後很久才connected.
把$url中的主機名改為ip, 速度即時回覆正常。
咁又兩日...

Tuesday, August 02, 2011

Google Map 移除"我的/他人"地圖(圖層)

Google Map for Android 加入了別人建立的地圖(圖層), 想移除在手機中弄來弄去, 清了cache以致其它貌似相關的apps的cache etc. 還是清不了,在"我的地圖" 選單中還是出現, 甚至移除google map的更新。依然不成功。
突然想到會不會透過網上google 帳號可在map中移除?果然在登入google 後在 map的 "我的位置"中找到該圖層並移除即可。 google 會不會太"暈"端,手機端找不到半點蛛絲馬跡。希望清cache 不會影响到其它apps 和系統穩定。

Saturday, July 30, 2011

MySql 管理及應用網文

設計應用
Foreign Key 相關
数据库中主键和外键的设计原则
http://www.cnblogs.com/tianyamoon/archive/2008/04/02/1134394.html

数据库设计中一个矛盾:数据库外键,用还是不用?你怎么看?
http://kb.cnblogs.com/a/1601193/

外键约束方式
http://www.cnblogs.com/bigshow/archive/2009/01/11/1373835.html

管理
mysqldump
MySQL数据库备份守则和方法
http://tech.ddvip.com/2008-09/122095329462345.html

mysqldump 5.1 資料備份詳細指令
http://jax-work-archive.blogspot.com/2009/07/mysqldump-51-mysql.html


mysql分区表介绍
http://www.sphinxsearch.org/archives/23

Saturday, July 23, 2011

Apache2 的設置檔不能用UTF-8編碼, 只能用ANSI!

Apache2 的設置檔不能用UTF-8編碼, 只能用ANSI!
發佈者:Ivan Lee· 2010年8月30日
設置完 ... 後執行apache2ctl configtest 出現錯誤信息sites-enabled/mysite​: without matching section
重新儲存為ANSI編碼後一切正常.
(咁又幾粒鐘)

注:轉自FB

Wednesday, July 06, 2011

tar 命令使用 - 備份www 資料夾

用tar總是忘記用法和出錯,以下以備份A機/var/www 到B機/var/www為例
http://linux.vbird.org/linux_basic/0240tarcompress.php#pack
一、命令參數
參數記法:
1. 決定用那一種壓縮方法有 z和j
2. x解壓還是c壓縮或t只是看壓縮檔內容
3. 要詳細列出過程v
4. 要處理的檔案f file_name.tar 若是解壓則為已存在的檔案名,若是壓縮則為將要用的檔名,f參數建議放最後,以便後跟檔案名
5. -C /tmp 指定解壓至/tmp
根據上面順序
若壓縮則得到 root@A:/var# tar -zcvf backup.tar.gz www
;www為目錄
解壓則得到 root@A:/var# tar -zxvf backup.tar.gz
;B機/var/www/會被新內容覆蓋
二、目錄的位置
若上壓縮時寫為root@A:~# tar -zcvf backup.tar.gz /var/www
若查看會全部帶有var/www, 解壓時要在對的目錄並放回對應的目錄或利用-C,否則會多了一層或覆寫了其它目錄,亦要有權限,否則出現can not open file...

Sunday, July 03, 2011

PHP Session/Cookie

PHP Session/Cookie
Ivan Lee 寫於 2011年3月23日 20:16
session_set_cookie_params($lifeTime);
只對client browser 設置有效, 無助server side session 清理,詳細參閱以下內容
[/etc/php5/apach2/php.ini]
; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.

; This is disabled in the Debian packages, due to the strict permissions
; on /var/lib/php5. Instead of setting this here, see the cronjob at
; /etc/cron.d/php5, which uses the session.gc_maxlifetime setting below.
; php scripts using their own session.save_path should make sure garbage
; collection is enabled by setting session.gc_probability
;session.gc_probability = 0
session.gc_divisor = 100

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440

; NOTE: If you are using the subdirectory option for storing session files
; (see session.save_path above), then garbage collection does *not*
; happen automatically. You will need to do your own garbage
; collection through a shell script, cron entry, or some other method.
; For example, the following script would is the equivalent of
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
; cd /path/to/sessions; find -cmin +24 | xargs rm

google map 全屏CSS設定

google map 全屏CSS設定
Ivan Lee 寫於 2011年4月30日 3:15
#map-canvas {
bottom: 0;
height: auto;
left: 0;
position: absolute;
right: 0;
top: 0;
}

若設成
#map-canvas{
width: 100%;
height: 100%;
}
會出現空白頁, 若height指定px值, 則自動佔滿寛度.
可能成因,
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/49cc3e330b0bafb2
the problem is that you've got a strict html doctype at the start, but the "hello world" example leaves out the doctype (and therefore runs in quirks mode). In strict mode the browser calculates the 100% height as zero (inherited from body) so you need CSS like this to see the map:


html,body {
height: 100%;
margin: 0px;
}

Thursday, June 30, 2011

PHP5-Memcached 釘文

Q1 31 Jun
PHP Warning: Unknown: Failed to write session data (memcached). Please verify that the current setting of session.save_path is correct (tcp://127.0.0.1:11211) in Unknown on line 0

成因:
$mcdhost = '127.0.0.1';
$mcdport = '11211';
ini_set('session.save_handler', 'memcached'); 有d
ini_set('session.save_path', $session_save_path);
其中$session_save_path = "$mcdhost:$mcdport";
不是$session_save_path = "tcp://$mcdhost:$mcdport";僅用於php5-memcache

Q2 31 Jun
PHP Warning: Unknown: Failed to write session data (memcached). Please verify that the current setting of session.save_path is correct (127.0.0.1:11211) in Unknown on line 0

成因:
故意停止Memcached 服務器後運行Memcached::addServer(),本打算用if/try{}catch 判斷若不能連接Memcached Server則用回files形式儲存,雖php手冊中指addServer()返回為TRUE或FALSE但判斷未成功,只出現上述警告
這方面用php5-memcache的Memcache::connect()較好, 因為若不成功連接會返回false。出現的錯誤用@抑止後不影响session header的輸出,退回用file儲存session方式

http://www.gocar.idv.tw/phpbb3/viewtopic.php?f=24&p=79
試例子只適用於php5-memcache
在php.ini 中預設session.save_handler = files 和 session.save_path = /path_to_file/

Q3 31 Jun
用Memcached server處理http session cookie,但有個問題是未能控制session cookie何時因閒置而過期問題。
是否與只在php程序中用ini_set()修改了session handler 而非在php.ini中修改,因此garbage collection 不會在預設1440秒後清除閒置的session?
1 July
在PHP5-MEMCACHE(NO d)的PHP script 中設了 int_set('session.gc_maxlifetime', 20); telnet查看該session 雖然不一定刪除該key,但Memcached server 還是會清去其內的value,但此轉到用PHP5-MEMCACHED(WITH D)中在Pphp.ini中設了session.save_handler = memcached及session.gc_maxlifetime = 30,當中的key-value即使逾時還是會保留,打開verbose -vv tail -f /var/log/memcached.log 觀察,有定期delete key 的紀錄(可能因client端的app定期更新行為)

2008年一篇對memcached garbage collector 的討論電郵
http://lists.danga.com/pipermail/memcached/2008-May/006849.html
Memcache(d) to store PHP sessions 比較php-memcache和php-memcached
http://beeznest.wordpress.com/2011/04/18/memcached-to-store-php-sessions/

php5-memcached 不會清除過期的session(的值, key會保留),試過改session.gc_maxlifetime session.gc_probability/session.gc_divisor =1/1 但仍然無效,估計可能在寫入memcached時expire time為0(即不過期)有關,未找到如何修改,或者需要重新override session_save_handler()。用PHP5-Memcach則會自動清理,改用這。

memcached 與 memcache比較及其它

除了結尾的一個d字差別外(有指結尾的d代表demand守護進程),因為名字混用引起混淆,今日在Debian5.0和Ubuntu10.04LTS試用後理解如下

memcached本身為一個服務守護進程,只有memcacheD没所講的memcache,獨立運行,類似apache server. 會接受客戶端如PHP擴展連線。

而php之下有兩個packges 一個名為php5-memcached 而另一個為php5-memcache,兩者角色一樣同為客戶端,功能略有不同可參考http://www.leonzhang.com/2011/06/24/memcached-vs-php-memcache/和php手冊
memcache http://www.php.net/manual/en/book.memcache.php
memcached http://www.php.net/manual/en/book.memcached.php

舊版Debian 5(backport sources.list) apt-cache 没有php5-memcached只有php5-memcache。相反較新的Ubuntu 10只有php5-memcached
Debian: ~# apt-cache search php5-memcached (有d)
没內容顯示

Debian5: ~# apt-cache search php5-memcache (没有d)
php5-memcache - memcache extension module for PHP5

Ubuntu10:~# apt-cache search php5-memcached
php5-memcached - memcached extension module for PHP5

dpkg -L php5-memcache 或dpkg --get-selections 查看已安裝軟件包

安裝
若要使用memcache,需完整安裝服務器memcached和php對應的客戶端(memcache與memcachd比較) 免混淆,皆加上php5-前綴
安裝server
apt-get install memcached

安裝php擴展
apt-get install php5-memcached

客戶端用法大致相同,會有d字之別,可參閱php手冊。

FAQ - Iterate all items - not design for
http://code.google.com/p/memcached/wiki/FAQ#Can_I_iterate_the_items_of_the_memcached_server?

wiki
http://code.google.com/p/memcached/wiki/NewStart

protocol
http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt
https://github.com/trondn/memcached/blob/master/doc/protocol.txt
中英對照
http://www.jb51.net/shouce/memcached/index.html

一些memcache的特別注意地方
http://www.caiapps.com/memcached-for-load-balancing-sessions/
http://www.caiapps.com/duplicate-key-problem-in-memcache-php/

自訂session handler 用 memcache
http://www.keboola.com/blog/php-sessions-with-memcached-and-a-database-session-in-the-cloud-done-right/
Memcache(d) to store PHP sessions 比較php-memcache和php-memcached
http://beeznest.wordpress.com/2011/04/18/memcached-to-store-php-sessions/

替代品
http://www.mohawksoft.org/?q=node/8

Wednesday, June 29, 2011

Android ad-hoc tether problem

昨日升級華為tether軟件, 希望解決不能3G共享給其它android機問題,其中有句講到明原來採用ad-hoc mode 共享, android2.1的client不能以這種方式連接(apple 機無問題)。疑惑了半年的問題終於有答案,但未有解決方法。唯有等升級。

http://gfans.bryan.tw/2010/10/20/1243
任何一套wireless tether軟體都是將3.5G透過Ad-hoc模式分享

http://forum.xda-developers.com/showthread.php?t=553508
Shocking! Hero cannot see ad-hoc network
見第八貼

Thursday, June 23, 2011

Java 中Thread 和 Runnable

Java 中Thread 和 Runnable都可以作為多線程的程序中使用,兩者中不同是
Thread 是一個Class
Runnable 是一個Interface

通過extends Thread,可獲得start(), sleep(), 並覆蓋run(), 使用時直接用start(),但有時不太方便通過繼承(extends)而進行多線程,例如已繼承了其它Class(Java 不允許多重繼承)時,就應該實現(implements) Runnable寫多線程程序。

注意,implements Runnable創建的只有run()方法而没有start(),因此要利用其它機制來啟動。這要創建兩個instances,第一個是Runnable的,第二個是Thread的,然後把第一個當成參數傳給第二個

例子:
private class RunnableThread implements Runnable {
public void run(){ // Runnable's run method
//do something while run

try {
//Static Method from Thread class, coz Runnable no such method.
Thread.sleep(100);
}catch (InterruptedException e)
{ }
}
}

Thread aRunnThread = new Thread(new RunnableThread());
aRunnThread.start(); //其中start()會調用runnable中的run()

==============
一般Thread寫法
private class GenThread extends Thread{
public void run() {
//do thread job
...
try{
sleep(300); //release cpu to do other job
}catch(InterruptedException e)
{.....}
}
}

//on other class to call it
Thread theGenThread = new GenThread();
theGenThread.start();

Sunday, June 19, 2011

vi

http://blog.csdn.net/linrui6/archive/2009/02/10/3875644.aspx

http://www.tuxfiles.org/linuxhelp/vimcheat.html

http://www2.nsysu.edu.tw/csmlab/unix/vi_command.htm

http://www.vixual.net/blog/archives/234

Friday, June 17, 2011

關於DNS 網文集

鳥哥
http://linux.vbird.org/linux_server/0350dns.php

nslookup 使用示例
http://faculty.ndhu.edu.tw/~comput/computer_c/training/hbc0122/dns-1.htm
http://tw.myblog.yahoo.com/chen_10220214/article?mid=890&next=832&l=f&fid=6
http://elouai.com/nslookup-reference.php
http://www.computerhope.com/unix/unslooku.htm

Trouble Shoot
http://www.microsoft.com/taiwan/technet/itsolutions/network/support/trblshoot/dnstshot.aspx?mfr=true

Ubuntu
Bind9安裝設置指南
http://wiki.ubuntu.org.cn/index.php?title=Bind9%E5%AE%89%E8%A3%85%E8%AE%BE%E7%BD%AE%E6%8C%87%E5%8D%97&variant=zh-tw

https://help.ubuntu.com/8.04/serverguide/C/dns-configuration.html

https://help.ubuntu.com/community/BIND9ServerHowto

Round Robin DNS records for web server load balance
http://mingwang0824.pixnet.net/blog/post/27709276
http://www.zytrax.com/books/dns/ch9/rr.html

TTL 值
http://www.zytrax.com/books/dns/info/minimum-ttl.html

Thursday, June 16, 2011

JQuery Mobile 網文集

JQM與google map
http://code.google.com/p/jquery-ui-map/

JQM 範例: 混合android apps運行的新聞閱讀器
http://mobile.tutsplus.com/tutorials/mobile-web-apps/jquery_android/

其它http://miamicoder.com/2011/interesting-jquery-mobile-tutorials/

自訂ICON
http://www.interactivebynature.net/blog/wordpress/2011.04.04.jquery-mobile-custom-icons

JSON
http://www.jquery4u.com/json/15-jquery-json-plugins/
http://tomcoote.co.uk/code-bank/jquery-json-suggestsearch-box/ 完整suggest search例子
http://www.ibm.com/developerworks/xml/tutorials/x-jquerymobilejsontut/index.html

JSONP 範例
http://www.ibm.com/developerworks/library/wa-aj-jsonp1/

JSONP 原理示例
http://www.jqueryload.com/jsonp-twitter-example-how-to-access-the-twitter-api-and-get-tweets-without-pass-through-the-server

Saturday, June 11, 2011

Debian root password reset

因為之前Debian不能正常關機而強制apci shutdown,今日再次開機原來的登入密碼報錯, 懷疑關時未正確保存. 據網上文章重設一次, 可正常登入.
貼文如下, 以備日後查找:
現在我們一般使用grub作為系統的引導程式,而lilo進入單用戶的方法很簡單,這裏就不提了。
對於一些版本的OS(如redhat)來說,編輯grub,在後面加上“single”即可進入單用戶模式。
但是對於debian來說,這種方式是無效的,因為debian進入單用戶模式也需要你輸入root用戶的密碼。

下面介紹一個在所有版本linux的grub上均可以使用的方法:

1、在Grub的引導裝載程式功能表上,選擇你要進入的條目,鍵入 “e” 來進入編輯模式。
2、在第二行(類似於kernel /vmlinuz-2.6.15 ro root=/dev/hda2 ),鍵入”e”進入編輯模式;
3、在句末加上”init=/bin/bash”,回車;
4、按“b”啟動系統。
這樣我們即可獲得一個bash的shell。

進入shell後,根分區的掛載模式默認是唯讀,我們要將其改為可寫,否則不能更改root密碼:

mount -no remount,rw /
passwd root
sync
mount -no remount,ro /
reboot
這樣即可成功更改debian的root用戶的密碼。
http://moto.debian.org.tw/viewtopic.php?t=11346

Monday, June 06, 2011

Collectd - Linux 操作系統狀態紀錄及圖示化安裝筆記

http://collectd.org/
http://wiki.debian.org/SystemMonitoring

開啟Plugin exec
<plugin exec="">
Exec user "path/to/myscript"
</plugin>
myscript 內容
#!/bin/bash
echo test message
now
在/var/log/syslog輸出如下
Jun 9 01:17:03 DBS collectd[10066]: exec plugin: Prepending `PUTVAL' to this line: Thu Jun 9 01:17:03 HKT 2011
Jun 9 01:17:13 DBS collectd[10066]: exec plugin: Prepending `PUTVAL' to this line: test message!


設定Collectd-exec示例
http://flux242.blogspot.com/2011/01/collectd-mod-exec-part-1.html

http://ubuntuforums.org/showthread.php?t=1479963

Mail list
http://dir.gmane.org/gmane.comp.monitoring.collectd

錯誤信息
collectd[4533]: mysql plugin: The `Port' config option needs exactly one string argument.
4.7版後 Port 3306
4.6版後 Port "3306"


停止apache2 Log檔記錄
因每十秒在/var/log/apache2/access.log產生一行紀錄如下
localhost - - [19/Jun/2011:07:00:13 +0800] "GET /server-status?auto HTTP/1.1" 200 477 "-" "collectd/4.8.2"
apache2 log 可據條件進行記錄,將以下加入/etc/apache2/sites-available/default設定檔中
# Mark requests from the loop-back interface
#SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog #來源IP, 没使用, 免影响記錄其它本機的請求
#SetEnvIf Remote_Host "localhost" dontlog #來源主機名, 没使用
SetEnvIf User-Agent "collectd/4.8.2" dontlog #User-Agent 為Collectd, 不記錄.
#SetEnvIf Request_URI "^/server-status" dontlog #未知是否成功.
CustomLog /var/log/apache2/access.log combined env=!dontlog

!!以上需在/etc/apache2/sites-available/default中註去CustomLog /var/log/apache2/access.log combined, 否則只接受最後者設定

試過在apache2.conf加入上設定, 但會視為other virtualhost 的紀錄
而混進(包括default的log!!)/var/log/apache2/other_vhosts_access.log

CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
互相干擾, 故SetEnvIf的CustomLog不放在apache2.conf中.

Debian sources.list 使用舊版軟件

以前使用的hk.debian.org改了sources.list不能用,後來 亂改用了一段十分長的時間, 雖然可用但還是會收到一些軟件包錯誤提示,近日發現原來放置軟件包的目錄結構改動了,應改是早几年已改,主要原因是我OS依然使用舊版本(5.0乃至4.0)且好長一段時間没有升級。但設定上卻使用stable main (當前最新) deb http://ftp.hk.debian.org/debian/ stable main contrib non-free

新的目錄結構是把一些舊的版本Deabian 放在oldstable。設定如下:
deb http://ftp.hk.debian.org/debian/ oldstable main contrib non-free (後面兩類按需)
另外Debian社群為一些使用舊版系統但希望使用新版軟件包的提供了一個方法和網站,詳見:
http://backports.debian.org/

collectd 安裝筆記
原來Debian 5.0 lenny所附collectd為4.4太舊,想安裝5.0(只有源程序),查找軟件包列表只有4.10只不屬於lenny,不允許安裝。
先修改sources.list 只有一句如下:
deb http://backports.debian.org/debian-backports lenny-backports main
運行apt-cache showpkg collectd 可顯示軟件包版本和資訊
Package: collectd
Versions:
4.10.1-1+squeeze1~bpo50+1
...
安裝特定版本軟件包apt-get install package_name=version
apt-get install collectd=4.10.1-1+squeeze1~bpo50+1

注:collectd安裝後在/var/log/syslog顯示部份lib(lt_ldopen: mysql.so 等 file not found, 要自己動手
再安裝一些如libmysqlclient16(又依賴mysql-common ver.5.1.49-3~bpo50+1 )
http://collectd.org/faq.shtml

Sunday, May 08, 2011

PHP分界符 <<< 與 Parse error: parse error, unexpected T_SL

分界符可以免卻處理'及"等的麻煩,用法需注意事項
1. <<< TEST後不可含空格及其它
2. 結束TEST必需於行頭
$longtext <<< TEST
< html >
有'及"情況
斜/及反斜\
含PHP變量{$phpvar}
........
< /html >
TEST;

Friday, May 06, 2011

Google kml structure and format for Eclipse Andriod Emulator Control

Eclipse Android Emulator Control accepts below structure of a KML file, this file must saved as ANSI format. This example file is convert from GE2ADT.
P.S remove the underscore in the xml tag before use.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<document>
<name>GE2ADT</name>
<placemark><name>0</name><description>GE2ADT Route</description><point><coordinates>113.546133,22.20166,550.000000</coordinates></point></placemark>
..........
<placemark><name>0</name><description>GE2ADT Route</description><point><coordinates>113.547218,22.200682,-25.000000</coordinates></point></placemark>
</document>
</kml>

Tuesday, May 03, 2011

"var" or not "var", that is the question @javascript

又一次在javascrit 中遇到因為變量範圍而苦惱了几日(對上是年多前做GP1,首次體會到var的影响, 但無寫低, 唔記得詳細code)
今次又是google map下(api v3) 引用一個例子略加修改, 目的想加一個infowindow(一開始彷照 var center_market 建立), 然後過一段時間自動關閉(setTimeout()), 但總是出現"infowindow is undefined", 經過嘗試, 想信是variable scope問題, 用第一種程序編寫 "//@@"部份, 把 infowindow 變成全域變量, 讓setTimeout可以找得到, 但就結構而言, 會較混亂. 於是試第二種(下面程序未註的碼). 這種較符合原來的結構, 且較清晰( 雖然infowindow 依然是全域變量). 關鍵在於建立infowindow = new google.map.InfoWindow();時, 勿加入var (本域變量Local Variable). 但奇怪的是同樣的center_mark卻没問題, 難道是之後没有引用
另外在測試期間, 在各處加入"this", 但無助解決問題.

程序如下:((大致結構)
<_script>
//@@ var infowindow = new google.map.InfoWindow();
function DistanceWidget(map){
//一開始彷照 var center_market 建立
var center_marker = new google.maps.Marker({ ... });
// Bind the marker map property to the DistanceWidget map property
center_marker.bindTo('map', this);
....
....
//設為全域變量,不可在之前加var, 否則找不到.
infowindow = new google.maps.InfoWindow();
inforwindow.setOption(....); //在DistanceWidget()內不可加this,
infowindow.open(map, center_marker);
....
} //end DistanceWidget();
DistanceWidget.prototype = new google.maps.MVCObject();

//新加的method
DistanceWidget.prototype.autoclose_info = function(){
setTimeout("this.infowindow.close()",20000); //加不加this, 無影响.
}

function init(){
....
....
distanceWidget = new DistanceWidget();
distanceWidget.autoclose_info();
//@@ setTimeout("distanceWidget.infowindow.close()", 20000);
//@@即使用OO語法寫明distanceWidget都是"is undefined"
} //end init();

google.maps.event.addDomListener(window, 'load', init);

//@@ setTimeout("infowindow.close()", 20000);
<_/script>
other html code

http://code.google.com/intl/zh-TW/apis/maps/articles/mvcfun.html

http://www.mredkj.com/tutorials/reference_js_intro.html#scope

Thursday, April 14, 2011

MySql及PHP 中文設定

mysql> status;
--------------
mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (i486) using readline 5.2
Connection id: 226
Current database: taxi
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.0.51a-24+lenny4 (Debian)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1

UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 1 day 41 min 6 sec
Threads: 1 Questions: 1068 Slow queries: 0 Opens: 665 Flush tables: 1 Open tables: 64 Queries per second avg: 0.012
--------------

原本粗體全部為latin1, 用alter database db_name collate utf8_unicode_ci;
Db Characterset變為utf8.

用set names uft8;則Client 及 Conn. Characterset 都變為utf8

寫的PHP網頁由DB提取中文字出現問號, 在mysql console 下亦以問號(同debian無裝中文有關).phpmyadmin下insert 同select 都可以正常顯示,create table 時已加character set = utf8, 尚在處理中...

試左一輪, 响mysql同php連線前用mysql_query("set names utf8;");則之後的query 的中文正確顯示不再出現問號

參考以下几個網頁

資料庫內,某個 table 內某個 column 的 collation 錯誤造成無法儲存中文
http://0rz.tw/6NWaF

MySQL中文編碼徹底研究 *有點舊,但中文原理講得詳細
http://tw.myblog.yahoo.com/waian-950604/article?mid=1631&prev=1636&next=1630

mysql插入中文出乱码
http://www.nowamagic.net/database/db_CharsetPrinciple.php

让MYSQL彻底支持中文(slack10.1版)
http://slack.linuxsir.org/main/?q=node/165

MySQL參考手冊 第10章:字符集支持
http://dev.mysql.com/doc/refman/5.1/zh/charset.html

9.1.4. Connection Character Sets and Collations
http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

php 解决乱码的通用方法
http://blog.51yip.com/php/572.html

InnoDB 匯入時關閉 Foreign Key 檢查及支援UTF8 (在SQL滙入的文件中加入)
http://jax-work-archive.blogspot.com/2009/07/innodb-foreign-key-mysql.html
SET FOREIGN_KEY_CHECKS = 0; //0 turn off
SET NAMES 'UTF8';

mysqldump & mysql command for UTF-8 database
http://jax-work-archive.blogspot.com/2011/01/mysql-mysqldump-mysql-command-for-utf-8.html

utf8中文编码范围
詳細介紹UTF8中文及原理及例子
http://www.sphinxsearch.org/archives/40