Tuesday, February 10, 2009

Format Currency in Ruby on Rails

I was looking for a way to display currency data coming from the database as a long. I found out that Ruby on Rails has a buil-in Module Helper method called
ActionView::Helpers::NumberHelper:number_to_currency which allows one to format a number according to some options:


  • :precision - Sets the level of precision (defaults to 2).

  • :unit - Sets the denomination of the currency (defaults to "$").

  • :separator - Sets the separator between the units (defaults to ".").

  • :delimiter - Sets the thousands delimiter (defaults to ",").

  • :format - Sets the format of the output string (defaults to "%u%n").


Using this method, we could write something like this:


<%=h number_to_currency @transaction.value, :unit => 'R$', :separator => ",", :delimiter => "." %>

This would work fine, but in this solution we are breaking the DRY (Don't Repeat Yourself) rule, because I would need to set the same parameters in every place I was displaying currency values.

A better solution would be to have a helper method which I could use in every piece of code where I need a currency. So I came up with the solution below, which consists in writing my own helper method in app/helpers/application_helper.rb:

module ApplicationHelper

number_to_currency(number,:delimiter => ".", :unit => "R$ ",:separator => ",")
end
end

Now, in my templates I should write something like this:

<%=h real_currency @transaction.value %>


Ain't that easier?


Find this article also on Define Null.

Tuesday, January 20, 2009

Top 25 most dangerous programming errors

A colleague at work just sent me this interesting list of the most dangerous programming errors.
I think it a very thorough list considering the type of error the average programmer does and normally does not have the time (or interest, or knowledge, or whatever... :)) to care on a daily basis.

The comments on what each error is and how to avoid are quite useful!

Enjoy it!

Thursday, January 15, 2009

Scrum - info and links for starters

Being a Certified Scrum Master and working with Scrum for over a year, people quite often come to me asking for directions about information on Scrum.
I created this post to keep this information handy for me next time I am asked for this and to share it with the community.

Is, in their own words, "nonprofit organization committed to delivering articles, resources, courses, and events that will help Scrum users be successful". It was founded by Ken Schwaber, Mike Cohn and Esther Derby some of the founders of Scrum itself. There is one specific article which points the user to important fundamentals of Scrum like sprints and user stories. The Glossary of Terms of Scrum is very useful tool for anyone browsing through Scum information through the web or books.

Is "the home of the Certified ScrumMasters organization, offering training, gatherings, information, and materials regarding Scrum, including frequent articles". Amongst their resources you can find this brief overview of Scrum and

  • Videos
This video (with legend) from Ken Schwaber is also a great introductory resource. It is a speech given by him at Google.
  • Books
In general, all the books by Ken Schwaber regarding Scrum are great (if not the best) references for understanding and starting the use of Scrum in your company. I would begin with "Agile Project Management With Scrum" and then, after having the basics in your mind read "The Enterprise and Scrum".

Have fun!

Tuesday, January 13, 2009

Take Care of your passwords

Now that even Barack Obama had his twitter password hacked by some kids using a brute force attack using a simple dictionary, makes a lot of sense to spread the word: take good care of your passwords.

There is an interesting site called passwordmeter.com with some functions that check how strong is a password. Try using it before adopting a new password.

The site whatsmypass just published a list with the worst 500 passwords ever. Do you use any of those? :)

Here are the top 10:

  1. 123456
  2. password
  3. 12345678
  4. 1234
  5. pussy
  6. 12345
  7. dragon
  8. qwerty
  9. 696969
  10. mustang
Now, what the hell is "dragon" doing amongst the top 10? Are we really that geek?

By the way, this list was compiled in a book by Mark Burnett called "Top 500 Worst Passwords Of All Time".

Saturday, January 10, 2009

Change Netbeans 6.5 IDE language

I downloaded and installed today the Netbeans 6.5 and for my surprise its IDE was in Portuguese. I prefer using the IDE in English, so I tried to change it using the way I remembered from previous versions, i.e. at the Tools menu. As it happens, it is not possible to change the language of the IDE through the interface, because it is based on the locale of your machine.

After some experimenting and searching I found out that it is necessary to pass the locale to the IDE and force it to use something different from your system. So, go to the shortcut which starts your IDE (yep, using Windows here) and pass "--locale en:US" in the command line.

It should look like something like this:


"C:\Program Files\NetBeans 6.5\bin\netbeans.exe" --locale en:US

Tuesday, November 4, 2008

Speaker at PMI Congress in Brazil

Hello All,

I will be presenting a case study on my experience on going from formal methodologies of project management into scrum. The conference will be in Recife - PE and is held by the PMI Chapter of Pernambuco.

Cheers,
Dani

Monday, July 14, 2008

Google Releases Web Security Assessment Tool

Google has just released an open-source web security assessment tool called ratproxy.

"Ratproxy is a semi-automated, largely passive web application security audit tool."

According to the documentation of the tool, ratproxy offers several important advantages over more traditional methods and tools like WebScarab, Paros, Burp, ProxMon and Pantera.


  • No risk of disruptions.

  • Low effort, high yield.

  • Preserved control flow of human interaction.

  • WYSIWYG data on script behavior.

  • Easy process integration.



Best way to decide, might be biving it a try!