<?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>Al&#039;s blog</title>
	<atom:link href="http://blog.alweb.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.alweb.org</link>
	<description>Alexis Toulotte</description>
	<lastBuildDate>Wed, 09 Mar 2011 02:07:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>TimeZone coté navigateur &amp; RubyOnRails</title>
		<link>http://blog.alweb.org/2011/01/timezone-cote-navigateur-rubyonrails/</link>
		<comments>http://blog.alweb.org/2011/01/timezone-cote-navigateur-rubyonrails/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 05:36:33 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Geekeries]]></category>

		<guid isPermaLink="false">http://blog.alweb.org/?p=179</guid>
		<description><![CDATA[Il est parfois utile d&#8217;afficher les dates et les heures selon la TimeZone de l&#8217;utilisateur dans nos applications Web. Il y a la manière que l&#8217;on retrouve le plus (pénible à mon gout) qui consiste à la faire choisir à l&#8217;utlisateur via un énorme &#60;select&#62;, ceci qui ressemble à peu près à ça : De [...]]]></description>
			<content:encoded><![CDATA[<p>Il est parfois utile d&#8217;afficher les dates et les heures selon la TimeZone de l&#8217;utilisateur dans nos applications Web.</p>
<p>Il y a la manière que l&#8217;on retrouve le plus (pénible à mon gout) qui consiste à la faire choisir à l&#8217;utlisateur via un énorme <code>&lt;select&gt;</code>, ceci qui ressemble à peu près à ça :</p>
<p><img src="/wp-content/uploads/TimeZone-select.png" alt="TimeZone select" /></p>
<p>De plus, il faut ensuite stocker cette TimeZone en base de données ou dans un cookie. Bref, pénible pour le développeur et pour l&#8217;utilisateur.</p>
<p>C&#8217;est pourquoi, le mieux serait d&#8217;obtenir la TimeZone du navigateur directement. Malheureusement, les navigateurs n&#8217;envoient pas de <code>header HTTP</code> avec la TimeZone configurée sur la machine (un peu comme pour les locales). La seule manière donc, est d&#8217;utiliser Javascript.</p>
<p>Dans le petit script ci-dessous, on va stocker dans un cookie l&#8217;<code><a href="http://fr.wikipedia.org/wiki/Temps_universel_coordonné">UTC</a> offset</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> TimeZone <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> getOffset<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTimezoneOffset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> offset <span style="color: #339933;">=</span> getOffset<span style="color: #009900;">&#40;</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>offset <span style="color: #339933;">!=</span> Cookie.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'time_zone_offset'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            Cookie.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'time_zone_offset'</span><span style="color: #339933;">,</span> offset<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">'init'</span><span style="color: #339933;">:</span> init
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
document.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'dom:loaded'</span><span style="color: #339933;">,</span> TimeZone.<span style="color: #660066;">init</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Note : les méthodes <code>Cookie.get</code> et <code>Cookie.set</code> sont issues d&#8217;un autre bout de Javascript. Demandez-moi si vous en avez besoin.</p>
<p>Maintenant coté serveur (Rails), on va changer la TimeZone en fonction de la valeur de ce cookie :</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> ApplicationController <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActionController::Base</span>
&nbsp;
  before_filter <span style="color:#ff3333; font-weight:bold;">:set_time_zone_from_cookies</span>
&nbsp;
  private
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> set_time_zone_from_cookies
    <span style="color:#9966CC; font-weight:bold;">if</span> cookies<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'time_zone_offset'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">present</span>?
      <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">zone</span> = cookies<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'time_zone_offset'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">zone</span> = Rails.<span style="color:#9900CC;">configuration</span>.<span style="color:#9900CC;">time_zone</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>On se retrouve maintenant avec les dates et les heures qui s&#8217;affichent correctement partout dans le monde.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2011/01/timezone-cote-navigateur-rubyonrails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mix Drum ‘n’ Bass : deuxième partie</title>
		<link>http://blog.alweb.org/2009/04/mix-drum-n-bass-deuxieme-partie/</link>
		<comments>http://blog.alweb.org/2009/04/mix-drum-n-bass-deuxieme-partie/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 11:44:37 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Musique]]></category>

		<guid isPermaLink="false">http://blog.alweb.org/?p=138</guid>
		<description><![CDATA[Après mes premiers essais, il est temps de remettre ça ! Alors c&#8217;est simple, pour écouter c&#8217;est là : /wp-content/uploads/al-deuce.mp3 … et pour télécharger l&#8217;intégralité du mix c’est ici. Le mix fait 40 minutes pour 20 titres : Aphrodite &#8211; Mind Breaks Xample &#8211; Contra Phetsta &#8211; Dutty Funk State Of Mind &#8211; Real McCoy [...]]]></description>
			<content:encoded><![CDATA[<p>Après <a href="//blog.alweb.org/2008/01/mix-drum-n-bass-premiers-essais/">mes premiers essais</a>, il est temps de remettre ça !</p>
<p>Alors c&#8217;est simple, pour écouter c&#8217;est là :</p>
<p><!-- Dewplayer Begin--><object type="application/x-shockwave-flash" data="http://blog.alweb.org/wp-content/plugins/dewplayer-flash-mp3-player/dewplayer.swf?mp3=/wp-content/uploads/al-deuce.mp3&amp;showtime=1&amp;bgcolor=FFFFFF" width="200" height="20"><param name="bgcolor" value="FFFFFF" /><param name="movie" value="http://blog.alweb.org/wp-content/plugins/dewplayer-flash-mp3-player/dewplayer.swf?mp3=/wp-content/uploads/al-deuce.mp3&amp;showtime=1&amp;bgcolor=FFFFFF" /></object><!-- Dewplayer End--><a href="/wp-content/uploads/al-deuce.mp3">/wp-content/uploads/al-deuce.mp3</a></p>
<p>… et pour télécharger l&#8217;intégralité du mix <a href="/wp-content/uploads/al-deuce.mp3">c’est ici</a>.</p>
<p>Le mix fait <strong>40 minutes</strong> pour <strong>20 titres</strong> :</p>
<ol>
<li><strong>Aphrodite</strong> &#8211; Mind Breaks</li>
<li><strong>Xample</strong> &#8211; Contra</li>
<li><strong>Phetsta</strong> &#8211; Dutty Funk</li>
<li><strong>State Of Mind</strong> &#8211; Real McCoy</li>
<li><strong>Logistics</strong> &#8211; Toytown</li>
<li><strong>State Of Mind</strong> &#8211; City On Fire</li>
<li><strong>Culture Shock</strong> &#8211; Machine</li>
<li><strong>Sub Focus</strong> &#8211; Swamp Thing</li>
<li><strong>Moving Fusion</strong> &#8211; Now&#8217;s The Time</li>
<li><strong>Moving Fusion</strong> &#8211; Guy Fawkes</li>
<li><strong>State Of Mind</strong> &#8211; Deadzone</li>
<li><strong>Hive</strong> &#8211; Neo Remix</li>
<li><strong>Chase &#038; Status</strong> &#8211; Pieces</li>
<li><strong>State Of Mind</strong> &#8211; Dark Man</li>
<li><strong>Sub Focus</strong> &#8211; Scarecrow</li>
<li><strong>Calibre</strong> &#8211; Two Drop</li>
<li><strong>Logistics, Shimon &#038; Andy C</strong> &#8211; Colour Wheel</li>
<li><strong>Teebee</strong> &#8211; Warehouse</li>
<li><strong>Akira</strong> &#8211; Expedition</li>
<li><strong>Alix Perez</strong> &#8211; Dubrock</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2009/04/mix-drum-n-bass-deuxieme-partie/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MacAmphibian</title>
		<link>http://blog.alweb.org/2009/01/macamphibian/</link>
		<comments>http://blog.alweb.org/2009/01/macamphibian/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 16:35:00 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[En vrac]]></category>

		<guid isPermaLink="false">http://daiquiri.alweb.org/?p=11</guid>
		<description><![CDATA[Après MaCoffee, MacAmphibian :]]></description>
			<content:encoded><![CDATA[<p>Après <a href="/post/2008/09/30/MaCoffee">MaCoffee</a>, MacAmphibian :</p>
<p><img class="aligncenter size-full wp-image-94" title="MacAmphibian" src="/wp-content/uploads/mac_amphibian_m.jpg" alt="MacAmphibian" width="316" height="448" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2009/01/macamphibian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Andy C &#8211; Global Gathering 2008</title>
		<link>http://blog.alweb.org/2009/01/andy-c-global-gathering-2008/</link>
		<comments>http://blog.alweb.org/2009/01/andy-c-global-gathering-2008/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 19:51:00 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Musique]]></category>

		<guid isPermaLink="false">http://daiquiri.alweb.org/?p=22</guid>
		<description><![CDATA[Je suis tombé il y a peu sur un très très bon live d&#8217;Andy C. Cela vaut le coup d&#8217;être partagé (pour ceux qui supportent la D&#038;B), alors voilà : /wp-content/uploads/andy_c_global_gathering_2008.mp3 Et pour le télécharger c&#8217;est là.]]></description>
			<content:encoded><![CDATA[<p> Je suis tombé il y a peu sur un <strong>très très bon live d&#8217;Andy C</strong>. Cela vaut le coup d&#8217;être partagé (pour ceux qui supportent la D&#038;B), alors voilà : </p>
<p><!-- Dewplayer Begin--><object type="application/x-shockwave-flash" data="http://blog.alweb.org/wp-content/plugins/dewplayer-flash-mp3-player/dewplayer.swf?mp3=/wp-content/uploads/andy_c_global_gathering_2008.mp3&amp;showtime=1&amp;bgcolor=FFFFFF" width="200" height="20"><param name="bgcolor" value="FFFFFF" /><param name="movie" value="http://blog.alweb.org/wp-content/plugins/dewplayer-flash-mp3-player/dewplayer.swf?mp3=/wp-content/uploads/andy_c_global_gathering_2008.mp3&amp;showtime=1&amp;bgcolor=FFFFFF" /></object><!-- Dewplayer End--><a href="/wp-content/uploads/andy_c_global_gathering_2008.mp3">/wp-content/uploads/andy_c_global_gathering_2008.mp3</a></p>
<p> Et pour le télécharger <a href="/wp-content/uploads/andy_c_global_gathering_2008.mp3">c&#8217;est là</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2009/01/andy-c-global-gathering-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MaCoffee</title>
		<link>http://blog.alweb.org/2008/09/macoffee/</link>
		<comments>http://blog.alweb.org/2008/09/macoffee/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 14:04:00 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[En vrac]]></category>

		<guid isPermaLink="false">http://daiquiri.alweb.org/?p=10</guid>
		<description><![CDATA[Et là, c&#8217;est le drame&#8230;]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-91" title="MaCoffee" src="/wp-content/uploads/mac_coffee.png" alt="MaCoffee" width="476" height="353" /></p>
<p>Et là, c&#8217;est le drame&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2008/09/macoffee/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Quercus &#8211; Stop Global Warming</title>
		<link>http://blog.alweb.org/2008/09/quercus-stop-global-warming/</link>
		<comments>http://blog.alweb.org/2008/09/quercus-stop-global-warming/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 00:00:00 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[En vrac]]></category>

		<guid isPermaLink="false">http://daiquiri.alweb.org/?p=9</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div><object width="425" height="344"><param name="movie" value="//www.youtube.com/v/P_9mjBUSDng&amp;hl=en&amp;fs=1" /><param name="allowFullScreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="//www.youtube.com/v/P_9mjBUSDng&amp;hl=en&amp;fs=1" allowfullscreen="true"></embed></object></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2008/09/quercus-stop-global-warming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixtures on Rails 2.1</title>
		<link>http://blog.alweb.org/2008/06/fixtures-on-rails-21/</link>
		<comments>http://blog.alweb.org/2008/06/fixtures-on-rails-21/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 14:41:00 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Geekeries]]></category>

		<guid isPermaLink="false">http://daiquiri.alweb.org/?p=18</guid>
		<description><![CDATA[Suite à mon précédent billet concernant la création d&#8217;un jeu de données propre à une migration en utilisant les fixtures ainsi qu&#8217;aux nouveautés concernant les migrations dans rails 2.1, quelques ajustements ont du être effectués. Les fichiers de migrations sont désormais préfixées par un timestamp (exemple : db/migrate/20080618211857_create_admin_user.rb) et non plus par un simple identifiant [...]]]></description>
			<content:encoded><![CDATA[<p>Suite à mon <a title="Fixtures on Rails" href="/2007/07/fixtures-on-rails/">précédent billet</a> concernant la création d&#8217;un jeu de données propre à une migration en utilisant les <em>fixtures</em> ainsi qu&#8217;aux <a href="http://railscasts.com/episodes/107">nouveautés concernant les migrations dans rails 2.1</a>, quelques ajustements ont du être effectués.</p>
<p>Les fichiers de migrations sont désormais préfixées par un <code>timestamp</code> (exemple : <code>db/migrate/20080618211857_create_admin_user.rb</code>) et non plus par un simple identifiant incrémental. Vos fichiers de <em>fixtures</em> doivent désormais être préfixés par ce même <code>timestamp</code> (exemple : <code>db/fixtures/20080618211857_users.yml</code>).</p>
<p>Voici donc le script <code>lib/create_fixtures.rb</code> mis à jour :</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> MigrateFixtures
&nbsp;
  FIXTURES_LOCATION = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/../db/fixtures'</span>
  MIGRATIONS_LOCATION = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/../db/migrate'</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">extended</span><span style="color:#006600; font-weight:bold;">&#40;</span>object<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> object
      alias_method <span style="color:#ff3333; font-weight:bold;">:migrate_without_fixtures</span>, <span style="color:#ff3333; font-weight:bold;">:migrate</span> <span style="color:#9966CC; font-weight:bold;">unless</span> method_defined?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:migrate_without_fixtures</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      alias_method <span style="color:#ff3333; font-weight:bold;">:migrate</span>, <span style="color:#ff3333; font-weight:bold;">:migrate_with_fixtures</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> migrate_with_fixtures<span style="color:#006600; font-weight:bold;">&#40;</span>direction<span style="color:#006600; font-weight:bold;">&#41;</span>
    migrate_without_fixtures<span style="color:#006600; font-weight:bold;">&#40;</span>direction<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#ff3333; font-weight:bold;">:down</span> == direction
    migration = current_migration
    cnx = <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">connection</span>
    files = fixture_files.<span style="color:#9900CC;">find_all</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
      file =~ <span style="color:#006600; font-weight:bold;">/</span>\<span style="color:#006600; font-weight:bold;">/</span><span style="color:#008000; font-style:italic;">#{migration}_/</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    files.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
      table_name = file.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#006600; font-weight:bold;">*</span>\<span style="color:#006600; font-weight:bold;">/</span>\d<span style="color:#006600; font-weight:bold;">+</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>\.<span style="color:#9900CC;">yml</span><span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">'<span style="color:#000099;">\1</span>'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      say_with_time<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Adding #{table_name} fixtures&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        Fixtures.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>cnx, table_name, <span style="color:#0000FF; font-weight:bold;">nil</span>, file.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>\.<span style="color:#9900CC;">yml</span><span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">'<span style="color:#000099;">\1</span>'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">insert_fixtures</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  private
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> current_migration
      version = <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migrator</span>.<span style="color:#9900CC;">current_version</span>
      file = migration_files.<span style="color:#9900CC;">find</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
        version = <span style="color:#996600;">'%03d'</span> <span style="color:#006600; font-weight:bold;">%</span> version <span style="color:#9966CC; font-weight:bold;">if</span> version.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">size</span> <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#006666;">3</span>
        f =~ <span style="color:#006600; font-weight:bold;">/</span>\<span style="color:#006600; font-weight:bold;">/</span><span style="color:#008000; font-style:italic;">#{version}_/</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
      index = migration_files.<span style="color:#9900CC;">index</span> file
      file = index ? migration_files<span style="color:#006600; font-weight:bold;">&#91;</span>index <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> : migration_files.<span style="color:#9900CC;">first</span>
      file.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#006600; font-weight:bold;">*</span>\<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>_.<span style="color:#006600; font-weight:bold;">*/</span>, <span style="color:#996600;">'<span style="color:#000099;">\1</span>'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> fixture_files
      <span style="color:#0066ff; font-weight:bold;">@fixture_files</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#CC00FF; font-weight:bold;">Dir</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{FIXTURES_LOCATION}/[0-9]*_*.yml&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">sort</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> migration_files
      <span style="color:#0066ff; font-weight:bold;">@migration_files</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#CC00FF; font-weight:bold;">Dir</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{MIGRATIONS_LOCATION}/[0-9]*_*.rb&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">sort</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>.<span style="color:#9900CC;">extend</span><span style="color:#006600; font-weight:bold;">&#40;</span>MigrateFixtures<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Note : Cette version est compatible avec les anciennes version de rails.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2008/06/fixtures-on-rails-21/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iSport</title>
		<link>http://blog.alweb.org/2008/04/isport/</link>
		<comments>http://blog.alweb.org/2008/04/isport/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 11:23:00 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Geekeries]]></category>

		<guid isPermaLink="false">http://daiquiri.alweb.org/?p=17</guid>
		<description><![CDATA[Voici une petite appli Web adaptée pour iPhone / iPod Touch : iSport. Elle permet d&#8217;avoir les informations sportives ainsi que les résultats des matchs en direct (pour l&#8217;instant, que Fooball, Tennis, Basket US et Rugby). La chose utilise Ruby, Rails, Hpricot et comme d&#8217;habitude : Prototype. Quelques screenshots pour la peine : Des retours [...]]]></description>
			<content:encoded><![CDATA[<p>Voici <a href="http://isport.alweb.org">une petite appli Web adaptée pour iPhone / iPod Touch : iSport</a>.</p>
<p>Elle permet d&#8217;avoir les informations sportives ainsi que les résultats des matchs en direct (pour l&#8217;instant, que Fooball, Tennis, Basket US et Rugby).</p>
<p>La chose utilise <a href="http://fr.wikipedia.org/wiki/Ruby">Ruby</a>, <a href="http://rubyonrails.com">Rails</a>, <a href="http://code.whytheluckystiff.net/hpricot/">Hpricot</a> et comme d&#8217;habitude : <a href="http://prototypejs.org/">Prototype</a>.</p>
<p>Quelques screenshots pour la peine :</p>
<p><img class="aligncenter size-full wp-image-88" title="iSport (1)" src="/wp-content/uploads/2009/01/isport-1.jpg" alt="iSport (1)" width="320" height="480" /></p>
<p><img class="aligncenter size-full wp-image-89" title="iSport (2)" src="/wp-content/uploads/2009/01/isport-2.jpg" alt="iSport (2)" width="320" height="480" /></p>
<p>Des retours et / ou commentaires sont les bienvenus !</p>
<ul>
<li><a href="http://www.iphon.fr/post/2008/04/26/iSport-%3A-tout-le-sportau-format-iPhone">Ils en parlent ailleurs</a></li>
<li><a href="http://www.alweb.org/projects/isport/">Accès au source, etc.</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2008/04/isport/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>mount /dev/null</title>
		<link>http://blog.alweb.org/2008/04/mount-devnull/</link>
		<comments>http://blog.alweb.org/2008/04/mount-devnull/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 10:19:00 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Geekeries]]></category>

		<guid isPermaLink="false">http://daiquiri.alweb.org/?p=16</guid>
		<description><![CDATA[Ce matin un collègue a trouvé un gentil mot de notre administrateur système :]]></description>
			<content:encoded><![CDATA[<p>Ce matin un collègue a trouvé un gentil mot de notre administrateur système :</p>
<p><img src="/wp-content/uploads/2009/01/format_m.jpg" alt="Format" title="Format" width="336" height="448" class="aligncenter size-full wp-image-86" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2008/04/mount-devnull/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Diff SVN</title>
		<link>http://blog.alweb.org/2008/02/diff-svn/</link>
		<comments>http://blog.alweb.org/2008/02/diff-svn/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 14:08:00 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Geekeries]]></category>

		<guid isPermaLink="false">http://daiquiri.alweb.org/?p=15</guid>
		<description><![CDATA[En regardant le script de davux, permettant la colorisation d&#8217;un diff, je me suis dit qu&#8217;il devait y avoir une possibilité d&#8217;intégrer ça de manière simple à subversion. Collez ce petit script dans un fichier (nous allons prendre ici /usr/local/bin/colorized_diff) et rendez le exécutable : #! /bin/sh &#160; plus='^[[0;32m' minus='^[[0;31m' diff &#34;$@&#34; &#124; sed 's/^+.*$/'&#34;$plus&#34;'&#38;^[[0m/; [...]]]></description>
			<content:encoded><![CDATA[<p>En regardant le <a href="http://da.weeno.net/code/diff-u">script de davux</a>, permettant la colorisation d&#8217;un diff, je me suis dit qu&#8217;il devait y avoir une possibilité d&#8217;intégrer ça de manière simple à <a title="aka SVN" href="http://subversion.tigris.org/">subversion</a>.</p>
<p>Collez ce petit script dans un fichier (nous allons prendre ici <code>/usr/local/bin/colorized_diff</code>) et rendez le exécutable  :</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>
&nbsp;
<span style="color: #007800;">plus</span>=<span style="color: #ff0000;">'^[[0;32m'</span>
<span style="color: #007800;">minus</span>=<span style="color: #ff0000;">'^[[0;31m'</span>
<span style="color: #c20cb9; font-weight: bold;">diff</span> <span style="color: #ff0000;">&quot;$@&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^+.*$/'</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$plus</span>&quot;</span><span style="color: #ff0000;">'&amp;^[[0m/; s/^-.*$/'</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$minus</span>&quot;</span><span style="color: #ff0000;">'&amp;^[[0m/'</span></pre></div></div>

<p>Ensuite, modifiez le fichier <code>~/.subversion/config</code> pour y rajouter ou modifier la ligne suivante dans la section <code>[helpers]</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">diff-cmd = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>colorized_diff</pre></div></div>

<p>Vous pouvez omettre le chemin (<code>/usr/local/bin</code>) si il est dans votre <code>PATH</code>. Maintenant, un <code>svn diff</code> dans un shell vous affichera les lignes supprimées en rouge et les lignes ajoutées en vert. C&#8217;est pas plus mignon ?</p>
<p>Note : <code>^[</code> est le caractère d&#8217;échappement, vous pouvez le taper dans vim en faisant Ctrl-V puis Echap</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alweb.org/2008/02/diff-svn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

