Sunday, January 31, 2010

Child and Parent FLEX

Accessing the parent functions is not as simple as always, I did try using DisplayObject but it didn't work as i thought. The best way really is to rethink the relationship between the child and parent. Normally, if the function exist with the parent as opposed to residing on the child, the function can be as simple as just:

private function changePot(event:MouseEvent):void {
this.parentApplication.changePot((event.currentTarget as Image).name);
}

Of course the parent application needs to have a function call changePot. Thats it!

Sunday, January 24, 2010

Configuring PHP on Windows

If you are getting 500 errors but everything else in PHP runs normally (in IIS 7), then chances are Session is not working. You can verify this by just having a script that runs session_start().

Two things to fix:
1. session.save_path, session.use_cookes and session.start has to be set too
2. warnings: error_reporting = E_ALL & ~E_NOTICE

Wednesday, December 23, 2009

Javascript textfield counter

maxL = 1000;
var bName = navigator.appName;

function taLimit(taObj) {
if (taObj.value.length == maxL) {
return false;
}
return true;
}

function taCount(taObj,Cnt) {
objCnt=createObject(Cnt);
objVal=taObj.value;
if (objVal.length > maxL) {
alert("Description field has to be less than 1000 characters.");
objVal = objVal.substring(0, maxL);
}

if (objCnt) {
if(bName == "Netscape"){
objCnt.textContent=maxL-objVal.length;}
else{objCnt.innerText=maxL-objVal.length;}
}
return true;
}
function createObject(objId) {
if (document.getElementById) return document.getElementById(objId);
else if (document.layers) return eval("document." + objId);
else if (document.all) return eval("document.all." + objId);
else return eval("document." + objId);
}


To update the counter at last, do something like this:
<script type="text/javascript">
taCount(document.getElementById('txtDescription'), 'myCounter');
</script>

Monday, December 21, 2009

PHP Date Convert

echo date("d/m/y", strtotime($row_sprees['issueDate'])); ?>

Monday, December 14, 2009

mySQL and msSQL Limit and TOP

SELECT TOP 10 * FROM stuff;

Will return the top ten rows, effectively doing the same thing as

SELET * FROM stuff LIMIT 10;

Saturday, December 12, 2009

Router configuration

Home network setup:
WRT300N - the router at level 1
WRT54G - the router at level 2 flashed with DD-WRT firmware, used as repeater.

The information to access the router are as follows:
level1: 192.168.1.1 (admin, admin)
Level2: 10.0.0.1 (root, admin)

Tuesday, December 8, 2009

convert url to links in C# using Regex

public string ConvertUrlsToLinks(string msg)
{
string newMsg = "";

string regex = @"((www\.|(http|https|ftp|news|file)+\:\/\/)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])";
Regex r = new Regex(regex, RegexOptions.IgnoreCase);
newMsg = r.Replace(msg, "$1").Replace("href=\"www", "href=\"http://www");

string emailRegex = @"(([a-zA-Z0-9_\-\.]+@)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])";
Regex r2 = new Regex(emailRegex, RegexOptions.IgnoreCase);
newMsg = r2.Replace(newMsg, "$1");

return newMsg;
}