Sahid Ferdjaoui Blog - Funraill Foundation Bienvenue, Log in - thème 2007 RC1

Powered by OpenSource Softwares

Outil de déboggage colaborative
reduire

Microsoft Azure ??

le 22 juin 2009 par sahid

Microsoft à sa solution de cloud computing

Alors, je ne sais pas vous, mais moi je tombe des nu, je viens de découvrir que Microsoft a sa plateforme de cloud computing “Microsoft Azure” …

En farfouillant sur Wikipedia, j’ai pu lire un bref article ou l’annonce du projet avait été faite par Mr Balmer en Octobre 2008.

Bon j’ai quand même regardé le “taux de popularité” du projet sur google.com, et j’en est profité pour comparer les résultats avec Amazon AWS et Google App Engine:

      104,000,000 for amazon web services
      65,700,000 for app engine
      4,290,000 for microsoft azure

appengine, microsot azure, amazon web services

 microsoft azure  
 aws  
 app engine  

ils sont vraiment à la traine chez Microsoft, et je ne parle pas de leur “nouveau” moteur de recherche bing …souhaitons leur bonne chance quand même.

reduire

Google App Engine Books

le 22 juin 2009 par sahid

Livres sur Google App Engine

A ma grande surprise, plusieurs livres sur GAE son sorties, ils sont tous en anglais et il me semble qu’ils traitent pour la plupart des notions de base seulement. Enfin celà peut toujours être intéressant en complément de la doc.

Je me laisserai bien tenter part “Programming Google App Engine” pour ma part ;)


Google App Engine books

reduire

A Visual Expedition Inside the Linux File Systems

reduire

Amazon AWS continue to suprise me… (each time !)

le 18 mai 2009 par sahid

Today, Amazon lunch 3 very nice features, Elastic Load Balancing, Auto Scaling and Cloud Watch
Just i paste a permalink and a newsletter :

http://aws.typepad.com/aws/2009/05/new-aws-load-balancing-automatic-scaling-and-cloud-monitoring-services.html

Dear Amazon Web Services Customer,

We are excited to announce the public beta of several new features for
the Amazon Elastic Compute Cloud (Amazon EC2): Amazon CloudWatch, a
web service for monitoring AWS cloud resources, Auto Scaling for
automatically growing and shrinking Amazon EC2 capacity based on
demand, and Elastic Load Balancing for distributing incoming traffic
across Amazon EC2 compute instances. Together, these capabilities
provide you with visibility into the health and usage of your AWS
compute resources, enhance application performance, and lower costs.

Monitoring

Amazon CloudWatch is a web service that provides monitoring for AWS
cloud resources, starting with Amazon EC2. It provides customers with
visibility into resource utilization, operational performance, and
overall demand patterns -- including metrics such as CPU utilization,
disk reads and writes, and network traffic. To use Amazon CloudWatch,
simply select the Amazon EC2 instances that you'd like to monitor;
within minutes, Amazon CloudWatch will begin aggregating and storing
monitoring data that can be accessed using web service APIs or Command
Line Tools.

Auto Scaling

Auto Scaling allows you to automatically scale your Amazon EC2
capacity up or down according to conditions you define. With Auto
Scaling, you can ensure that the number of Amazon EC2 instances you're
using scales up seamlessly during demand spikes to maintain
performance, and scales down automatically during demand lulls to
minimize costs. Auto Scaling is particularly well suited for
applications that experience hourly, daily, or weekly variability in
usage. Auto Scaling is enabled by Amazon CloudWatch and available at
no additional charge beyond Amazon CloudWatch fees.

Elastic Load Balancing

Elastic Load Balancing automatically distributes incoming application
traffic across multiple Amazon EC2 instances. It enables you to
achieve even greater fault tolerance in your applications, seamlessly
providing the amount of load balancing capacity needed in response to
incoming application traffic. Elastic Load Balancing detects unhealthy
instances within a pool and automatically reroutes traffic to healthy
instances until the unhealthy instances have been restored. Customers
can enable Elastic Load Balancing within a single Availability Zone or
across multiple zones for even more consistent application
performance.

Like all Amazon Web Services and features, Amazon CloudWatch and
Elastic Load Balancing are available on a pay-as-you-go basis with no
up-front fee, minimum spend or long term commitment. Auto Scaling is
free to Amazon CloudWatch customers. Each instance launched by Auto
Scaling is automatically enabled for monitoring and the Amazon
CloudWatch monitoring charge will be applied.

For more information on these new features and details on how to start
using them, please see the resources listed below:

Amazon EC2 Detail Page
Release Notes

These have been among the most requested Amazon EC2 features by our
customers. We hope they prove useful to you, and we look forward to
your feedback.

Sincerely,

The Amazon Web Services Team

We hope you enjoyed receiving this message. If you wish to remove
yourself from receiving future product announcements or the AWS
Newsletter, please update your communication preferences.

Amazon Web Services LLC is a subsidiary of Amazon.com, Inc. Amazon.com
is a registered trademark of Amazon.com, Inc. This message produced
and distributed by Amazon Web Services, LLC, 1200 12th Ave South,
Seattle, WA 98144.
reduire

Migrate your static contents in S3 and deploy this with FrontCloud

le 10 mai 2009 par sahid

Using an EC2 instance to populate S3 and deploy with FrontCloud.

This cgi script it a simple example to use AWS services to migrate your static contents in FrontCloud.


  1. #!/usr/bin/env python
  2.  
  3. import os
  4. import cgi, cgitb
  5. import urllib2
  6. import hashlib
  7.  
  8. from time import time
  9.  
  10. from boto import connect_sdb
  11. from boto import sdb
  12. from boto import connect_s3
  13. from boto import s3
  14. from boto.s3 import bucket, key
  15.  
  16. #
  17. AWS_ACCESS_KEY_ID     = # Your AWS Access Key ID
  18. AWS_SECRET_ACCESS_KEY = # Your AWS Secret Access Key
  19.  
  20. AWS_SBD_DOMAIN        = # Your AWS SDB domain for stored data (ex: aws_forwarder)
  21. AWS_S3_BUCKET         = # Your AWS S3 bucket for stored data
  22. AWS_FC_DISTRIBUTION   = # Your AWS Frontcloud domain (ex: xyz.cloudfront.net)
  23.  
  24. REQUEST_KEY = ‘u’ # The key of request. for example your images use :
  25.                   # <img src="my.ec2.amazon.com/forwarder.py?u=/images/img00.jpeg"/>
  26.  
  27. REPOSITORY  =  # Your repository url. (ex: http://www.domain.com)
  28.                   # This script send a request at http://www.domain.com/images/img00.jpeg
  29.                   # for get a contents if it not already stored in S3.
  30.  
  31. EXPIRE      = 0   # Set expire of document, 0 = not expiration
  32. cgitb.enable ()
  33.  
  34. def http_response (status, reason, body = ""):
  35.   print ("Status: %s %s" % (status, reason))
  36.   print ("Content-Type: application/xml")
  37.   print ("")
  38.   print (body)
  39.   exit ()
  40.  
  41. # Check request.
  42. request = cgi.FieldStorage ()
  43. if not request.has_key (‘u’):
  44.   http_response (status = 400, reason = "Bad Request")
  45.   exit ()
  46.  
  47. # Ok, now check if it is already in S3.
  48. try:
  49.   query = request[‘u’].value.lstrip (‘/’)
  50.  
  51.   # SDB initialisation.
  52.   dbh = connect_sdb (aws_secret_access_key = AWS_SECRET_ACCESS_KEY,
  53.                      aws_access_key_id = AWS_ACCESS_KEY_ID)
  54.   try:
  55.     domain = dbh.get_domain (AWS_SBD_DOMAIN);
  56.   except:
  57.     domain = dbh.create_domain (AWS_SBD_DOMAIN)
  58.    
  59.   hash = hashlib.md5 (query).hexdigest ()
  60.   item = domain.get_item (hash)
  61.  
  62.   if item and EXPIRE > 0:
  63.     if item[‘expire’] > time () + EXPIRE:
  64.       item = None
  65.      
  66.   if not item:
  67.     try:
  68.       # Get file from a repository
  69.       document = urllib2.urlopen ("%s/%s" % (REPOSITORY, query))
  70.      
  71.       # Put contents in S3
  72.       s3 = connect_s3 (aws_secret_access_key = AWS_SECRET_ACCESS_KEY,
  73.                        aws_access_key_id = AWS_ACCESS_KEY_ID)
  74.      
  75.       b = bucket.Bucket (s3, AWS_S3_BUCKET)
  76.       k = key.Key (b)
  77.       k.key = query
  78.       k.set_contents_from_string (document.read ())
  79.      
  80.       # Add a name of file in SDB
  81.       item = domain.new_item (hash)
  82.       item[‘name’]   = query
  83.       item[‘expire’] = int (time () + EXPIRE)
  84.     except Exception, e:
  85.       http_response (status = e.status, reason = e.reason, body = e.body)
  86.  
  87.   # Ok, redirect into frontcloud
  88.   print ("Status: %s %s" % (301, "Moved Permanently"))
  89.   print ("Location: http://%s/%s" % (AWS_FC_DISTRIBUTION, item[‘name’]))
  90.   print ("")
  91.  
  92. except Exception, e:
  93.   http_response (status = e.status, reason = e.reason, body = e.body)

Note: this script use SimpleDB, for best performance use this in a EC2 instance

reduire

du nouveau chez appengine

le 8 avril 2009 par sahid

Google App Engine

Runtime Java

C’est fait, Google App Engine supporte officiellement le Java.
L’annonce de se nouveau runtime est faite sur le blog http://googleappengine.blogspot.com/2009/04/seriously-this-time-new-language-on-app.html.

Serivce de taches Cron

Pour ceux qui comme moi ne sont pas particulièrement fou du Java, on peut se consoler avec l’arrivé du service de taches Cron http://code.google.com/appengine/docs/python/config/cron.html.

Runtime Perl ??

Et dernière petite news sur appengine, en suivant du curseur les projets de Brad Fitzpatrick développeur de memcached j’ai vu qu’il bossait sur le projet perl-appengine http://code.google.com/p/perl-appengine/, et qu’une version pre-alpha etait déjà en ligne.


reduire

Taille d’une chaine de caractère en utf-8

le 26 mars 2009 par sahid

strlen for utf8 charsets

  1. var_dump (strlen ("é") == 2) // bool(true)
  2. var_dump (mb_strlen ("é", ‘utf-8′) == 1) // bool(true)


reduire

Gérer les exceptions et transactions avec mysqli

le 22 mars 2009 par sahid

Gérer les exceptions et transactions avec mysqli

Dans cet article j’essaie de voir comment améliorer l’implémentation mysqli de PHP.
Pour ceux qui ne la connaissent pas, la classe mysqli est le client PHP5 orienté objet du serveur MySQL.
Donc on va voir comment mettre en place deux ou trois méthodes afin d’obtenir un meilleur debug sur les requêtes passées au serveur, gérer les erreurs via des exceptions et pour finir trouver une solution pour gérer les Transactions.
Pour le moment on va simplement étendre mysqli afin de pouvoir changer son comportement.


Etendre mysqli

  1. class MySQLException extends Exception {}
  2. class MySQL extends mysqli {}


Ajout d’un debug des requêtes à mysql

Maintenant voyons comment avoir un meilleur suivi des requêtes envoyées à notre serveur MySQL.
Pour ça, on va lui ajouter deux méthodes, une pour ajouter un message debug et l’autre pour les récupérer.


  1. class MySQL extends mysqli {
  2.       protected $_debug = "";
  3.       public function setDebug ($string) { $this->_debug .= strftime ("%D %r").$string."\n"; }
  4.       public function getDebug () { return $this->_debug; }
  5. }


Exceptions dans mysqli

on redéfinit la méthode query afin d’avoir quelques informations sur les requêtes passées et déclencher une exception en cas d’échec.

  1. class MySQL extends mysqli {
  2.       protected $_debug = "";
  3.       public function setDebug ($string) { $this->_debug .= strftime ("%D %r").$string."\n"; }
  4.       public function getDebug () { return $this->_debug; }
  5.  
  6.  public function query ($sql)
  7.       {
  8.         $this->setDebug ($sql);
  9.         if (parent::query ($sql) === false)
  10.            throw new MySQLException ("Invalid Query : {$sql}\n");
  11.       }
  12. }


Transaction avec mysqli

Pour finir voici une implémentation permettant de gérer les transactions avec mysqli.
on va tout d’abord ajouter une nouvelle méthode à notre classe MySQL begin celle-ci va envoyer l’ordre START TRANSACTION qui avertit le serveur mysql que les requêtes suivantes doivent être considérées comme des transactions et attendre les évènements COMMIT ou ROLLBACK pour la terminer.

  1. public function begin ()
  2.         {
  3.         $this->query ("START TRANSACTION");
  4.       }


  1. $dbh = new MySQL ();
  2.  
  3. try {
  4.   $dbh->begin ();
  5.  
  6.   $dbh->query ("INSERT INTO table1 VALUES (1, 2, 3, 4"));
  7.   $dbh->query ("INSERT INTO table2 VALUES (5, 6, 7, 8"));
  8.  
  9.   $dbh->commit ();
  10. }
  11. catch (MySQLException $e) {
  12.   $dbh->rollback ();
  13. }
  14.  
  15. echo $dbh->getDebug ();

Chaque requête va être executée dans un block try catch, si une exception est lancée via la méthode query
alors on met fin à la transaction en exécutant le rollback, sinon on envoit le commit.


reduire

tolink filter in ootemplate

le 21 mars 2009 par sahid

Example to use tolink’s filter in ootemplate


I have add a new filter in ootemplate for create an elegants permalinks.
For example, you have an array with all posts of your blog, a post is composed by an ID, title, body and date,
you want print all posts and create a pretty urls for them.


  1. <div id="posts">
  2.   {% for post in allposts %}
  3.   <div class="briefpost">
  4.     <a href="{{ post.title | tolink }}-{{ post.ID }}.html">
  5.       <h3>{{ post.title }}</h3>
  6.     </a>
  7.     <p>{{ post.body | wrap: ‘30′ ‘…’ }}</p>
  8.     <span class="date">{{ post.date | date: "%d.%m.%y" }}</span>
  9.   </div>
  10.   {% endfor %}
  11. </div>


this example print

  1. <div id="posts">
  2.   <div class="briefpost">
  3.     <a href="my-first-post-is-hello-world-1.html">
  4.       <h3>My First post is Hello World !</h3>
  5.     </a>
  6.     <p>this post explain blabla bla bla…</p>
  7.     <span class="date">17.11.2008</span>
  8.   </div>
  9.   <div class="briefpost">
  10.     <a href="second-post-superstar-2.html">
  11.       <h3>Second post, superstar</h3>
  12.     </a>
  13.     <p>this post explain blabla bla bla…</p>
  14.     <span class="date">20.11.2008</span>
  15.   </div>
  16. </div>


reduire

MVC – Router URLs, or URLs dispatcher with PHP

le 20 mars 2009 par sahid

MVC – Mettre en place un routeur URLs en PHP

Des URLs élégantes sont un des détails importants au niveau de la qualité d’une application Web.
On connaît tous rewrite d’apache pour gérer ses urls,
mais dans cet article je vous propose de voir une solution parmi d’autres pour gérer de belles urls via PHP.
Vous pouvez lire cet article intéressant du W3C écrit par Tim Berners-Lee W3C Cool URIs don’t change

Donc pour notre routeur, nous avons besoin d’un fichier de configuration,
celui-ci possède les règles nécessaires pour faire correspondre une url en particulier avec un controleur.


  1. [*]
  2. url       = "/hello.html";
  3. script  = HelloWorld
  4. type    = static

Le code présenté sert d’illustration, et pourra bien entendu être amélioré.
il ne faut pas aussi oublier d’activer le mod rewrite d’Apache2 et faire passer toutes les urls reçues dans l’index.

  1. RewriteEngine On
  2. RewriteRule ^.*$ /var/www/index.php [NC,L]


prettyurls.conf

Le fichier prettyurls.conf est utilisé pour stocker nos urls, son format est assez simple
et pourra facilement être agrementé de nouvelles fonctionnalités.

  • url : la pattern de l’url à chercher
  • script : le nom du script ou controleur à charger
  • type : le type de pattern (static|regex)


  1. [*]
  2. url     = /;
  3. script = Home;
  4. type   = static;
  5.  
  6. [category]
  7. url     = "/categories/.*-([0-9]+).html";
  8. script = Category;
  9. type   = regex;
  10.  
  11. [404]
  12. url     = "/.*";
  13. script = NotFound;
  14. type   = regex;


Le moteur du routeur d’url

Dans un premier temps on enregistre dans la variable $request
l’url issue de la requête HTTP sans ses paramètres.

Ensuite on charge notre fichier de configuration prettyurls.conf via la fonction,
parse_ini_file (), les configurations sont retournées sous la forme d’un tableau associatif.

  1. $request     = preg_replace (‘/^(.*)\?.*/’, ‘$1′, $_SERVER[‘REQUEST_URI’]);
  2. /** examples */
  3. $request     = ‘/categories/eh-coco-1.html’;
  4. $request     = ‘/’;
  5. $request     = ‘/categories/eh-coco-1.html’;
  6. $request     = ‘/notfound/123456′;
  7.  
  8. /** load prettyurls */
  9. $pretty_urls = parse_ini_file (‘prettyurl.conf’, true);



Le tableau est parcouru via une boucle foreach,
à chaque itération on vérifie le type d’url recherché, en fonction de celui-ci on teste la validité du pattern associé.

  1. $is_ok   = false;
  2. $matched = array ();
  3.  
  4. foreach ($pretty_urls as $bit)
  5.   {
  6.     switch (@$bit[‘type’])
  7.       {
  8.       case ‘regex’:
  9.         preg_match (‘@’.$bit[‘url’].‘@’, $request, $matched);
  10.         if (!empty ($matched))
  11.           $is_ok = true;
  12.         break;
  13.  
  14.       case ’static’:
  15.         if (strcasecmp ($request, $bit[‘url’]) === 0)
  16.           $is_ok = true;
  17.         break;
  18.       }
  19.  
  20.     /** url has been matched */
  21.     if ($is_ok)
  22.       {
  23.         $controller = $bit[’script’];
  24.         break;
  25.       }
  26.   }
  27.  
  28. //FrontController::load ($controller, $matched);
reduire

FSF News – textbooks for GNU/Linux users

le 19 mars 2009 par sahid

FSF Produced free software textbooks for GNU/Linux users


You can participate in the online authoring of this new text by visiting

http://www.fsf.org/blogs/community/book-sprint

reduire

Petition for php support on app engine

le 16 mars 2009 par sahid

Support de PHP dans Google App Engine

Une petition de Google pour savoir qu’elle est le prochain runtime supporté par app engine.


http://i-want-php.appspot.com   je croise les doigts :)

  • levitra versus cialis
  • ingredient in phentermine
  • lipitor drug
  • generic trileptal
  • januvia 100 mg
  • gabapentin 100 mg
  • new anxiety drugs
  • keppra
  • reglan 10 mg
  • order prednisolone
  • fluticasone propionate
  • rogaine coupons
  • yasmin prescription
  • singulair 5 mg
  • sexual stamina tips
  • alavert drug
  • revatio 20 mg
  • lexapro drugs
  • european pharmacy anxiety
  • attacking anxiety and depression
  • cheap retin a
  • drugs for depression
  • cialis table
  • singulair 10 mg
  • penis enlargement exercises
  • cephalexin sinus
  • phentermine no prescription
  • order nolvadex
  • green tea pill
  • cialis advertisement
  • supplement hoodia
  • cheap viamax
  • valium without prescription
  • fosamax generic
  • cialis name brand cheap
  • ambien dosage
  • viagra and blood pressure
  • xanax rx
  • order viagra without prescription
  • atacand
  • buy prandin
  • cheap yohimbe
  • half life of valium
  • order capoten
  • alprazolam cheap
  • buy cialis by check
  • vitamins for erectile dysfunction
  • klonopin medication
  • drugs used to treat depression
  • online claritin
  • buy cialis online uk
  • benadryl loratadine
  • anxiety meds online
  • asthma in elderly
  • propecia 1mg
  • levitra vardenafil generic
  • cialis online discount
  • order cialis professional
  • clomid treatment
  • medicine xanax
  • methylsulfonylmethane
  • xanax mechanism of action
  • pharmacy online australia
  • cialis vs viagra
  • order lisinopril
  • viagra online best price
  • increase penis size with herbs
  • oxybutynin
  • bayer levitra online pharmacy
  • phentermine consultation
  • free levitra samples
  • acticin cream
  • ventolin inhalador
  • natural viagra substitute
  • glipizide side effects
  • benadryl dosing
  • new treatments for lung diseases
  • viagra jelly
  • types of antidepressants
  • perennial allergic rhinitis
  • mebendazole
  • levitra ad
  • cheap hangover helper
  • interaction zocor
  • cheapest cialis generic
  • cialis cost low
  • clonazepam .5mg
  • kamagra oral jelly
  • ativan no prescription
  • gerd in children
  • prozac social anxiety
  • antidepressant pill high
  • how to cure depression
  • use imitrex
  • cheap robaxin
  • what are the effects of klonopin
  • how to buy viagra online
  • coral calcium
  • canada in levitra
  • cheap viagra pill
  • discount levitra purchase
  • buy levothroid
  • purchase vardenafil
  • online tramadol
  • cialis dosage 20mg
  • viagra soft tab
  • norvasc 10
  • sample ambien
  • lamictal drug
  • herb echinacea
  • effects side ultram
  • endep
  • bayer levitra professional pro
  • addiction ultram
  • giant eagle pharmacy
  • benfotiamine
  • green tea capsule
  • cheap male enhancement
  • order caffeine
  • how much is viagra
  • drug ceftin
  • sumatriptan
  • cialis tablet
  • danazol
  • soma the drug
  • medication for bipolar disorder
  • cozaar medication
  • recreational use of xanax
  • cheap avandia
  • zithromax medication
  • buy lorazepam without prescription
  • reglan side effects
  • drug skelaxin
  • canada pharmacy viagra
  • buy zelnorm
  • phentermine no prescription overnight
  • impotence depression
  • buy ampicillin
  • levitra for sale
  • viagra patent lawsuit levitra
  • cialis vs viagra vs levitra
  • metformin hcl 500mg
  • ways to relieve anxiety
  • order rimonabant
  • natural prednisone
  • generic orlistat
  • nitroglycerin sublingual
  • wellbutrin paxil
  • schizophrenia drugs new zealand
  • lasix furosemide
  • unisom online
  • viagra half price pharmacy
  • manufacturer of revatio
  • clomiphene tablets
  • valium low cost
  • vpxl uk
  • ibuprofen
  • buy probenecid
  • buy etodolac
  • cialis canadian generic
  • stop smoking gum
  • order topamax
  • celebrex pharmacy
  • stop smoking zyban
  • purchase cheap cialis online
  • children aspirin
  • treatment for impotence
  • cialis line order
  • what prednisone
  • buy cialis by the pill
  • buying ultram no prescription
  • venlafaxin
  • buy generic tramadol no prescription
  • allegra side effects
  • prescription nexium
  • order starlix
  • serevent
  • soft tab viagra
  • effects of premarin
  • cheap lovastatin
  • order amantadine
  • viagra and cialis
  • discount levitra online
  • meds for erectile dysfunction
  • sale carisoprodol
  • effects propecia
  • on rx legal diazepam
  • effects of viagra on women
  • buy generic allergy medication
  • ciallis or viagra
  • cheap imitrex
  • order amoxicillin
  • ativan normal doses
  • generic cialis soft
  • purchase phentermine mexico
  • saw palmetto products
  • buy ativan online
  • discount soma online
  • allegra order
  • genric viagra