Skip to content

Instantly share code, notes, and snippets.

@kn0ll
Created October 30, 2010 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kn0ll/654959 to your computer and use it in GitHub Desktop.
Save kn0ll/654959 to your computer and use it in GitHub Desktop.
small ruby server to show a random tinygrab image
require 'sinatra'
require 'open-uri'
get '/' do
tryImg
end
def tryImg
rand = ''
1.upto(4) { rand << rand(36).to_s(36) }
open('http://grab.by/%s' % rand) do |c|
if c.content_type == 'image/png'
content_type c.content_type
c.read
else
tryImg
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment