Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Matt Powell

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Obfuscate email addresses in TextMate

// Textmate / e command for obfuscating email addresses

   1  
   2  #!/usr/bin/env ruby
   3  
   4  email = STDIN.read
   5  url_email = email.gsub(/./) { |c| '%' + c.unpack('H2' * c.size).join('%').upcase }
   6  html_email = url_email[1..-1].split(/%/).collect { |c| sprintf("&#%03d;", c.to_i(16)) }.join
   7  
   8  print "<a href=\"mailto:#{url_email}\">#{html_email}</a>"
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS