JavaScript - check starts with and ends with | test startsWith and endsWith

Add this functions to the String prototype:
if (typeof String.prototype.startsWith != 'function') {
  String.prototype.startsWith = function (str){
    return this.slice(0, str.length) == str;
  };
}
if (typeof String.prototype.endsWith != 'function') {
  String.prototype.endsWith = function (str){
    return this.slice(-str.length) == str;
  };
}
Then use it:
"Starts with JavaScript".startsWith("Starts"); // true
var foo= "Ends with JavaScript";
var bar= "JavaScript";
foo.startsWith(bar); // true

UnRar - extract files from rar archives | BackTrack 5

apt-get install unrar
unrar x file.rar path/


unrar --help

MySQL - ERROR 2002 (HY000): Can't connect to local MySQL server through socket | BackTrack 5

mysql -u root -p
****

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

mkdir /var/run/mysqld
touch /var/run/mysqld/mysqld.sock
chown -R mysql /var/run/mysqld
/etc/init.d/mysql restart