<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Jabberwocky</title>
  <id>http://127.0.0.1</id>
  <updated>2008-09-12T00:00:00Z</updated>
  <author>
    <name>Elise Huard</name>
  </author>
  <entry>
    <title>Ruby Garbage Collection</title>
    <link href="http://127.0.0.1/2010/09/03/ruby-garbage-collection/" rel="alternate"/>
    <id>http://127.0.0.1/2010/09/03/ruby-garbage-collection/</id>
    <published>2010-09-03T00:00:00Z</published>
    <updated>2010-09-03T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;Last week, I came across a very interesting tidbit of information:
&lt;strong&gt;The Ruby Garbage Collector was not meant to run&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Garbage collection is one of the Achilles'heels of MRI ruby performance.  It combines a fairly naive algorithm with a 'stop the world' assumption, as in it's not a background process, and any other ruby activity can bloody well wait until it is done.&lt;/p&gt;

&lt;p&gt;I found &lt;a href="http://www.ruby-forum.com/topic/215163#new"&gt;this thread&lt;/a&gt; in the ruby-lang mailing list very interesting.  Next quotes are enlightening:&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Last week, I came across a very interesting tidbit of information:
&lt;strong&gt;The Ruby Garbage Collector was not meant to run&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Garbage collection is one of the Achilles'heels of MRI ruby performance.  It combines a fairly naive algorithm with a 'stop the world' assumption, as in it's not a background process, and any other ruby activity can bloody well wait until it is done.&lt;/p&gt;

&lt;p&gt;I found &lt;a href="http://www.ruby-forum.com/topic/215163#new"&gt;this thread&lt;/a&gt; in the ruby-lang mailing list very interesting.  Next quotes are enlightening:&lt;/p&gt;

&lt;blockquote&gt;In particular, the GC algorithms in MRI and YARV are specifically
designed with the assumption that they will never actually run in
99.999% of all cases. They are designed for scripting, where a script
doesn't even allocate enough memory to trigger a collection, runs for
a couple of seconds and then exits, after which the OS simply reclaims
the memory: no GC needed.
&lt;br/&gt;
That's why YARV and especially MRI are so exceptionally bad for server
loads. It's also why REE can never be merged into mainline. (Jorg W. Mittag Aug 21 2010)&lt;/blockquote&gt;




&lt;blockquote&gt;99.999% is a bit over-exaggerated, but it is true that garbage
collection algorithm of YARV and MRI focus for throughput on
non-memory extensive short-running programs, and GC of REE is not
suitable for those programs. (Matz Aug 21 2010)&lt;/blockquote&gt;


&lt;p&gt;Scripting was the original use case for ruby, so that's understandable.  It explains a lot.&lt;/p&gt;

&lt;p&gt;In other related news, I &lt;a href="http://twitter.com/elise_huard/status/22786825799"&gt;asked on Twitter&lt;/a&gt; whether there was an Enterprise Edition for Ruby 1.9 in the works.  Enterprise edition Ruby fixes some of the worst evils by, amongst other things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;exposing some garbage collection parameters, and tuning it a little out of the box&lt;/li&gt;
&lt;li&gt;doing &lt;a href="http://en.wikipedia.org/wiki/Copy-on-write"&gt;Copy on Write&lt;/a&gt;, allowing several threads to use common resources in a read-only way.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Unfortunately, Phusion people told me there are &lt;a href="http://twitter.com/ninh/status/22795175286"&gt;no immediate plans&lt;/a&gt; to make an enterprise edition of ruby 1.9, since they are now going full throttle on an overhaul of Passenger.  Additionally MRI ruby 1.9 needs some patching to make it &lt;a href="http://twitter.com/ninh/status/22794838064"&gt;Copy on Write friendly&lt;/a&gt;, and that hasn't happened yet.&lt;/p&gt;

&lt;p&gt;I'd like to have a look at Rubinius, where garbage collection is done differently.  And of course JRuby benefits from the JVM memory handling, which has been optimized to death by many PhDs and all the developer budgets Sun and IBM could spend on it.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Selenium</title>
    <link href="http://127.0.0.1/2010/07/24/selenium/" rel="alternate"/>
    <id>http://127.0.0.1/2010/07/24/selenium/</id>
    <published>2010-07-24T00:00:00Z</published>
    <updated>2010-07-24T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;Selenium is a tool for integration testing - you run tests directly in your browser - the browser of your choice - and test the whole stack, from client javascript to database access.&lt;/p&gt;

&lt;p&gt;Cucumber can integrate with selenium.  It's one of the ways to factor in javascript in your tests.&lt;/p&gt;

&lt;h2&gt;Installing&lt;/h2&gt;

&lt;p&gt;Installing Selenium itself is a piece of cake.
Download Selenium Core from &lt;a href="http://seleniumhq.org/download/"&gt;here&lt;/a&gt;. Unzip the archive, and copy the content of the core directory into a publically accessible directory on the same location (virtualhost/server) as your application&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Selenium is a tool for integration testing - you run tests directly in your browser - the browser of your choice - and test the whole stack, from client javascript to database access.&lt;/p&gt;

&lt;p&gt;Cucumber can integrate with selenium.  It's one of the ways to factor in javascript in your tests.&lt;/p&gt;

&lt;h2&gt;Installing&lt;/h2&gt;

&lt;p&gt;Installing Selenium itself is a piece of cake.
Download Selenium Core from &lt;a href="http://seleniumhq.org/download/"&gt;here&lt;/a&gt;. Unzip the archive, and copy the content of the core directory into a publically accessible directory on the same location (virtualhost/server) as your application.
In rails, this means in a subdirectory of public.&lt;/p&gt;

&lt;h2&gt;IDE&lt;/h2&gt;

&lt;p&gt;In our project, we plan to use Selenium for User Acceptance testing. The testers don't want to redo every test scenario.  Selenium IDE is the answer: before you start to run a scenario you start recording, and you stop after you're done.&lt;/p&gt;

&lt;p&gt;Selenium IDE is a Firefox extension.  Download it from &lt;a href="http://seleniumhq.org/download/"&gt;the same location&lt;/a&gt;. Load it using File -&gt; Open File.&lt;/p&gt;

&lt;h2&gt;Integrating selenium tests in test sets&lt;/h2&gt;

&lt;p&gt;Selenium IDE allows you to export to Ruby, .Net, Java.  They might need to be edited a little - the generated class for test cases for instance, or the configuration under which to run to run the tests (url, browser).&lt;/p&gt;

&lt;p&gt;To run those tests an extra tool is needed: Selenium Remote Control, and corresponding driver for your language.
Download Selenium RC from the &lt;a href="http://seleniumhq.org/download/"&gt;same site&lt;/a&gt; again.
The only component you're going to use is selenium-server.jar
(Under Debian, you might need to install the packages sun-java6-jdk update-java-alternatives -s java-6-sun)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;java -jar selenium-server.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which starts jetty, a light java server, by default on port 4444&lt;/p&gt;

&lt;p&gt;In Ruby&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gem install selenium-client
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then you can run your tests, as you would normally, maybe with their own rake task.&lt;/p&gt;

&lt;p&gt;Selenium does Firefox, IE, Safari - not yet Chrome for as far as I know.  These have to be installed on the machines you run the test on.&lt;/p&gt;

&lt;p&gt;It might make more sense to run these tests as part of continuous integration, as they are known to be slower. But it's really handy to have them, as they do reflect the users' experience.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>RPCFN #11</title>
    <link href="http://127.0.0.1/2010/07/01/rpcfn-11/" rel="alternate"/>
    <id>http://127.0.0.1/2010/07/01/rpcfn-11/</id>
    <published>2010-07-01T00:00:00Z</published>
    <updated>2010-07-01T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;The Ruby Programming Challenge For Newbies is an initiative on the Rubylearning.org blog started by Satish Talim of Josh Software.  It's usually a Ruby programming problem that aims to combine fun and a difficulty level that is just hard enough to be a challenge for Ruby newbies.&lt;/p&gt;

&lt;p&gt;I was contacted to provide the challenge for this month, and I selected the &lt;a href="http://rubylearning.com/blog/2010/06/28/rpcfn-the-game-of-life-11/"&gt;Game of Life&lt;/a&gt;&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;The Ruby Programming Challenge For Newbies is an initiative on the Rubylearning.org blog started by Satish Talim of Josh Software.  It's usually a Ruby programming problem that aims to combine fun and a difficulty level that is just hard enough to be a challenge for Ruby newbies.&lt;/p&gt;

&lt;p&gt;I was contacted to provide the challenge for this month, and I selected the &lt;a href="http://rubylearning.com/blog/2010/06/28/rpcfn-the-game-of-life-11/"&gt;Game of Life&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's a not very difficult problem by itself, but can be approached creatively, especially in the initialization (seeds of the game), and in the dimension variables of the chosen universe (edge handling, n-dimensional space).&lt;/p&gt;

&lt;p&gt;If you feel tickled, but you are not a newbie, you can have a go in the 'just for fun' category (there's a few interesting submissions in that category already, like an unreadable perl implementation by Ian Dekkers and movie generation by James Edward Gray II).&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Additions to my Ruby Gallery</title>
    <link href="http://127.0.0.1/2010/06/29/additions-to-my-ruby-gallery/" rel="alternate"/>
    <id>http://127.0.0.1/2010/06/29/additions-to-my-ruby-gallery/</id>
    <published>2010-06-29T00:00:00Z</published>
    <updated>2010-06-29T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;a href="http://www.flickr.com/photos/21066916@N07/4739029167/" title="Matz by elisehuard, on Flickr"&gt;&lt;img src="http://farm5.static.flickr.com/4095/4739029167_a580fa0368.jpg" width="500" height="375" alt="Matz"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.flickr.com/photos/21066916@N07/4739033131/" title="dhh by elisehuard, on Flickr"&gt;&lt;img src="http://farm5.static.flickr.com/4137/4739033131_cdecffa054.jpg" width="500" height="375" alt="dhh"&gt;&lt;/a&gt;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;a href="http://www.flickr.com/photos/21066916@N07/4739029167/" title="Matz by elisehuard, on Flickr"&gt;&lt;img src="http://farm5.static.flickr.com/4095/4739029167_a580fa0368.jpg" width="500" height="375" alt="Matz"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.flickr.com/photos/21066916@N07/4739033131/" title="dhh by elisehuard, on Flickr"&gt;&lt;img src="http://farm5.static.flickr.com/4137/4739033131_cdecffa054.jpg" width="500" height="375" alt="dhh"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I got both pictures in the space of two weeks, in different timezones.  Go on, laugh, but (if you know at all who they are) admit you're jealous.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Railsconf 2010</title>
    <link href="http://127.0.0.1/2010/06/27/railsconf-2010/" rel="alternate"/>
    <id>http://127.0.0.1/2010/06/27/railsconf-2010/</id>
    <published>2010-06-27T00:00:00Z</published>
    <updated>2010-06-27T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;Highlights of Railsconf 2010 in Baltimore for me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;a href="http://en.oreilly.com/rails2010/public/schedule/detail/14132"&gt;keynote by Yehuda Katz&lt;/a&gt;, where everyone left wide-eyed and energized - great speaking.  basically, most keynotes were interesting (Gary Vee gets my vote in the impro category).  The Youtube channel is &lt;a href="http://www.youtube.com/watch?v=mo-lMdQMsdw"&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://en.oreilly.com/rails2010/public/schedule/detail/11337"&gt;Async &amp;amp; Cooperative Web Servers with Ruby 1.9&lt;/a&gt; by Ilya Grigorik, encouraging Rails to go in the evented direction, pointing to the success of node.js&lt;/li&gt;
&lt;/ul&gt;

</summary>
    <content type="html">&lt;p&gt;Highlights of Railsconf 2010 in Baltimore for me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;a href="http://en.oreilly.com/rails2010/public/schedule/detail/14132"&gt;keynote by Yehuda Katz&lt;/a&gt;, where everyone left wide-eyed and energized - great speaking.  basically, most keynotes were interesting (Gary Vee gets my vote in the impro category).  The Youtube channel is &lt;a href="http://www.youtube.com/watch?v=mo-lMdQMsdw"&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://en.oreilly.com/rails2010/public/schedule/detail/11337"&gt;Async &amp;amp; Cooperative Web Servers with Ruby 1.9&lt;/a&gt; by Ilya Grigorik, encouraging Rails to go in the evented direction, pointing to the success of node.js&lt;/li&gt;
&lt;li&gt;&lt;a href="http://en.oreilly.com/rails2010/public/schedule/detail/14146"&gt;Ruby on Rails: Tasty Burgers&lt;/a&gt; talk by Aaron Patterson, with some clever ruby examples&lt;/li&gt;
&lt;li&gt;&lt;a href="http://en.oreilly.com/rails2010/public/schedule/detail/11337"&gt;Garbage Collection and the Ruby Heap&lt;/a&gt;, where Joe Damato explained how they implemented memprof&lt;/li&gt;
&lt;li&gt;Bohconf, the unconference organized by the Baltimore Ruby User Group.&lt;/li&gt;
&lt;li&gt;The evenings at the pub with many people :)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;And I regret missing many other great talk.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://en.oreilly.com/rails2010/public/schedule/detail/14232"&gt;My talk&lt;/a&gt; went well. I feared to have an audience of 2, because of competition with some great names on other tracks, but I still had a decent size of group in front of me.  Enjoyable experience, and a good opportunity to meet the US rubyists.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>bikeshedding for fun</title>
    <link href="http://127.0.0.1/2010/06/07/bikeshedding-for-fun/" rel="alternate"/>
    <id>http://127.0.0.1/2010/06/07/bikeshedding-for-fun/</id>
    <published>2010-06-07T00:00:00Z</published>
    <updated>2010-06-07T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: If you don't know the reference to the &lt;a href="http://en.wikipedia.org/wiki/Parkinson's_Law_of_Triviality"&gt;the color of the bikeshed&lt;/a&gt;, you should definitely check it out.&lt;/p&gt;

&lt;p&gt;My bikeshed of the month was my blog.  A blog is nice and simple, so thinking about its implementation is really, really easy.&lt;/p&gt;

&lt;p&gt;I wanted a blog where I could just commit and push a markdown file to a repository, and voila: it is published&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: If you don't know the reference to the &lt;a href="http://en.wikipedia.org/wiki/Parkinson's_Law_of_Triviality"&gt;the color of the bikeshed&lt;/a&gt;, you should definitely check it out.&lt;/p&gt;

&lt;p&gt;My bikeshed of the month was my blog.  A blog is nice and simple, so thinking about its implementation is really, really easy.&lt;/p&gt;

&lt;p&gt;I wanted a blog where I could just commit and push a markdown file to a repository, and voila: it is published.&lt;/p&gt;

&lt;p&gt;The first and obvious candidates are static sites generators like &lt;a href="http://github.com/ddfreyne/nanoc"&gt;nanoc&lt;/a&gt; and &lt;a href="http://github.com/mojombo/jekyll"&gt;jekyll&lt;/a&gt;.  But I wasn't really convinced, as I was thinking of adding more dynamic features, like, say, comments, or rack middleware shininess.&lt;/p&gt;

&lt;p&gt;I started making my own blog engine with sinatra, like everyone and his neighbour, I even had a nice name for it, but then I stumbled onto &lt;a href="http://github.com/cloudhead/toto"&gt;toto&lt;/a&gt;.  Toto is a thin layer of blog icing on top of rack.&lt;/p&gt;

&lt;p&gt;So I took toto, played a bit to be able to use haml with it and have a decent error page, and here's my blog, such as it is.  I'll probably add a fork and a comment gem to toto at some point (haven't decided how to call it, probably something Oz-related).&lt;/p&gt;

&lt;p&gt;The amendments to config.ru for haml:&lt;/p&gt;

&lt;pre class="brush: ruby"&gt;
require 'haml'
...
set :to_html   do |path, page, ctx|
  Haml::Engine.new(File.read("#{path}/#{page}.haml")).render(ctx)
end
&lt;/pre&gt;


&lt;p&gt;and the error page with haml and layout:&lt;/p&gt;

&lt;pre class="brush: ruby"&gt;
require 'haml'
set :error do |code|
  # fake the bindings for the layout haml
  class LayoutCtx
    def title; 'title' end
    def archives; "" end
  end
 
   Haml::Engine.new(File.read("templates/layout.haml")).render(LayoutCtx.new) do |content|
      Haml::Engine.new(File.read("templates/pages/error.haml")).render(Object.new,:code =&gt; code)
   end
end
&lt;/pre&gt;


&lt;p&gt;And then, the cherry on the cake: the git hook required to make it work on your web server: &lt;a href="http://toroid.org/ams/git-website-howto"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: I still have an issue with markdown and code, as you can notice.  Still have to look that up.&lt;/p&gt;

&lt;p&gt;So there. git push.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Euruko 2010</title>
    <link href="http://127.0.0.1/2010/06/01/euruko-2010/" rel="alternate"/>
    <id>http://127.0.0.1/2010/06/01/euruko-2010/</id>
    <published>2010-06-01T00:00:00Z</published>
    <updated>2010-06-01T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;I finally attended my first &lt;a href="http://euruko2010.org/"&gt;Euruko&lt;/a&gt;.  It had, for me, the perfect size (250 people) and the perfect length (2 days).  And it was an opportunity to see Krakow, a lovely town in the south of Poland.  The castle, the historical buildings, the churches, the lively nightlife in well hidden locations, you name it, Krakow has it.  Very green too, with lots of parks and trees.
(note to self: go back there for a proper short holiday)&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I finally attended my first &lt;a href="http://euruko2010.org/"&gt;Euruko&lt;/a&gt;.  It had, for me, the perfect size (250 people) and the perfect length (2 days).  And it was an opportunity to see Krakow, a lovely town in the south of Poland.  The castle, the historical buildings, the churches, the lively nightlife in well hidden locations, you name it, Krakow has it.  Very green too, with lots of parks and trees.
(note to self: go back there for a proper short holiday)&lt;/p&gt;

&lt;p&gt;I did a talk, which is a condensed and enhanced version of the talk I did at ScotRuby. While I was again extremely nervous (which did influence my perception of the event), it went well and people seemed interested.&lt;/p&gt;

&lt;p&gt;Other talks I recommend to check out: Ruby Profiling by Piotr Szotkowski, DSL or NoDSL by Jose Valim, Choice architectures by Elliot Crosby-McCullough, Florian Gilcher's talk about encodings. Unfortunately, I missed some interesting talks on saturday and also on sunday since I had to clear out to catch my plane.&lt;/p&gt;

&lt;p&gt;I also enjoyed Matz's talk, in which he said 2 things: that the Ruby community should stay nice, open and tolerant, even through its growth, and that standing still in open source is death, so we should always move forward.&lt;/p&gt;

&lt;p&gt;I got to take a picture with to Matz (I look like I felt,  terribly self-conscious), I got to talk to the developer of rbdbgr (Rocky Bernstein), which I wanted to do, I got to sit next to Jose Valim and Yehuda Katz (secretly trying to soak up some of their 'fu). Medium-sized conferences are great.&lt;/p&gt;

&lt;p&gt;Thanks Paul Klipp, Ela Madej, Agatha and team for the fantastic conference !&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>12 hours to rate a rails application</title>
    <link href="http://127.0.0.1/2010/03/29/12-hours-to-rate-a-rails-application/" rel="alternate"/>
    <id>http://127.0.0.1/2010/03/29/12-hours-to-rate-a-rails-application/</id>
    <published>2010-03-29T00:00:00Z</published>
    <updated>2010-03-29T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;Here's the presentation I did this weekend.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.slideshare.net/ehuard/12-hours-to-rate-a-rails-application"&gt;12 Hours To Rate A Rails Application&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, just as I was about to start, my laptop died and refused to start again.  Lost me some precious minutes, but fortunately I had a USB key with a backup, and my coworker Alain Ravet lent me his laptop (Julian Fischer also kindly offered, but his computer didn't like my presentation).  Murphy's law in all its glory.  After that, things went more or less smoothly&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Here's the presentation I did this weekend.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.slideshare.net/ehuard/12-hours-to-rate-a-rails-application"&gt;12 Hours To Rate A Rails Application&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, just as I was about to start, my laptop died and refused to start again.  Lost me some precious minutes, but fortunately I had a USB key with a backup, and my coworker Alain Ravet lent me his laptop (Julian Fischer also kindly offered, but his computer didn't like my presentation).  Murphy's law in all its glory.  After that, things went more or less smoothly.&lt;/p&gt;

&lt;p&gt;If you had the opportunity to attend, I would really appreciate your feedback on &lt;a href="http://speakerrate.com/talks/2887-12-hours-to-rate-a-rails-application"&gt;speakerrate&lt;/a&gt;, as I'm going to give this talk another couple of times.  I sensed when it worked, and when it didn't, but the more input, the better I can fine-tune it.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Fscking up with git and how to solve it</title>
    <link href="http://127.0.0.1/2010/03/24/fscking-up-with-git-and-how-to-solve-it/" rel="alternate"/>
    <id>http://127.0.0.1/2010/03/24/fscking-up-with-git-and-how-to-solve-it/</id>
    <published>2010-03-24T00:00:00Z</published>
    <updated>2010-03-24T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;I've been using git for nearly two years now, but this job is the first time I'm using it with more than 2 people on the same project.  And it's different, I can tell you.&lt;/p&gt;

&lt;p&gt;In this case you need a workflow: we adopted &lt;a href="http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html"&gt;this one&lt;/a&gt;, also described &lt;a href="http://geewax.org/2009/11/21/agile-git-workflow.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's a good workflow.  But human error means that you can go wrong&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I've been using git for nearly two years now, but this job is the first time I'm using it with more than 2 people on the same project.  And it's different, I can tell you.&lt;/p&gt;

&lt;p&gt;In this case you need a workflow: we adopted &lt;a href="http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html"&gt;this one&lt;/a&gt;, also described &lt;a href="http://geewax.org/2009/11/21/agile-git-workflow.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's a good workflow.  But human error means that you can go wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forgetting to branch&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The workflow demands that you do all your work on branches - that way you avoid merges on master, and can maintain a nice straight and clear master branch.
But, as you start working on a new feature, you might forget to do that git checkout -b boldly_go
And start coding and committing on your local master.
What now ?  Well, git offers an easy solution.  Tag your latest commit (give it a label)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git tag boldly_go_tag
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;reset the master to its remote position (do not use --hard or you will lose your work)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git reset --soft HEAD
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;create a branch out of your tagged commit, which is not on any branch just now&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git checkout -b  boldly_go boldly_go_tag
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Better:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git checkout -b boldly_go
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;to create the branch&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git checkout master
git reset --hard origin/master
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;to reset the master to its original position.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My last commit message lacks poetry &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Or I forgot to add this one file.  Solution:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git commit --amend
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Forget I ever did that last commit&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Careful, this will remove any changes you added in that commit.  This will only work locally, of course:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git reset --hard HEAD^
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;if you want your commit to go away, but your code to still be around:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git reset --soft HEAD^
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Going off the map&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As you work on your branch, you want to do regular rebase with the remote master, to minimize any later merges and avoid surprises.  After every commit:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git checkout master
git pull
git checkout boldly_go
git rebase master
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here's where you can go very, very wrong: as long as you're in rebase state, you're in a situation where you're NOT on a branch. So if after a coffee break you forgot you're in rebase, and you continue working, you're working into the void !!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$&amp;gt; git branch
*(no branch)
boldly_go
master
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you then try to do a rebase again to get up to date with master, you won't find your commits where you expected them.  Oh noes !  Where did my work go !
No panic (to be honest, i did panic a little): git keeps all your commits.  You can find them in the .git/objects directory, if you care to have a look.  What you just did is create a 'dangling commit', that is a commit unlinked to any branch.  Fortunately, there's the aptly named git fsck command.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git fsck | grep commit
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(the grep commit helps separating the commits from the other dangling stuff) then use the SHA associated with your commit to create a tag:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git tag sos 9a4e6286aa2e2bd97334ad35b555169c2d3033b4
git checkout -b not_so_bold_now sos
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;this creates a branch based on the tag, and you can continue working.&lt;/p&gt;

&lt;p&gt;another good one to know in that case is&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git reflog
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;this shows all commits, dangling ones included, with their message, making it easier to find the commit you're looking for.  Same procedure for the rest.&lt;/p&gt;

&lt;p&gt;This and many other tips, and sources, can be found on
&lt;a href="http://www.gitready.com/"&gt;git-ready&lt;/a&gt;.
Thanks to Alain Ravet for some of the tips :)&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Scottish Ruby Conference</title>
    <link href="http://127.0.0.1/2010/03/20/scottish-ruby-conference/" rel="alternate"/>
    <id>http://127.0.0.1/2010/03/20/scottish-ruby-conference/</id>
    <published>2010-03-20T00:00:00Z</published>
    <updated>2010-03-20T00:00:00Z</updated>
    <author>
      <name>Elise Huard</name>
    </author>
    <summary type="html">&lt;p&gt;Time flies, and next week already,&lt;img src="http://scottishrubyconference.com/images/badges/src-240-speaking.jpg" alt="I'm speaking at the scottish ruby conference" /&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;in case of acquisitions (I've been asked to look over an application as an outside expert)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;when you're going to take over legacy codebase&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I'm going the extra mile on metrics (or quantitative code analysis), which are excellent tools to judge a large-ish codebase&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Time flies, and next week already,&lt;img src="http://scottishrubyconference.com/images/badges/src-240-speaking.jpg" alt="I'm speaking at the scottish ruby conference" /&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;in case of acquisitions (I've been asked to look over an application as an outside expert)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;when you're going to take over legacy codebase&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I'm going the extra mile on metrics (or quantitative code analysis), which are excellent tools to judge a large-ish codebase.
Whoo !  Large and interesting subject, all compressed in 45 minutes.  A day might come when I'll be totally relaxed about giving talks, but I'm not there yet.  Cross fingers.&lt;/p&gt;
</content>
  </entry>
</feed>
