Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created April 1, 2010 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jhsu/351886 to your computer and use it in GitHub Desktop.
Save jhsu/351886 to your computer and use it in GitHub Desktop.
# Final Countdown
# config.middleware.use Roll
class Roll
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
ip = request.ip
if roll?
return [302, {'Location' => 'http://www.youtube.com/v/tt_ro2aerQg&autoplay=1&iv_load_policy=3&start=12'}, ["Final Countdown!"]]
else
@app.call(env)
end
end
private
def roll?
(rand(10) == 4)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment