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.

Blogger Buzz: Announcing the Blogger app for iOS

I think I should buy a new smart phone

Blogger Buzz: Announcing the Blogger app for iOS: Today we’re excited to announce the new Blogger app for iOS. With the Blogger app, you can write a new blog post and publish it immediately ...

Copy wordpress from local to online

I have installed wordpress latest version (3.2.1)  , on my local machine , and then uploaded it to a host , when I go to the admin panel , it keeps redirecting me to the local address .

After debugging , I discovered that wordpress stores some info in a configuration file , and other info in database , and I have uploaded the database as it is .

To solve this problem , I open phpmyadmin on the host server , and I changed the site_url option to the correct one , from table wp_options .

Create a new module on joomla 1.7

I moved to joomla to make a small job .
I needed to make a new module to make things customizable on the home page ,  but it seems that joomla 1.7 uses a new way to make modules, rather than the one described in their documentation ( click here ) .

You will make everything as the tutorial said , except some small changes in the xml file .
To add files and folders , you don't need to write all files in each folder but you can include a complete folder in a way like that

	mod_hello_world.php
	index.html
	tmpl
	mod_hello_world.xml

When you write tmpl , all files inside this folder are automatically included .
Also you will have to take care when you include parameters , there is a new way to do that


 
  

spaghetti code

I am working these days enhancing an old project .
I am writing some tweaks in a php page , that prints html code , and sometimes javascript code , that is included from another php code , that reads a cached file and writes a js array and then prints html code .

The legacy application connects to MsSql database , and for making a development virtual machine , we were obligated to run the application on windows xp , installing xampp and we started the game .

Always the first level is easy , some minor enhancements were required , and we were done .
But the post levels were tricky , some pages were not working at all , I struggled to find the reason , and I was surprised when I found it .

Some php pages where including some other pages , a way like this

include "/var/www/lib/ClassName.php" ;

Of course that was not working in Windows Xp , as there is now "/var/www" in windows platforms , so I learned a new lesson , when writing an application , the safest way to include files is to make one file of configuration that holds all the root folders as constant variables .
And when including specific files , you use those variables , and change it whenever you want , for example if you change the environment .

I love Linux .

Zend Framework modular design


Hi

This is a repost of the old post about the zend framework modular redesign .

Files and directories hierearchy

www/
 application/
  admin/
   controllers/
   forms/
   layouts/
   models/
   views/
  configs/
   application.ini
  default/
   controllers/
   forms/
   layouts/
   models/
   views/
  Bootrstap.php
 library/
  Zend/
 public/
  index.php

And here is the configs/application.ini file , I will list the most important lines .
This is for the modules , note that we have made the module directory , the Application Path itself , so you can put your modules inside application directory as we did in the directories hierarchy .

includePaths.library = APPLICATION_PATH "/../library"

bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

appnamespace = "Application"
resources.frontController.moduleDirectory = APPLICATION_PATH 
resources.modules[] = 


and in the Bootstrap file , you can define _init function as you can , the most important one is the autoload function , here is Bootstrap.php file
here you are loading the two namespace you have ( default and admin ) .

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

    public function _initAutoload() {
        $autoloader = new Zend_Application_Module_Autoloader(
                        array('namespace' => 'Default',
                            'basePath' => dirname(__FILE__) . '/default',
                        )
        );
        
        $autoloader2 = new Zend_Application_Module_Autoloader(
                        array('namespace' => 'Admin',
                            'basePath' => dirname(__FILE__) . '/admin',
                        )
        );
        
        $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
        Zend_Layout::startMvc();
        $bootstrap = $application->getBootstrap();

        Zend_Session::start();
        $db = new Zend_Db_Adapter_Mysqli($bootstrap->getOption("database"));
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
        return $autoloader;
    }
}
That's it , feel free to ask any questions .

BAD SUPERBLOCK

I fixed a bad superblock on linux ubuntu 10.10
I did recover some important files , I will reinstall ubuntu 11.04 64bit .

I took advice from this link
http://www.cyberciti.biz/faq/recover-bad-superblock-from-corrupted-partition/

Blogger Buzz: Announcing Blogger Mobile Templates

Blogger Buzz: Announcing Blogger Mobile Templates: "Posted by Jiho Han, Software Engineer A few months ago we introduced mobile templates to Blogger in Draft . Today, we’re excited to announ..."

From Blogger Buzz

This is very nice , I tried it for this blog and it seems good on iphone .

How to know first revisions on svn branches ?

So , if you are working as builder who merge the branches to the trunks , and find conflicts and all that *** * , I think that command will help you .

This will help you the first revision of the branch , so you can only merge the needed revisions

svn log BRANCH_LINK --stop-on-copy
The last revision will be the revision of copying .
Merging of course will be easy like this

svn merge -r REVISION:HEAD BRANCH_LINK

Assuming that your current directory is the working copy .

How to know the changed files on your svn branch ?

Hi all

Sometimes I encountered this problem with working with SVN , I took a branch and made a lot of changes , then I need to know which files I have changed in .

This can be done with a simple svn command , execute it on your branch .

svn diff -r 1234:HEAD --summarize

Where 1234 is the revision of the branch when you first copied it .
That's it , this command will list all your changes .

How to install jre on Ubuntu 10.10

Hi

This is a problem that faced me on installing a new version of ubuntu 10.10 , I think a big number of ubuntu users have the same problem .

How to install java ( jre and jdk ) on Ubuntu

I followed the instructions on this page from ubuntugeek.com and it worked successfully .

sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-jdk sun-java6-plugin

I hope it will help anyone .