Skip to content

Instantly share code, notes, and snippets.

@jordanbrock
jordanbrock / span_delay.rb
Created August 4, 2012 04:13 — forked from madpilot/span_delay.rb
A Metal app that looks for a timestamp on a form field, and makes sure it happened at least two seconds ago...
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class SpamDelay
def self.call(env)
@request = Rack::Request.new(env)
if env["PATH_INFO"] =~ /^\/contact/
if env['REQUEST_METHOD'] == 'POST'
if @request.params['t'] && @request.params['t'].to_i < Time.now.gmtime.to_i - 2