Created
September 9, 2009 15:41
-
-
Save hitode909/183830 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
# tiny counter bot | |
$count = 0 | |
get '/' do | |
$count+=1 | |
puts $count | |
$count.to_s | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'timeout' | |
require 'readline' | |
$limit = ARGV.first.to_i || 2 | |
get '/' do | |
input | |
end | |
def input | |
timeout($limit) do | |
p [Time.now, Time.now + $limit] | |
Readline.readline("> ", true) | |
end | |
rescue Timeout::Error | |
puts "timeout" | |
'' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment