Archive for the 'Programming' Category

memcache.php stats like apc.php

on Wednesday, May 21st, 2008

For a long time I was looking for a nice web interface like the apc.php (comes with the apc’s source) that displays whole nine yards of stats. The only good tool is memcache-tool from the danga guys. It’s quite complete but I guess I’m too lazy to go on the command line.

Anyways, I decided to rip write my own. Totally based on the original apc.php (I even recycled some functions) and apart from completeness, here is a memcache.php that you can get stats and dump from multiple memcache servers.
Here is a screenshot:
Read more…

PHP APC apc_shm_create error on CLI

on Tuesday, March 11th, 2008

If you’re getting an error like this one below on Windows PHP commandline make sure that you are not running an apache server that uses apc on the same machine!

[apc-error] apc_shm_create: shmget(0, 8388608, 658) failed: No error. It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of 32MB per segment.

This was hard to figure! Tested with PHP 5.2.5, APC 3.1.0-dev.

Black box or unit testing

on Saturday, November 24th, 2007

Nobody denies the benefits of testing and especially unit testing.
However I’m still having hard time understanding the baised testing methodology of phpunit or other automated unit testing frameworks.

In test driven development, programmer writes a test then fills in the code to make the test pass. I find this extremely baised.
Alternatively, I find coding baised test cases that can cover the code 100% gives the developers a false sense of safety. This is rather a phylosophycal discussion than practical.

For complex scenarios of testing, can unit testing cover everything efficiently? How efficient is to find and write the correct test cases that test everything throughly? Does any company have the time and money for this (or they are willing to pay for their testers to write code for 100% coverage) ?

I really like the idea of php unit and automated tests. However for web, I’m still for the black box testing, if there is a good way of analysing the efficiency of blackbox tests.
Feel free to comment.

Updated: typos

Full text index and other complex indexes together

on Monday, April 30th, 2007

Always remember, if you’re using MyIsam tables, KEEP THE INDEX AS SMALL AS POSSIBLE.

That means, your full text index will be huge and you don’t want to keep them together with other types of index for faster queries.

Simply create another table to have the text fields and full text indexes and left join. It works way faster for me on a table with 230K rows.

Data take about 500MB and the indexes take about 700MB. I don’t think I over indexed the table because of the delicate business logic. Even for a simple 1 field query (with normal index on it) it was taking more than 30secs. I removed the table with out the full text indexes and now it takes 1 sec.
Wow, a good thing to remember. A mental note to myself again.

Thoughts Aside:
The process of data security is the best computer backup solution and it is the way of ensuring that backup computer files are kept protected from corruption with free software and that access to it is properly controlled on a back up server. It also facilitates the process of online file sharing. The globalization of data recovery hardware networking is a facility with the help of which your stock can be sourced from anywhere in the world by doing up with your online storage.