Saturday, July 7, 2012

Marriage from “Software Engineer” point of view


Abstract !
before any thing , don’t judge me after you read this I’m not a crazy person and I don’t have any mental issues. but because the nature of programming work , you have to make choices all the day, you have to think before you choose , you have to know the logic behind each step and why you are going with a solution over the other. so at some point you can ask your self what will happen if I applied the same rules to real life? mathematics  are supposed to solve real life problems , mathematics are supposed to help you. so why we can’t use them to solve some social problems like “Marriage”

Marriage is a choice
if you don’t agree that Marriage is a choice , I think you should stop reading this because all the next is based on the assumption that marriage is a choice , if you want a quick proof , simply there are people around you chose to be single ! and they don’t want to get married , and there are others who chose to be married , so marriage is a choice.

Since you choose to get married you have to select your best options , the best candidate , the best soul mate ,…whatever. but you have to choose , and here is the problem given a set of candidates what is the best one to choose. for example here is the set of candidates for a girl
{mohammed , mustafa , tamer , hany , adel , kareem , hassan }
and here is a set of candidates for a guy
{maya , sally , nancy , sarah , fatmaa , amira , yasmine}

so how will you choose your candidate , according to the mathematics you are looking for “global maximum” that means the best solution ever in other terms there isn’t any other solution that can fit like the global maximum , in our case to know if the one you choose is your global maximum , you have to ask your self after 30 years from now , if I go back on time would I make the same choice again ? , if the answer is yes then congrats, otherwise here we go Smile.

The Best Choice
as you are going to choose , it is obviously clear that you followed some rules , logic , steps , …etc. I tried to summarize how people choose in three points : “the best candidate according to “ , “the random way” and “the unknown method”

The best candidate according to:
in this way each one wants to get married put some rules or qualifications, for example a girl is looking for a guy that is easygoing , cool , traveling a lot , responsible , like kids , rich guy , …etc. so what if you find all these qualification in your candidate will that make him the best “your global maximum” ! , at this point you found “local maximum” which means that there is a solution that can solve your equation at this current time but at the next time or iteration there is can be a more better solution.
so lest assume the following
  • each year , month , day in your life is an iteration
  • each one you meet is a candidate and can be in your set , so each on can have a set like this {work mates , class mates , friends , friends of friends , school mates , college mates } and this set is expanding for every iteration.
so if you are one of the guys who choose based on qualification , you will never rich a global maximum because at each iteration you have you can find a better candidate “ more cool guy , more responsible , richer ,..”

and there is also another problem here , the qualification or the rules you choose at twenties will be different at fourties !, so your “local maximum” can be an invalid solution and is not even a solution to your problem. 
so what is the solution here ? , the solution is simple , stop putting people in your set , and this can be done be living in a closed society that don’t allow you to see more candidates , so if you want to choose based on qualification then the solution is simple get married and travel to Afghanistan” Smile

The Random way:
and this is simple , go to your mother , father , brother , friend or whatever and ask him/her to introduce you to someone , and then visit them at home , and done. after that moment you will try to convince your self is that you are happy , but are you really happy ? this what will you have after this kind of choice.

The Unknown way:
in this way , the logic disappears , after asking a lot of people that married using “the unknown way “ I found the best describing words are “the last scene of beautiful mind”

"What truly is logic? Who decides reason? My question has taken me to the physical, the metaphysical, the delusional, and back. I have made the most important discovery of my career - the most important discovery of my life. It is only in the mysterious equations of love that any logic or reasons can be found. I am only here tonight because of you"

transcript: “What truly is logic? Who decides reason? My question has taken me to the physical, the metaphysical, the delusional, and back. I have made the most important discovery of my career - the most important discovery of my life. It is only in the mysterious equations of love that any logic or reasons can be found. I am only here tonight because of you”

Sunday, January 8, 2012

The disappointing truth of preg_match on windows !!



lately , I have been working on extracting some information from html documents, when you do that all what you will need is a parser and sometimes the need to use regular expressions. it is supposed to be easy job , isn't it ? .
here is the problem , writing a regular expression like that will crash your apache on windows.
 $matches= array(); 
preg_match(“/<p>(<?value>(.)+)<.p>/i”,$htmlString,$matches);
var_dump($matches);
after a lot of searching why this is crashing the server , the problem was on the stack size given for the apache on windows , so how can you fix that ?!!!

First solution :
download this tool http://www.ntcore.com/exsuite.php , it will give you the ability to change the stack size of the httpd.exe , if you put extra “FF” on the left of the value , this will give you a lot of space.

Second solution:
why the hell is the stack is running out of space any way ?!! , the number of characters in the document was 50,000 characters so what is the big deal ?! , the problem was in (.)+ part , because actually to match this expression the built in library had to generate lots of trees and recursive calls. if you replaced this part by writing the possible characters that could appear. it will generate less trees and less recursive calls without the need to change anything.

Third solution:
if you aren’t ok with the above solutions and you don’t want to change any thing , you can run the script from the command line interface.

I hope this article will save time for you. 

Monday, April 4, 2011

Creating web services using PHP

 

What is web service?


first of all I want to explain or define what is web service ? , you can think of web services as DLL files over the web you write the code then compile it and every one can use it whatever the language they are using , but in the web you don’t compile anything , actually when I started using webservices , I was writing c# code so .Net was doing every thing for me , I couldn’t understand what is happening behind the scene I just type [webservice] above the function and everything is running , so In this article i ‘m going to explain what is happening

 

How it works?

web_service

 

1) WSDL

first you have to define what you are serving , think of it as a menu in a restaurant, you can define this by creating WSDL file (web service definition language)  you actually define what are the functions you are using , types

2) SOAP

you can consider SOAP as a waiter in a restaurant , he writes your order ,delivers it to the kitchen and gets the food back to you, that is actually what the soap does; you encapsulate your request to a standard format that matches the definitions in your WSDL file , and the server in the return encapsulates the result into a standard format based also on the WSDL file ; you can consider the WSDL file as the menu in the restaurant , you have to order something from the menu , and the kitchen has to deliver to you what you requested according to the details on the menu

What do you need?

php soap

if you are using php 5 or more  on windows , go to your php.ini and uncomment the following line extension=php_soap.dll , when run your phpinfo you should see it installed

if you are uisng linux , you can intall it using the following line

yum install php-soap

if you are using php 4 you can use nusoap

Creating your first web service

we are going to create a web service for a library , users can search for authors, books , browse each author’s books

each author has the following :

author_id

author_name

and each book has the following:

book_id

book_name

author_id

we are going to assume that each book is written by only one author to simplify the example

 

Creating the WSDL file

I’m going now to create the WSDL file “menu” , here is the code

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions name="Library" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="Library" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="Library" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" >
<xsd:documentation></xsd:documentation>
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="Library">
<xsd:complexType name="Book">
<xsd:sequence>
<xsd:element name="ID" type="xsd:integer"></xsd:element>
<xsd:element name="NAME" type="xsd:string" ></xsd:element>
<xsd:element name="AUTHOR" type="tns:Author" ></xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Author">
<xsd:sequence>
<xsd:element name="ID" type="xsd:integer"></xsd:element>
<xsd:element name="NAME" type="xsd:string" ></xsd:element>
<xsd:element name="BOOKS" type="tns:Book"
minOccurs="0" maxOccurs="unbounded">
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Authors">
<xsd:sequence>
<xsd:element name="AUTHOR" type="tns:Author"
minOccurs="0" maxOccurs="unbounded">
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Books">
<xsd:sequence>
<xsd:element name="BOOK" type="tns:Book"
minOccurs="0" maxOccurs="unbounded">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema></wsdl:types>
<wsdl:message name="searchAuthorsRequest">
<wsdl:part name="NAME" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="searchAuthorsResponse">
<wsdl:part name="AUTHORS" type="tns:Authors"></wsdl:part>
</wsdl:message>
<wsdl:message name="searchBooksRequest">
<wsdl:part name="NAME" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="searchBooksResponse">
<wsdl:part name="BOOKS" type="tns:Books"></wsdl:part>
</wsdl:message>
<wsdl:portType name="Library">
<wsdl:operation name="searchAuthors">
<wsdl:input message="tns:searchAuthorsRequest"/>
<wsdl:output message="tns:searchAuthorsResponse"/>
</wsdl:operation>
<wsdl:operation name="searchBooks">
<wsdl:input message="tns:searchBooksRequest"></wsdl:input>
<wsdl:output message="tns:searchBooksResponse"></wsdl:output>
</wsdl:operation>

</wsdl:portType>
<wsdl:binding name="Library" type="tns:Library">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="searchAuthors">
<soap:operation soapAction="http://localhost/Blog/Library/library.php" />
<wsdl:input>
<soap:body use="literal" namespace="Library" />
</wsdl:input>

<wsdl:output>
<soap:body use="literal" namespace="Library" />
</wsdl:output>
</wsdl:operation>

<wsdl:operation name="searchBooks">
<soap:operation soapAction="http://localhost/Blog/Library/library.php" />
<wsdl:input>
<soap:body use="literal" namespace="Library" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="Library" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Library">
<wsdl:port binding="tns:Library" name="YLibrary">
<soap:address location="http://localhost/Blog/Library/library.php" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

the wsdl file contains main 4 parts :

  1. types
            you simply define the types that you are going to use , it looks like the variables definition in a PASCAL
            program.
  2. messages
            each function in the web service has two messages; one for the input and the other for the
            output , also you can add one message to handle the exception. 
  3. port type
            the port type combines one or messages to represent a function , for example the “searchBooks”
            operation combines two messages; one for the input and one for the response
  4. binding
             in the binding section , you define protocol details for the web service 
            






I will create two classes to hold the data  one for books and the other for authors, please notice that you have to name the members exactly the same way you did in the WSDL file 

The BookData class

<?php
class BookData {
public $ID;
public $NAME;
public $AUTHOR;
}
?>

 

The Author Data class

<?php
class AuthorData {
public $ID;
public $NAME;
public $BOOKS;
}
?>

?>

now I am going to create wrapper classes

book class

<?php
class Book {
private $_nID;
private $_strName;

public function __construct($ID,$Name){
$this->SetID($ID);
$this->SetName($Name);
}
public function SetID($ID){
$this->_nID=mysql_real_escape_string($ID);
}


public function GetID(){
return $this->_nID;
}

public function SetName($Name){
$this->_strName=mysql_real_escape_string($Name);
}

public function GetName () {
return $this->_strName;
}

public function CreateBook (){
//Code to create Book
}

public function UpdateBook () {
//code to update book
}

public function DeleteBook () {

//code to delete book

}
public function SearchBooks () {
$SQL = "SELECT *
FROM books
INNER JOIN authors
on books.author_id= authors.author_id
where books.book_name like '%{$this->_strName}%'
";
$Query = mysql_query($SQL) or die (mysql_error());

$NumOfBooks = mysql_num_rows($Query);
$Result= array () ;
for ($i=0;$i<$NumOfBooks;$i++){

$Author = new AuthorData();
$Author->ID=mysql_result($Query, $i,"author_id");
$Author->NAME=mysql_result($Query, $i,"author_name");
//we will set this when we search by author name
$Author->BOOKS=array();

$Book = new BookData();
$Book->ID = mysql_result($Query, $i,"book_id");
$Book->NAME=mysql_result($Query, $i,"book_name");
$Book->AUTHOR=$Author;

$Result[]= $Book;
}
return $Result;
}
}?>

Author Class

<?php



class Author {

private $_nID;
private $_strName;

public function __construct($ID,$Name){
$this->SetID($ID);
$this->SetName($Name);
}

public function SetID($ID){
$this->_nID=mysql_real_escape_string($ID);
}

public function GetID(){
return $this->_nID;
}

public function SetName($Name){
$this->_strName=mysql_real_escape_string($Name);
}

public function GetName () {
return $this->_strName;
}

public function CreateAuthor (){
//Code to create Author
}

public function UpdateAuthor() {
//code to update Author
}

public function DeleteAuthpr() {
//code to delete Author
}


public function SearchAuthors() {
$SQL = "SELECT *

FROM
authors
where authors.author_name like '%{$this->_strName}%'
";

$Query = mysql_query($SQL) or die (mysql_error());
$NumOfAuthors= mysql_num_rows($Query);

$Result= array () ;

for ($i=0;$i<$NumOfAuthors;$i++){
$Author = new AuthorData();
$Author->ID=mysql_result($Query, $i,"author_id");
$Author->NAME=mysql_result($Query, $i,"author_name");
$Author->BOOKS=$this->GetBooksByAuthorID($Author->ID);
$Result[]= $Author;
}
return $Result;
}

public function GetBooksByAuthorID($ID){

$SQL = "select * from books where author_id = $ID";

$Query = mysql_query($SQL);
$NumOfBooks = mysql_num_rows($Query);

$Result = array () ;

for($i=0;$i<$NumOfBooks;$i++){

$Book = new BookData();
$Book->ID=mysql_result($Query, $i,"books.book_id");
$Book->NAME=mysql_result($Query, $i,"books.book_name");

$Result[]= $Book ;

}
return $Result;
}
}
?>

finally we will create php file who is supposed to receive the request from soap clients and return results , this file is the one written in the soap action attribute in the WSDL file

library.php

<?php

mysql_connect("localhost","root","");
mysql_select_db("library");


function __autoload($ClassName) {
require_once $ClassName.".php";
}

function searchAuthors ($NAME) {
$Author = new Author(null, $NAME);
return $Author->SearchAuthors();
}

function searchBooks($NAME){
$Book = new Book(null, $NAME);
return $Book->searchBooks();
}

ini_set("soap.wsdl_cache_enabled", "0");

$classmap = array(
"Book"=>"BookData",
"Author"=>"AuthorData"
);
$server = new SoapServer("Library.wsdl",array("classmap"=>$classmap));
$server->addFunction("searchAuthors");
$server->addFunction("searchBooks");
$server->handle();
?>

 

please notice you have to create a map between your complex types and your classes ”the ones that hold the data”

for example here , I mapped between Book ”the complex type in the WSDL file ” and BookData “The php class”

 

now everything is ready , lets call the web service

index.php

<?php
$client = new SoapClient("http://localhost/Blog/Library/Library.wsdl",array("trace" => 1));
try
{
$response = $client->searchAuthors("Beh");
//$response = $client->searchBooks("comp");

var_dump($response);
echo "Request".htmlspecialchars($client->__getLastRequest())."<br>";
echo "Response".htmlspecialchars($client->__getLastResponse())."<br>";

}catch(Exception $e){
var_dump($e);
echo $client->__getLastRequest();
echo $client->__getLastResponse();
}
?>

Saturday, November 6, 2010

Your First Google Map Application

Sometimes you need to add a map to your location in your site so that the users can reach you easily. what i like about Google maps is their API, it is very structured , easy to understand and the documentation is excellent.

So follow me in the next few steps:

1.You need to register a key

go to http://code.google.com/apis/maps/signup.html , and enter your site URL. your key will be generated and you will find a lot of ways to include Google Maps , here we will include Google Maps into web pages using Javascript.

for example

<script src=http://maps.google.com/maps?file=api&amp;v=2&amp;&amp;key=YourKey type="text/javascript"></script>
2.Documentation 


i totally recommend you to keep an eye on the documentation 


http://code.google.com/apis/maps/documentation/javascript/v2/reference.html
3. Map.html 

<html>
    <head>
       
        <title>My First Google Map</title>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAt_j1jxA-
OrN2zgFscf196hQ81ypfsrwFppodUYGd3WJUYwK81BQMmvl7uCUsxJJdrC9XnVo-dI7fZQ" type="text/javascript"></script>
<!—Google.js is the file that will define RenderMap(DivID)-->
   <script src="Google.js" type="text/javascript"></script>
        <script type="text/javascript">
            function LoadMap () {
                RenderMap('GoogleMap'); 
            }
            window.onload=LoadMap;
        </script>
    </head>
    <body>
        My Map will be in this Div
        <div id="GoogleMap" style="width:500px;height:500px;">
        </div>
    </body>
</html>
4. Google.js
function RenderMap(DivID)
{
var MapDiv = document.getElementById(DivID);
var GoogleMap = null;
if (GBrowserIsCompatible()) {
GoogleMap = new GMap2(MapDiv);

//Add Navigation Control and Zoom Control on the Map
GoogleMap.addControl(new GSmallMapControl());
GoogleMap.addControl(new GMapTypeControl());

//Enable Scrolling on the Mouse Wheel
GoogleMap.enableScrollWheelZoom();

//Next we will add a marker to our company

//Company Latitude And Longitude
//You can get your Latitude And Longitude From Google Earth , i entered random values
var CompanyLongLat = new GLatLng(29.449790329784214, 28.9599609375);

//Company Marker On The Map
var CompanyMarker= new GMarker (CompanyLongLat) ;


//we need to add a "left click" event to the marker
//when the user click on the marker , a balloon will appear that has the address information
GEvent.addListener(CompanyMarker,"click", function() {
var AddressInfo= 'My Address Information';
CompanyMarker.openInfoWindowHtml(AddressInfo);
});


//Finally , add the Company Marker to the map
GoogleMap.addOverlay(CompanyMarker);

GoogleMap.setCenter(CompanyMarker.getLatLng(),10);
}

}








That is all , Enjoy


Wednesday, October 20, 2010

AjaxFormSubmitter

when you are using AJAX in your web application , you do a lot of cool stuff but some parts of the application is totally boring like creating a form and get every eleement’s value in that form , create a new XMLHttpObject and handle the result.

So i created this class so that you can pass the form id ,  div id , or any html element that has a data you are interested in and send it  asynchronously to a web page , imagine the line of codes and the time that you will save and the most of it cutting the boring time of .

You Can Download The Class From

          http://www.jsclasses.org/package/26-JavaScript-Submit-Form-Data-asynchronously-.html

You need to include JQuery first , because the class is based on JQuery , you can download one from this link

           http://docs.jquery.com/Downloading_jQuery

The Class is  the file called “AjaxFormSubmitter”

To use the class follow this example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content"text/html; charset=iso-8859-1">
<title>Test Ajax Form</title>
<Script src="jquery-1.3.2.min.js" type="text/javascript"></Script>
<Script src="AjaxFormSubmitter.js" type="text/javascript"> </Script>
<script type="text/javascript">
function OnLoading () {
alert("I am loading");
}

function OnSuccess (data){
alert ("request completed " );
alert(data);
}

function OnError (XML){
alert(XML);
}

function SendData(){
var AjaxForm = new AjaxFormSubmitter("MyForm");
AjaxForm.SetURL("data.php");
AjaxForm.SetMethod("POST");

AjaxForm.SetOnSuccess(
function(data){
OnSuccess(data);
}
);

AjaxForm.SetOnFailure (
function (error){
OnError(error);
}
);

AjaxForm.SetOnLoading (
function (){
OnLoading();
}
);

AjaxForm.Submit();
}



</script>
</head>

<body>
<form id="MyForm" action="#" method="post" >
<input type="text" id="name" name="name" value="Text"/>
<input type="hidden" id="hidden" name="hidden" value="hiddenVlaue"/>
<input type="password" id="password" name="password" value="passwordValue"/> <br>
<input type="checkbox" id="chbox1" name="chbox1" checked="checked"/>
<input type="checkbox" id="chbox2" name="chbox2" /> <br>
<input type="radio" id="radio1" name="choice" value="1" />
<input type="radio" id="radio2" name="choice" value="2"/>
<input type="radio" id="radio3" name="choice" value="3" checked="checked"/>
<input type="radio" id="radio4" name="choice" value="4"/><br>
<select id="Select" multiple="multiple">
<option value="option1">option one</option>
<option value="option2">option two</option>
<option value="option3">option three</option>
</select> <br>

<textarea id="textarea">My Text Area</textarea> <br>

<input type="button" value="Send Data" name="Send" onclick="SendData();"/>
</form>
</body>
</html>


In The Example you will find a function called “Send Data” , this is the function that do all the work.
var AjaxForm = new AjaxFormSubmitter("MyForm"); 
AjaxForm.SetURL("data.php");
AjaxForm.SetMethod("POST");


We created an object from the class  and pass the Form id to the constructor , then we tell the class the url that will receive the data , and the method that will it use “POST or GET”.



the next steps are optional , in case of you are not interested in handling the results.


AjaxForm.SetOnSuccess(
function(data){
OnSuccess(data);
}
);

AjaxForm.SetOnFailure (
function(error){
OnError(error);
}
);

AjaxForm.SetOnLoading (
function (){
OnLoading();
}
);

In the previous screen shot , you tell the class what to do in the following events: success , error , and loading

OnSuccess will recieve the resutned text from the web page , and will be called after the request is completed 

OnFailure Will recieve an object from the XML http Object , and will be called in case that any error happend

OnLoading : will be called before the data is sent .

what you have to do next , is to call the submit function
AjaxForm.Submit();


You have finished , i hope the class will be useful for you
Listed at Hot Scripts Listed in JavaScript





Thursday, September 2, 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 ?