Make Skype working on Linux Ubuntu 13.10 64bit

If you have a fresh install or an upgrade to Ubuntu 13.10 , you may encounter some difficulties on skype, whatever your pc or laptop is.
You may also download skype from its website and find it working perfectly , but if you get all sounds on skype distorted or no sound at all , then here is the solution .


  1. Remove any installation of skype 
    sudo apt-get remove skype
    
  2. Open "Software & Updates" and enable the "Canonical Partners" repository. Open Terminal or Alt+F2 and type
    software-properties-gtk
    
  3. Update and install skype
    sudo apt-get update
    sudo apt-get install skype
    
  4. Run this command 
    sudo sed -i 's/^Exec=.*/Exec=env PULSE_LATENCY_MSEC=30 skype %U/' /usr/share/applications/skype.desktop
    This is a workaround t get skype working with PulseAudio 4.0.
    In any shortcut of skype , or if you want to run it from terminal just add( PULSE_LATENCY_MSEC=30 )

Use @font-face with an Arabic Font

Now you can add an arabic font to your css , and make all you arabic web pages look the same at all browsers that support ( @font-face ) .
Download Amiri Font from here (  http://www.amirifont.org/ ) and enjoy creating arabic websites .

Introductive Guide for using Facebook php sdk

In this post I will explain how to connect your website visitors with their Facebook accounts , so you don't need to prompt your users with registration forms or login forms , just a button to login with Facebook or connect with Facebook and you are done .
You can save your users Facebook data in your database , also you can save their Facebook login status in cookies not to prompt them every time with the login dialog .

I will also explain how to post on Facebook users timeline , also post on the pages they own ( or the pages in which they are admin ) .
Also the post can include photos or videos like any post you put on facebook.

Let's begin .
First you have to create a new app , go to http://developers.facebook.com/apps and then click on "Create New App" button , choose a unique name and then click Create .
You can choose free webhosting if you don't have a host .

You will be redirected to a page where you can edit your app settings , to visit this page again , you can go to http://developers.facebook.com/apps you will find your apps on the left , and Edit Settings link on the right .

The first page is Basic page , you can edit general information about your app , the most important thing you have to check is "App Domains" , you can enter several domains , but you must have control on them.
Also in the Basic page you have you app ID and app Secret , grab them and save them for now .

The second page is Basic > Permissions , you have 2 fields to edit ( User & Friend Permissions ) and ( Extended Permissions ) , you will find a list of available permissions here ( http://developers.facebook.com/docs/reference/login/#permissions ) .

If you need access to the users friends list , you have to add read_friendlists to extended permissions .
If you want to post on their behalf , you should add publish_stream .
And if you need to manage their pages , you have to add manage_pages to extended permissions.

Go now and download from github the facebook php sdk ( https://github.com/facebook/facebook-php-sdk ) , copy the src folder to somewhere included in your website .

Go to your index.php page , or any page you need to be accessed by facebook and type the following.
First include facebook sdk file
require_once 'src/facebook.php' ;

Next create new instance from this class
$facebook = new Facebook(array('appId' =>APP_ID,
'secret' =>APP_SECRET
));
APP_ID and APP_SECRET can be got from the basic page of your facebook app ( http://developers.facebook.com/apps ) .

Second you need to check if the user is logged in and has authorised your application or not , this can be done using the following line .
$facebook->getUser();
This function check if the user is logged in and authorised to your app or not , and is saving the logging data in session
If the user is not logged in , we should print a login url to connect the user with facebook .
if(!$facebook->getUser()){
printf('Connect With Facebook') , $facebook->getLoginUrl(array("scope" => "manage_pages,publish_stream")));
}
You should add the scope ( or the permissions ) you have included from the settings page in your app , in the login url that the user will go and click and authorise your app , so he ( the user ) will authorise your app for the permissions included .

The user should be prompted with something like that .

If the user authorised your app , he should be redirected back to your website so you can check again if he logged in or not.
if(!$facebook->getUser()){
printf('Connect With Facebook') , $facebook->getLoginUrl(array("scope" => "manage_pages,publish_stream")));
} else {
// the user is logged in and authorised the app
// we can grab the user account data .
$userData = $facebook>api('/me');
printf ( 'Welcome %s' , $userData["name"]);
}
If you need to publish a post on behalf of the user , remember that you need "publish_stream" permission
$params = array("message" => "Testing the new facebook sdk");
$facebook->api("USER_ID/feed" , 'POST' , $params);
You can get User_ID from $userData ( $facebook->api('/me') );
$params is associative array of the post parameters , you can get full description of the parameters here ( https://developers.facebook.com/docs/reference/api/post/ ) .

If you need a list of the pages the user owns or admins
$pages = $facebook->api("/me/accounts");
I hope that will be useful for anyone want to use the facebook php sdk .

Easiest way to install LAMP on ubuntu ( using task-sel )

This is the easiest way to install LAMP on linux ubuntu , using only one or two commands from your terminal . Open your terminal and type the following :
sudo apt-get install task-sel

That will install Task Selector , with which you can install a bunch of services on Ubuntu .
After completing the installation , type the following
sudo task-sel

You will find the terminal changing to the following
Select "LAMP server" package ( press space to select ) and press OK ( press tab and then enter ) .
The packages will be downloaded ( apache , php and mysql ) and then they will be installed , the mysql  installation will prompt to you to choose the root password .

That's it , you now have a full working LAMP server.

You can also install phpmyadmin by typing the following
sudo apt-get install phpmyadmin


Upgrade Ubuntu

If you want to upgrade your ubuntu version to the 12.0 ( Quantal Quetzal ) , make sure you have a working internet connection , then open your terminal or command window ( Alt+F2 ) and type
update-manager -d


The update manager will open and you will find a new box for the upgrade , click "upgrade" and relax ; it will take some time not like installing a fresh version.

This way has been useful with me for upgrading ubuntu for several versions , and I think it will be the same afterwards for upgrading for each new version for ubuntu.

What Every Developer Must Know About PHP 5.4

This article is a very helpful brief about the new features in php 5.4
http://bit.ly/MwG6Xe


Php Configuration : expose_php

I have read about this in Apress ( Apress Beginning PHP and MySQL From Novice to Professional ) , Chapter 21 ( Securing Your Web Site )

Each scrap of information that a potential attacker can gather about a web server increases the
chances that he will successfully compromise it. One simple way to obtain key information about server
characteristics is via the server signature.
For example, Apache will broadcast the following information
within each response header by default:
Apache/2.2.0 (Unix) PHP/5.3.0 PHP/5.3.0-dev Server at www.example.com Port 80
Disabling expose_php prevents the web server signature (if enabled) from broadcasting the fact that
PHP is installed. Although you need to take other steps to ensure sufficient server protection, obscuring
server properties such as this one is nonetheless heartily recommended.

Simply this information you won't use if you are working on a shared hosting , or working locally on you machine, but if you manage to create your own servers, you would rather disable expose_php .

Simply Ubuntu

First Book in arabic to explain How to install Ubuntu and work with ubuntu .
I am really proud of it
Please visit http://www.simplyubuntu.com/ 

Honeypot , to catch spam bots

This is a wordpress plugin ( http://wordpress.org/extend/plugins/contact-form-7-honeypot/ ) , it adds a hidden form input field , in your contact form , so the spam bots will fill it automatically , but the form submission will fail if you fill it .

Usually normal users will not see this empty hidden field , and so their submission will be correct .

Surely , the same concept can be applied in any form not only wordpress forms.
I have first read about this in Lornajane blog ( http://www.lornajane.net/posts/2012/wordpress-contact-form-7-without-captcha ) .

The Shapes of CSS

The Shapes of CSS

This link is so useful , with which you can draw any shape you want with just pure css.