Skip to content

Instantly share code, notes, and snippets.

View mdepolli's full-sized avatar

Marcelo De Polli mdepolli

View GitHub Profile
@mdepolli
mdepolli / Gemfile
Created September 13, 2012 16:17
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@mdepolli
mdepolli / gist:3674398
Created September 8, 2012 12:27
Titleize equivalent for pt-BR
def br_titleize(word)
humanize(underscore(word)).gsub(/(?!(?<= )(de|da|do|das|dos|d'|e|a|o)\b)(\b[a-z\u00E0-\u00FC])/) { |s| s.mb_chars.capitalize.to_s }
end
@mdepolli
mdepolli / application_helper.rb
Last active October 10, 2015 08:27
Bootstrap 2.1-compatible flash messages helper
def flash_message
types = { :notice => 'info', :success => 'success', :error => 'error', :alert => 'error' }
flash.inject("") do |sum, message|
content_tag :div, :class => "alert alert-#{types[message[0]]}" do
button_tag('&#215;'.html_safe, :type => 'button', :class => 'close', :'data-dismiss' => 'alert', :name => nil) +
message[1]
end
end
end