# Host two or multiple wordpress sites on 1 server

I have wrote about How to setup wordpress on Andrew File System(AFS) @ CMU. a while ago (two years ago). Now I am beginning to set up a second wordpress for a project. Actually you can put two or more wordpress sites on 1 server with 1 sql Here's how:

Download the tar and extract. Put stuff (sql database user name, password, etc) into the wp-configure.php. Now you run install.php can it will say that wordpress already installed.

The trick is to change the the follow in the wp-config.php  (around line 62)

$table_prefix = 'wp_'; Change prefix wp_ to whatever and then you can run install.php and have your 2nd wordpress. # 拱猪要拱几张Q 癸巳仲秋，出游，打拱猪。与道伴论： 从107张牌里拱出一张牌(猪牌Q)更难，还是放两张猪(Q)在牌堆里拱出两张更难。 这里说的拱是指输家的惩罚，我们一般是要求输家用鼻子从牌堆里拱出猪牌。我们玩的是两副牌的，所以一共108张牌。现在讨论两种情况的难易。 Scenario 1) 107张牌里放着一张黑桃Q。另一张黑桃Q放一边，所以是107张牌。 Scenario 2) 108张牌里两张黑桃Q。要全用鼻子拱出来。 我们假设是一张一张拱。就是说不允许一下子把牌打算然后从桌面上找出猪牌。 要计算1和2情况的难易，首先想到是概率，比如说情况1下，抽中猪的概率1/107。情况二下抽中猪的概率是2/108。 但是很快就发现，这样太naive了。我们真正要计算的是Expectation，就是在1和2下吗，预期要多少步抽到所有猪牌(黑桃Q)。所以就是比 $E(X)$$E(Y)$ 的大小。小的更容易。 $X$ = number of steps need to find spade Q in a deck of 107 cards containing 1 single spade Q. $Y$ = number of steps need to find the second spade Q in a deck of 108 cards containing two spade Q. 然后我试下了 $E(X)$$E(Y)$ 的展开。就是 $E(X) = \sum_{X} X * P(X)$ 。然后发现 $E(X)$ 容易。 $E(X) = (1+107)/2 = 54$ .然后 $E(Y)$ 是个无底洞，然后我放弃了。 所以，现在唯一要解决的问题是怎么算 $E(Y)$ 还有种想法是， $E(Y)$ 中的Y，这个random variable，可以看成是第二张猪牌在牌堆中的位置。这样，求 $E(Y)$ 就等于求他的Expected position. 这样好像比把Y看作number of steps要容易些。想了下，操作起来还是难。 最后种想法是， $E(Y)$ 中的Y，这个random variable，可以看作是从108个数中(1,2,3 ... 108)，挑出两个数中那个大的数。这个是基于上面position想法的。但是一旦换成108数中抽二取大，马上映入我脑海的是一个叫做德国坦克问题的有趣的数学问题。 关于这个德国坦克问题的种种历史和解法，可以参阅维基。大致是说，二战时，某战场上有一支德国的坦克部队，盟军想知道它有多少辆坦克。一次战役后，盟军捕获了5辆坦克，它们的序列号分别是20,31,43,78,92。假设德国人给坦克的编号是从1开始1,2,3,4..这样的，问，求： 基于20,31,43,78,92， 推测这支坦克部队到底有几辆坦克。 这个问题有意思，还很有实际意义。 具体的解法是。。。有很多种。一个比较常见和简单的是叫 minimum-variance unbiased estimator (MVUE). 具体推演看维基去吧。这里直接给计算公式。 $\hat{N} = m (1+\frac{1}{n})+1$ 其中 $\hat{N}$ 是你要求的坦克数， $n$ 是你捕获的坦克数， $m$ 是你捕获的坦克中编号最大的那个的编号。所以上边那个例子的解就是： $\hat{N} = 92 (1+\frac{1}{5})-1 = 109.2$ 现在回到我们的拱猪问题的简化问题：求 $E(Y)$$E(Y)$ 中的Y，这个random variable，可以看作是从108个数中(1,2,3 ... 108)，挑出两个数中那个大的数。这样正好就是德国坦克问题的反问题。知道总共有几辆坦克(108)，知道捕获了几辆坦克(2)，求捕获坦克中编号最大的那个。所以由 $\hat{N} = m (1+\frac{1}{n})-1$ 我们可以得到 $\hat{m} = n\frac{N+1}{n+1}=\frac{2}{3}(108+1)=72.667$ 所以 $E(Y)$ = 72.667 ，比 $E(X)$ = 54大不少，所以还是拱一张更简单些。 Run了100000个simulation。果然如此。mean of Xs = 54.03, mean of Ys = 72.67 最后非常郑重地说下。关于MVUE的estimator从 $\hat{N}$ 到反问题的 $\hat{m}$ 是不是直接能这样反转我其实根本不确定。没仔细想过。凭着直觉觉得是可以这么倒过来的。记得以前做过类似的题，好像是可以倒过来的。仅此而已。 # Fight with Margaret in Persona 4 Golden (PS Vita) In Persona 4 Golden (P4G), there's this golden trophy for defeat the hidden ultimate boss Margaret, see Trophy One Who Has Proven Their Power. I Googled and found that several sources (such as this one) seem to indicate that, in order to get the invitation (Aqua Invitation) from Margaret for the battle with her, one of the pre-requisite is that you need to defeat all the optional bosses (those boss in all dungeons that you have already cleared for the 1st time in the story plot.) by December 3. But actually, the latest time/ chance for fulfilling that is February 13 when you were in the ski trip Dungeon (the one with Marie). Also, remember that you can only obtain the Aqua Invitation from Margaret after you talked to Igor and received the Orb of Sight, and before talking with the gas station attendant. So the steps are: (1) get the Orb of Sight (2) get out and re-enter the Velvet Room (3) Receive the Aqua Invitation (4) talk to the attendant. Hope this helps. # Persona 4 Golden (PS Vita Game) I was playing Persona 4 Golden (P4G) for the whole May, and finally got the Platinum trophy. Quite a wonderful game. Highly recommended. Best PS Vita game so far. Here are some screen shots I took in the game. # My All Time Favorite Games Saw Diablo 2 battlechest dropped to$9.99 today. Guess it's time to make my ATF games list.

1. Diablo2 (with LoD expansion pack)
2. Horeos of Might and Magic. (with 2 expansion packs)
3. Might and Magic 6
4. 金庸群侠传
5. 炎龙骑士团
6. Fallout 2
7. God of War
8. Gears of War
9. Final Fantasy VI
10. DOTA 2

Some runner ups: Starcraft 1, Red Alert, CS, Pokemon Green, 第二次超级机器人大战, 侍魂4，New Super Mario Bros DS，FF8，真三国无双3. NFS:Underground2, Sleeping Dogs

Definitely not in the list : 仙剑奇侠传。

# How to run a program/script when windows shutdown

I need to run a script to record something whenever windows shutdown.Here's what I found. I am running windows 7, but I believe the following should work for other recent versions as well.

Step1: In windows7, open the Local Group Policy Editor via running gpedit.msc. (You can use win+R to call up the "Run" window and then type gpedit.msc and click OK)

Step2: In the left panel of Local Group Policy Editor, Navigate Local Computer Policy --> Computer Configuration --> Windows Settings --> Scripts (Startup/ Shutdown), then double click Shutdown on the right hand side panel

Step3: Add the script...

# grabbed a Logitech m510 mouse

I got one Logitech m510 mouse to replace my two year old compact size m305.
The m510 is a full size mouse, and it feel great with my big hands. The side button is particularly handy, with the "bump up" shape design.
Side buttons are always not so handy to me as my thumb doesn't have the necessary agility to press them efficiently. I have two mice with side buttons: The Logitech performance MX, and CM Storm Xornet Gaming mouse. Both are great mice and I love them, however, the side buttons on those two are almost useless to me. Now with m510, i finally begin to see the greatness of having size buttons. I can see how they will become useful in DOTA2 with I assign item shortkey to them. XD.

# AHCI vs "native IDE" mode

Just noticed that the SSD on my new build 2 days old desktop is actually running on "native IDE" mode, as shown in the BIOS, south bridge configurations (motherboard: biostar A75MG). The SSD drive was that Kingston HyperX 3K 120G I mentioned in the previous post. I did some google and it turns out that  the "native IDE" mode is not recommended for SSD, while AHCI should be the choice. Hence I changed it to AHCI, can not get into windows. After more googling and I found this and followed the procedures described there and everything works out just fine. I re-ran the benchmark using CrystalDiskMark for the SSD to see if there 's any performance improvement for AHCI over IDE, and here's the strange thing.

The left one is on "native IDE" and the right is AHCI . The reading performance is greatly improved (esp. the random 4k QD32), while the writing seems to get worse. That's really strange, and I don't have a good explanation for that. But ... the loading and system overall performance is more related to the random small reading, thus I am indeed (with conservation) satisfied that I changed to AHCI.

Update: Nov/8/2012: Windows Experience Index (WEI) jumped from 7.6 to 7.9 (max) when changed to AHCI mode in bios.

# SSD drives

Finally I got myself into the SSD hunting safari, and got my two SDD drive:

# Kingston HyperX 3K 120 GB SATA III   [link]

I have tried them both on my 3 years old Thinkpad X200s, which have SATA II interface. Here are the benchmarks by crystalDiskMark:

From Left to Right: my 7200RPM SATA2 HDD; Intel X25-M 80G SATA2, Kingston Hyper X3 SATA 3 on SATA2. Even though both works on SATA 2 machine, the SATA 3 one seems to outperform the SATA 2 SSD. Also, you can see the huge difference between SDD and mechanical HDD, especially for benchmarks on 4k random access