Saturday, September 3, 2011

How To add a HTTPS address to your etc/hosts File

First Open your hosts file on   /etc/hosts on Linux  OR  C:\Windows\System32\drivers\etc on Windows systems

As known, the default port for web browsing is port 80, so every record inserted in the hosts file as default use port 80.

In order to add an "https" address just specify the ssl port for the desired record like so:

Now will be handled by your localhost

Friday, September 2, 2011

How To Add Social Like and Share buttons to your site or blog

The internet is going social and if there's a free easy way to get more publicity and attract more people then why not?!

To get a good coverage of social sharing you'll need three most important buttons
provided by Google, Facebook and Twitter social networks
So, to get a social buttons stripe just like that:

 You'll need the following code:

Google plusone


<script type="text/javascript">
      (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    <g:plusone size="medium"></g:plusone>

for more info and more versions of the Google plusone button see:

Twitter Tweet Button

<a href="" class="twitter-share-button" data-count="horizontal" >Tweet</a>
<script type="text/javascript" src=""></script>

for more info and more versions of the Tweet Button see:

Facebook Like Button

<div id="fb-root">
<script src=";xfbml=1">
<fb:like layout="button_count" send="true" show_faces="false"></fb:like>

for more info and more versions of the Facebook Like button see:

The Complete Code:

<div class="social_buttons">

<!-- Facebook -->
<div id="fb-root"></div>
<script src=";xfbml=1"></script>

<span><fb:like layout="button_count" send="true" show_faces="false"></fb:like></span>

<!-- Twitter -->
<span><a class="twitter-share-button" data-count="horizontal" href="">Tweet</a></span>
<script src="" type="text/javascript"></script>

<!-- Google -->
<script type="text/javascript">
(function() {var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;po.src = '';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

<span><g:plusone size="medium"></g:plusone></span>


Friday, July 29, 2011

Calculate time-diff and calculate age from birth date

On my searches I've found many many different, complicated functions for time difference and many different functions calculate age, But for such a simple task I thought there should be a simpler solution.
so here are a few good simple ways to calculate time differences and age

good and simple function that because of the versatility of strtotime function can support many different date formats:

function dateDiff($from, $to = "now")
return round((strtotime($to) - strtotime($from))/60/60/24);

and if age calculation is what you desire,
a simple function to calculate age by birth date

* Calc age from MySQL date format
* @param string $date YY-mm-dd (MySQL Date Format)
function calcAge($date)
//Break the date into an array
list($Y,$m,$d) = explode("-",$date);
//Calculate Year Diff
$age = date("Y")-$Y;
//Subtract a year if exact birth date hasn't passed yet
if(date("md") < $m.$d) $age--;
//And finally return the age
return $age;