Skip to content

Instantly share code, notes, and snippets.

@shifi
shifi / benchmark
Created January 25, 2013 16:11
unix timestamp vs rfc3339 first test: 1 000 000 samples second test: 10 000 000 samples
shifi@ShifiLinux ~/Desktop $ ruby test.rb
user system total real
unix_timestamp 2.970000 0.000000 2.970000 ( 2.967849)
rfc3339_format 8.300000 1.120000 9.420000 ( 9.420792)
shifi@ShifiLinux ~/Desktop $ ruby test.rb
user system total real
unix_timestamp 30.000000 0.020000 30.020000 ( 30.059516)
rfc3339_format 83.690000 11.380000 95.070000 ( 95.122119)
@shifi
shifi / rescue_from.rb
Created January 7, 2013 14:59
use rescue_from in ApplicationController and manually send exceptions to Exceptional
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from Exception, with: :render_status
def render_status(exception)
Exceptional::Catcher.handle_with_controller(exception, self, request)
render :template => "your_custom_template"
end