This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function simpleFormat(str) { | |
return '<p>' + | |
str.replace(/\r\n?/, "\n") | |
.replace(/\n\n+/g, '</p>\n\n<p>') | |
.replace(/([^\n]\n)(?=[^\n])/g, '$1<br/>') + | |
'</p>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/views/photos/_photo.html.haml | |
.photo[photo] | |
= image_tag photo.image_url(:thumb) if photo.image? | |
= link_to "Delete", property_photo_path(@property, photo), :method => :delete, :confirm => "Are you sure?", :remote => :true | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rspec' | |
class Fixnum | |
ROMANS = { M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50, XL: 40, X: 10, IX: 9, V: 5, IV: 4, I: 1 } | |
def to_roman | |
ROMANS.detect do |roman, arabic| | |
diff = self - arabic | |
return "#{roman}#{diff.to_roman}" if diff >= 0 | |
end |