Saturday, September 4, 2010

Tamer Hosny is singing “Hotel California “

When Idiots Succeed !

 

believe it or not but it happened , tamer hosny is singing in English after the big success in Arabic singing !

our idiot chose to sing “Hotel California” from all the English classics , to show us that he can sing like the eagles , i liked my friend comment on this disaster  “the first step of classics distortion after we have lost the ability of every beautiful damn thing we could make” by hassan.

i don’t know why did tamer choose to sing in English? but whatever his reasons , it is not acceptable , i can't imagine Eminem is singing in Arabic ! , but let us think in different way; why tamer succeeded in the first place ? , it can’t be his chest hair ! , what if we can analyze tamer fans ? what we would get? ,i can’t deny that i listened to tamer songs , and i really liked some of them , but this guys is pushing us to the limits because of his lyrics ! . lets back to the fans , after i did the analysis , i categorized the fans to three levels :

 

Level Type Description
1 absolute supporters tamer hosny is their god father ; they admire every thing about him , his clothes, hair style , …. etc. in addition to every peace of paper he wrote or sang it , plus the 100 poster in their rooms , and some of them went to support tamer in court ! and  attend every concert for him
2 Songs Only they don’t like tamer as a person , but they like every song for him and it remind them with some emotional events in their lives and  they may go to some concerts.
3 Moderate they like some songs , they don’t care about attending tamer concerts , they are just having fun in the car while they are driving or while they are working.

 

is tamer stoppable ?

according to my analysis there are too many people in level 1 even from my relatives , so this guy is not stoppable in the near future , let us pray that tamer wont sing “je suis malade- French ” or  “caruso – italian ”

 


Friday, September 3, 2010

Design Patterns: Singleton

What is Singleton ?
i am not a good person to define things, but any way , when you feel you need only one instance from a class then you need a singleton!
Did computer scientists waste their time to instantiate only one object?
absolutely no , it is a very useful solution , some time having multiple copies of objects can lead to chaos , resource looking , resource over used , …. etc
When it is needed?
Most of the common usage is to handle global setting like database connections , registry settings  , who is online now ? , .etc

here is an example to implement singleton while connecting to MYSQL connection

<?php
//ConnectionConf.php
class ConnectionConf 
{
public $Username; 
public $Password; 
public $ServerAddress; 
public $Database;
}
?>
<?php
require_once 'ConnectionConf.php';
class Connection
{
/**
* Varaible to hold the unique instance  
* @var Connection
*/
private static $UniqueInstance; 
/**
* Connetion User name 
* @var string
*/
private $_strUsername; 
/**
* Connection Password
* @var string
*/
private $_strPassword; 
/**
* Connection Address
* @var string
*/
private $_strServerAddress; 
/**
* Database Name 
* @var string
*/
private $_strDatabase; 
/**
* Last Error happend 
* @var string
*/
private $_strLastError; 
/**
* mysql link identfier 
* @var mysql resource
*/
private $_resConnectionResource; 
/**
* Class constructor , it is private , 
* so no way you can create it using new Connection 
* @param $ConnectionConf ConnectionConf
* @return void
*/
private function __construct($ConnectionConf)
{
$this->_strUsername=$ConnectionConf->Username; 
$this->_strPassword=$ConnectionConf->Password; 
$this->_strServerAddress=$ConnectionConf->ServerAddress; 
$this->_strDatabase=$ConnectionConf->Database;
$this->StartConnection(); 
}
/**
* @param $ConnectionConf ConnectionConf
* @return Connection
*/
public static function GetInstance ($ConnectionConf=null) 
{
if (Connection::$UniqueInstance==null)
{
if ($ConnectionConf==null)
throw new Exception("Connection Configuration Can't be null at first time"); 
Connection::$UniqueInstance = new Connection($ConnectionConf); 
return Connection::$UniqueInstance ; 
}
return Connection::$UniqueInstance ; 
}
/////////////////////////////// Sets and Gets Start/////////////////////////////////// 
public function GetUsername () 
{
return $this->_strUsername;
}
public function GetPassword () 
{
return $this->_strPassword; 
}
public function GetServerAddress () 
{
return $this->_strServerAddress; 
}
public function GetDatabaseName()
{
return $this->_strDatabase;  
}
public function GetConnectionResource () 
{
return $this->_resConnectionResource; 
}
public function GetLastError () 
{
return $this->_strLastError;
}
////////////////////////////Sets And Gets End/////////////////////////////////////////////////////
/**
* 
* @return bool
*/
public function StartConnection () 
{
try{
$this->_resConnectionResource=mysql_connect($this->_strServerAddress,$this->_strUsername,

$this >_strPassword);
mysql_select_db($this->_strDatabase);
}
catch(Exception $e){
$this->_strLastError=$e->getMessage(); 
return 0 ;   
}
return 1; 
}
public function CloseConnection () 
{
try{
mysql_close($this->_resConnectionResource); 
}
catch (Exception $e)
{
$this->_strLastError=$e->getMessage(); 
return 0 ; 
}
return 1; 
}
public function RestartConnection () 
{
$this->CloseConnection(); 
$this->StartConnection(); 
}
}
$Config = new ConnectionConf(); 
$Config->Username= "root"; 
$Config->Password= ""; 
$Config->ServerAddress= "localhost"; 
$Config->Database= "road";
//First instance 
$Connection = Connection::GetInstance($Config);
var_dump($Connection); 
//will return the same instance declared before
$Connection1 = Connection::GetInstance(); 
var_dump($Connection1);
?>



here are the files


http://www.4shared.com/file/9d_RHQ0I/ConnectionConf.html
http://www.4shared.com/file/DoOt0KUh/singleton.html

Do you still have your EX on your facebook account?

don’t ask me why i wrote this ? i keep my reasons for me. but i did  a lot of surveys  and i found that most of us leave his/her EX on facebook account!

here are some reasons :

1- love can turn to friendship:

what i can say about this reason is : liars , liars  ,liars ,liars ,liars , liars .
love can’t turn to friendship , your father cant be your sister !! so as love cant turn to friendship

2- curiosity
most of us are curios what is happening with the others whatever they are to them.

3- i don’t delete a friend form facebook
some said that , they don’t delete a friend from their account whatever happened , but to show him/her that they are upset , they just give them an access to their limited profile.

So What a bout you ?



 

Google Translator is using “Statistical Translation Machine”

Before i start the article , i want to send a message to a group of idiots that said “Google Is using Rule Based” , the amazing thing is they don’t know the difference between them , so if you still don’t know the difference , i will show you the difference in this article so you can be in the safe side not the idiot side.

Rule Based Approach:
you will spend a lot of years building this engine and you wont get  good results in the end.

summary :

at this approach you have a dictionary that contains the two languages that you will translate from and to the other. then you have an engine that contains your language rules and their exceptions. when you translate you keep in mind the subjects , adverbs , verbs , ….etc. in both languages .

Statistical Translation Machine:
All what you need is data !

summary:

it simulates the way humans learn a new language , when you learn a new language you wont necessarily need to know the rules of the language , you will need to know the sentence in Arabic and its English equivalent.
first you need data , the data in this approach is any piece of text and its translation , then the algorithm tries to find a pattern in the data , based on the frequency of the text.
here is a reference
http://translate.google.com/about/intl/en_ALL/