<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Amicalement Web - Astuces et Bons plans dans le développement web &#187; Astuces</title>
	<atom:link href="http://www.amicalement-web.net/categorie/astuces/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.amicalement-web.net</link>
	<description>Astuces et bons plans d&#039;un web developpeur</description>
	<lastBuildDate>Wed, 04 Jan 2012 14:54:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Python tips &amp; tricks</title>
		<link>http://www.amicalement-web.net/python-tips-tricks/2011/09/27/</link>
		<comments>http://www.amicalement-web.net/python-tips-tricks/2011/09/27/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 07:31:18 +0000</pubDate>
		<dc:creator>Benoit</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[paramiko]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[serveur web]]></category>
		<category><![CDATA[sftp]]></category>
		<category><![CDATA[ternaire]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=1836</guid>
		<description><![CDATA[Depuis quelques temps, je développe pas mal en python et durant mes différents projets, j&#8217;ai rencontré tout un tas de petits problèmes ou besoins. Je me suis donc dis que cela pourrait être intéressant de regrouper en vrac dans un article quelques unes des solutions trouvées. Non seulement cela vous servira peut être un jour, [...]]]></description>
			<content:encoded><![CDATA[<p><a  href="http://www.amicalement-web.net/wp-content/uploads/python_tips_and_tricks1.png"><img src="http://www.amicalement-web.net/wp-content/uploads/python_tips_and_tricks1.png" alt="" title="python_tips_and_tricks" width="614" height="100" class="aligncenter size-full wp-image-1861" /></a></p>
<p>Depuis quelques temps, je développe pas mal en python et durant mes différents projets, <strong>j&#8217;ai rencontré tout un tas de petits problèmes ou besoins</strong>.</p>
<p>Je me suis donc dis que cela pourrait être intéressant de <strong>regrouper en vrac dans un article quelques unes des solutions trouvées</strong>. Non seulement cela vous servira peut être un jour, mais en plus, <strong>vous aurez peut être des solutions plus simples/adaptées à me proposer</strong> ;)</p>
<p><span id="more-1836"></span></p>
<h3>Opérateur ternaire</h3>
<p>J&#8217;utilise souvent en php l&#8217;opérateur ternaire (x ? a : b) et je voulais trouver une équivalence en python.<br />
Ma première réaction a été de faire simplement un :</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #008000;">bool</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> a <span style="color: #ff7700;font-weight:bold;">or</span> b</pre></div></div>

<p><strong>Mais si &laquo;&nbsp;a&nbsp;&raquo; est un booléen à false</strong>, cela ne fonctionne pas comme le montre le petit test ci-dessous :</p>
<p><a  href="http://www.amicalement-web.net/wp-content/uploads/tips.python.01.png"><img class="aligncenter size-full wp-image-1842" title="tips.python.01" src="http://www.amicalement-web.net/wp-content/uploads/tips.python.01.png" alt="" width="211" height="264" /></a></p>
<p>J&#8217;ai donc cherché plus en profondeur et j&#8217;ai trouvé <strong>une solution des plus simple en utilisant une liste avec 2 valeurs</strong> :</p>

<div class="wp_syntax"><div class="code"><pre class="pyhton" style="font-family:monospace;">[a, b][bool(x)]</pre></div></div>

<p>Suivant la valeur de <strong>&laquo;&nbsp;x&nbsp;&raquo;</strong>, la valeur retournée sera <strong>la 0 ou la 1</strong>.</p>
<p>&nbsp;</p>
<h3>Récupérer son adresse IP publique</h3>
<p>En python, <strong>pas possible de faire comme en PHP en utilisant $_SERVER['REMOTE_ADDR'] pour afficher l&#8217;IP</strong>. Il fallait donc trouver une solution, et après plusieurs minutes de recherche, la seule solution vraiment valable que j&#8217;ai trouvé, est toute simple.</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">urllib2</span> <span style="color: #ff7700;font-weight:bold;">import</span> urlopen
public_ip = urlopen<span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://whatismyip.org'</span><span style="color: black;">&#41;</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p><strong>N.B:</strong> l&#8217;idéal serait d&#8217;utiliser un try &#8230; except pour faire propre mais bon, ca c&#8217;est à vous de le faire</p>
<p>Si vous connaissez une autre solution, je suis preneur ;)</p>
<p>&nbsp;</p>
<h3>Un serveur web instantané</h3>
<p>Envie de partager un ou plusieurs fichiers avec quelqu&#8217;un sans devoir le mettre sur une url publique (ex: www.mondomaine.com/fichier_pour_toi.png) ou créer un compte FTP ? Envie d&#8217;analyser vos requêtes http ? Autre envie ?</p>
<p>Python vous permet <strong>en une ligne de commande de réaliser un serveur web</strong> :</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">python -c <span style="color: #483d8b;">&quot;import SimpleHTTPServer;SimpleHTTPServer.test()&quot;</span></pre></div></div>

<p>Il vous suffit ensuite de vous connecter sur <strong>l&#8217;ip de votre serveur sur le port 8000</strong> et naviguer dans l&#8217;arborescence du répertoire ou la commande à été lancée :</p>
<p><a  href="http://www.amicalement-web.net/wp-content/uploads/tips.python.02.png"><img class="aligncenter size-full wp-image-1848" title="tips.python.02" src="http://www.amicalement-web.net/wp-content/uploads/tips.python.02.png" alt="" width="550" height="81" /></a></p>
<p>Pour arrêter le serveur, un petit <strong>&laquo;&nbsp;CTRL+C&nbsp;&raquo; dans votre shell</strong> et c&#8217;est fini ;)</p>
<p><strong>N.B:</strong> il est tout a fait possible en une dizaine de lignes de faire un serveur un peu plus abouti avec notamment une gestion du port.</p>
<p>&nbsp;</p>
<h3>Envoyer un fichier par sftp</h3>
<p>Envoyer un fichier (backup, sources &#8230;) d&#8217;un serveur à un autre est possible de différente façon (FTP, webdav &#8230;) mais une des manière les plus sécurisées et sans installation supplémentaire (quand le serveur autorise les accès ssh) reste pour moi le sftp.</p>
<p>Et j&#8217;ai trouvé &laquo;&nbsp;paramiko&nbsp;&raquo; qui existe en paquet debian, donc un simple &laquo;&nbsp;apt-get install python-paramiko&nbsp;&raquo; et hop.</p>
<p>Le code :</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> paramiko
&nbsp;
host = <span style="color: #483d8b;">'127.0.0.1'</span>
port = <span style="color: #ff4500;">22</span>
transport = paramiko.<span style="color: black;">Transport</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>host, port<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #dc143c;">user</span> = <span style="color: #483d8b;">'mon_user'</span>
<span style="color: #ff7700;font-weight:bold;">pass</span> = <span style="color: #483d8b;">'mon_pass'</span>
transport.<span style="color: black;">connect</span><span style="color: black;">&#40;</span>username = <span style="color: #dc143c;">user</span>, password = <span style="color: #ff7700;font-weight:bold;">pass</span><span style="color: black;">&#41;</span>
&nbsp;
sftp = paramiko.<span style="color: black;">SFTPClient</span>.<span style="color: black;">from_transport</span><span style="color: black;">&#40;</span>transport<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
path = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>
localpath = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
sftp.<span style="color: black;">put</span><span style="color: black;">&#40;</span>localpath, path<span style="color: black;">&#41;</span>
&nbsp;
sftp.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
transport.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Upload done.'</span></pre></div></div>

<p>Ensuite il suffit de lancer le script :</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python send_over_sftp.py <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>fichier.txt <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>distant<span style="color: #000000; font-weight: bold;">/</span>fichier.txt</pre></div></div>

<p>Et c&#8217;est tout :)</p>
<p><strong>N.B:</strong> A noter qu&#8217;il est préférable de configurer ses serveurs pour fonctionner avec des clefs plutot que de mettre le password en clair dans le script python et de sécuriser les paramètres envoyés au script si vous donnez l&#8217;utilisation à d&#8217;autres utilisateurs.</p>
<p>&nbsp;</p>
<h3>PHP to PYTHON</h3>
<p>Pour finir, un petit lien très pratique qui vous permet de voir l&#8217;équivalence python des fonctions php (quand elle existe) : <a  title="php2python" href="http://www.php2python.com/">http://www.php2python.com/</a></p>
<p><a  href="http://www.amicalement-web.net/wp-content/uploads/tips.python.03.png"><img class="aligncenter size-full wp-image-1852" title="tips.python.03" src="http://www.amicalement-web.net/wp-content/uploads/tips.python.03.png" alt="" width="609" height="325" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/python-tips-tricks/2011/09/27/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Générer la documentation Symfony2</title>
		<link>http://www.amicalement-web.net/generer-la-documentation-symfony2/2011/03/21/</link>
		<comments>http://www.amicalement-web.net/generer-la-documentation-symfony2/2011/03/21/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 09:00:22 +0000</pubDate>
		<dc:creator>Vince</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[symfony2]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=1752</guid>
		<description><![CDATA[Symfony2 bouge encore relativement beaucoup, et c&#8217;est donc aussi le cas de sa documentation. Si comme moi vous aimez toujours utiliser la dernière version de Symfony encore en développement, et que vous aimeriez disposer de la documentation en local et toujours à jour, voici comment procéder. Récupérer la documentation sur git La documentation officielle de [...]]]></description>
			<content:encoded><![CDATA[<p><a  href="http://www.amicalement-web.net/generer-la-documentation-symfony2/2011/03/21/"><img src="http://www.amicalement-web.net/wp-content/uploads/symfony-book.png" alt="" title="symfony-book" width="614" height="100" class="alignnone size-full wp-image-1772" /></a><br />
Symfony2 bouge encore relativement beaucoup, et c&#8217;est donc aussi le cas de sa documentation. Si comme moi vous aimez toujours utiliser la dernière version de Symfony encore en développement, et que vous aimeriez disposer de la documentation en local et toujours à jour, voici comment procéder.<br />
<span id="more-1752"></span></p>
<h3>Récupérer la documentation sur git</h3>
<p>La documentation officielle de Symfony2 est bien sur hébergée sur Git. Rendez-vous sur le <a  href="https://github.com/symfony/symfony-docs">dépôt Git officiel</a> et clonez la documentation en local.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>symfony<span style="color: #000000; font-weight: bold;">/</span>symfony-docs.git</pre></div></div>

<h3>Installer Sphinx</h3>
<p>Tout d&#8217;abord la documentation Symfony2 est générée grâce à <a  href="http://sphinx.pocoo.org/">Sphinx</a>, un projet écrit en Python. Il serait donc de bon aloi de l&#8217;installer ;-)</p>
<p>Si comme tout gens bien vous utilisez ArchLinux, il vous suffit d&#8217;un petit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> pacman <span style="color: #660033;">-S</span> python-sphinx</pre></div></div>

<p>Pour les autres utilisez easy_install directement :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">easy_install <span style="color: #660033;">-U</span> Sphinx</pre></div></div>

<p>SI vous n&#8217;avez pas easy_install (hey les gens, faut vraiment vous mettre au Python !), c&#8217;est <a  href="http://pypi.python.org/pypi/setuptools">par ici</a>.</p>
<h3>Créez un Makefile</h3>
<p>Pour l&#8217;instant, le repo Git officiel ne fournit pas de Makefile pour générer la documentation. Il va donc falloir en créer un. Pour ce faire utilisez la commande suivante dans votre répertoire <code>symfony-docs</code> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">sphinx-quickstart</pre></div></div>

<p>Cette commande va vous poser tout plein de questions, acceptez toujours les choix par défaut (appuyez sur entrée pour ce faire). Vous aurez juste trois choses à saisir, le nom du projet (mettez Symfony2), le nom de l&#8217;auteur (Fabien Potencier serait fair play ;-) ) et la version (est-ce un piège ?).<br />
Lorsque cette question va arriver <code>> Name of your master document (without suffix)</code> mettez n&#8217;importe quoi d&#8217;autre que index, on s&#8217;en fiche un peu, mais si vous mettez index il va pas être content le mÔssieur.</p>
<h3>Installez l&#8217;extension configuration</h3>
<p>Fabien a du créer une extension pour gérer plusieurs formats (YAML/XML/PHP dans notre cas) pour les fichiers de configuration. Pour l&#8217;installer, créez un répertoire _exts dans votre répertoire symfony-docs et placez-y le fichier se trouvant sur le <a  href="https://github.com/fabpot/sphinx-php/blob/master/configurationblock.py">repo Git sphinx-php de Fabien</a>.</p>
<p>Éditez le fichier <code>conf.py</code> qui se trouve dans symfony-docs, et ajoutez-y cette ligne en haut après la ligne d&#8217;<code>import</code> :</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">abspath</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'_exts'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Trouvez ensuite la ligne des extensions et rajoutez-y celle que l&#8217;on a téléchargée plus haut :</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">extensions = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'configurationblock'</span><span style="color: black;">&#93;</span></pre></div></div>

<p>Vous être prêt à générer votre première documentation Symfony2.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span> html</pre></div></div>

<p>Et voilà ! Le fichier index.html généré se trouve dans _build/html/index.html</p>
<p>Amusez-vous bien, et n&#8217;hésitez pas à contribuer dès que vous le pouvez.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/generer-la-documentation-symfony2/2011/03/21/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery : Rendez vos lignes cliquables!</title>
		<link>http://www.amicalement-web.net/jquery-rendez-vos-lignes-cliquables/2011/02/11/</link>
		<comments>http://www.amicalement-web.net/jquery-rendez-vos-lignes-cliquables/2011/02/11/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 10:00:28 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[astuce]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=1692</guid>
		<description><![CDATA[Petit billet rapide pour une petite astuce jQuery, ca faisait longtemps! Le but ici est simplement de donner la possibilité de cliquer sur un élément parent d&#8217;un lien pour l&#8217;activer. Et comme j&#8217;ai un peu galéré je me suis dit que ca valait le coup de partager le code. Que se soit dans une liste [...]]]></description>
			<content:encoded><![CDATA[<p><a  href="http://www.amicalement-web.net/jquery-rendez-vos-lignes-cliquables/2011/02/11/line/" rel="attachment wp-att-1698"><img src="http://www.amicalement-web.net/wp-content/uploads/line.png" alt="" title="line" width="614" height="100" class="alignnone size-full wp-image-1698" /></a><br />
Petit billet rapide pour une petite astuce jQuery, ca faisait longtemps! Le but ici est simplement de donner la possibilité de cliquer sur un élément parent d&#8217;un lien pour l&#8217;activer. Et comme j&#8217;ai un peu galéré je me suis dit que ca valait le coup de partager le code.<br />
<span id="more-1692"></span><br />
Que se soit dans une liste ou dans un tableau, il y a parfois qu&#8217;un seul lien, et je trouve assez pratique souvent de donner la possibilité à l&#8217;utilisateur de cliquer sur toute la ligne pour l&#8217;activer sans pour autant dégrader mon code html. Et comme je suis du genre à aimer ouvrir des liens dans un nouvel onglet, je comptais bien reproduire ce comportement.</p>
<p>Voici donc le code, résultat de cette réflexion, ou un clic avec ctrl (ou cmd pour les mac) ou le bouton du milieu de la souris devrait ouvrir le lien dans un nouvel onglet, comme le ferait un lien normal :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.line-click'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  e.<span style="color: #660066;">stopPropagation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  href <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a:first'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">ctrlKey</span> <span style="color: #339933;">||</span> e.<span style="color: #660066;">metaKey</span> <span style="color: #339933;">||</span> e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    window.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>href<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    window.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> href<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cursor'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'pointer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A utiliser avec le code html suivant par exemple:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;line-click&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;monimage.jpg&quot;</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;youpi&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 10/02/11 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;monlien.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Titre de mon billet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;line-click&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;monimage2.jpg&quot;</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;youpi&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 07/02/11 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;monlien2.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Titre de mon 2e billet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;line-click&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;monimage3.jpg&quot;</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;youpi&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 21/01/11 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;monlien3.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Titre de mon 3e billet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>A adapter selon vos envies. Ici c&#8217;est le premier lien trouvé dans l&#8217;élément avec la class <code>line-click</code> qui sera déclenché. Voilà, en attendant que j&#8217;arrive à finir un billet plus consistent!</p>
<p><small>Crédit photo : http://www.flickr.com/photos/flyingturtle/837938254</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/jquery-rendez-vos-lignes-cliquables/2011/02/11/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Tips : Configuration de serveurs #2</title>
		<link>http://www.amicalement-web.net/tips-configuration-de-serveurs-2/2010/12/21/</link>
		<comments>http://www.amicalement-web.net/tips-configuration-de-serveurs-2/2010/12/21/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 09:39:35 +0000</pubDate>
		<dc:creator>Benoit</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=1581</guid>
		<description><![CDATA[Suite à quelques demandes, notamment de @Ouark lors d&#8217;une soirée sur Paris, je vais essayer de publier régulièrement quelques petites astuces que j&#8217;ai trouvé et qui m&#8217;ont bien aidé/dépanné. Voici donc la partie #2 des Tips concernant la configuration de serveurs et le développement. Reset du pass root MySQL Qui n&#8217;a jamais perdu son mot [...]]]></description>
			<content:encoded><![CDATA[<p><a  href="http://www.amicalement-web.net/wp-content/uploads/tips_server_2.png"><img src="http://www.amicalement-web.net/wp-content/uploads/tips_server_2.png" alt="" title="tips_server_2" width="614" height="100" class="aligncenter size-full wp-image-1597" /></a></p>
<p>Suite à quelques demandes, notamment de <a  href="http://twitter.com/#!/Ouark">@Ouark</a> lors d&#8217;une soirée sur Paris, je vais essayer de publier régulièrement quelques petites astuces que j&#8217;ai trouvé et qui m&#8217;ont bien aidé/dépanné.</p>
<p>Voici donc la partie #2 des Tips concernant la configuration de serveurs et le développement.</p>
<p><span id="more-1581"></span></p>
<h3>Reset du pass root MySQL</h3>
<p>Qui n&#8217;a jamais perdu son mot de passe root MySQL, ce mot de passe que l&#8217;on vous demande à l&#8217;installation et dont vous allez vous servir ponctuellement, préférant par sécurité utiliser des utilisateurs plus précis et associés à une BDD spécifique. Je ne suis surement pas le seul en tout cas ^^</p>
<p>Ne stockant jamais mes mots de passe (question de sécurité), le mot de passe root MySQL est celui que j&#8217;ai le plus souvent oublié, même si ca ne m&#8217;arrive pas toutes les semaine non plus. Voici donc une petite astuce pour le reset et en créer un nouveau sans devoir tout réinstaller.</p>
<h4>1 &#8211; Arrêter votre serveur MySQL</h4>
<p>La première chose à faire bien entendu, est d&#8217;arrêter MySQL, le tout en étant root sur la machine bien entendu (comme pour toutes les commandes qui suivront)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>mysql stop</pre></div></div>

<h4>2 -MySQL en safe mode</h4>
<p>Il faut maintenant lancer MySQL en safe mode avec l&#8217;option <strong>&laquo;&nbsp;&#8211;skip-grant-tables&nbsp;&raquo;</strong> pour ne pas prendre en compte la table des privilèges.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysqld_safe <span style="color: #660033;">--skip-grant-tables</span> <span style="color: #000000; font-weight: bold;">&amp;</span></pre></div></div>

<p>A noter aussi le<strong> &laquo;&nbsp;&&nbsp;&raquo;</strong> qui permet de lancer en background le serveur et ainsi continuer à modifier le pass root.</p>
<h4>3 &#8211; Login</h4>
<p>Maintenant on peut se loguer au serveur MySQL en root de manière &laquo;&nbsp;anonyme&nbsp;&raquo; ou plutôt sans avoir le soucis des privilèges</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">--user</span>=root mysql</pre></div></div>

<h4>4 &#8211; Modifier le pass root</h4>
<p>Une fois connecté, il suffit d&#8217;effectuer une requête pour mettre à jour le pass de la table user.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #993333; font-weight: bold;">USER</span> <span style="color: #993333; font-weight: bold;">SET</span> Password<span style="color: #66cc66;">=</span>PASSWORD<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'mon_nouveau_pass'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">USER</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'root'</span>;
<span style="color: #993333; font-weight: bold;">FLUSH</span> PRIVILEGES;</pre></div></div>

<h4>5 &#8211; C&#8217;est repartit !</h4>
<p>Maintenant, on arrête le safe mode puis on relance le serveur MySQL</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>mysql restart</pre></div></div>

<p>Vous pouvez à nouveau vous connecter en root et gérer vos bases.</p>
<p><i>N.B: Cette manipulation à été testé sur Ubuntu, Debian et Slackware, et, même si le principe reste le même quelque soit la distribution, il peut varier un petit peu ;)</i></p>
<p></p>
<h3>Nombre de visiteurs à partir des logs apache</h3>
<p>Régulièrement, il m&#8217;arrive de vouloir connaitre le nombre de visiteurs unique qui sont passé la veille sur les sites hébergés sur mon serveur, le tout sans devoir consulter des outils de stats que je n&#8217;ai pas forcément à disposition (pas installé, pas autorisé &#8230;).</p>
<p>Voici donc un petit script qui va calculer tout ca directement à partir des<strong> logs Apache</strong>.</p>
<p>Pour infos, la plupart de mes logs Apache sont sous le format suivant (il est important de connaître son <strong>LogFormat</strong> pour bien ajuster le script) :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #ff0000;">&quot;%V %h %{PHPSESSID}C %l %u %t <span style="color: #000099; font-weight: bold;">\&quot;</span>%r<span style="color: #000099; font-weight: bold;">\&quot;</span> %&gt;s %b <span style="color: #000099; font-weight: bold;">\&quot;</span>%{Referer}i<span style="color: #000099; font-weight: bold;">\&quot;</span> <span style="color: #000099; font-weight: bold;">\&quot;</span>%{User-Agent}i<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span></pre></div></div>

<p>Et le petit script qui va calculer le nombre de visiteurs uniques pour le <strong>LogFormat</strong> ci-dessus et en prenant les fichiers de logs placé dans <strong>&laquo;&nbsp;/var/www/&nbsp;&raquo;</strong> et <strong>nommé avec le nom du domaine</strong> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #000000; font-weight: bold;">for</span> k <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/*</span>.log.1<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
     <span style="color: #007800;">domaine</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$k</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f4</span> <span style="color: #660033;">-d</span><span style="color: #ff0000;">'/'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/.log.1//g'</span><span style="color: #000000; font-weight: bold;">`</span>
     <span style="color: #007800;">nbr</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$k</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f2</span> <span style="color: #660033;">-d</span><span style="color: #ff0000;">' '</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">uniq</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
     <span style="color: #007800;">len</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$domaine</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -c<span style="color: #000000; font-weight: bold;">`</span>
     <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$len</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">16</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
         <span style="color: #007800;">tab</span>=<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>
     <span style="color: #000000; font-weight: bold;">else</span>
         <span style="color: #007800;">tab</span>=<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>
     <span style="color: #000000; font-weight: bold;">fi</span>
     <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$domaine</span><span style="color: #007800;">$tab</span><span style="color: #007800;">$nbr</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Ce qui donne :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">domaine.net			<span style="color: #000000;">347</span>
domaine.com			<span style="color: #000000;">283</span>
blog.domaine.net		<span style="color: #000000;">1301</span>
www.domaine.fr			<span style="color: #000000;">705</span></pre></div></div>

<p></p>
<h3>LogFormat personnalisé &#038; variable PHP</h3>
<p>Si vous aimez analyser vos logs Apache pour faire des statistiques personnelles, il est toujours intéressant de pouvoir customiser le format de ses logs. Personnellement, je spécifie des format de logs dans <strong>&laquo;&nbsp;/etc/apache/conf.d/logformat&nbsp;&raquo;</strong> avec la syntaxe suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LogFormat <span style="color: #ff0000;">&quot;%V %h %{forum_username}C %{PHPSESSID}C %l %u %t <span style="color: #000099; font-weight: bold;">\&quot;</span>%r<span style="color: #000099; font-weight: bold;">\&quot;</span> %&gt;s %b <span style="color: #000099; font-weight: bold;">\&quot;</span>%{Referer}i<span style="color: #000099; font-weight: bold;">\&quot;</span> <span style="color: #000099; font-weight: bold;">\&quot;</span>%{User-Agent}i<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> forum
LogFormat <span style="color: #ff0000;">&quot;%V %h %{user_id}n %{PHPSESSID}C %l %u %t <span style="color: #000099; font-weight: bold;">\&quot;</span>%r<span style="color: #000099; font-weight: bold;">\&quot;</span> %&gt;s %b <span style="color: #000099; font-weight: bold;">\&quot;</span>%{Referer}i<span style="color: #000099; font-weight: bold;">\&quot;</span> <span style="color: #000099; font-weight: bold;">\&quot;</span>%{User-Agent}i<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> site</pre></div></div>

<p>Dans le premier cas, je précise 2 variables venant des cookies, on le remarque avec le <strong>&laquo;&nbsp;C&nbsp;&raquo;</strong> placé après la variable.</p>
<p>Dans le second exemple, j&#8217;utilise une variable provenant d&#8217;un cookie mais aussi de mon environnement avec <strong>&laquo;&nbsp;%{user_id}n&nbsp;&raquo;</strong>. Le petit <strong>&laquo;&nbsp;n&nbsp;&raquo;</strong> placé à la fin signifie que la valeur provient de l&#8217;utilisation d&#8217;un <a  href="http://php.net/manual/fr/function.apache-note.php">apache_note()</a></p>
<p>Dans mon code, je définis simplement :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">apache_note</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user_id'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$monUserId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>J&#8217;utilise beaucoup cette technique afin d&#8217;obtenir des stats très précise sur mes visiteurs mais aussi d&#8217;effectuer des analyses afin d&#8217;enrechir un CRM par exemple.</p>
<p>Il suffit par la suite dans son fichier de configuration Apache de placer la directive suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CustomLog <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>forum.domaine.net.log forum</pre></div></div>

<p></p>
<p>Voilà, en espérant que ces petites astuces vous servent par la suite ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/tips-configuration-de-serveurs-2/2010/12/21/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symfony: Une utilisation du type array de Doctrine</title>
		<link>http://www.amicalement-web.net/symfony-une-utilisation-du-type-array-de-doctrine/2009/11/04/</link>
		<comments>http://www.amicalement-web.net/symfony-une-utilisation-du-type-array-de-doctrine/2009/11/04/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 10:00:47 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[astuce]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=925</guid>
		<description><![CDATA[Oui, les billets Symfony commençaient à me manquer. Mais difficile de trouver et le temps et la ressource pour en faire. Mais voici une petite astuce illustrée qui permet de trouver une application au type array de Doctrine tout en simplifiant une problématique. Tout ce que j&#8217;aime. Commençons par rendre à César ce qui est [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/check.png" alt="check" title="check" width="614" height="100" class="alignnone size-full wp-image-927" /> Oui, les billets Symfony commençaient à me manquer. Mais difficile de trouver et le temps et la ressource pour en faire. Mais voici une petite astuce illustrée qui permet de trouver une application au <a  href="http://www.doctrine-project.org/documentation/manual/1_1/en/defining-models#columns:data-types:array">type array de Doctrine</a> tout en simplifiant une problématique. Tout ce que j&#8217;aime.<br />
<span id="more-925"></span><br />
Commençons par rendre à César ce qui est à César, j&#8217;avais dans l&#8217;idée d&#8217;essayer ce type mais les exemples sur la doc ou sur le net n&#8217;était pas légion. En bon fainéant que je suis, j&#8217;ai demandé un peu d&#8217;aide et c&#8217;est mon nouveau voisin de droite, <a  href="http://twitter.com/colinux">Colin</a> qui m&#8217;a soufflé un bout de code où il l&#8217;utilise.</p>
<h3>Problématique</h3>
<p>Il me fallait stocker le résultat d&#8217;une question à choix multiple sans pour autant avoir à manipuler ensuite ses résultats autrement que par simple visualisation. Du coup, je voulais éviter d&#8217;avoir à créer une table pour stocker ces réponses et une table d&#8217;association avec ma table miroir de mon formulaire.</p>
<p>C&#8217;est là où le type array intervient. Rien de compliqué en fait, il ne fait que simplifier un traitement tout bête qui consiste à stocker un tableau php en base après sérialisation. Et qui le désérialise quand on le récupère depuis un enregistrement de la base.<br />
Une chose de moins à faire en fait et c&#8217;est bien là ce qu&#8217;on recherche nous autres développeurs, en faire le moins possible ;)</p>
<h3>La solution codée</h3>
<p>Niveau code, c&#8217;est très simple. On défini notre champ dans notre <code>schema.yml</code> comme n&#8217;importe quel autre champ</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">meschoix: { type: array(1000) }</pre></div></div>

<p>Qui donnera un champ text en mysql.</p>
<p>Ensuite, il suffit de modifier le formulaire obtenu pour transformer notre champ en liste de checkbox de manière très classique:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">widgetSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'meschoix'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfWidgetFormChoice<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'choices'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'0'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Choix1'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'1'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Choix2'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'2'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Choix3'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'3'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Choix4'</span>
      <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'multiple'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'expanded'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span>
    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Et puis c&#8217;est tout! Maintenant, lors de l&#8217;enregistrement, Doctrine va sérialiser le résultat de votre sélection et le stocker en base. Et quand vous peuplerez votre formulaire avec des données en base, il le désérialisera et donnera les bonnes valeurs à notre liste de checkbox.</p>
<p>Bien sûr, ca nous oblige à ne pas changer l&#8217;ordre des questions et les rend difficilement modifiables. Mais c&#8217;est une décision qui doit être prise en connaissance de cette limitation.</p>
<p><small>Crédit photo: http://www.flickr.com/photos/40491122@N03/3738306829/</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/symfony-une-utilisation-du-type-array-de-doctrine/2009/11/04/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Symfony et les tests</title>
		<link>http://www.amicalement-web.net/symfony-et-les-tests/2009/10/13/</link>
		<comments>http://www.amicalement-web.net/symfony-et-les-tests/2009/10/13/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 09:00:41 +0000</pubDate>
		<dc:creator>Vince</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[tests]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=840</guid>
		<description><![CDATA[On entend partout que les tests unitaires sont indispensables, que si tu n&#8217;en fais pas c&#8217;est que tu es sale, voire même que tu codes sous Windows avec Wordpad (quoi il n&#8217;y a pas de rapport ?). Si vous aussi vous faites partie des gens qui sont persuadés que oui c&#8217;est bien (sinon je peux [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-877" src="http://www.amicalement-web.net/wp-content/uploads/Capture-d’écran-2009-10-12-à-17.17.12.png" alt="Capture d’écran 2009-10-12 à 17.17.12" width="614" height="100" /><br />
On entend partout que les tests unitaires sont indispensables, que si tu n&#8217;en fais pas c&#8217;est que tu es sale, voire même que tu codes sous Windows avec Wordpad (quoi il n&#8217;y a pas de rapport ?). Si vous aussi vous faites partie des gens qui sont persuadés que oui c&#8217;est bien (sinon je peux plus rien pour vous), mais je vois vraiment pas comment faire et par où commencer avec mon code, peut être que je vais pouvoir vous éclairer.<br />
<span id="more-840"></span><br />
Commencez par aller faire un tour sur le site de symfony pour lire la partie sur les <a  href="http://www.symfony-project.org/jobeet/1_2/Doctrine/en/08">tests unitaires dans Jobeet</a> ou dans<a  href="http://www.symfony-project.org/book/1_2/15-Unit-and-Functional-Testing"> le livre de référence</a> si ce n&#8217;est pas encore fait, et lisez ce qui suit !</p>
<h3>Le modèle MVC</h3>
<p>Le fameux Modèle Vue Controlleur. Si vous vous dites qu&#8217;à part avec un test fonctionnel (c&#8217;est à dire un test qui simule le comportement utilisateur via des clicks, avec un sfBrowser ou <a  href="http://seleniumhq.org/" target="_blank">Selenium</a>) ça va pas être possible de tester votre appli, c&#8217;est surement vrai ; que les tests fonctionnels ça se fait vers la fin de l&#8217;écriture de votre module, quand votre code HTML bouge plus trop c&#8217;est vrai aussi ; et que donc dans le coup vous voyez pas trop comment tester votre application avant de l&#8217;avoir finie, c&#8217;est vrai aussi.</p>
<h3>Du M dans le C</h3>
<p>Mais si vous vous dites tout ça, c&#8217;est qu&#8217;il y a du M dans le C. C&#8217;est à dire qu&#8217;il y a des parties de votre Modèle dans votre Controlleur et dans le coup, vous ne pouvez tester votre modèle sans votre Controlleur (et dans le coup sans la Vue aussi). C&#8217;est typiquement le cas quand vous faites quelque chose comme ça :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeIndex<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$objects</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Objects'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'o'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'o.titi=?'</span><span style="color: #339933;">,</span><span style="color: #000088;">$titi</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">andWhere</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'...'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderBy</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'...'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Faites pas style c&#8217;est pas vous, je vous ai vu. Pourquoi ne pas faire ça dans l&#8217;action :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeIndex<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$objects</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Objects'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">getObjectsByTiti</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$titi</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>et ça dans la classe ObjectTable :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getObjectsByTiti<span style="color: #009900;">&#40;</span><span style="color: #000088;">$titi</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Objects'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'o'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'o.titi=?'</span><span style="color: #339933;">,</span><span style="color: #000088;">$toto</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">andWhere</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'...'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderBy</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'...'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Vous serez d&#8217;accord avec moi que le résultat est le même mais que c&#8217;est un peu plus découplé. On pourra reparler plus tard du fait que le summum serait de retourner un tableau (le fameux <a  href="/benchmark-apache-doctrine-hydrate-object-vs-array/2009/10/08/">HYDRATE_ARRAY</a> de Doctrine passé à la requête) dans la méthode getObjectsByTiti afin de ne pas se retrouver avec quelque chose dépendant de dépendant de l&#8217;ORM dans le controlleur (ici une Doctrine_Collection), mais ce n&#8217;est pas le sujet ici ;-)</p>
<h3>Si c&#8217;est pareil, pourquoi c&#8217;est mieux alors ?</h3>
<p>Parce que je vous le dis ! Oui bon d&#8217;accord. Plusieurs avantages, vous n&#8217;avez qu&#8217;un endroit à aller voir en cas de souci de logique métier : le Modèle. Mais surtout plus vous en mettrez dans le modèle (le premier que je vois écrire du HTML dans le modèle devra coder avec Wordpad), plus vous pourrez en tester ! Et plus vous écrirez de tests unitaires pour vos modèles, plus vous serez confiant dans votre code et plus votre code sera de qualité. Vos controlleurs devraient faire environ 10 lines de code, pas plus. Essayez de vous y tenir, ça vous changera la vie (mettez ce qui concerne la sessions dans votre classe myUser par exemple).</p>
<p>Maintenant nous pourrions écrire un test unitaire du style :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$t</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ok</span><span style="color: #009900;">&#40;</span>
  <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span>Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Object'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getObjectsByTiti</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mogito'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'-&gt; Getting object by mogito returns more than 4 objects'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ici je teste que notre méthode retourne au moins 4 objets si je lui demande un mogito.</p>
<h3>Vers la rédemption</h3>
<p>Si vous faites bien attention de ne pas avoir de M dans le C, vous pourrez coder toute votre logique applicative sans ouvrir un seul navigateur internet, et c&#8217;est même ce que vous devrez vous forcer à faire. Vous pouvez, voire même devez, faire marcher votre logique métier sans la moindre page web, juste en faisant tourner vos tests unitaires qui sont suffisants (et nécessaires) pour voir si votre code est bon et fait ce qu&#8217;il doit faire.</p>
<p>En faisant ça, vous pourrez ne vous concentrer que sur le modèle, sur le coeur de la logique métier, sans être parasité par des besoins webs (que le formulaire soit valide pour pouvoir récupérer l&#8217;objet, c&#8217;est pas le problème du modèle ça !).</p>
<p>Une fois que vous aurez les principales fonctions métier de codées dans votre modèle vous pourrez ensuite écrire vos controlleurs et pages web et à la fin les tests fonctionnels. Mais avant de faire ça, vous saurez qu&#8217;il y aura déjà une bonne partie de votre code qui sera écrit et testé.</p>
<h3>Et après ?</h3>
<p>Quand vous aurez pris l&#8217;habitude d&#8217;écrire des tests unitaires et que vous en serez devenu accrocs, vous pourrez passer au développement guidé par les tests (le TDD). Là vous écrivez avant les tests (donc en gros ce que vous attendez de votre modèle) et ensuite vous écrivez le modèle : vous serez assuré que tout votre modèle est couvert par les tests, et vous aurez écrit ce que doit faire votre modèle avant de l&#8217;avoir implémenté (c&#8217;est toujours bien de réfléchir avant de coder, sisi).</p>
<p>Quand vos tests commencerons à prendre du temps à s&#8217;exécuter, vous commencerez à vous intéresser à des outils d&#8217;intégration continue comme phpUnderControl ou Hudson, dont NiKo a récemment décrit<a  href="http://prendreuncafe.com/blog/post/2009/10/06/Simple-Continuous-Integration-of-a-Symfony-Project-using-Hudson" target="_blank"> l&#8217;intégration avec symfony</a> dans un de ses articles.</p>
<p>Pour finir, en effet ça va vous demander plus de temps de réaliser votre application web en écrivant des tests unitaires. Comme vous êtes Freelance et que le temps c&#8217;est de l&#8217;argent, vous vous dites que vous ne le ferez pas. Oui mais quand vous aurez livré et que le client reviendra 10 fois vers vous ensuite à cause de bugs, ou que vous aurez changé quelque chose qui aura tout cassé sans que vous ne vous en rendiez compte, et que ça commencera à se savoir que ce que vous faites est buggé : vous penserez fortement à une méthode qui vous permettra d&#8217;être beaucoup plus confiant dans votre code, à savoir l&#8217;écriture de tests !</p>
<p>Si vous êtes stagiaire ça marche aussi pour prendre de bonnes habitudes et ne pas vous faire taper dessus par votre supérieur, si vous êtes salarié reportez vous au cas du stagiaire ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/symfony-et-les-tests/2009/10/13/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Benchmark Apache: doctrine hydrate object vs array</title>
		<link>http://www.amicalement-web.net/benchmark-apache-doctrine-hydrate-object-vs-array/2009/10/08/</link>
		<comments>http://www.amicalement-web.net/benchmark-apache-doctrine-hydrate-object-vs-array/2009/10/08/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 09:00:59 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[hydrate]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=806</guid>
		<description><![CDATA[Il faut se rendre à l&#8217;évidence, défendre une idée sans argument, c&#8217;est bien souvent très compliqué. Et quand il a fallu que j&#8217;arrive à quantifier le réel apport d&#8217;une hydratation en tableau plutôt qu&#8217;en object, c&#8217;était un peu difficile. Rappelez-vous, j&#8217;en avais parlé dans les secrets de doctrine. Je me suis donc dis que j&#8217;allais [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/clock.png" alt="clock" title="clock" width="614" height="100" class="alignnone size-full wp-image-829" /> Il faut se rendre à l&#8217;évidence, défendre une idée sans argument, c&#8217;est bien souvent très compliqué. Et quand il a fallu que j&#8217;arrive à quantifier le réel apport d&#8217;une hydratation en tableau plutôt qu&#8217;en object, c&#8217;était un peu difficile. Rappelez-vous, j&#8217;en avais parlé <a  href="/doctrine-quelques-petits-secrets/2009/08/26/">dans les secrets de doctrine</a>.</p>
<p>Je me suis donc dis que j&#8217;allais tout simplement le benchmarker grosso modo, afin d&#8217;avoir une idée du gain qu&#8217;on peut avoir à passer par des tableaux. Car en fait, on sait très bien que le 2e est plus rapide, mais la question, c&#8217;est de combien.<br />
<span id="more-806"></span><br />
J&#8217;ai donc pris un modèle assez classique. Un couple de Departement/Region de France.</p>
<p>Dans mon fichier Table de mes départements, je rajoute la méthode suivante pour faire ma jointure sur régions</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #009900;">&#41;</span>
      <span style="color: #339933;">-&gt;</span><span style="color: #004000;">leftJoin</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d.Regions r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Hydratation en objet</h3>
<p>Parfait, maintenant, je crée une action qui récupère seulement tous les items de ma table, soit environ <strong>100 départements</strong>, en relation avec une région chacun.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeIndex<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Departements'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ca reste un cas tout a fait commun. J&#8217;ai donc lancé un <code>ab</code>, un programme livré avec apache qui permet de lancer l&#8217;exécution d&#8217;une page web, n fois avec n requêtes concurrentielles.  j&#8217;ai décidé de le lancer <strong>100 fois avec 10 requêtes à la fois</strong>. Et voici le résultat:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Document Path:          <span style="color: #000000; font-weight: bold;">/</span>hydrate<span style="color: #000000; font-weight: bold;">/</span>index
Document Length:        <span style="color: #000000;">2400</span> bytes
&nbsp;
Concurrency Level:      <span style="color: #000000;">10</span>
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests:  <span style="color: #000000;">16.862</span> seconds
Complete requests:      <span style="color: #000000;">100</span>
Failed requests:        <span style="color: #000000;">0</span>
Write errors:           <span style="color: #000000;">0</span>
Total transferred:      <span style="color: #000000;">269400</span> bytes
HTML transferred:       <span style="color: #000000;">240000</span> bytes
Requests per second:    <span style="color: #000000;">5.93</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #666666; font-style: italic;">#/sec] (mean)</span>
Time per request:       <span style="color: #000000;">1686.205</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Time per request:       <span style="color: #000000;">168.621</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Transfer rate:          <span style="color: #000000;">15.60</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes<span style="color: #000000; font-weight: bold;">/</span>sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received
&nbsp;
Connection Times <span style="color: #7a0874; font-weight: bold;">&#40;</span>ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>
              min  mean<span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #000000; font-weight: bold;">/</span>-sd<span style="color: #7a0874; font-weight: bold;">&#93;</span> median   max
Connect:        <span style="color: #000000;">0</span>    <span style="color: #000000;">0</span>   <span style="color: #000000;">0.5</span>      <span style="color: #000000;">0</span>       <span style="color: #000000;">4</span>
Processing:  <span style="color: #000000;">1172</span> <span style="color: #000000;">1665</span> <span style="color: #000000;">167.3</span>   <span style="color: #000000;">1662</span>    <span style="color: #000000;">2337</span>
Waiting:     <span style="color: #000000;">1172</span> <span style="color: #000000;">1663</span> <span style="color: #000000;">166.5</span>   <span style="color: #000000;">1661</span>    <span style="color: #000000;">2337</span>
Total:       <span style="color: #000000;">1172</span> <span style="color: #000000;">1665</span> <span style="color: #000000;">167.4</span>   <span style="color: #000000;">1662</span>    <span style="color: #000000;">2338</span>
&nbsp;
Percentage of the requests served within a certain <span style="color: #000000; font-weight: bold;">time</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000;">50</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1662</span>
  <span style="color: #000000;">66</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1709</span>
  <span style="color: #000000;">75</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1750</span>
  <span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1783</span>
  <span style="color: #000000;">90</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1860</span>
  <span style="color: #000000;">95</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1928</span>
  <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">2102</span>
  <span style="color: #000000;">99</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">2338</span>
 <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">2338</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>longest request<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<h3>Hydratation en tableau</h3>
<p>2e action, le même code, le même résultat HTML souhaité, mais on passe dans le execute le fameux paramètre. Notre résultat ne sera donc plus une Doctrine_Collection, mais un tableau associatif avec en clé, les noms des champs.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeIndex2<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Departements'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">HYDRATE_ARRAY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et voici le résultat</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Document Path:          <span style="color: #000000; font-weight: bold;">/</span>hydrate<span style="color: #000000; font-weight: bold;">/</span>index2
Document Length:        <span style="color: #000000;">2400</span> bytes
&nbsp;
Concurrency Level:      <span style="color: #000000;">10</span>
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests:   <span style="color: #000000;">10.086</span> seconds
Complete requests:      <span style="color: #000000;">100</span>
Failed requests:        <span style="color: #000000;">0</span>
Write errors:           <span style="color: #000000;">0</span>
Total transferred:      <span style="color: #000000;">269400</span> bytes
HTML transferred:       <span style="color: #000000;">240000</span> bytes
Requests per second:    <span style="color: #000000;">9.92</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #666666; font-style: italic;">#/sec] (mean)</span>
Time per request:       <span style="color: #000000;">1008.569</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Time per request:       <span style="color: #000000;">100.857</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Transfer rate:          <span style="color: #000000;">26.09</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes<span style="color: #000000; font-weight: bold;">/</span>sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received
&nbsp;
Connection Times <span style="color: #7a0874; font-weight: bold;">&#40;</span>ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>
              min  mean<span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #000000; font-weight: bold;">/</span>-sd<span style="color: #7a0874; font-weight: bold;">&#93;</span> median   max
Connect:        <span style="color: #000000;">0</span>    <span style="color: #000000;">1</span>   <span style="color: #000000;">1.4</span>      <span style="color: #000000;">0</span>       <span style="color: #000000;">6</span>
Processing:   <span style="color: #000000;">598</span>  <span style="color: #000000;">992</span> <span style="color: #000000;">112.9</span>   <span style="color: #000000;">1003</span>    <span style="color: #000000;">1239</span>
Waiting:      <span style="color: #000000;">598</span>  <span style="color: #000000;">991</span> <span style="color: #000000;">113.0</span>   <span style="color: #000000;">1002</span>    <span style="color: #000000;">1239</span>
Total:        <span style="color: #000000;">599</span>  <span style="color: #000000;">993</span> <span style="color: #000000;">113.0</span>   <span style="color: #000000;">1003</span>    <span style="color: #000000;">1239</span>
&nbsp;
Percentage of the requests served within a certain <span style="color: #000000; font-weight: bold;">time</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000;">50</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1003</span>
  <span style="color: #000000;">66</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1051</span>
  <span style="color: #000000;">75</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1081</span>
  <span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1085</span>
  <span style="color: #000000;">90</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1104</span>
  <span style="color: #000000;">95</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1128</span>
  <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1149</span>
  <span style="color: #000000;">99</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1239</span>
 <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1239</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>longest request<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<h3>Bilan</h3>
<p>Alors évidemment, il faut prendre en compte la différence de temps de réponse qu&#8217;on peut avoir entre 2 lancement de <code>ab</code>. Mais l&#8217;objectif est surtout de montrer que le gain est non négligeable et vraiment réel.</p>
<p>On constate que le HTML reçu est bien le même. On a donc le même rendu!<br />
Et côté performance, le 1er cas nous donne une requête en <strong>1,7sec</strong> quand le 2e nous donne <strong>1s</strong> soit près de<strong> 60% de mieux</strong>.</p>
<p>Conclusion, quand on souhaite réaliser seulement de l&#8217;affichage de données, il faut hydrater en tableau! Même si dans le cas présent, on parle de 0,7sec, il faut voir que c&#8217;est un projet vierge avec rien d&#8217;autre autour. Le gain est donc bien réel et pas seulement gadget.</p>
<p><small>Crédit photo: http://www.flickr.com/photos/don3rdse/3208161023/</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/benchmark-apache-doctrine-hydrate-object-vs-array/2009/10/08/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Tips : Configuration de serveurs</title>
		<link>http://www.amicalement-web.net/tips-configuration-de-serveurs/2009/09/22/</link>
		<comments>http://www.amicalement-web.net/tips-configuration-de-serveurs/2009/09/22/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 08:34:45 +0000</pubDate>
		<dc:creator>Benoit</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tcpdump]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=750</guid>
		<description><![CDATA[Pour bien configurer un serveur, il existe plusieurs façons, chaque administrateur ayant la plupart du temps sa propre conf en fonction de ses habitudes et celles de ses users. Je vous propose ici quelques petits tips à mettre en place sur votre serveur pour voir un peu se qui s&#8217;y passe. Connexion SSH Il est [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/tips_config_serveur.png" alt="Tips : Configuration de serveurs" width="614" height="100" class="alignnone size-full wp-image-640" /></p>
<p>Pour bien configurer un serveur, il existe plusieurs façons, chaque administrateur ayant la plupart du temps sa propre conf en fonction de ses habitudes et celles de ses users.</p>
<p>Je vous propose ici quelques petits tips à mettre en place sur votre serveur pour voir un peu se qui s&#8217;y passe.</p>
<p><span id="more-750"></span></p>
<h3>Connexion SSH</h3>
<p>Il est toujours intéressant de connaître les <strong>connexions ssh</strong> des utilisateurs sur votre serveur, que ce soit pour des statistiques ou tout simplement surveiller les différentes connexions pour par exemple intervenir rapidement en cas d&#8217;intrusion.</p>
<p>Pour cela, il existe un moyen très simple avec l&#8217;utilisation de <strong>sshrc</strong>. Dans le man, il est dit :</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">/etc/ssh/sshrc
Commands in this file are executed by ssh when the user logs in,
just before the user's shell (or command) is started.
See the sshd(8) manual page for more information.</pre></div></div>

<p>Nous allons donc y introduire un petit bout de script qui enverra un mail automatiquement.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%d-%m-%Y %H:%M&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">IP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$SSH_CONNECTION</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">REVERSE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dig</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$IP</span> +short<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Message + envoi du mail</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;USER : <span style="color: #007800;">$USER</span>
IP : <span style="color: #007800;">$IP</span>
ReverseDNS : <span style="color: #007800;">$REVERSE</span>
Date : <span style="color: #007800;">$DATE</span>
&nbsp;
&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;[SSH] <span style="color: #007800;">$DATE</span> - Connexion de <span style="color: #007800;">$USER</span>&quot;</span> your_email<span style="color: #000000; font-weight: bold;">@</span>domaine.com</pre></div></div>

<p>A chaque connexion ssh d&#8217;un utilisateur, vous recevrez un mail contenant diverses informations. Je souligne au passage qu&#8217;un <strong>authentification ssh par clef</strong> est toujours plus sûre ;)</p>
<h3>Modifications de fichiers</h3>
<p>Il existe plusieurs applications (plus ou moins performantes) permettant de voir les fichiers modifiés sur votre serveur. Ici, un petit script tout bête qui va vous permette de voir <strong>les modifications effectuées depuis X jours</strong> sur votre serveur dans un ou plusieurs répertoires donnés.</p>
<p>Bien entendu c&#8217;est une surveillance basique, rien de comparable avec un contrôleur d&#8217;intégrité (tripwire par exemple), mais cela peut s&#8217;avérer très pratique, notamment pour retrouver rapidement une erreur faite dans un script après une modification, mais aussi pour vérifier qu&#8217;aucune modification externe n&#8217;est faite sur des fichiers sensibles.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%d-%m-%Y %H:%M&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">LAPS</span>=<span style="color: #000000;">1</span>
<span style="color: #007800;">INFOS</span>=<span style="color: #ff0000;">&quot;Liste des fichiers modifiés :<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-mtime</span> -<span style="color: #007800;">$LAPS</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-mtime</span> -<span style="color: #007800;">$LAPS</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$i</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #007800;">INFOS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$INFOS</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #007800;">$i</span>&quot;</span>
        <span style="color: #000000; font-weight: bold;">fi</span>;
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$INFOS</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;[MODIF] <span style="color: #007800;">$DATE</span> - Fichiers modifies&quot;</span> your_email<span style="color: #000000; font-weight: bold;">@</span>domaine.com</pre></div></div>

<p><em>N.B : Une vérification est faite pour n&#8217;avoir que les fichiers et non les répertoires + fichiers.</em></p>
<p>Dans l&#8217;instruction <strong>for i in &#8230; ; do</strong> vous pouvez mettre plusieurs répertoire en utilisant <strong>`find /rep/ -mtime -$LAPS`</strong>.</p>
<p>Une fois le script créé, il vous suffit de mettre en place un cron (ici à 23h59 tous les jours) qui le lancera automatiquement et vous avertira par mail des changements.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">59</span> <span style="color: #000000;">23</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>your<span style="color: #000000; font-weight: bold;">/</span>script</pre></div></div>

<h3>Consommation de bande passante</h3>
<p>Savoir qui consomme le plus de bande passante sur un serveur est souvent très intéressant, je vous propose donc ici un petit script qui va vous permettre de recevoir par mail les informations concernant les hôtes qui consomment le plus de bande passante, ici sur les <strong>10000 derniers paquets</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%d-%m-%Y %H:%M&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
tcpdump <span style="color: #660033;">-c</span> <span style="color: #000000;">10000</span> <span style="color: #660033;">-ni</span> eth0 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-lane</span> <span style="color: #ff0000;">'END{@keys=sort{$h{$a}  &lt;=&gt; $h{$b}} keys %h;for(reverse(@keys)){printf(&quot;%32s =&gt; %i\n&quot;, $_, $h{$_}) if($h{$_}&gt;100);}} $h{$F[1]}++;'</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;[BP] <span style="color: #007800;">$DATE</span> - Consommation bande passante&quot;</span> your_email<span style="color: #000000; font-weight: bold;">@</span>domaine.com</pre></div></div>

<p>A noter que pour faire plaisir à <a  href="http://blog.devorigin.fr/">Vincent</a>, j&#8217;ai utilisé du perl et non du python ^^</p>
<p>Une fois le script en place, un petit ajout dans le cron et c&#8217;est partit. Vous pouvez le faire tourner autant de fois que vous voulez, cela dépend surtout du traffic de votre serveur, ici 4 fois par jour soit toutes les 6 heures.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">* */6 * * * /path/to/your/script</pre></div></div>

<p>Voilà, si cela vous intéresse, il y aura surement d&#8217;autres tips à venir et surtout n&#8217;hésitez pas à demander si vous cherchez un petit truc particulier ou si vous avez des remarques.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/tips-configuration-de-serveurs/2009/09/22/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Mini solution antispam, quand le CSS retourne l&#8217;envers du PHP</title>
		<link>http://www.amicalement-web.net/mini-solution-antispam-quand-le-css-retourne-lenvers-du-php/2009/09/03/</link>
		<comments>http://www.amicalement-web.net/mini-solution-antispam-quand-le-css-retourne-lenvers-du-php/2009/09/03/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 11:00:46 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=711</guid>
		<description><![CDATA[Dans le monde du web, un seul fléau uni tout le monde contre lui, le spam. Rien à dire, en plus de ne pas être écologique, on a du mal à y voir un intérêt, pauvres humains que nous sommes. Mais quand vient le moment d&#8217;écrire son adresse mail sur un site web qui sera [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/stop-spam.jpg" alt="stop-spam" title="stop-spam" width="614" height="100" class="alignnone size-full wp-image-715" /><br />
Dans le monde du web, un seul fléau uni tout le monde contre lui, le spam.</p>
<p>Rien à dire, en plus de ne pas être écologique, on a du mal à y voir un intérêt, pauvres humains que nous sommes. Mais quand vient le moment d&#8217;écrire son adresse mail sur un site web qui sera visible par tout le monde, on en tremblerait presque.</p>
<p>Du coup, il existe beaucoup de techniques, l&#8217;idéal étant encore de ne pas écrire son adresse mail en toutes lettres sur son site! Mais des fois, cela reste bien pratique. Voici donc une solution très simple à mettre en place, qui sans être parfaite, assure quand même le boulot dans la majorité des cas.<span id="more-711"></span></p>
<p>A noter que cette technique est tiré du site de <a  href="http://www.symfony-project.org">Symfony himself</a>. Comme je ne l&#8217;avais jamais croisé auparavant, ca peut valoir le coup d&#8217;en parler un peu.</p>
<p>Le principe est simpliste mais bien pensé.</p>
<p>On écrit, notre adresse mail à l&#8217;envers en PHP (ou tout autre langage serveur on est d&#8217;accord) et on demande à notre CSS de l&#8217;afficher à l&#8217;envers également. Et vous l&#8217;aurez compris, l&#8217;envers de l&#8217;envers, et bien&#8230; c&#8217;est l&#8217;endroit! Fou je vous l&#8217;accorde.</p>
<p>En terme de code, voilà ce que ca donnera schématiquement:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;span class=&quot;reverse&quot;&gt;
 <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">strrev</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'monmail@monadresse.com'</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// qui va écrire moc.esserdanom@liamnom du coup ?&gt;</span>
<span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Il suffit maintenant de changer la direction de lecture de notre span reverse via CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">span<span style="color: #6666ff;">.reverse</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">direction</span><span style="color: #00AA00;">:</span>rtl<span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">unicode-bidi</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bidi-override</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Et voilà, notre adresse est maintenant lisible à l&#8217;endroit à tout le monde bénéficiant d&#8217;un support CSS, donc en théorie, tout le monde sauf, les vilains méchants robots spammeurs. Malheureusement ça reste de la théorie mais en pratique, cela reste un manque niveau accessibilité, tout comme on est pas sûr que les robots ne sauront pas interpréter le CSS très bientôt. Mais je pense que ca reste une solution à connaitre.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/mini-solution-antispam-quand-le-css-retourne-lenvers-du-php/2009/09/03/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Yahoo aspire Smushit</title>
		<link>http://www.amicalement-web.net/yahoo-aspire-smushit/2009/09/01/</link>
		<comments>http://www.amicalement-web.net/yahoo-aspire-smushit/2009/09/01/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 09:00:55 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[smushit]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yslow]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=698</guid>
		<description><![CDATA[SmushIt, j&#8217;en ai parlé à mes débuts, c&#8217;est un des services web que j&#8217;utilise régulièrement. Mais la semaine dernière, j&#8217;ai été étonné de voir que l&#8217;extension firefox ne fonctionnait plus, le site web aussi semblait dans les choux. La cause? A Yahoo qui avait un peu loupé sa redirection vers la nouvelle URL de ce [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/smushit.png" alt="smushit" title="smushit" width="614" height="100" class="alignnone size-full wp-image-707" /> <a href="pour-un-web-a-son-image-smush-it/2009/01/27/">SmushIt, j&#8217;en ai parlé à mes débuts</a>, c&#8217;est un des services web que j&#8217;utilise régulièrement. Mais la semaine dernière, j&#8217;ai été étonné de voir que l&#8217;extension firefox ne fonctionnait plus, le site web aussi semblait dans les choux. La cause?  A Yahoo qui avait un peu loupé sa redirection vers <a  href="http://developer.yahoo.com/yslow/smushit/">la nouvelle URL de ce service</a>.<br />
<span id="more-698"></span></p>
<p>Mais smushit n&#8217;est pas mort, Yahoo l&#8217;a juste intégré dans son très bon <a  href="http://developer.yahoo.com/yslow/">Yslow</a>. On peut se demander si niveau marketing, c&#8217;est une bonne idée, tant Yslow est déjà très complet. Mais je vais laisser cette analyse aux spécialistes. Pour ma part, je vais me contenter de vous montrer comment on s&#8217;en sert maintenant. Parce que même si les alternatives existent, je l&#8217;aime bien moi ce Smushit!</p>
<p>Première étape, il faut déjà retrouver l&#8217;option dans l&#8217;armada Yahoo: <a  href="http://www.amicalement-web.net/wp-content/uploads/Image-80.png"><img src="http://www.amicalement-web.net/wp-content/uploads/Image-80-300x135.png" alt="Image 80" title="Image 80" width="300" height="135" class="alignnone size-medium wp-image-704" /></a></p>
<p>Il faut donc aller sur l&#8217;onglet Tools et vous aurez accès en bas à l&#8217;option All Smush.it. Un simple clic et on vous envoie vers une nouvelle url où vous aurez accès à toutes les images de la page courante smushé!</p>
<p>Oui rien de bien compliqué, mais ca méritait d&#8217;être dit selon moi ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/yahoo-aspire-smushit/2009/09/01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
