Skip to content

Instantly share code, notes, and snippets.

@wayneeseguin
Forked from jhsu/roll.rb
Created April 1, 2010 14:51
Show Gist options
  • Save wayneeseguin/351888 to your computer and use it in GitHub Desktop.
Save wayneeseguin/351888 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
@lenary
Copy link

lenary commented Apr 7, 2010

what is line 9 and 10 for? they don't seem used at all...

@wayneeseguin
Copy link
Author

Line 9 is to get the request object in order to retrieve the ip on line 10, we were originally doing the rick-roll based on IP.

@lenary
Copy link

lenary commented Apr 7, 2010

That's not my point. They're not used in that... Though it's easy to see how they could be.

@wayneeseguin
Copy link
Author

Yes, it's simply 'artifact' and/or a launching point for others to do some very crafty things :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment