<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>omaroid</title>
	<atom:link href="http://www.omaroid.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.omaroid.com</link>
	<description>a humanoid&#039;s tech blog</description>
	<lastBuildDate>Wed, 24 Apr 2013 14:14:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>CakePHP Locale and Routing</title>
		<link>http://www.omaroid.com/cakephp-locale-language-routing/</link>
		<comments>http://www.omaroid.com/cakephp-locale-language-routing/#comments</comments>
		<pubDate>Tue, 31 Jul 2012 03:38:31 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cakephp 2.0]]></category>
		<category><![CDATA[cakephp locale]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[internationalization]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[routes]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=326</guid>
		<description><![CDATA[When I was working on the cakephp localization ( l10n ) and internationalization ( i18n ), I came across a problem so I decided to let the world know about it if anyone had got the same issue. What we want here is that a user can go to the localized version of the website [...]]]></description>
				<content:encoded><![CDATA[<div style="float: right;"><a title="cakephp" href="http://cakephp.org/" target="_blank"><img class="alignnone size-thumbnail wp-image-366" title="CakePHP" src="http://www.omaroid.com/wp-content/uploads/2012/07/cakephp_logo_250_trans-150x150.png" alt="CakePHP" width="150" height="150" /></a></div>
<p>When I was working on the <strong><a href="http://book.cakephp.org/2.0/en/core-libraries/internationalization-and-localization.html" target="_blank">cakephp localization ( l10n ) and internationalization ( i18n )</a></strong>, I came across a problem so I decided to let the world know about it if anyone had got the same issue.</p>
<p>What we want here is that a user can go to the localized version of the website according to the URL identified, for instance we want the website to load the English <strong>locale</strong> when we pass a URL like this http://example.tld/eng/Controller/Action</p>
<p>The <strong>problem</strong> is that while implementing the <strong>routes</strong> for the language detection, the plugins made a conflict with the rules in the routes file. Language routing is easy but sometimes can be tricky.<br />
<span id="more-326"></span></p>
<h2>Why Use Language Routes?</h2>
<p>Simply because its much better for the SEO.</p>
<h2>Setting Up A Default Locale</h2>
<p>Next we have to define a default language for the website in Bootstrap.php. I&#8217;m setting it as &#8216;eng&#8217; since cakephp uses the 3 letter code</p>
<pre class="brush: php; title: ; notranslate">
Configure::write('Config.language', 'eng');
</pre>
<p>This will load and use default.po located in app/Locale/eng/LC_MESSAGES/ for translation. It&#8217;s called default since its the default domain.<br />
Any call to the function <a href="http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__" target="_blank">__()</a> will load the key from the loaded PO file. You can also translate from another domain using <a href="http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d" target="_blank">__d($domain,$key)</a>. For instance to load a city called &#8216;cairo&#8217; from a domain called &#8216;cities&#8217; you can call __d(&#8216;cities&#8217;,'cairo&#8217;) which will load app/Locale/eng/LC_MESSAGES/cities.po and translate the key &#8216;cairo&#8217; to the adjacent translation since we set the locale to be &#8216;eng&#8217;.</p>
<h2>Language Detection From The URL</h2>
<p>Let&#8217;s first detect the locale or language key using cakephp routes in the app/Config/routes.php.</p>
<pre class="brush: php; title: ; notranslate">
Router::connect('/:language/:controller/:action/*', array(), array('language' =&gt; '[a-z]{3}'));
</pre>
<p>This line says that match the language regular expression, the controller, the action and any parameters beyond, to overcome the default behavior that if we put the language key (eg. eng) it will try to find a controller with the same name for instance it will try to find a controller named &#8216;eng&#8217; which is not what we want.</p>
<p>Next we need to set the captured locale/language key to load the appropriate language file (po file).<br />
In the AppController.php we can implement a method to set the language from the url as the following</p>
<pre class="brush: php; title: ; notranslate">
class AppController extends Controller {
    public function beforeFilter() {
    	$this-&gt;_setLanguage();
    }

    private function _setLanguage() {
    	if(isset($this-&gt;params['language']) &amp;&amp;
    			($this-&gt;params['language'] != $this-&gt;Cookie-&gt;read('Config.language')))
    	{
    		$this-&gt;Cookie-&gt;write('Config.language', $this-&gt;params['language']);
    		// set the application language
    		Configure::write('Config.language',$this-&gt;params['language']);
    	}elseif(!isset($this-&gt;params['language']) &amp;&amp; $this-&gt;Cookie-&gt;read('Config.language')){
    		// set the application language
    		Configure::write('Config.language',$this-&gt;Cookie-&gt;read('Config.language'));
    	}
    }
}
</pre>
<p>Above we are storing the language in a cookie, if the language was not sent in the URL them we load it from the cookie,if the language was sent in the URL but different from the cookie value then we set the cookie value to the value passed from the URL. if none was sent, then we have got the default language set in the bootstrap as mentioned earlier.</p>
<h2>The Problem (Router Conflicts)</h2>
<p>This method works perfectly but what happens if you want to access a plugin?</p>
<p>There is no distinction between the controller name and the plugin name, they are both strings and have undetermined number of characters and nothing is unique about any of them. With a url like this: http://example.tld/eng/PluginName/ControllerName/ActionName it will match the plugin name as the controller which is not really what we want here.</p>
<h2>The Solution</h2>
<p>So in order to solve this issue, we need to match the <strong>plugin</strong> names so that it wont consider it as a <strong>controller</strong>. I have implemented the following code in order to solve this issue.</p>
<pre class="brush: php; title: ; notranslate">
// make an array of loaded plugins
$loaded = CakePlugin::loaded();
array_walk($loaded, function(&amp;$item,$key){
	$item = Inflector::underscore($item);
});
$loaded = implode('|', $loaded);

Router::connect('/:language/:plugin/:controller/:action/*', array(), array('language' =&gt; '[a-z]{3}','plugin' =&gt; &quot;($loaded)&quot;));
</pre>
<p>What are we doing here? We are getting an array of loaded plugins using the loaded() method, then we convert the Multiword plugin (CamelCase) to underscored lowercases using the Inflector::underscore() method and then implode them with the pipe generating an <strong>OR</strong>ed regular expression to match the plugin key in the route. So now since we hard coded the rules dynamically in the routes so there wont be any conflicts in <strong>cakephp routing</strong>.</p>
<p>Hope that helps someone</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/cakephp-locale-language-routing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>M-greetings.com</title>
		<link>http://www.omaroid.com/m-greetings-com/</link>
		<comments>http://www.omaroid.com/m-greetings-com/#comments</comments>
		<pubDate>Mon, 30 Jul 2012 23:48:12 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[Portfolio]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=342</guid>
		<description><![CDATA[M-greetings is a platform for generating Rich Media Content through a flash designer. I Developed HTTP API and mobile application API, Sending Bulk SMS. I designed architecture and developed it for sending SMS/MMS workers enhanced for maximum flexibility and cpu usage. Integrated several payment gateways. Mentored other team members. Developed cakephp Plugins. The workers I&#8217;ve [...]]]></description>
				<content:encoded><![CDATA[<p>M-greetings is a platform for generating Rich Media Content through a flash designer.<br />
I Developed HTTP API and mobile application API, Sending Bulk SMS.<br />
I designed architecture and developed it for sending SMS/MMS workers enhanced for maximum flexibility and cpu usage. Integrated several payment gateways. Mentored other team members. Developed cakephp Plugins.</p>
<p>The workers I&#8217;ve designed can send millons of SMS&#8217;s in a few minutes.</p>
<p><span id="more-342"></span></p>
<p><strong>Technologies:</strong> PHP, MySQL, Cakephp, JavaScript,  jQuery, AJAX, XHTML, CSS</p>
<p><strong>URL:</strong> <a href="http://www.m-greetings.com">www.m-greetings.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/m-greetings-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Variable Variables and Variable Constants</title>
		<link>http://www.omaroid.com/php-variable-variables-and-variable-constants/</link>
		<comments>http://www.omaroid.com/php-variable-variables-and-variable-constants/#comments</comments>
		<pubDate>Sat, 16 Jun 2012 23:28:07 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[constants]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[variable constants]]></category>
		<category><![CDATA[variable variables]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=321</guid>
		<description><![CDATA[In this small article I&#8217;ll illustrate PHP&#8217;s variable variables and Variable constants. There is no variable constants in PHP but I&#8217;m introducing a methodology to implement the same approach and achieve the same functionality as variable variables. As you may know that you can have a variable variable like the following: Where the variable name [...]]]></description>
				<content:encoded><![CDATA[<p>In this small article I&#8217;ll illustrate PHP&#8217;s <strong>variable variables</strong> and <strong>Variable constants</strong>. There is no variable constants in PHP but I&#8217;m introducing a methodology to implement the same approach and achieve the same functionality as variable variables.<br />
<span id="more-321"></span><br />
As you may know that you can have a <strong>variable variable</strong> like the following:</p>
<pre class="brush: php; title: ; notranslate">
$who = 'world';
$world = 'World!';
$people = 'People!';
echo 'Hello ' . $$who;
// output: Hello World!
</pre>
<p>Where the variable name here becomes $world as the value of $who, if we changed the value of $who to be &#8216;people&#8217;, in the last line it will load the variable $people. </p>
<pre class="brush: php; title: ; notranslate">
$who = 'people';
$world = 'World!';
$people = 'People!';
echo 'Hello ' . $$who;
// output: Hello People!
</pre>
<p>What if you want to have a variable constant? I mean like you want to lookup a name of a constant dynamically.</p>
<p>Suppose we have got the following constants:</p>
<pre class="brush: php; title: ; notranslate">
define('PAYPAL_MIN_AMOUNT',5); // minimum amount of payment for paypal method
define('CREDIT_CARD_MIN_AMOUNT',30); // minimum amount of payment for credit card method
</pre>
<p>Now we want to dynamically validate the submitted amount against the minimum amount according to the payment method.</p>
<p>The submitted value is either PAYPAL or CREDIT_CARD<br />
we can do the following:</p>
<pre class="brush: php; title: ; notranslate">
// suppose this was the submitted value
$paymentMethod='PAYPAL';
echo &quot;Minimum amount for {$paymentMethod} is &quot; . constant($paymentMethod.'_MIN_AMOUNT') . ' USD';
// output: Minimum amount for PAYPAL is 5 USD
$paymentMethod='CREDIT_CARD';
echo &quot;Minimum amount for {$paymentMethod} is &quot; . constant($paymentMethod.'_MIN_AMOUNT') . ' USD';
// output: Minimum amount for CREDIT_CARD is 30 USD
</pre>
<p>We made use of the <a href="http://php.net/manual/en/function.constant.php">constant()</a> php standard function to call a variable constant name. Which returns the value of a given constant name.</p>
<p>Happy programming <img src='http://www.omaroid.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/php-variable-variables-and-variable-constants/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP: get and set custom HTTP headers</title>
		<link>http://www.omaroid.com/php-get-and-set-custom-http-headers/</link>
		<comments>http://www.omaroid.com/php-get-and-set-custom-http-headers/#comments</comments>
		<pubDate>Tue, 01 May 2012 18:11:17 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[http headers]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=303</guid>
		<description><![CDATA[In this short tutorial I will illustrate how can you send and read custom HTTP headers using php. First let&#8217;s start by sending a custom HTTP header to the server. I will be using cURL library to send HTTP requests. Sending The Request Header Let&#8217;s say our custom header name is &#8216;Authorization&#8217; and we want [...]]]></description>
				<content:encoded><![CDATA[<p>In this short tutorial I will illustrate how can you send and read custom <strong>HTTP headers</strong> using php.</p>
<p>First let&#8217;s start by sending a custom <strong>HTTP header</strong> to the server. I will be using <a href="http://php.net/manual/en/book.curl.php" target="_blank">cURL</a> library to send HTTP requests.</p>
<p><span id="more-303"></span></p>
<h2>Sending The Request Header</h2>
<p>Let&#8217;s say our custom header name is &#8216;Authorization&#8217; and we want to set its value to &#8217;123456&#8242;, now create a file named http-request.php with the following content:</p>
<pre class="brush: php; title: ; notranslate">
$uri = 'http://localhost/http.php';
$ch = curl_init($uri);
curl_setopt_array($ch, array(
	CURLOPT_HTTPHEADER	=&gt; array('Authorization: 123456'),
	CURLOPT_RETURNTRANSFER	=&gt;true,
	CURLOPT_VERBOSE		=&gt; 1
));
$out = curl_exec($ch);
curl_close($ch);
// echo response output
echo $out;
</pre>
<p>Now we have sent the request with method POST. The CURLOPT_VERBOSE option is used for debugging when you want to output the request headers and the response headers. You shall remove it on production.</p>
<h2>Reading the custom header</h2>
<p>Now let&#8217;s create the reads that custom header sent from the curl request. create a file named http.php with the following contents</p>
<pre class="brush: php; title: ; notranslate">
print_r(apache_request_headers());
</pre>
<p>Now execute the http-request.php using cli to watch the debug output.<br />
Now if you are lucky enough you will see the Authorization header as below:</p>
<pre class="brush: plain; title: ; notranslate">
Array
(
    [Host] =&gt; localhost
    [Accept] =&gt; */*
    [Authorization] =&gt; 123456
    [Content-Length] =&gt; 9
    [Content-Type] =&gt; application/x-www-form-urlencoded
)
</pre>
<p>Oh, What if I&#8217;m not lucky? then you have PHP installed as CGI and have got php < 5.4 . People who have PHP installed as an Apache module or have PHP version 5.4 are the lucky ones, but don't worry I've got your back.</p>
<h2>Custom Headers with PHP CGI</h2>
<p>To work around this we will have to play around with the .htaccess but you will need mod_rewrite.</p>
<pre class="brush: plain; title: ; notranslate">

    RewriteEngine On
    RewriteRule .? - [E=Authorization:%{HTTP:Authorization}]

</pre>
<p>What are we doing up there? Well we are reading the HTTP header named &#8216;Authorization&#8217; by %{HTTP:Authorization} and setting it as an environment variable with the E so it will be accessible by the $_SERVER superglobal. Also make sure that the rule is right after the &#8216;RewriteEngine On&#8217; statement to avoid conflicts.</p>
<p>Now try this in the http.php:</p>
<pre class="brush: plain; title: ; notranslate">
echo $_SERVER['Authorization'];
</pre>
<p>Voila!</p>
<p>Reference:<br />
<a href="http://httpd.apache.org/docs/2.0/env.html" title="Environment Variables in Apache" target="_blank">Environment Variables in Apache</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/php-get-and-set-custom-http-headers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cakephp: Force SSL on certain actions</title>
		<link>http://www.omaroid.com/cakephp-force-ssl-on-certain-actions/</link>
		<comments>http://www.omaroid.com/cakephp-force-ssl-on-certain-actions/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 20:00:49 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cakephp 2.0]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=276</guid>
		<description><![CDATA[After going here and there and implementing alot of solutions, I found that every post request is getting redirected to get even if it was with HTTPS because of the implementation of the ForceSSL in the manual, so my word to you, save your time and implement this simple solution. I have tested it on [...]]]></description>
				<content:encoded><![CDATA[<p>After going here and there and implementing alot of solutions, I found that every post request is getting redirected to get even if it was with HTTPS because of the implementation of the ForceSSL in the manual, so my word to you, save your time and implement this simple solution. I have tested it on <strong>cakephp 2.0</strong> however I think it wouldn&#8217;t mind to work on <strong>cakephp 1.3</strong><br />
<span id="more-276"></span><br />
First thing, we are going to define the actions that requires SSL, which I&#8217;ll name the secure actions</p>
<pre class="brush: php; title: ; notranslate">
class AppController extends Controller {
    protected $secureActions = array(
    	'place_order',
    	'login',
    	'checkout'
    );
}
</pre>
<p>We are going to check if the current action is in our secure actions</p>
<pre class="brush: php; title: ; notranslate">
function beforeFilter() {
        if (in_array($this-&gt;params['action'], $this-&gt;secureActions) 
            &amp;&amp; !isset($_SERVER['HTTPS'])) {
                $this-&gt;forceSSL();
        }
}
</pre>
<p>Then we will implement a method to redirect to the same URI but with <strong>HTTPS</strong></p>
<pre class="brush: php; title: ; notranslate">
public function forceSSL() {
	$this-&gt;redirect('https://' . $_SERVER['SERVER_NAME'] . $this-&gt;here);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/cakephp-force-ssl-on-certain-actions/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Cakephp: Pagination sorting from foreign fields (fields from associated models)</title>
		<link>http://www.omaroid.com/cakephp-pagination-sorting-from-foreign-fields-fields-from-assoiciated-models-2/</link>
		<comments>http://www.omaroid.com/cakephp-pagination-sorting-from-foreign-fields-fields-from-assoiciated-models-2/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 17:41:01 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cakephp 2.0]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=284</guid>
		<description><![CDATA[I came across a problem while developing with cakephp 2.0. Suppose that you have got a Post model and a Category model, and you have a grid, with all posts and the category title they belong to. In order to sort by the category title you will need to do as the following in your [...]]]></description>
				<content:encoded><![CDATA[<p>I came across a problem while developing with cakephp 2.0. </p>
<p>Suppose that you have got a Post model and a Category model, and you have a grid, with all posts and the category title they belong to. In order to sort by the category title you will need to do as the following in your view.</p>
<pre class="brush: php; title: ; notranslate">
echo $this-&gt;Paginator-&gt;sort('Category.title','labelForTheTableHeader');
</pre>
<p>Hope that helps anyone<br />
Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/cakephp-pagination-sorting-from-foreign-fields-fields-from-assoiciated-models-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Egypt&#8217;s Mobile Number Change</title>
		<link>http://www.omaroid.com/egypts-mobile-number-change/</link>
		<comments>http://www.omaroid.com/egypts-mobile-number-change/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 15:33:50 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[egypt]]></category>
		<category><![CDATA[etisalat]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[mobinil]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[vodafone]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=257</guid>
		<description><![CDATA[I&#8217;ve developed a snipped to correct the old numbers with the new numbers The number change schema as follows: (old -> new) Mobinil 012 XXX XXXX -> 0122 XXX XXXX 017 XXX XXXX -> 0127 XXX XXXX 018 XXX XXXX -> 0128 XXX XXXX 0150 XXX XXXX -> 0120 XXX XXXX Etisalat 011 XXX XXXX [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve developed a snipped to correct the old numbers with the new numbers</p>
<p>The number change schema as follows:<br />
<strong><br />
(old -> new)</strong></p>
<p><strong>Mobinil </strong></p>
<p>012 XXX XXXX -> 0122 XXX XXXX<br />
017 XXX XXXX -> 0127 XXX XXXX<br />
018 XXX XXXX -> 0128 XXX XXXX<br />
0150 XXX XXXX -> 0120 XXX XXXX</p>
<p><strong>Etisalat</strong></p>
<p>011 XXX XXXX -> 0111 XXX XXXX<br />
014 XXX XXXX -> 0114 XXX XXXX<br />
0152 XXX XXXX -> 0112 XXX XXXX<br />
<strong><br />
Vodafone</strong></p>
<p>010 XXX XXXX -> 0100 XXX XXXX<br />
016 XXX XXXX -> 0106 XXX XXXX<br />
019 XXX XXXX -> 0109 XXX XXXX<br />
0151 XXX XXXX -> 0101 XXX XXXX</p>
<p>so here is my little <strong>php function </strong>that will use <strong>regular expressions</strong></p>
<pre class="brush: php; title: ; notranslate">
function changeMobileNumbers(&amp;$contents){
	// vodafone
	$contents = preg_replace('/(0151)([0-9]{7})/', '0101$2', $contents);
	$contents = preg_replace('/(010)([0-9]{7})/', '0100$2', $contents);
	$contents = preg_replace('/(016)([0-9]{7})/', '0106$2', $contents);
	$contents = preg_replace('/(019)([0-9]{7})/', '0109$2', $contents);
	
	// etisalat
	$contents = preg_replace('/(0152)([0-9]{7})/', '0112$2', $contents);
	$contents = preg_replace('/(011)([0-9]{7})/', '0111$2', $contents);
	$contents = preg_replace('/(014)([0-9]{7})/', '0114$2', $contents);
	
	// mobinil
	$contents = preg_replace('/(0150)([0-9]{7})/', '0120$2', $contents);
	$contents = preg_replace('/(012)([0-9]{7})/', '0122$2', $contents);
	$contents = preg_replace('/(017)([0-9]{7})/', '0127$2', $contents);
	$contents = preg_replace('/(018)([0-9]{7})/', '0127$2', $contents);
	return $contents;
}
</pre>
<p>Hope that was useful</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/egypts-mobile-number-change/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to reset MySQL root password</title>
		<link>http://www.omaroid.com/reset-mysql-root-password/</link>
		<comments>http://www.omaroid.com/reset-mysql-root-password/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 09:42:56 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=246</guid>
		<description><![CDATA[In this article I&#8217;ll go through resetting MySQL root password the easiest way We are going to stop the MySQL daemon to be able to run it in safe mode, then we are going to skip grant tables, which means we are skipping password authentication, then we will set our new password First, Let&#8217;s stop [...]]]></description>
				<content:encoded><![CDATA[<p>In this article I&#8217;ll go through resetting <strong>MySQL root password</strong> the easiest way</p>
<p>We are going to stop the MySQL daemon to be able to run it in safe mode, then we are going to skip grant tables, which means we are skipping password authentication, then we will set our new password<br />
<span id="more-246"></span><br />
First, Let&#8217;s stop the mysql service, In Red Hat&#8217;s family (<strong>Red Hat Enterprise</strong>, <strong>Fedora</strong>, <strong>CentOS</strong>) the Mysql Daemon is called &#8216;<strong>mysqld</strong>&#8216;, but in <strong>Debian</strong>like <strong>Ubuntu</strong> based distributions and <strong>OpenSuse</strong> its called &#8216;<strong>mysql</strong>&#8216;. I&#8217;ll be using the debian based naming</p>
<pre class="brush: bash; title: ; notranslate">
sudo service mysql stop
</pre>
<p>OR</p>
<pre class="brush: bash; title: ; notranslate">
sudo /etc/init.d/mysql stop
</pre>
<p>Now, we&#8217;ll start the server in safe mode and skip grant tables so that it wont ask for the password we had lost when we try to login</p>
<pre class="brush: bash; title: ; notranslate">
sudo mysqld_safe --skip-grant-tables
</pre>
<p>you should see something like this</p>
<pre class="brush: bash; title: ; notranslate">
111026 11:05:46 mysqld_safe Logging to syslog.
111026 11:05:46 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
</pre>
<p>Now open a new terminal window and run the mysql console using the main mysql database named &#8216;<strong>mysql</strong>&#8216; using the <strong>root</strong> user</p>
<pre class="brush: bash; title: ; notranslate">
mysql --user=root mysql
</pre>
<p>Then we&#8217;ll reset the password from the mysql&#8217;s users table, flush privieges, then exit the mysql console</p>
<pre class="brush: sql; title: ; notranslate">
UPDATE user SET password=PASSWORD('new-password') WHERE user='root';
</pre>
<pre class="brush: bash; title: ; notranslate">
flush privileges;
exit;
</pre>
<p>Start again the mysql daemon</p>
<pre class="brush: bash; title: ; notranslate">
sudo service mysql stop
sudo service mysql start
</pre>
<p>That&#8217;s All <img src='http://www.omaroid.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/reset-mysql-root-password/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Changing Window Icon in Tkinter</title>
		<link>http://www.omaroid.com/changing-window-icon-in-tkinter/</link>
		<comments>http://www.omaroid.com/changing-window-icon-in-tkinter/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 23:31:24 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tkinter]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=235</guid>
		<description><![CDATA[Tkinter is the most commonly used GUI programming toolkit for python Here is how you can change the program icon in tkinter Where window.ico is the icon file you want to use instead of the default tkinter logo You can convert ico to xpm using GIMP]]></description>
				<content:encoded><![CDATA[<p><strong>Tkinter</strong> is the most commonly used <strong>GUI programming toolkit</strong> for <strong>python</strong></p>
<p>Here is how you can change the program icon in <strong>tkinter</strong><br />
<span id="more-235"></span></p>
<pre class="brush: python; title: ; notranslate">
#instantiate tkinter
root=gui.Tk()
#change the window icon to be window.ico
#this works on windows for linux icon files shall be .xpm
root.iconbitmap('window.ico')
root.mainloop()
</pre>
<p>Where window.ico is the icon file you want to use instead of the default tkinter logo</p>
<p>You can convert ico to xpm using <a href="http://www.gimp.org" target="blank">GIMP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/changing-window-icon-in-tkinter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing LAMP with PHP 5.3 on Ubuntu 11.04 Natty Narwhal / 11.10 Oneric Ocelot</title>
		<link>http://www.omaroid.com/installing-lamp-with-php-5-3-6-on-ubuntu-11-04-natty-narwhal/</link>
		<comments>http://www.omaroid.com/installing-lamp-with-php-5-3-6-on-ubuntu-11-04-natty-narwhal/#comments</comments>
		<pubDate>Fri, 20 May 2011 10:20:33 +0000</pubDate>
		<dc:creator>Omar Abdallah</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[narwhal]]></category>
		<category><![CDATA[natty]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php 5.3]]></category>
		<category><![CDATA[php 5.3.6]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.omaroid.com/?p=211</guid>
		<description><![CDATA[I wont cover what&#8217;s new in php 5.3 since it would be another article, however it contains alot of improvements including PHP Namespaces, Late Static Bindings, lambda functions, closures&#8230;etc. I would strongly recommend using it. I&#8217;ll be explaining how to install LAMP stack with PHP 5.3.8 without compiling It&#8217;s fairly easy using the dotdeb repository [...]]]></description>
				<content:encoded><![CDATA[<p>I wont cover <a href="http://blogs.sitepoint.com/whats-new-php-5-3/" target="_blank">what&#8217;s new in php 5.3</a> since it would be another article, however it contains alot of improvements including <strong>PHP Namespaces</strong>, <strong>Late Static Bindings</strong>, <strong>lambda functions</strong>, <strong>closures</strong>&#8230;etc. I would strongly recommend using it.</p>
<p>I&#8217;ll be explaining how to install <strong>LAMP stack</strong> with <strong>PHP 5.3.8</strong> without <strong>compiling</strong></p>
<p>It&#8217;s fairly easy using the dotdeb repository</p>
<p><span id="more-211"></span></p>
<h2>Step 1: Add the dotdeb repository:</h2>
<p>first we need to add the <strong>dotdeb</strong> application sources to our sources list</p>
<pre class="brush: bash; title: ; notranslate">
sudo nano /etc/apt/sources.list
</pre>
<p>And copy and paste the following lines and save using ctrl+o</p>
<pre class="brush: bash; title: ; notranslate">
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
</pre>
</p>
<h2>Step 2: Import the GPG key for the dotdeb repository</h2>
<p>Then we&#8217;ll add the GPG key for the dot deb repository by the following command:</p>
<pre class="brush: bash; title: ; notranslate">
wget http://www.dotdeb.org/dotdeb.gpg &amp;&amp; cat dotdeb.gpg | sudo apt-key add -
</pre>
<p>Now we&#8217;ll refresh the packages list by the following command:</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get update
</pre>
</p>
<h2>Step 3: Installation</h2>
<p>
Now we&#8217;re ready to install our <strong>LAMP stack</strong></p>
<pre class="brush: bash; title: ; notranslate">
sudo aptitude install apache2 apache2-mpm-prefork mysql-client-5.5 mysql-server-5.5 php5 php5-cli php5-mysql libapache2-mod-php5 php5-dev php5-mcrypt php5-curl php5-gd phpmyadmin
</pre>
<p>Now we&#8217;re all set, just need to test it<br />
go to http://localhost/ to test apache<br />
and we can test php by writing in the bash</p>
<pre class="brush: bash; title: ; notranslate">php -v</pre>
<p>you should see something like the following:</p>
<pre class="brush: bash; title: ; notranslate">
PHP 5.3.8-1~dotdeb.2 with Suhosin-Patch (cli) (built: Aug 25 2011 13:30:46)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
</pre>
</p>
<h3>Update:</h3>
<p>Since the new distros of the Ubuntu uses <strong>php 5.3</strong>, the magical command in <strong>step 3</strong> will be sufficient, however if you need a more updated version use the <strong>dotdeb</strong> repository, if you don&#8217;t care much about which version to use 5.3.x just skip to step 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omaroid.com/installing-lamp-with-php-5-3-6-on-ubuntu-11-04-natty-narwhal/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
