Zak's Blog http://kaddari.info Most recent posts at Zak's Blog posterous.com Wed, 28 Mar 2012 04:43:00 -0700 jQuery event handling best practice http://kaddari.info/jquery-binding-event-handling-best-practice http://kaddari.info/jquery-binding-event-handling-best-practice

Anonymous functions are usually used extensively in jQuery events handling, however, anonymous functions are difficult to debug, maintain, test, or reuse.

A better way is to use object literals as in this example:

 

//BAD
$(document).ready(function() {
  $('.status .delete').click(function(e) {
    //Do something
  });

  $('.status').dblclick(function(e) {
    //Do the same thing
  });
});

//GOOD
var bindingObject = {
  onReady : function() {
    $('.status .delete').click(bindingObject.deleteTweet);
    $('.status').dblclick(bindingObject.deleteTweet);
  },
  deleteTweet : function(e) {
    //Do something
  }
};

$(document).ready(bindingObject.onReady);

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1252856/Train.JPG http://posterous.com/users/hesvJTVfJIulI Zakaria KADDARI kadzaki Zakaria KADDARI
Tue, 27 Mar 2012 04:56:00 -0700 10 Symfony 1.4 best practices http://kaddari.info/10-symfony-14-best-practices http://kaddari.info/10-symfony-14-best-practices

Here is a list of 10 Symfony 1.4 best practices:

  1. Manage the view withing the view, try to avoid the use of view.yml, this will simplify future interventions by designers who are not necessary familiar with YML.
  2. Always call a redirect after posting data, this will inhence security and avoid content duplication in the database.
  3. The template must contain PHP alternative templating syntax.
  4. Only deploy production front controllers in production.
  5. Change the session_name param under the storage section in factories.yml
  6. Make sure a csrf_secret is defined in the settings.yml file.
  7. always apply Symfony coding standards http://trac.symfony-project.org/wiki/HowToContributeToSymfony
  8. Always create custom 404 and 500 error pages.
  9. Use sfLogger for debugging instead of echoing variables
  10. Use Symfony tasks system for CLI batch sripts.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1252856/Train.JPG http://posterous.com/users/hesvJTVfJIulI Zakaria KADDARI kadzaki Zakaria KADDARI
Tue, 27 Mar 2012 04:39:00 -0700 Symfony 1.4 Cheat Sheets http://kaddari.info/symfony-14-cheat-sheets http://kaddari.info/symfony-14-cheat-sheets

Can't remember all of Symfony 1.4 commands, syntax, architecture, ...? there is an amazing collection of cheat Sheets availeble from http://www.symfony-project.org/more-with-symfony/1_4/en/03-Enhance-your-Productivity under the "Cheat Sheets" section, here is some of the most interesting ones.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1252856/Train.JPG http://posterous.com/users/hesvJTVfJIulI Zakaria KADDARI kadzaki Zakaria KADDARI
Sun, 11 Dec 2011 11:49:14 -0800 TEDxOujda http://kaddari.info/56437850 http://kaddari.info/56437850

One month and a half after the first TEDx event took place in Oujda, Morocco (for more information about TED and TEDx you may go to http://www.ted.com and http://www.ted.com/tedx) am still feeling inspired by the ideas I saw that day, and by the speakers I met, it was an unforgettable experience, this was the first TEDx event in the city and the 3rd in the country.

I was honored to be a member of TEDxOujda organizers team.

Dsc_2341

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1252856/Train.JPG http://posterous.com/users/hesvJTVfJIulI Zakaria KADDARI kadzaki Zakaria KADDARI
Sun, 19 Jun 2011 03:55:00 -0700 RTL your CSS style http://kaddari.info/rtl-your-css-style http://kaddari.info/rtl-your-css-style

Suppose we have a CSS file called style.css, now create a separate CSS file, let's call it style-rtl.css for example, the first file contains all of our CSS properties, the other one will only contains the flipped CSS rules.

For example, if we are styling links in style.css as:

a{color:red; margin-left:10px;}

in the styles-rtl.css stylesheet we'll only include the flipped rule:

a{margin-right:10px;}

And then we link both:

<link rel="stylesheet" type="text/css" href="styles.css"/> <link rel="stylesheet" type="text/css" href="styles-rtl.css"/>

Make sure you include the overriding stylesheet after the original one to ensure the rules are overridden.

But notice that the link in RTL now has a margin-left of 10px AND a margin-right of 10px which is not what we want. We want the margin-left to be a margin-right. In that case we "reset" the margin-left like below:

a {margin-left:0; margin-right:10px;}

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1252856/Train.JPG http://posterous.com/users/hesvJTVfJIulI Zakaria KADDARI kadzaki Zakaria KADDARI
Wed, 25 May 2011 13:11:00 -0700 Google Days Maghreb, an amazing experience http://kaddari.info/google-days-maghreb-an-amazing-experience http://kaddari.info/google-days-maghreb-an-amazing-experience

Back from Google Days Maghreb, it was really an amazing experience ! so much information, great people (specially the Googlers :D) and most of all, diving inside the "Google culture", it was an unforgettable three days, full of techie conferences, workshops and fun :) I hope that this will be just the beginning of Google here in Morocco. 

Dsc05709

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1252856/Train.JPG http://posterous.com/users/hesvJTVfJIulI Zakaria KADDARI kadzaki Zakaria KADDARI