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:

http://img.skitch.com/20090817-trbwuudkf34umdstpdpsdupkbg.jpg

telephone number of *99#
Access Point Name: internet.eplus.de
IP-Adresse: dynamic
Primary DNS: 212.23.97.2
Secondary DNS: 212.23.97.3
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

http://img.skitch.com/20090811-gswfp5bqm87pkwd76usumrd2et.jpg

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

Before:



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) }])
end

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) }])
end

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) }])
end

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) }])
end



After:



def self.find_expiring_soon_with_donations
find(:all,
:include => :donations,
:conditions => [
"expires_soon = 0
#{with_expiring_criterias}
AND donated_amount > 0", { :date => four_months_and_a_half_ago }])
end

def self.find_expiring_soon_without_donations
find(:all,
:conditions => [
"expires_soon = 0
#{with_expiring_criterias}
AND donated_amount = 0", { :date => four_months_and_a_half_ago }])
end

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

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

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)
end

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/"

Explanation:
  • 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)
  • "s/ENTER OLD STRING OR TEXT TO REPLACE/ENTER REPLACEMENT STRING OR TEXT/"

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!

Run
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
daily
missingok
notifempty
copytruncate
}


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

UPDATE:
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"

http://www.thedailygreen.com/green-homes/eco-friendly/congress-incandescent-light-bulbs-ban-461217

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 !
Link
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.from_tuesday.to_sunday
@schedule.pretty_format.should equal("Tuesdays–Sundays (10am–5pm)")
end

=>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...

03 December 2008

Paris on Rails 2008

Paris on Rails 2008 was my 3rd conference this year, after XP Days France and citcon europe in Amsterdam . I talked about User Acceptance Testing with cucumber at webrat and selenium. Apologize to my non-french speaking readers, I will write the rest of this post in french.

Je suis de retour de Paris on Rails 2008! Richard et Laurent de nuxos ont vraiment assuré l'organisation de la conf: merci messieurs, ce fut très pro!
Ce que je retiendrais, en vrac:

  • Russ Olsen, en direct skype des US s'est levé à 5h du mat pour philosopher sur les langages de programmation. Son speech était comme du miel, c'est définitivement un"story teller": impressionant!
  • Philippe Hanrigou nous a servi sur un plateau une présentation très intéressante sur les Tests d'acceptance web à forte valeur ajoutée. Son utilisation de vidéos et de photos pour illustrer son propos m'a paru une excellente idée. Sur le plan technique, j'ai retenu 2-3 patterns que je vais implémenter ASAP
  • DHH est cool mais finalement, je ne sais pas si il apporte autre chose qu'un "icing on the cake" à une conférence plutot dense.
  • Les autres présentations étaient également enrichissantes, sauf peut-être liquid dont je n'ai pas compris la valeur ajoutée
  • Par rapport aux autres conf, le temps pour "socializer" était encore 1 fois trop limité. Il nous manque un apéro, un petit déjeuner, un goûter d'1 heure pour que l'on puisse échanger des cartes de visites et débattre. C'était un peu la course pour la pause déjeuner ... Quel contraste avec XP Days ou citcon où j'ai eu le temps de tisser de nombreux liens d'amitié lors de soirées d'anthologie et quelque peu éthyliques!
  • une autre suggestion afin de motiver la communauté: faire un "call for participants" avec un site web 2.0 qui permet de voter pour les propositions. La conférence espagnole est un exemple à suivre.
Quant à ma présentation, ce fut quelque peu épique car je me suis trompé de fichier et j'ai découvert en live une version beta ! J'avoue avoir pas mal bosser pour préparer la conf et voir tous ces slides mal foutues alors que j'avais passé une partie du dimanche à les fignoler m'a filé un coup (aïe!) . L'année prochaine, j'aurais un script pour automatiser le backup sur memory stick et je vais lire les bouquins américains que Phillippe m'a conseillé pour les mettre en pratique.
Link
Pour ceux que ça intéresse, voici la denière version de ma présentation, avec quelque photos censurées ;-)


Vos questions sont les bienvenues, sachez que je compte démarrer un projet sur github avec des exemples de features pour selenium et de specs pour RSpec.
Malheureusement, je n'ai pas pu me rendre à la Rails Party organisé par Jean-François Trân et rubyfrance.org. Mais le programme avait l'air prometteur et j'avoue que je suis très fan de ces rencontres informelles. Si l'année prochaine, ils la refont et previennent un peu plus en avance, je me ferai tout mon possible pour être présent!

Pour conclure ce long post, cette conférence m'a conforté dans ma décision de tenter ma chance de l'autre côté de l'Atlantique afin d'aquérir de nouvelles compétences. Il me reste tellement de choses à apprendre avant de devenir peut-être un jour un "master" en Rails (From Journeyman to Master) !

Donc, si tout va bien, je devrai être à San Francisco à partir de mars 2009. Si vous avez des contacts ou connaissez une start up on Rails, merci de le faire savoir ...

19 November 2008

Ubuntu hardy: Fan got crazy because of a bug in NetworkManager

Found the soluton in the ubuntu forum:
http://ubuntuforums.org/showthread.php?p=4559250#post4559250

Copy-paste from the forum:

Last update:
If you update hal to last version (0.5.11~rc2-1ubuntu2) you shouldn't have this issue anymore, and thus you could update network-manager again.

To check your installed version:
Code:

apt-cache madison hal

Quote:
hal (0.5.11~rc2-1ubuntu2) hardy; urgency=low
* debian/rules: build using --with-deprecated-keys, since we don't want to
break packages that were assuming this worked right up through beta.
LP: #204768.

Old thread follows:
'''''''''''''''''''''''''''''''''''''''

I've read some posts here regarding wireless issues since last update.

I had issues too, and noticed that NetworkManager was eating 100% CPU and avoiding wireless to work.

So this is what I did:
* Connect to the internet in other machine and download the previous version of network-manager:
https://launchpad.net/ubuntu/hardy/i...0.6.6-0ubuntu1
or directly:http://launchpadlibrarian.net/124982...untu1_i386.deb

* Downgrade network-manager with:
Code:

sudo dpkg -i network-manager-gnome_0.6.6-0ubuntu1_i386.deb

It will automaticly stop and restart NetworkAdmin.
After that just configure again your connection.

EDIT:Bug reports follow (as some users reported):
#204931 - NetworkManager 100% cpu usage on WiFi
https://bugs.launchpad.net/ubuntu/+bug/178530
https://bugs.launchpad.net/ubuntu/+s...er/+bug/204868

EDIT2: If you want to keep aptitude from installing the broken package:
Code:

sudo aptitude hold network-manager

When you want to release it again:
Code:

sudo aptitude unhold network-manager

To check its version after an update:
Code:

apt-cache madison network-manager

17 November 2008

Invalid Google Maps API key

Today, it took me 1 hour to find the reason why my google map was not showing in production env whereas everything was fine in development env. Needless to say I have a "view" spec + a selenium acceptance test which pass.

Google Maps API has only one error message for this kind of problem: "The Google Maps API key used on this web site was registered for a different web site. You can generate a new key for this web site at http://code.google.com/apis/maps/. "

Therefore, I started looking at the wrong place and changed the key set up for the "production" environment in the RAILS_ROOT + '/config/gmaps_api_key.yml many times without any success ...

Finally, I ended up looking at the source of the page and it appeared that the key parameter was empty!

  <script src="http://maps.google.com/maps?file=api&v=2.x&key=&hl=" type="text/javascript">
View Jean-Michel Garnier"s profile on LinkedIn
        
  • Services
  • Contact
  • Recommend Me

    Speaker at:
    Amsterdam 2008
    2008
    2007 & 2008

    Tags

    Powered By Blogger