Mensa Hash Horror Event

Programming, Random Thought, Web Development 1 Comment

Over at Jeff Atwood’s blog on the Coding Horror site, there is quick mention of a foible at Mensa’s web site. The problem he alludes to, and which many comments point out and discuss at great length, is the lack of security used with the site’s login credentials.

What I find quite humorous is that the Mensa site’s ‘forgotten password’ page appears to be located within the calendar section of the site as an event. Mensa membership is supposedly based upon processing power and not memory, so why make a calendar event out of a member’s lack of memory? :-P

Happy Albert ‘Cerebronaut’ Hawking Brain Fart Day!!!

SyntaxHighlighter

Education, Programming, Web Development No Comments

I finally got a syntax highlighter installed. I figure that since I’m taking the free Ruby course at RubyLearning.org, I should make my code look nice (and be more usable) when I decide to put some here on my blog. Just to get things rolling, here is a bit of code from one of the exercises I’ve done during the first few weeks of the course.


class Dog
  def initialize(name)
    @name = name.capitalize
    @what = self.class.to_s.downcase
    puts "Hi! I'm #{@name}, your new #{@what}!"
  end

  def teach(new_trick)
    @tricks = Array.new unless @tricks
    @tricks += [new_trick]
    puts "#{@name} now knows how to #{new_trick}!"
  end

  def show_tricks
    list_of_tricks = [@tricks[0]]
    1.upto(@tricks.length-1) do |modify|
      list_of_tricks += [" and #{@tricks[modify]}"]
    end
    @name + ' knows how to ' + list_of_tricks.to_s
  end

  def bark
  end

  def eat
  end

  def chase_cat
  end

  def to_s
    @name + " (your #{@what})"
  end

  def capable_of?(capability)
    self.respond_to?(capability) ?
    puts("I can #{capability} or my name's not #{@name}!") :
    @tricks.include?(capability) ?
    puts("I have recently been taught to #{capability}!") :
    puts("This is something I have not heard of before... \
    #{capability} you said?")
  end

  def method_missing(method, *more_arguments)
    "#{@name} cocks it's head to the side as if to say \n\t\
    \"I don't understand what #{method} means.\""
  end
end

# a few examples of usage:
rex = Dog.new 'rex'
max = Dog.new 'Max'
rex.teach 'jump through hoops'
ObjectSpace.each_object(Dog) {|dog| dog.teach('chase cars') }
puts rex.show_tricks
rex.capable_of? 'bark'
rex.capable_of? 'chase cars'
rex.capable_of? 'fetch'
puts "#{max} is feeling a bit left out..."

Sadly, I had misinterpreted the challenge guidelines. The instructor wanted the learned tricks to be methods and not properties. Anyhoot, this post is just so I can see what the highlighter will do on my blog. :-P