Friday, April 8, 2011

Notify When Rake Task Fails

There is an useful script to notify via email or let hoptoad know whenever a rake tasks fails with any exceptions. It is a small job to how to make it work in your application.

Post the content into your own Rakefile, change FROM_EMAIL and TO_EMAIL.

require 'pony'

EMAIL_FROM = 'from@example.com'
EMAIL_TO = 'to@example.com'

def handle_exception(exception)
$stderr.puts "#{name} aborted!"
$stderr.puts exception.message
$stderr.puts exception.backtrace.join("\n")

# Send email

subject = "Rake exception - #{exception.message}"
body = "#{exception.message}\n\n#{exception.backtrace.join("\n")}"

Pony.mail(:to => EMAIL_TO, :from => EMAIL_FROM, :subject => subject, :body => body)

OR

# Send to hoptoad

HoptoadNotifier.notify(exception)


$stderr.puts
$stderr.puts
$stderr.puts "Exception details sent to #{EMAIL_TO}"
end

module Rake
class Application

def standard_exception_handling
begin
yield
rescue Exception => e
handle_exception(e)
exit(false)
end
end

end
end

Tuesday, February 2, 2010

Rails 3 beta

Rails 3 is going to be release.The new version of Rails will incorporate Merb features such as improved performance, support for jQuery and a simpler routing API for better REST support. Inspired by Merb, Rails 3 will also incorporate an API to make plug-ins easier to add and manage and become "test framework agnostic" to support rSpec as well as traditional unit tests.

Rails 3 is not just about Merb features; a mechanism to protect against cross site scripting attacks, easier complex queries in ActiveRecord, ActiveModels to abstract functionality from ActiveRecord to help support non-SQL back ends and a new way of packaging Rails applications, will all feature in Rails 3.

Thursday, December 3, 2009

Ruby on Rails Techniques

Group Operations in a Transaction

ActiveRecord is the handy persistence engine that allows you to do many cool things with data and logic. One of the really handy things that ActiveRecord allows you to do is to group multiple inserts in a single transaction.

Instead of

my_collection.each do |q|

Quote.create({:phrase => q})

end

Use:

Quote.transaction do

my_collection.each do |q|

Quote.create({:phrase => q})

end

end

or for rolling back the whole transaction if any insert fails, use:

Quote.transaction do

my_collection.each do |q|

quote = Quote.new({:phrase => q})

quote.save!

end

end

Tuesday, August 11, 2009

Ultra-Wideband: 200x personal-area networking

A technology for rapidly transmitting data over radio in the 3.1- to 10.6-GHz range, UWB is capable of generating data transfer rates approaching 500Mbit/sec. with relatively low power consumption. By way of contrast, Bluetooth's top speed is only 2.1Mbit/sec. One of the underlying strengths of Ultra-Wideband is that it uses data-rich repeated pulses of energy in the radio spectrum to transmit data. These pulses have a fairly short range of 30 feet. In contrast to most wireless systems, which typically transmit data over a narrow band of frequencies, UWB transmissions occur over a much wider spectrum of radio frequencies.

Wednesday, August 5, 2009

Ruby on Rails for Java Technology Developers

Ruby on Rails is a framework for quickly building web applications. Rails takes advantage of many of the lessons learned over the past decade of web development. Rails uses Model/View/Controller (MVC), view templates, sessions, cookies, and many other abstractions that developers in any web framework will find familiar.But Rails improves on the past as well. With convention over configuration, you use configuration only where necessary, so simple applications do not require hundreds of lines of boilerplate XML.In this session you will learn why Rails is so powerful, and why other frameworks are racing to emulate Rails best features. Best of all, Ruby and Java technology are growing together. With JRuby, you can run your Rails apps on a Java technology-based VM, and continue to access the enormous base of useful Java libraries. You will see how easy it is to get an application started with JRuby on Rails.