Design Patterns for PHP

Erhm… ok I am not the owner of this post, I am sharing only, to help me review it back next time prior to my job interviews.

  • The factory pattern
  • The singleton pattern
  • The observer pattern
  • The chain-of-command pattern
  • The strategy pattern

Read it yourself :)

http://www.ibm.com/developerworks/library/os-php-designptrns/

Modify pre-comfiled SWF file

If you have a pre-compiled SWF file, with some craps inside e.g. copyright and logo, sometimes you do not want to see them within the flash when it is part of software package that is about to go live.

At least I am facing this problem at the moment, and after 2 hours of google digging, I found this software to work the best:

http://code.google.com/p/asdec/

It is JAVA base app, which should be safe to be used on any platform with JVM. So what you need to do is to run the .jar file to bring up the app, then open the swf file that you wish to modify. Now what you see next is list of JAVA class files. If you are a programmer you should know how to continue from here. If you don’t, get someone who is a programmer.

Good luck.

Installing PHP with OCI8 enabled

I believe most people will have problem installing WAMP with OCI8 / OCI8_11G extension enabled. I am here to guide you through and hopefully you will not waste your time for setting it up (like me).

Downloading

Depending on the version of your PHP and its library (32 bit or 64 bit) / WAMP, you will need to download the matching version of Oracle Instant Client in order to get things right. i.e. if you are installing 32 bit PHP (majority of WAMP installer comes with 32 bit of PHP) then you will need Oracle Instant Client 32 bit, and obviously 64 bit PHP will need Oracle Instant Client 64 bit.

Installing

  1. Extract/Install the downloaded copy of Oracle Instant Client into C:\instantclient_11_2
  2. Setup Path variable for 2000/XP or Vista/7 by appending the line with “;C:\instantclient_11_2\;”
  3. Install your preferred WAMP installer, or do it manually.
  4. Enable the php_oci8.dll or php_oci8_11g.dll extension by editing php.ini directly, or via the user interface provided by WAMP installer. Remember that you only need either one of this DLL file to be enabled, Not Both!

Reboot

After all steps above have been carried, simply restart your windows in order to get PATH value to be reloaded. Start your WAMP server if it doesn’t start automatically. Go to WAMP’s dedicated www root folder and create a test file “phpinfo.php”, with simple script <?php phpinfo();?> in the file. Now go to your browser and hit “http://127.0.0.1/phpinfo.php” to see all php information. You should also find the OCI8 entry in the page, if everything is being setup correctly.

Common Issue

In most cases you will see this error message while starting Apache / WAMP server: “Unable to load dynamic library ‘D:\PHP\extensions/php_oci8.dll’ – The specified procedure could not be found.”

This is due to php_oci8.dll / php_oci8_11g.dll is not compatible with the Oracle Instant Client, particular 32-bit / 64-bit unmatched in most cases, or the PATH variable was not setting up correctly. Try fixing these issue and restart windows, and try again!

Last Word

If you still could not get this oci8 to work after following all my steps, GOOD LUCK with google because I was not able to find much information on the internet as you do!

jQuery Floating Infobox Plugin

I have been searching for jQuery Floating Infobox on the Internet but was not able to find a suitable one. I have decided to write my own plugin for jquery to suit what I need.

Usage is really simple:

1
$('#maincontent').floatingInfoBox();

and the infobox will appear above.

This plugin has got extensive configurations to make itself flexible to use. Read the source code to find out all options.

Download: http://blog.mingspc.com/wp-content/plugins/download-monitor/download.php?id=5

Cross Browser eval() for Javascript / AJAX

I’ve found this sometimes ago and was not able to get it via google search recently. So I have decided to ‘forward’ this piece of code to my blog so that I can find it easily.

The original credit goes back to the developer who created this code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function evalScripts(scripts){
	try	{
		if(scripts != '')		{
			var script = "";
			scripts = scripts.replace(/]*>([\s\S]*?)<\/script>/gi, function(){
				if (scripts !== null) script += arguments[1] + '\n';
				return '';
			});
			if(script) 
				(window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}catch(e){
		alert(e)
	}
}



Source from: http://www.ajax-community.de/javascript/6749-execute-javascript-after-ajax-response.html#post33614