Skip to content

Instantly share code, notes, and snippets.

@gomasy
Created April 4, 2014 17:39
Show Gist options
  • Save gomasy/9979392 to your computer and use it in GitHub Desktop.
Save gomasy/9979392 to your computer and use it in GitHub Desktop.
class SandBox
def self.exec(code)
result = nil
Timeout::timeout(5) do
result = Thread.new do
$SAFE = 4
instance_eval(code)
end.value
end
return result
rescue Exception => ex
return ex.message
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment