Follow me on Twitter

Posted on JANUARY 14TH, 2009

I have been on Twitter for quite a while but I have just recently ramped up my use of it and in turn its usefulness.

I have not had any time to blog as my contracting is keeping me really busy right now. Any ‘free time’ that I do have is going into my side projects and incorporating a company to keep those under (more news on that as it unfolds).

So if you are interested in updates there are lots over here.

Cheers

Tags

Adding Gravatar To Your Website Or Blog (In under 30 seconds)

Posted on APRIL 16TH, 2008

Update This has all been wrapped up into a much friendlier and configurable rails plugin over on Github. gravatar_image_tag plugin

Bells and whistles are always fun, so when whipping together this blog I wanted to try my hand at adding a few. First “nice-to-have” I went after was adding Gravatar to the comments. I did not really expect to much of a challenge but I had no idea it would be this straightforward.

Extend the string class a little.


# config/initializers/string_extensions.rb
class String
  
  def md5
    Digest::MD5.hexdigest(self)
  end
  
  def uri_encode
    URI.escape(self, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
  end
  
end

Add a few constants for cleanup.


# config/initializers/constants.rb
GRAVATAR_BASE_URL = 'http://www.gravatar.com/avatar.php'
GRAVATAR_DEFAULT_IMAGE = "http://#{HOST}/images/default_gravatar.gif"
GRAVATAR_SIZE = 40

And of course add in your view helper.


# app/helpers/application_helper.rb
def gravatar_image_tag(email, html_options = {})
  image_tag gravatar_url(email), html_options
end

private
  def gravatar_url(email)
    return GRAVATAR_DEFAULT_IMAGE if email.nil?
    "#{GRAVATAR_BASE_URL}?gravatar_id=#{email.md5}&default=#{GRAVATAR_DEFAULT_IMAGE.uri_encode}&size=#{GRAVATAR_SIZE}"
  end

That is it… done! Start calling it from your views.


gravatar_image_tag comment.email

Update This has all been wrapped up into a much friendlier and configurable rails plugin over on Github. gravatar_image_tag plugin

Tags

Fight Spam With JavaScript

Posted on APRIL 15TH, 2008

I’m willing to bet that email harvesting spam crawlers don’t have any capabilities to deal with JavaScript.

As an alternative to the many readable only to a human expressions such as mdeering – at – mdeering – dot – com why not try the following.

If you are visting this site with JavaScript disabled you will see content matching the following image in the “Quick Contact” area in the footer of all this sites pages.

Contact Information With JavaScript Disabled

If you are visiting this site with JavaScript enabled you will see content matching the following image in the “Quick Contact” area in the footer of all this sites pages.

Contact Information With JavaScript Enabled

My application view template renders the following div with the id of ‘quick_contact’ on every page of this site.


<div class="footer_column">
  <h3>Quick Contact</h3>
  <div id="quick_contact">
    To avoid spam this information is only available to browsers with javascript enabled.
  </div>
</div>

When the page loads the JavaScript function ‘addQuickContactInfo’ is called to populate my contact information.


function addQuickContactInfo() {
// Do the minimum to hide my email with this replace
 var email        = 'spam@example.com'.replace(/(spam|example)/g, 'mdeering');
// Use the same technique as above to hide my phone number
 var phone_number = '555.444.3333'.replace(/555/, '780').replace(/444/, '906').replace(/3333/, '6632');
 this.addClassName('vcard');
// Clear out the static content from the div
 this.update('');
// Next 4 lines just populate the div with the information
 this.appendChild( $div( {'class': 'fn org'}, 'Michael Deering' ) );
 this.appendChild( $div( {'class': 'email'}, $a( {href: 'mailto:' + email}, email ) ) );
 this.appendChild( $div( {'class': 'url'}, $a( {href: 'http://mdeering.com'}, 'http://mdeering.com' ) ) );
 this.appendChild( $div( {'class': 'tel'}, $span( {'class': 'type'}, 'Cell' ), ': ', $span( {'class': 'value'}, phone_number ) ) );
}

Event.addBehavior({
  '#quick_contact':               addQuickContactInfo,
});

I’m using the LowPro and Prototype JavaScript libraries here obviously.

What do you think, did I just send my spam filter into overdrive, or is this a viable alternative to cryptic contact information?

Tags

Available For Hire

Contact Me

Michael Deering http://mdeeirng.com Cell: 780.906.6632

Testimonials

" Michael understands what is means in business to abide by timelines and budget. His great work ethic and agile perspective allow him to motivate and manage himself, and his team, seemingly without effort. He has a great attitude and enjoys sinking his teeth into projects that leverage and push his skill set to the limit. "
Erik Lagerway / Co-Founder & CEO / Gaboogie

" Michael's attention to detail and intense interest in continuously improving the software development process made working with him a very enjoyable experience. Michael was a great manager to work with during my time at Lypp. In addition he was an excellent software developer that set a high standard for others to meet. I would definitely work with Michael again in the future. "
Dan Kubb / Ruby Hero

" Mike is a very sharp technologist with an eye for simplicity. He is able to break down complex concepts into elegant solutions and communicate them effectively with a remote team. Mike's leadership is apparent by his ability to manage scope, keep deadlines and translate evolving business requirements into flexible technical solutions. "
Jason Cartwright / CTO / Cogwise Software

Post Categories