Created
March 21, 2010 16:39
-
-
Save Raynes/339388 to your computer and use it in GitHub Desktop.
This file contains 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
net.licenser.sandbox> (def sc (create-sandbox-compiler)) | |
#'net.licenser.sandbox/sc | |
net.licenser.sandbox> (def cap 100) | |
(defn trim [s] | |
(.replaceAll (apply str (take cap s)) "\n" " ")) | |
(defn execute-text [txt] | |
(let [writer (java.io.StringWriter.)] | |
(try | |
(trim (str writer ((sc txt) {'*out* writer}))) | |
(catch SecurityException _ "DENIED!") | |
(catch Exception e (.getMessage (.getCause e)))))) | |
#'net.licenser.sandbox/execute-text | |
net.licenser.sandbox> (execute-text "(loop [] (recur))") | |
; Evaluation aborted. | |
net.licenser.sandbox> (execute-text "(loop [] (recur))") | |
; Evaluation aborted. | |
net.licenser.sandbox> (execute-text "(loop [] (recur))") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment