Rails 3 validation awesomeness

On January 27, 2011, in Ruby on Rails, by Mike

Here is a good resource on new validations found in Rails 3

RAILS 3 Validation from lindsaar.net

 

Formatting date and time in Rails

On January 27, 2011, in IT Related, Ruby on Rails, by admin

Time.now()
=> Wed Dec 12 15:48:59 +0530 2007

Time.now().strftime(“%d/%m/%y %H:%M”)
=> “12/12/07 15:50″

Here’s the (shortened) table for strftime.

%a  weekday name.
%A  weekday name (full).
%b  month name.
%B  month name (full).
%c  date and time (locale)
%d  day of month [01,31].
%H  hour [00,23].
%I  hour [01,12].
%j  day of year [001,366].
%m  month [01,12].
%M  minute [00,59].
%p  AM or PM
%S  Second [00,61]
%U  week of year (Sunday)[00,53].
w  weekday [0(Sunday),6].
W  week of year (Monday)[00,53].
x  date (locale).
%X  time (locale).
%y  year [00,99].
%Y  year [2000].
%Z  timezone name.

Souce: amcubes.com

 

I got an error when installing Ruby Enterprise :

Error running './installer -a /home/ubuntu/development/rvm/rubies/ree-1.8.7-2010.01 --dont-install-useful-gems ', please check /home/ubuntu/development/rvm/log/ree-1.8.7-2010.01/install*.log
There has been an error while trying to run the ree installer. Halting the installation.
/home/ubuntu/development/rvm/scripts/selector: line 363: /home/ubuntu/development/rvm/rubies/ree-1.8.7-2010.01/bin/ruby: No such file or directory

My Solution:

When installing Ruby Enterprise Edition is not successful, you can try issuing these commands:
sudo apt-get install ruby ruby-dev curl libcurl4-openssl-dev git-core build-essential zlib1g-dev libssl-dev libreadline5-dev imagemagick libmagickwand-dev libmysqlclient-dev

the above command will install necessary libraries and tools that the ruby enterprise will require.

then, you can try re installing the Ruby Enterprise installer

 

I have been having problem installing some gems after i use RVM. One problem I encounter is installing the gem mysql. I have MAMP installed already. To install mysql gem on this setup, issue this command:

$ sudo gem install mysql — –with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

and this works for me.

Tagged with:  

Run-For.it

On October 16, 2010, in Personal, by admin

This will be a future home for all runners and for those who plans to join the running hobby.

Run-For.it is a social networking website where runners can connect with other runners and share thoughts and experiences. Run-For.it is also for Run Organizers where in they can manage the event  and the runners who join.

There will be many features that we will be adding soon.  Right now we are still refining the site but  you can subscribe for now so we can notify you when we launch our site. http://www.run-for.it.

You can send us your suggestions, comments, criticisms to me. michael@cebudirectories.com :)

Hell yeah.. Its about time!

 

Net::HTTP – SSL/HTTPS request

On August 16, 2010, in IT Related, Ruby on Rails, by admin
require "net/https"
require "uri"

uri = URI.parse("https://secure.com/yourfile")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
response.body
That's it! you can now read the file and parse.
Thanks to RubyInside.com
 

Does this error message look familar when you script/console?


$> script/console
Loading production environment (Rails 2.1.0)
/usr/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
from /usr/lib/ruby/1.8/irb/completion.rb:10
from /usr/lib/ruby/1.8/irb/init.rb:252:in `require'
from /usr/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
from /usr/lib/ruby/1.8/irb/init.rb:250:in `each'
from /usr/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
from /usr/lib/ruby/1.8/irb/init.rb:21:in `setup'
from /usr/lib/ruby/1.8/irb.rb:54:in `start'
from /usr/bin/irb:13

This happens when readline is somehow different than your current version of ruby or corrupted. The quick fix is to recompile readline. To do it in CentOS with yum:


$> yum install readline-devel -y
$> cd /root/src/ruby-1.8.6-p114/ext/readline/
$> ruby extconf.rb
$> make
$> sudo make install

Now you should have script/console working.

Source: http://web.elctech.com/2009/01/09/fixing-ruby-no-such-file-to-load-readline-error-in-centos/

 

how to enable flash audio in ubuntu

On April 19, 2010, in IT Related, by admin

source : http://ubuntuforums.org/showthread.php?t=789578

1. Backup (and then delete) your previous configuration files:
Code:

$ mkdir ~/pulse-backup && cp -r ~/.pulse ~/.asound* /etc/asound.conf /etc/pulse -t ~/pulse-backup/
$ rm -r ~/.pulse ~/.asound*
$ sudo rm /etc/asound.conf

2. Ensure you have the necessary PulseAudio libraries and configuration utilities installed:
Code:

 $ sudo apt-get install libasound2-plugins padevchooser libsdl1.2debian-pulseaudio

3. Ensure the evil “libflashsupport” library is not installed:
Code:

$ sudo apt-get remove --purge libflashsupport flashplugin-nonfree-extrasound

And restart Firefox or Chromium  ^_^

I have tried this with my Ubuntu Karmic

Tagged with:  

export ARCHFLAGS=”-arch i386 -arch x86_64″ ;sudo gem install –no-rdoc –no-ri -v=2.7 mysql — –with-mysql-dir=/Applications/MAMP/Library/bin/mysql –with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

 

Install NetBeans on Ubuntu 8.10

On March 16, 2010, in IT Related, Ruby on Rails, by admin
  1. Setup the Source Repository
  2. To install NetBeans via the Ubuntu Package Manager, ensure that the correct repository is listed in the source listing file. NetBeans is found inf the universe repository and Java is found in the multiverse repository.

    Code:

    sudo gedit /etc/apt/sources.list

    Ensure that the following sources are added to the configuration file:

    After the configuration file is updated, the package repository needs to updated with the following command:

    Code:

    sudo apt-get update
  3. Install Required Software
  4. To install Java version 6, the following command needs to be executed:

    Code:

    sudo apt-get install sun-java6-jdk sun-java6-plugin
  5. Install Netbeans IDE
  6. To install NetBeans, the following command needs to be executed. The package manager does not necessarily install the latest version of NetBeans. The package manager will install the latest NetBeans that is supported by Ubuntu.

    Code:

    sudo apt-get install netbeans

    Source : http://www.javadesign.info/SystemsHardware/OS/Ubuntu/install-netbeans-on-ubuntu

    sudo apt-get install netbeans