Simple example how-to extend JavaScript built-in methods

Let say you want to replace all spaces in string by dashes,
of course you can implement distinct function that does it:



 function ReplaceByDashes(string){
    return string.replace(/\s/g,'-');
 }

 // run it
 var string = "Hello my beautiful world!";
 string=ReplaceByDashes(string);
 alert(string); 



However, we can add our custom method to string object that already built-in in JavaScript:



  if(typeof String.prototype.rbd==='undefined'){ // we have to check if someone hasn't added it already
     String.prototype.rbd = function(){
        return this.replace(/\s/g,'-');
     }
  }

 // run it

 var string = "Hello my beautiful world!";
 string=string.rbd();
 alert(string); 



Some useful example, capitalize first letter of string



String.prototype.ucFirst = function () {
  return (this.substr(0,1).toUpperCase() + this.substr(1,this.length));
}

Java + Httpd + Tomcat + Sakai installation (step-by-step)

Please change paths according to your failsystem layout ;)

JAVA INSTALLATION:
— 1.
# cp jdk-1_5_0_22-linux-amd64.bin /srv
# cd /srv
# sh jdk-1_5_0_22-linux-amd64.bin
# ln -s jdk1.5.0_22 jdk

# updatedb;locate javac |grep bin
/srv/jdk1.5.0_22/bin/javac



( Continue )