17 August 2009

3G Huawei E220 & simyo.de on mac

Plug the modem and launch the MobileConnect application which is installed inside the E220.

Create a new profile for simyo.de:


telephone number of *99#
Access Point Name: internet.eplus.de
IP-Adresse: dynamic
Primary DNS:
Secondary DNS:
Account name: simyo
password: simyo

Click "Connect" and you should be online. After I found these configuration data with google, it works the first time. If you have a problem or a suggestion, leave a comment. Remember this config will only work in Germany with simyo.de

I am now ready to work with Rails on rails ;-) I will be indeed traveling a lot with the ICE, the German high speed train, which might not be as fast as the French TGV but it is very comfortable and has electric plugs in all the seats.

In this carbon junky world, I really hope that Copenhagen 2009 will enforce some regulations on plane transports. Instead of stupid competition between EU states railways, EU should also learn from the UK Rails privatization disaster. It would be so nice if the next generation of Europeans could travel on high speed rails transports with a public owned, interconnected, affordable and fast European rails network...

11 August 2009

Upgrade subclipse in Aptana Studio

At work, we just upgraded to subversion 1.6.3 from 1.4.x and it took us a 1-2 days to solve configuration issues. In order to make our life easier during merges, we decided to go for Aptana Studio. Unfortunately, at the time of this writing, this IDE is bundled with Subclipse 1.4.

Follow these manual steps to upgrade to http://subclipse.tigris.org/update_1.6.x

1. Remove Aptana Subversion Support

  1. Go to About Apanta Studio
    • In your Aptana Studio
      • On Windows, go to Help and select About Aptana Studio
      • On Mac, go to Aptana Studio and select About Aptana Studio
    • In you Eclipse
      • On Windows, go to Help and select About Eclipse SDK
      • On Mac, go to Eclipse and select About Eclipse SDK
  2. Select "Installation Details"
  3. Select the" Installed Software" Tab
  4. Select the plugins you would like to install and click "Uninstall".

2. Install subclipse 1.6.x

  1. From the Help menu, select Install new Software ...
  2. Select Available Software.
  3. Click the Add Site... button.
  4. In the Location text box, type http://subclipse.tigris.org/update_1.6.x
  5. Also add mylyn: http://download.eclipse.org/tools/mylyn/update/e3.4

3. Install Aptana RadRails


29 July 2009

to_yaml from mysql SELECT tip

Append \G at the end of a SELECT query .

select * from countries limit 5\G;

*************************** 1. row ***************************
id: 4
continent_id: 2
region_id: 14
permalink: afghanistan
name_en: Afghanistan
name_de: Afghanistan
lat: 33.9391
lng: 67.71
eu_member: 0
alpha2: NULL
alpha3: NULL
*************************** 2. row ***************************
id: 8
continent_id: 3
region_id: 19
permalink: albania
name_en: Albania
name_de: Albanien
lat: 41.1533
lng: 20.1683
eu_member: 0
alpha2: NULL
alpha3: NULL

13 July 2009

Fixing Bus Error BUG in ruby entreprise edition

If you want to use ruby enterprise edition (ree) for your project, it's very important to install all the dependencies with the ree gem command, especially if the gems rely on native code such as imagemagick, or ... bluecloth.

I bumped into the following bug when I tried to run my specs with ree:

$ /opt/ruby-enterprise-1.8.6-20090610/bin/ruby spec/models/advocacy_spec.rb
/.gem/ruby/1.8/gems/bluecloth-2.0.0/lib/bluecloth_ext.bundle: [BUG] Bus Error
ruby 1.8.6 (2008-08-11) [i686-darwin9.7.0]

Abort trap

The solution was to install the bluecloth gem again, with reee gem:

:trunk$ /opt/ruby-enterprise-1.8.6-20090610/bin/gem install bluecloth
WARNING: Installing to ~/.gem since /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8 and
/opt/ruby-enterprise-1.8.6-20090610/bin aren't both writable.
Building native extensions. This could take a while...
Successfully installed bluecloth-2.0.4
1 gem installed
Installing ri documentation for bluecloth-2.0.4...
Installing RDoc documentation for bluecloth-2.0.4...
jm-macbook:trunk jeanmichel$ /opt/ruby-enterprise-1.8.6-20090610/bin/ruby spec/models/advocacy_spec.rb

Finished in 0.349809 seconds

The recent versions of rubygems use the ~/.gem/ruby/1.8/ folder so it make sense to install gems in your home folder so standard ruby and ree can share them.

On a sidenote, running the specs with ree worked without any problem. memory consumption was lower but it did not improve the speed.

04 June 2009

Before | After


def self.find_expiring_soon(date_time = Time.now)
@@expiring_soon ||= find(:all, :conditions => ["type_id = 1 AND completed = 0 AND created_at < :date", { :date => (4.months + 14.days).ago(date_time) }])

def self.find_expiring_soon_with_donations(date_time = Time.now)
@@expiring_soon_with_donations ||= find(:all, :conditions => ["type_id = 1 AND completed = 0 AND donated_amount > 0 AND created_at < :date", { :date => (4.months + 14.days).ago(date_time) }])

def self.find_expiring_soon_without_donations(date_time = Time.now)
@@expiring_soon_with_donations ||= find(:all, :conditions => ["type_id = 1 AND completed = 0 AND donated_amount = 0 AND created_at < :date", { :date => (4.months + 14.days).ago(date_time) }])

def self.find_expiring_very_soon(date_time = Time.now)
@@expiring_very_soon ||= find(:all, :conditions => ["type_id = 1 AND completed = 0 AND created_at < :date", { :date => (6.months - 3.days).ago(date_time) }])


def self.find_expiring_soon_with_donations
:include => :donations,
:conditions => [
"expires_soon = 0
AND donated_amount > 0", { :date => four_months_and_a_half_ago }])

def self.find_expiring_soon_without_donations
:conditions => [
"expires_soon = 0
AND donated_amount = 0", { :date => four_months_and_a_half_ago }])

def self.find_expiring_very_soon
:conditions => [
"expires_very_soon = 0
", { :date => (6.months - 3.days).ago(date_time) }])

def self.find_expiring_now
:conditions => [
"expired = 0
#{with_expiring_criterias}", { :date => 6.months.ago }])

def self.with_expiring_criterias # DRY
"AND type_id = #{ElementType::MONEY}
AND completed = 0
AND activated_at < :date" end

private_class_method :with_expiring_criterias

def self.four_months_and_a_half_ago
@@FOUR_MONTHS_AND_A_HALF_AGO ||= (6.months - 6.weeks).ago(Time.now)

private_class_method :four_months_and_a_half_ago

  • Much more lines of code (LOC), does it improve readability and understading?
  • hardcoded values replaced by objects (ElementType::MONEY), does it make easier to understand the meaning of numbers without knowing the DB model
  • duplicate SQL DRyed in a private method
Which version do you prefer?

30 April 2009

Unix recursive Find and Replace

find spec ! -regex ".*.svn.*" -type f -exec grep -l "it_should_behave_like" {} \; | xargs sed -i "" "s/it_should_behave_like/#it_should_behave_like/"

  • find spec find in ./spec folfer
  • ! -regex ".*.svn.*" excluding .svn folders
  • -type f only files
  • -exec grep -l "it_should_behave_like" {} \; extra line to grep only files which contain "it_should_behave_like"
  • | xargs sed -i "" pipe to sed editor without creating any backup file (-i)

29 April 2009

svn trick: revert a folder when it can not be deleted

If you ever have this error message when running
svn status
! C stories
> local delete, incoming edit upon update

=> Clean it with reverting the conflicted folder with:

svn revert stories

Setting up logrotate with capitate

How many Rails projects "forget" to set up a log rotation of their production logs and end up filling the hard disk with gigabytes of log ...

Lots ;-) And mine before I found out about logrotate.

Fortunately, there is one tool which help you to no to reinvent the wheel and set up a log rotation within minutes: capitate ;-)

Install it:

sudo gem install capitate
Add the following snippet to your conf/deploy.rb:

# See http://capitate.rubyforge.org
require 'capitate'
require 'capitate/recipes'

# Add this line but remove it afterinstalling 'cap rails:logrotate:install'
set :use_sudo, true
Run cap -T to see how many recipes you have now!

cap logrotated:install_conf

It should install a new /etc/logrotate.d/rails_yourwebsite.com

/home/youruser/public_html/yourwebsite.com/shared/log/production.log {
size 10M
rotate 7

That's it!

26 March 2009

Giving and Receiving

Mxxxxx has left a new comment on your post "xyz":

totally useless. If i wanted to read this i would have read the txt file that came with the download.

This is the nice comment I just received about a post in my blog.

Blogging is giving free content to the world, without expecting anything in return ...
If this person was to meet me in person, would (s)he dare telling me the same thing???

At the end of day, you should never, ever write aggressive text in sms, email, forum, twitter, blog, etc ... Most of the time, if not always, you end up regretting your acts and only create negative energy.

We live in a society which is always connected, maybe it's time to write less emails, send less texts, spend less time on the internet and behave like a nice person in the Real World. Lots of positive energy shalt be the outcome.

Peace & Love :-)

23 March 2009

Netbeans usability

The netbeans community solved my problem in 24 hours!!! It was a bug due to a problem of deserialization ... Deleting the ~/.netbeans folder solved the problem. Check out http://www.netbeans.org/issues/show_bug.cgi?id=161070

One of thing I enjoy the most in life is cooking. I distrust most of the products processed by the food industry - gm, transfat, the list is too long... - and try to cook with local, raw and organics ingredient (when available at a fair price). The kitchen utensils I use must be of very good quality: the knifes must cut without effort, the pan must not contain carcinogen material, etc... As the whole cooking experience becomes slightly stressful if I have to cook with other utensils, I tend to bring my best knifes with me on holidays ;-)

To stick with the cooking metaphor, I see the code as the ingredients, the IDE being the kitchen utensils and the working and tested software the resulting meal.
A lot of my productivity and the joy I feel crafting a beautiful software depends on my interaction with an IDE.

I have been using Netbeans since february 2007, following its long path to become a mature IDE for Ruby on Rails. Most of the time, I have used the latest build, reported some issues and it has been a fun and productive experience.

However, I am feeling a bit frustrated now, because of some recent changes in the behavior of the Output Window(CTRL+4) . I rely highly on Autospec to run my unit tests. With Netbeans 6.5, I have the code on one widow and I use an undocked Output window on the right side in order to check out the tests results and open classes in 1 click. This is very handy because Netbeans opens the guilty class in the main window, at the exact location of the guilty line of the backtrace. This makes the whole development cycle "super" productive!

Since Netbeans latest build 23rd of March 2009 (7.0?), this behavior has changed. It seems that the Output window behaves like any other window. By default, it opens in a normal tab, forcing you to constantly CTRL+TAB to switch between classes and output. If you undock it and you click on a backtrace, it will open it in the same undocked window as the Output!!!

So unless you move theses windows to the main IDE, there is no way you can compare the tests output and the class itself. As far as I am concerned, this is a serious usability issue and I'd like to discuss it with other netbeans users and netbeans IDE developers. In the following screenshot, you can see that every time I click on a backtrace, it opens the window in a tab next to the Output window ....

Please, please rollback the Output Window to its previous behavior!

A last tip about running autospec. The netbeans Autospec implementation is flawed: output is polluted by zillions of %RSPEC_SUITE_FINISHED% and the constant scroll bar at the bottom is very distracting. The solution is to run autospec with a simple "Run File" (shit +F6) of the script/autospec. This is much more productive and faster than the RSpec runner built into Netbeans and always works!

In the future, I'd love to see a feature which would allow us to split the IDE in 3 vertical windows.
If you look at Jon and Sandro on Pair Programming hashrocket video, you'll see that they have split their screen in 3: a class, the test class and autotest. Always take inspiration from the best!

10 February 2009

The RSpec Book: Never Judge A Book By Its Cover

The RSpec Book is out in beta version!

It's a long expected book for the BDD Community. The first time I mention this book was at the Paris on Rails 2007 conference. Since then, many changes happened and it seems that API and Practices are mature enough to release a book. As far as I am concerned, the biggest boost was given by Aslak with Cucumber.

Before adding more love, I'll write about 2 small caveats. It's still a bit hard to contribute to the RSpec project as code is a bit complex, I mean compares to bacon or shoulda. The other is the painful upgrading process since version 1.0: no matters what, I always end up spending 2-3 hours to fix my specs or autospec when I update the RSpec gem ...

Apart from that, RSpec and cucumber are one of the things which make me feeling at home working with Ruby (on Rails). Being able to describe the business rules and features is a big step for the software industry. How many hours lost because of misunderstanding between customers and programmers???
This book is aimed at programmers, my hope is that there will be other books following, targeting the customers (business analyst, project manager, end user). So little by little, we learn how to communicate clearly to each other and build better software ...

Never Judge A Book By Its Cover!

The second part of this post has nothing to do with technology or the quality of the book. I want to question the choice of an incandescent bulb to represent a technology as innovative as RSpec.

I have been volunteering for 2 years in an environmentalist NGO and one of the things I keep repeating is how bad for the environment are the old incandescent bulbs. I guess pragmatic programmers editors and RSpec book authors are very busy finishing the book and have other priorities ...

However, in these times of "green revolution", I hope that many RSpec users feel concerned about environmental issues and ask David and other authors to pick another image cover. It's a detail, I know but we have to replace all these electricity greedy bulbs even in the book covers!

RSpec is for alpha geek - the earlier adopters - and I don’t identify myself to a technology born in the XIX century !!!

Why not using a Compact Fluorescent bulb?

Or even more alpha geek, an LED_lamp ?

More information on http://www.earth-policy.org/Updates/2007/Update66.htm

UPDATE: International Energy Agency Press release : "Worldwide, grid-based electric lighting consumes 19% of total global electricity production" ..."It shows that were end-users to install only efficient lamps that will save money over the life cycle of the lighting service. Following these measures would save more than 16 000 Mt of CO2 emissions over the same time frame – equivalent to about 6 years of current global car emissions – and would avoid USD 2 600 billion"


I found the LED bulb image at http://www.flickr.com/photos/partybooper_rob/2324613709/sizes/l/ (Collective Commons)

04 February 2009

Install rmagick on ruby entreprise edition

I was trying to install rmagick on an ubuntu 7.04 and

"ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension."

I found the solution in google cache: install the 1.15.12 version !
sudo /opt/ruby-enterprise-1.8.6-20090113/bin/gem install rmagick -v 1.15.12

30 January 2009

RubyCamp Lyon 2009

J'ai appris l'existence de ce barcamp dans le blog de Ruby onRails - comme quoi, la lecture de RSS n'est pas que de la procrastination ;-)

Dans la série "troublantes coïncidences", j'avais déjà prévu de passer sur Lyon le WE du samedi 21 février et ce pour des raisons personnelles. Ce barcamp tombe donc bien à point! Etant donné que je suis en train de planifier mon retour en France pour le second semestre 2009 - sans doute dans la région lyonnaise - cela sera une parfaite occasion de rencontrer les rubyistes locaux.

Je compte faire un remix de mes présentations de Paris on Rails 2008 et citcon amsterdam 2008:

  • La vengeance du concombre masqué: Tests d'Acceptance utilisateur avec cucumber
  • Rouge, Vert, Refactor: Initiation au Test Driven Development avec RSpec
Par rapport à Paris, je compte faire beaucoup plus court, 15 minutes - 10-15 slides - et beaucoup plus simple. Si vous avez des attentes particulières, je vous serai reconnaissant de bien vouloir me contacter ou de laisser un commentaire.

Plus d'info sur http://barcamp.org/RubyCampLyon

27 January 2009

n-dash VS m-dash

The good thing with software engineering is that you learn a new thing every day. Computer programs depend on so many different layers, libraries, hardware that it should be no surprise that things go wrong all the time.

One of the Agile practice to fight this entropy is unit testing and especially Test Driven Development (TDD). Since 2005, I work with TDD, writing the specs (tests) before the code and this is the best design method I have used so far! No more dead code :-) Moreover, the final code looks really clean and the tests are the best up to date documentation with examples I will ever write.

I am implementing a Schedule class which encapsulate event times such as in the flavorpill.com. Following TDD and being lazy(!), I wrote the spec first so I copy pasted directly the "When" text from the event page in flavorpill to my editor:

it "should output in a pretty format such as Tuesdays–Sundays (10am–5pm)" do
@schedule.starts_at = 10.am
@schedule.ends_at = 5.pm
@schedule.pretty_format.should equal("Tuesdays–Sundays (10am–5pm)")

=>expected "Tuesdays–Sundays (10am–5pm)", got "Tuesdays-Sundays (10am-5pm)" (using .equal?)

Don't you see the difference? Me neither, and it took me at least 5 minutes to understand what was going wrong.

After increasing the size of the font, it's a bit easier to spot:

expected "Tuesdays–Sundays (10am–5pm)", got "Tuesdays-Sundays (10am-5pm)"

Olala! A colleague of mine who works as an editor introduced me to the wonderful world of n-dash and m-dash.

The hyphen is used to hyphenate compound words and between non-continuing numbers, e.g., phone numbers.

The en dash - is used to "connect continuing, or inclusive, numbers -- dates, time, or reference numbers." [Chicago Manual of Style, sec. 5.115]

The em dash is used "to denote a sudden break in thought that causes an abrupt change in sentence structure." [Chicago Manual of Style, sec. 5.106]

Morality: copy-paste is evil!

But be honest, who knows about these characters, did you learn it in english classes? As far as I am concerned, there is no key in the keyboard to type the m-dash...