Wednesday, April 25, 2012

Dygraph fails on IE 8

Hello Guys,
      Just discover the problem while loading dygraph on IE 8. There are possible scenarios for dygraph failure.

case 1. instanceof is not support
           replace instanceof with Object.prototype.toString.call()
           Line 500 of dygraph-utils.js replace
              typeof Node === "object" ? o instanceof Node :
           with
              typeof Node === "object" ? Object.prototype.toString.call(o) === Node :

case 2. canvas can't load

<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
<!--[if IE]><script src="excanvas.js"></script><![endif]-->
<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="http://mycheckpoint.googlecode.com/svn-history/r95/trunk/dygraphs/excanvas.min.js"></script><![endif]-->


Hope above article will help you.

Thursday, April 19, 2012

Configure mailer with ruby

Hello Rubies,
    As we have to send the mail from rails application for that it requires to set the mailer configuration with rails.

First you have to install the package called 'sendmail'
sudo apt-get install sendmail

Now in environment.rb file of rails application set below code:

ActionMailer::Base.delivery_method = :sendmail

config.action_mailer.smtp_settings = {
  :address => "smtp.gmail.com",
  :port => 587,
  :domain => 'test.com',
  :authentication => :plain,
  :user_name => 'XYZ@gmail.com',
  :password => 'PWD' 
}

Hope this post will help you.

Tuesday, April 17, 2012

Number of days between two dates

Hello Rubies,
    Get the days between two dates using below method of ruby date class.

Lets consider we have date range like
date1 = Date.today.to_date
date2 = 1.year.ago.to_date
no_of_days = date1.mjd - date2.mjd

Hope this simple method of ruby date class will help you out to find days between to dates.

Friday, April 6, 2012

Combination of array element

Hello Guys,
    Want the combination of array elements using ruby? than use the below custom method.

def arr_combine(arr_1, arr_2)
    return arr_1 if arr_2.empty?
    arr_3 = []
    arr_1.each do |e1|
      arr_2.each do |e2|
        arr_3 << [e1, e2].flatten
      end
    end
    return arr_3
  end

eg. we have array like arr = [[1,2], [3,4,5]]
we expect the result as [[1,3],[1,4],[1,5],[2,3],[2,4],[2,5]] than simply invoke the above method by passing each element of given array.
arr_combine(arr[0], arr[1]) gives you required outcome.

Hope this post will help you out.