migrate wordpress from sub-directory to root and update Permalinks
Migrage from www.hang321.net/blog to www.hang321.net
1. backup
tar zcvf blog.`\bin\date +%Y%m%d`.tar.gz blog/
2. Move
mv * ../
3. edit wp_options table
LIKE %hang321.net/blog%
manually replace to hang321.net/ (could be done by sql too, but only couples of entries to modify)
4. change permalinks
change from ‘Numeric’ to ‘Day and name’, all links broken, especially from Google.
find a plugin, called permalinks-moved-permanently, generate a “301 Moved Permanently” to keep its pageRank
Not work because it look for postname, manually edit the query from post_name to ID
if( $ID = $wpdb->get_var( 'SELECT ID FROM '.$wpdb->posts.' WHERE ID = "'.$slug.'" AND post_status = "publish" ' ) ) {
Done!
Further Reading:
Moving a WordPress blog from a sub-directory to the root directory
http://www.rentablogger.com/blog/2009/01/23/moving-a-wordpress-blog-from-a-sub-directory-to-the-root-directory/
Permalinks Moved Permanently
http://wordpress.org/extend/plugins/permalinks-moved-permanently/
星期二
星期二晚時間過得特別快,
因為有Chuck + 24 + Heroes + .Big.Bang.Theory
thanks to eztv & tpg, super fast to get it, within 1 hour
Snow Leopard 一波十折, 由於年老的小黑老黑只是single layer DVD,
不支援 dual-layer, 7.xGB 的dmg file 只好另找方法
在升級10.6 Snow Leopard之前,整理、備份!http://www.macuknow.com/node/1696
Upgrade to Snow Leopard without a CD drive?http://superuser.com/questions/35108/upgrade-to-snow-leopard-without-a-cd-drive
系統預設的中文字體給換掉
http://www.macuknow.com/node/1716
Boot Camp Assistant: “Your startup disk cannot be partitioned…”
Use iDefrag (google it)
How-To Extract the Boot Camp Drivers from the Mac OS X v10.5 Leopard DMG
http://www.insanelymac.com/forum/index.php?s=b37944dc68dd657b4e015a5e73cc068a&showtopic=71519&view=findpost&p=1166208
Raw Disk with VirtualBox, Win7 host, ubuntu guest
reference:
http://virtualization.sysprobs.com/access-physical-disk-virtualbox-desktop-virtualization-software
http://vbox.innotek.de/pipermail/vbox-users/2009-August/006868.html
http://ubuntuforums.org/showthread.php?t=951588
http://www.supergrubdisk.org/w/index.php5?title=Howto_Boot_Linux_only
Background:
Host: Windows 7 Ultimate 64 bit
Guest: ubunut 9.04 64 bit
VirtualBox: 3.0.8 (someone report 3.0.10 fail to access raw disk,maybe fix on .11/.12)
Harddisk: 4 virtual disks on LSI 8344ELP RAID controller
Disk /dev/sda: 42.9 GB, 42949410816 bytes
Disk /dev/sdb: 64.4 GB, 64424509440 bytes
Disk /dev/sdc: 763.7 GB, 763726135296 bytes
Disk /dev/sdd: 85.8 GB, 85899214848 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5220 41929618+ 7 HPFS/NTFS
/dev/sdb1 1 7832 62910508+ 7 HPFS/NTFS
/dev/sdc1 2 92850 745809592+ f W95 Ext’d (LBA)
/dev/sdc5 2 84853 681573658+ 7 HPFS/NTFS
/dev/sdc6 84854 92850 64235871 7 HPFS/NTFS
/dev/sdd1 1 10013 80429391 83 Linux
/dev/sdd2 10014 10443 3453975 5 Extended
/dev/sdd5 10014 10443 3453943+ 82 Linux swap / Solaris
Create virtual disk for VirtualBox (VB)
- Manual, default at C:\Program Files\Sun\VirtualBox\doc, section 9.10 Using a raw host hard disk from a guest
- list all drive to ensure it drivename, e.g. PhysicalDrive[#|0,1,2,3]
C:\Program Files\Sun\VirtualBox>vboxmanage internalcommands listpartitions -rawd
isk \\.\PhysicalDrive0VirtualBox Command Line Management Interface Version 3.0.8
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
Number Type StartCHS EndCHS Size (MiB) Start (Sect)
1 0×07 0 /1 /1 1023/254/63 40946 63
- create rawdisk, e.g linuxhost.vmdk, winxp.vmdk…. , mkdir first if required.
(for me, I need to create all 4 drives, don’t know why, I expected only 0,3)
C:\Program Files\Sun\VirtualBox>vboxmanage internalcommands createrawvmdk -filename c:\Users\{YourUsername}\.VirtualBox\HardDisks\linux.vmdk -rawdisk \\.\PhysicalDrive3
VirtualBox Command Line Management Interface Version 3.0.8
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
RAW host disk access VMDK file c:\Users\{YourUsername}\.VirtualBox\HardDisks\linux.vmdk created successfully.
- Run VB as administrator (this make me confuse too, I am power user…yet, UAC isn’t turn off)
- Virtual Manager > add those created virutal disk files (*.vmdk)
- create a new virtual machine
System: uncheck “Enable IO APIC”
Harddisk:
Enable additional controller: SCSI (LsiLogic)
|
Hard Disks |
||
|
SCSI Port 0: |
winxp.vmdk (Normal, 40.00 GB) |
|
|
SCSI Port 1: |
win7.vmdk (Normal, 60.00 GB) |
|
|
SCSI Port 2: |
windata.vmdk (Normal, 711.28 GB) |
|
|
SCSI Port 3: |
linux.vmdk (Normal, 80.00 GB) |
|
N.B. : only add winxp.vmdk & linux.vmdk, blank screen with (00:00:03.291 Guest Log: BIOS: Booting from Hard Disk…) on VB log (right click VM, show log..)
- turn on VM, with 4 drives, now got GRUB 21 error.
good, at least it got the disk now….
- download Super GRUB disk, mount it as CD-ROM
follow this link:
http://www.supergrubdisk.org/w/index.php5?title=Howto_Boot_Linux_only
unmount, reboot, RORA !
- one more thing, install linux Guest Additions, manual section 4.3
sudo sh ./VBoxLinuxAdditions-amd64.run
Java Quick Starter
http://www.java.com/en/download/help/quickstarter.xml
Java Quick Starter (JQS) improves initial startup time for most Java applets and applications. This feature was added to Java in release Java SE 6 update 10 (6u10) and will be available in all future releases.
Steps to disable Java Quick Starter:
- Click Start.
- Click Control Panel.
- Double click on Java Control Panel.
- Click Advance tab in Java Control Panel.
- Scroll to Miscellaneous entry and Expand.
- Uncheck the check box for Java Quick Starter.
- Click Ok and restart the system.
呢個 evil 既 jqs.exe 只會影響 winxp /win2000 既users, 因為vista 已經有pre-loading mechanism
用java 做development 時完全唔覺得 load 個 eclipse 會快d …
但好多時屋企pc 唔係做野但不停 pre-fetch 做 I/O 同send data 出internet ,
仲要唔知點解同唔知send 去邊 (雖然我冇查清楚….)
總之就係佢 trigger wg111v2.exe (wireless usb 既 software) 而令到我誤會個software 寫得唔好, 有咁多I/O
6u10 係 Oct 15, 2008 relase
WL-500W flash DD-WRT
因為懷疑 Wireless USB adapter 附送的software 不斷有I/O, (最後證實兇手係jqs.exe)
買了一個wireless router 行wireless bridge mode 取代 usb adapter
條件:
1. 802.11 g / n
2. 有USB port
3. 8 MB flash memory
bonus:
1. gigabit ethernet
2. > 32MB ram
http://www.dd-wrt.com/wiki/index.php/Supported_Devices
Linksys WRT350N v1 同 WRT610N 是個很好的選擇, 可惜售價太貴,
所以還是 Asus WL-500W, AUD$109, + $12 shipping
[事前必讀] http://www.dd-wrt.com/wiki/index.php/Installation#Asus_WL500W
可到google 找多些information 才開始
(其實…..我都係analytics見到不時有人google 而誤入我呢個blog, 我先打算寫返個details d 既記錄)
@2009-03-30 wiki 提議用 dd-wrt.v24-11650_NEWD_mega.bin
2008-09 試個 v24 也可. 當然, 有新的firmware 應該/理論上 少些 bugs
- platform
小弟不才, 還是windows 比較熟手, 所以在 winxp 上flash.
- 事前準備
download firmware:
wl500g-clear-nvram.trx
wl500g-recover.trx
Mini-Asus.trx dd-wrt.v24-11650_NEWD_mini_asus.trx
dd-wrt.v24-11650_NEWD_mega.bin
install tftp software
1. 保留電腦與500W 的LAN線,移除所有其他的LAN線
2. 停用所有網絡(透過ASUS Firmware Restoration 升級一定要做這個動作)
3. 指定 NIC IP 192.168.1.2 ( 2-254 皆可)
subnet mask: 255.255.255.0
(optional) default gateway: 192.168.1.1
(optional) DNS: 192.168.1.1
4. 開啟Dos (windows key + R) > cmd > ping 192.168.1.1
(optional) 到 http://192.168.1.1
5. 先深呼吸, 真正的工作開始了 (著名的 30/30/30 法則)
(NB. 1 半年前我試過沒有用 wl500g-clear-nvram.trx , 直接跳去 wl500g-recover.trx, it works
不過穩妥點, 還是 clear nvram )
按住 restore 按鈕不放 (黑色那個, 不是紅色的), 等待約30秒
將WL-500W 的電源拔掉, 再等待約30秒 (其間依然按住 restore ),
再將電源接上,見到WL-500W 的電源燈閃爍, 等待約30秒, 此時可以放開 restore按鈕
6. 拔掉電源, 按住 restore 按鈕不放, 再將電源接上,見到WL-500W 的電源燈閃爍, 放開 restore按鈕
7. 執行TFTP, PUT wl500g-clear-nvram.trx 到router

8. 等 2-3 mins, 再執行 step 5 & 6
9. TFTP, PUT wl500g-recover.trx 到router

10. 再等 2-3 mins, 執行 step 5 & 6
11. TFTP, PUT Mini-Asus.trx dd-wrt.v24-11650_NEWD_mini_asus.trx 到router

12. 再等 2-3 mins, 執行 step 5 ( step 5 only!)
13. 拔掉電源, 等待數秒, 再將電源接上, 然後到 http://192.168.1.1 
14. 改password , 再到 administration > firmware upgrade
選擇 dd-wrt.v24-11650_NEWD_mega.bin , 再按 upgrade 
此時此刻只有一樣東西可以做, 就是等 !!
300 second 不足夠 for mega build, 如果此時拔掉電源, wl-500w 就會死掉
16. 見到 upgrade successful , 等多一會, 做最後一次 30/30/30 (step 5)
拔掉電源, 等待數秒, 再將電源接上, 然後到 http://192.168.1.1
17. 最後改回 NIC 做自動取得 IP, DNS
Domino Web Access – font size
problem:
font size too small
fix:
Open Form7.nsf in Designer > Shared Resources > Files > h_ShimmerSkin-h_StyleSheet
> Open With … (3rd party text editor)
Replace all: x-samll to small , xx-small to x-small
Save and exit text editor
Click Refresh in Designer, select ~h_ShimmerSkin-h_StyleSheet
> tell http quit
> dbcache flush
> load http
MySQL chinese support
http://mysql.chinahtml.com/2005/1125321683.shtml
MySQL — inline edit chinese character
1. stop MySQL service
2. open my.ini
3. change default-character-set of [mysqld] and [client] as utf8
4. launch mysql
5. create table as default or select tuf8
6. enjoy ~
Improve performance on Dual Core CPU
Microsoft提供這個修正程式(KB896256),讓核心電源管理員能夠追縱整體處理器的使用率,而非單一核心,使得應用程式的最佳頻率得以被計算出來。在這之後,即使執行緒仍在跳動,是否要降低處理器頻率,將視整體處理器(包含所有核心)而定,而非單一核心。
MySQL Master Master replication
A. background
OS: CentOS 4.4
MySQL package: 4.1.20-1.RHEL4.1
node1: 192.168.0.131 (Master 1/Slave 2)
node2: 192.168.0.132 (Master 2/Slave 1)
mysql path: /var/lib/mysql
mysql config file: /etc/my.cnf
reference:
http://www.howtoforge.com/mysql_master_master_replication
http://cha.homeip.net/blog/archives/2004/12/replication_in.html
B. procedure
1.
On Master 1, make changes in my.cnf
#vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
#replication
log-bin
binlog-do-db=horde
binlog-ignore-db=mysql
binlog-ignore-db=test
server-id=1
[mysql.server]
user=mysql
basedir=/var/lib
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
2.
On master 1, create a replication slave account in mysql.
#mysql -u root -p
mysql> grant replication slave on *.* to ‘replication’@192.168.0.132 identified by ‘slave’;
mysql> exit
and restart the mysql master1.
#service mysqld restart
3.
Now edit my.cnf on Slave1 or Master2 :
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
old_passwords=1
server-id=2
master-host = 192.168.0.131
master-user = replication
master-password = slave
master-port = 3306
[mysql.server]
user=mysql
basedir=/var/lib
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
4.
Restart mysql slave 1 and check config at
#service mysqld restart
#mysql -u root -p
mysql> start slave;
mysql> show slave statusG;
ensure Slave_IO_Running and Slave_SQL_Running: must be to YES.
mysql> exit
5.
On master 1:
mysql> show master status;
+————————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+————————+———-+————–+——————+
|MysqlMYSQL01-bin.000008 | 79 | horde | mysql,test |
+————————+———-+————–+——————+
1 row in set (0.00 sec)
The above scenario is for master-slave, now we will create a slave master scenario for the same systems and it will work as master master.
6.
On Master2/Slave 1, edit my.cnf and master entries into it:
#vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
server-id=2
master-host=192.168.0.131
master-user=replication
master-password=slave
master-port=3306
log-bin #information for becoming master added
binlog-do-db=horde
[mysql.server]
user=mysql
basedir=/var/lib
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
7.
Create a replication slave account on master2 for master1
mysql> grant replication slave on *.* to ‘replication’@192.168.0.131 identified by ‘slave2′;
8.
Edit my.cnf on master1 for information of its master.
#vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
#master
log-bin
binlog-do-db=adam
binlog-ignore-db=mysql
binlog-ignore-db=test
server-id=1
#information for becoming slave.
master-host=192.168.0.132
master-user=replication
master-password=slave2
master-port=3306
[mysql.server]
user=mysql
basedir=/var/lib
9.
Restart both mysql master1 and master2.
On mysql master1:
mysql> start slave;
On mysql master2:
mysql > show master status;
On mysql master 1:
mysql> show slave statusG;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.132
Master_User: replication
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: Mysql1MYSQL02-bin.000008
Read_Master_Log_Pos: 410
Relay_Log_File: Mysql1MYSQL01-relay-bin.000008
Relay_Log_Pos: 445
Relay_Master_Log_File: Mysql1MYSQL02-bin.000008
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 410
Relay_Log_Space: 445
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 103799
1 row in set (0.00 sec)
ERROR:
No query specified
make sure its running.
Now you can create tables in the database and you will see changes in slave. Enjoy!!
IE7 FrameSet
Try to fix IE7 frameset these days….. target on right frame but new windows popup. FF2 and IE6 no problem.
Env:
IE7 + TreeView js
Sol:
Internet Options > Security > Custom Level > Miscellaneous
ENABLE Navigate sub-frames across different domains
————————-
That’s it…. waste time to find out this suck problem in IE …
Here is some reference:
About Cross-Frame Scripting and Security
What does the IE “Access is Denied” error mean?
Useful tools in IE to debug:
Internet Explorer Developer Toolbar Beta 3
DOM Inspector for IE
HttpWatch












