Skip to content

Instantly share code, notes, and snippets.

@hannahwhy
Created April 21, 2011 12:44
Show Gist options
  • Select an option

  • Save hannahwhy/934406 to your computer and use it in GitHub Desktop.

Select an option

Save hannahwhy/934406 to your computer and use it in GitHub Desktop.
recreation of the listerine server
require 'redis'
require 'sinatra'
# to do:
# (1) checkout expiration
# (2) /introduce (not sure what it does)
# (3) support vidid harvesters
# more?
R = Redis.new
get '/introduce/:username/:external_ip' do
# ?
end
get '/getID/:username' do
R.multi do |r|
vidid = r.spop 'gv_done'
r.sadd 'gv_processing', vidid
end
vidid
end
get '/finishVid/:username/:id/:size/:hash' do
vidid = params['id']
data = {
'size' => params['size'],
'hash' => params['hash'],
'user' => params['username']
}
R.multi do |r|
r.srem 'gv_processing', vidid
r.sadd 'gv_downloaded', vidid
r.hmset vidid, data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment