The Passionate Craftsman

Ruby, PHP, MySql, Software engineering and more.

Wednesday, 16 November 2011

How to become successful

This is a quite inspiring speech. Reaching a target or becoming successful takes time and pain. Rewards are difficult to obtain, but when you get it... it is awesome:


Sunday, 13 November 2011

Create a Rails 3 project with "activerecord", "capybara", "devise", "git", "haml", "jquery", "rspec", "sass", "settingslogic"

You can run this commend:

rails new APP_NAME -m -J -T

I have created the template using

Labels: ,

Unix: change password one line

Labels: , ,

How to change the user password without re-typing the passowrd

You can use the following script to change the user password as root without having to re-type the password:

I found this script helpful when called via ssh.

Labels: , , ,

Friday, 11 November 2011

Catch all exceptions in your Ruby program

Just put your code between begin and rescue statements and print the error. An example:

ree-1.8.7-head :010 > begin
ree-1.8.7-head :011 >
ree-1.8.7-head :012?> rescue Exception => msg
ree-1.8.7-head :013?> puts "Something went wrong ("+msg+")"
ree-1.8.7-head :014?> end
Something went wrong (uninitialized constant Testing)
=> nil

You can boot your application between begin and rescue and you will be able to print the error, perform an action, send an email in the rescue begin section:

rescue Exception => msg
puts "Something went wrong ("+msg+")"