Skip to content

Instantly share code, notes, and snippets.

@unixcharles
unixcharles / wtf.rb
Created March 11, 2014 21:36 — forked from byroot/wtf.rb
class Foo
def self.define_attribute(name)
class_eval %{
def #{name}(*args)
attribute(#{name.inspect}, *args)
end
}
end
@unixcharles
unixcharles / creditcard.coffee
Created May 11, 2012 13:41 — forked from masylum/creditcard.coffee
Credit Card number validation in Coffee Script
# Ported from https://github.com/jzaefferer/jquery-validation/blob/master/jquery.validate.js
creditcard = (value)->
# accept only spaces, digits and dashes
return unless /[^0-9 \-]+/.test(value)
nCheck = nDigit = 0
bEven = false
checkDigit = (n) ->