Tuesday, March 29, 2011

Development Type


There are several type of development for each project.
Either its:
  • New development
  • Change Feature
  • Adding new Feature
  • or redesign / revamp code
  • Bug fixing / Code refactoring
A lot of people get both "bug fixing" and "revamp code" mixed up.
Its unlikely for client (non-programmer) to fully understand the concept behind revamping code,
as in their point of view, its just a piece of program which doesn't work with new business process or doesn't change with new business process.

Out of all 5 different type of tasks, new "development" and "redesign/revamp code" takes the longest time. But this is subjective to either, the code is developed by the same developer, or other developer.

As known that redesign/revamp code could take as long as new development, its best that every new development should goes with proper planning. Both the client / business development manager must cooperate together to discuss the business flow and future path for the system to be used for. The sole purpose would be meeting business long term goal and objective. Without a proper planning, revamping code could possibly be a better choice in later stage of the development. But, lots of time will be wasted bug fixing existing code / work around to fix issue to suite business where it was not developed for that sole purpose.
But, migration of existing system to a new revamped system will also incur lots of time. Not only that, new code also meant new bugs and the process get all reloaded from the start again.

To sum it up, developer should take more time to think of long term solution to the client business, while business manager should consider proper plan for the direction of the company along with the system to build.

By end of the day, both developer and business manager should shake hand and work as a team to make things happen. A little higher price / time spent for a properly planned system save a lot of time along the life of the system.

Saturday, March 26, 2011

modx-combo cascading selection

After spending hours trying to figure this out,
and realized that modx have override most extjs combo with its own data store calling.

I've finally found a way to do cascading to work.
To force it to add the parameter to on call ajax to populate the list,
you will have to add it as baseParams, as the 1st time you select the drop down,
it seems to be doing a auto load.
If you attempt to reload the store without setting baseParams, the first time it got populate, it will be without your additional param.
Example:
Ext.getCmp("state").baseParams.key1 = Ext.getCmp("region").getValue();

But this baseParams only work for 1st time call. It wont work when you subsequencely reselect the parent component.
To do that, we will have to use the load.
Ext.getCmp("state").store.reload({
params: { key1: Ext.getCmp("region").getValue() }
});

This will solve the cascading selection issue.
For example of complete code:
----------------------------------------------------
lets say we have a region > state > district
Ext.getCmp("region").on("change", function() {
var oState = Ext.getCmp("state");
var oDistrict = Ext.getCmp("district");
oState.setDisabled(true);
oState.setValue('');
oState.store.removeAll();
oState.baseParams.key1 = Ext.getCmp("region").getValue();
oState.store.reload({
params: { key1: Ext.getCmp("region").getValue() }
});
oState.setDisabled(false);
oDistrict.setDisabled(true);
oDistrict.setValue('');
oDistrict.store.removeAll();
oDistrict.setDisabled(false);
});
Ext.getCmp("state").on("change", function() {
var oDistrict = Ext.getCmp("district");
oDistrict.setDisabled(true);
oDistrict.setValue('');
oDistrict.store.removeAll();
oDistrict.baseParams.key1 = Ext.getCmp("state").getValue();
oDistrict.store.reload({
params: { key1: Ext.getCmp("state").getValue() }
});
oDistrict.store.reload();
oDistrict.setDisabled(false);
});
-------------------------------------

Thursday, March 17, 2011

object to array of a class with protected variable

Interesting finding for PHP.
By default, if you plan to use get_object_vars to change a class into array, its known that protected and private variable will not be exported to array. Even if you have __sleep method and __get method set to retrieve those variable.

The solution is to put get_object_vars within a method to return get_object_vars($this);

----------------
class A {
public $id = 1;
protected $name = "";

public function __get($name) {
return $this->$name;
}

public function __sleep() {
return array("id", "name");
}

public function toArray() {
return get_object_vars($this);
}
}

$o = new A();
print_r(get_object_vars($o)); //only public variable exposed
print_r($o->toArray()); // all variable are exposed

Tuesday, March 8, 2011

Started a project: FlexiSiteCopy

A general purpose flexible utility to copy database from 1 site to another. Currently tested on MODx 2 and standalone database. Allow modification on data before inserting remote data to local database

Relaying mail for internal server

Having a running staging server would be nice to test application before putting it live.
But since most of us in malaysia is on Streamyx or Unifi, the port25 has been blocked.

One way to solve it is to ask the smtp server to relay mail to an external mail server.
But will require a valid loginid and password of an email account to do so.

If you are using sendmail, you may do setup this way:
1. Find “DS” in /etc/mail/sendmail.cf and add your mail server name as below: -
DSmail.yourdomain.com

2. Find “Mrelay” in /etc/mail/sendmail.cf and add “587″ to “A=TCP $h”.
This port represent your external mail smtp port, since port 25 is blocked:
A=TCP $h 587

3. Add the following line below in /etc/mail/access file in one line: -

AuthInfo:mail.yourdomain.com "U:user@yourdomain.com" "I:user@yourdomain.com" "P:youremailpassword" "R:yourdomain.com" "M:LOGIN PLAIN"

4. Then, restart your Sendmail service as below: -

service sendmail restart

4. Finally, you can monitor your maillog using the command below: -

tail -f /var/log/mail.log

IE8 bypass self signed ssl

* Click on View certificates
* In the Certificate dialog, press Install Certificate
* In the Certificate Import Wizard, click Next
* On page 2 of the wizard, select Place all certificates in the following store and click Browse;
* In the Select Certificate Store dialog, select Trusted Root Certification Authorities, click OK

* In the wizard, click Next, click Finish
* If a security message pops up, choose Yes

Sunday, March 6, 2011

firefox bypass self signed ssl

Bypassing the warning

  1. On the warning page, click Or you can add an exception....
  2. Click Add Exception.... The Add Security Exception dialog will appear.
  3. Click Get Certificate.
  4. Read the text describing the problems with this site.
  5. Click Confirm Security Exception if you want to trust the site.