Skip to content

Instantly share code, notes, and snippets.

View lawitschka's full-sized avatar

Moritz Lawitschka lawitschka

View GitHub Profile
@lawitschka
lawitschka / about.html.erb
Created September 23, 2013 07:47
Rendering sections of ERb templates in Markdown with Rails
<%= markdown do %>
# About
a paragraph....
* one
* two
<% end %>
@lawitschka
lawitschka / image.rb
Created January 13, 2011 06:33
A processor for Paperclip performing standard thumbnailing tasks and adds a logo stamp at specified position to the image
class Image < ActiveRecord::Base
has_attached_file :image, :styles => { :small => ['60x60#', :jpg],
:thumb => ['150x150#', :jpg],
:normal => {
:processors => [:logostamp],
:geometry => '660x660',
:format => :jpg,
:logostamp_geometry => "+5+5"
}
@lawitschka
lawitschka / photo.rb
Created November 30, 2010 11:20
Automatically retrieving and caching image sizes of processed images in Paperclip. Dependencies: * typed_serialize (http://github.com/jqr/typed_serialize) If you do not want to use typed_serialize, make sure to initialize an empty Hash in cache_ima
class Photo < ActiveRecord::Base
has_attached_file :image, :styles => { :thumb => ['150x150#', :png],
:normal => ['660x660', :png] },
:default_style => :normal
typed_serialize :sizes, Hash
before_save :cache_image_sizes
# Get size of this photo for specified style
#