Skip to content

Instantly share code, notes, and snippets.

View pweldon's full-sized avatar

Peter Weldon pweldon

  • Lollotec Software Inc
  • Langford, BC, Canada
View GitHub Profile
require 'rubygems'
require 'sinatra'
require 'fileutils'
# upload with:
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename
# or just go to http://localhost:4567/user/filename with a browser
get '/:name/:filename' do
@pweldon
pweldon / gist:3221309
Created July 31, 2012 22:38 — forked from ileitch/gist:1459987
Interruptible sleep in Ruby
module InterruptibleSleep
def interruptible_sleep(seconds)
@_sleep_check, @_sleep_interrupt = IO.pipe
IO.select([@_sleep_check], nil, nil, seconds)
end
def interrupt_sleep
@_sleep_interrupt.close if @_sleep_interrupt
end
end