Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am intelekshual on github.
  • I am intelekshual (https://keybase.io/intelekshual) on keybase.
  • I have a public key ASAGnc0x6itbdq_FmpLPXKQmJD7-8skP3fhcnwx9wYqsTQo

To claim this, I am signing this object:

@intelekshual
intelekshual / get-elements-by-attribute.js
Created November 4, 2011 01:39
getElementsByAttribute
function getElementsByAttribute(tag, name, value) {
var elements = (tag == "*" && document.all) ? document.all : document.getElementsByTagName(tag),
matches = [],
re = (typeof name !== "undefined") ? new RegExp("(^|\\s)" + value + "(\\s|$)", "i") : null,
current,
attribute;
for (var i = 0; i < elements.length; i++) {
current = elements[i];
attribute = current.getAttribute && current.getAttribute(name);
@intelekshual
intelekshual / expiration_date_validator.rb
Created April 7, 2011 21:14
credit card expiration date validator
class ExpirationDateValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
expiration_date, today = value, Date.today
if today.year > expiration_date.year || today.month > expiration_date.month
object.errors[attribute] << (options[:message] || "is not valid")
end
end
end