Skip to content

Instantly share code, notes, and snippets.

@agis
agis / Linus.md
Created May 18, 2014 18:48 — forked from weakish/Linus.md

On Mon, Jul 15, 2013 at 1:41 PM, Sarah Sharp [email protected] wrote:

Oh, FFS, I just called out on private email for "playing the victim card". I will repeat: this is not just about me, or other minorities. I should not have to ask for professional behavior on the mailing lists. Professional behavior should be the default.

Bullshit.

@agis
agis / dimensions_validator.rb
Created September 12, 2012 13:42
Paperclip image dimension validator for Rails
# #attribute is a private method so we can't call it directly, that's why we use #send.
class DimensionsValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if record.send("#{attribute}?".to_sym)
dimensions = Paperclip::Geometry.from_file(value.queued_for_write[:original].path)
width = options[:width]
height = options[:height]
record.errors[attribute] << "To πλάτος πρέπει να είναι #{width}px" unless dimensions.width == width