Archive for the ‘Programming’ Category


I use textmate as my main php editor for mac. Once you get used with it, it will increase your productivity. Unfortunately, textmate doesn’t work with php very well out of the box. You must configure it and use the custom php bundle.

Here is how to get the custom bundle.

1) Open terminal

2) Execute the following commands:

?Download c1
mkdir -p /Library/Application\ Support/TextMate/Bundles
?Download c2
cd /Library/Application\ Support/TextMate/Bundles
?Download c3
svn co http://svn.textmate.org/trunk/Bundles/PHP.tmbundle

If you have textmate running, try to reload the bundle. You will see a new PHP bundle.

trac1

Subversion (svn) is a source control management tool. Each time we have finished with a certain task, we will need to commit our work (files and folders) to svn server. Each commit, the svn server will record the log and give a revision number. So in a simple use, we always have a backup of each revision. We can always back to any revision number and never lost our work.

The other use of svn is for a team collaboration. Each team member can change any files without worrying to overwrite other team member work. Svn can automatically merge modified files by other team member. With the revision log, project manager can easily track the progress and performance of each team member.

One of the common use of subversion is to get the difference between revision. This difference is important to create a patch. In web development, like in PHP script, patch is important for users so they do not need to re-upload and reinstall everything from the beginning again. Just apply the patch and run an upgrade sql query.

Okay, back to the difference / patch, here is what I usually do with svn and trac.

1) Go to trac page, browse source, and visit the main folder. Then click revision log.

2) Select the revision number, start from which number and end from which number. Click View change.

select revision number to create diff

3) Scroll down until end of file, click Zip Archive

Download zip archive

Today I need to add suffix to my css codes. Unfortunately I’m too lazy to do this repeated task again and again. With PHPDesigner, I tried to automate this task and with a little knowledge of regular expression now the problem is solved.

A quick explanation of regex that I use:

^\.([a-zA-Z\-]*)
- ^\. search for string start with .
- (…) capture the content inside with scope
- [a-zA-Z\-] only contain a-z, A-Z, and -
- * repeat the search condition [a-zA-Z\-] for next characters

\.$1_red
- \. write .
- $1 write matched string in the scope
- _red write _red

Find and replace regular expression

Google Trend

This morning I was so excited to start mining google trend. If you are new with Google Trend, it will show keywords that are recently getting popular. You will get 100 top popular keywords. This keyword list is updated every hour.

I’m planning to populate them, mining the data in order to get the ‘hot’ and long term profitable keyword that I can use to build adsense websites.

I will show you how to do this with a simple PHP script.
Read the rest of this entry »

One of my client request an improvement of his current website. He want an uploaded image could be resized automatically so his users no longer bothered with image size problem.

From google result, I found a ready made function for this purpose. In this tutorial I show you how to use this great function for you project.

Read the rest of this entry »

Ajax 503 error

Ajax 503 error

Today I got a problem when working with client website that is hosted with dreamhost.com. There is an Ajax function that did not work as it should do. With the help of firebug I’m able to see that this Ajax is trying to POST data and somehow the server reject its request then return 503 error.

Read the rest of this entry »