Skip to content

Instantly share code, notes, and snippets.

@kikito
kikito / simpleFormat.js
Last active December 16, 2015 03:39 — forked from kares/simpleFormat.js
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>';
}
@kikito
kikito / _photo.html.haml
Created April 10, 2012 13:43 — forked from assimovt/_photo.html.haml
Carrierwave uploader sample
# 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
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