Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.