This file contains hidden or 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
| (ns walton.core | |
| (:use clojure.contrib.duck-streams | |
| clojure.contrib.str-utils | |
| clojure.contrib.seq-utils | |
| clj-html.core | |
| net.licenser.sandbox | |
| walton.integration | |
| walton.find-user) | |
| (:gen-class)) |
This file contains hidden or 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
| (defn categorize-code [files] | |
| (reduce (fn [result code] | |
| (try | |
| (let [r (*sandbox* code)] | |
| (update-in result [:good] conj [code r]) | |
| [code (pr-str r)]) | |
| (catch Exception e | |
| (update-in result [:bad] conj code)))) | |
| {} | |
| (find-lines text files))) |
This file contains hidden or 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
| (defn categorize-sexps [] | |
| (reduce (fn [code, result] | |
| (try | |
| (let [r (*sandbox* code)] | |
| (update-in result [:good code] | |
| [code (pr-str r)])) | |
| (catch Exception e | |
| (update-in result [:bad code] | |
| [code])))) | |
| (all-expressions logfiles) |
This file contains hidden or 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
| (defn categorize-sexps [] | |
| (reduce (fn [result, code] | |
| (try | |
| (let [r (*sandbox* code)] | |
| (update-in result [:good] | |
| conj [code (pr-str r)])) | |
| (catch Exception e | |
| (update-in result [:bad] | |
| conj [code nil])))) | |
| {} |
This file contains hidden or 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
| (defproject walton "0.5" | |
| :description "Walton will traverse caves filled with snakes to find you example clojure code containing the function you desire." | |
| :dependencies [[org.clojure/clojure "1.1.0"] | |
| [clj-sandbox/clj-sandbox "0.2.9-SNAPSHOT"] | |
| [org.clojure/clojure-contrib "1.1.0"] | |
| [clj-html "0.1.0"]] | |
| :dev-dependencies [[swank-clojure "1.2.0-SNAPSHOT"] | |
| [autodoc "0.7.0"]] | |
| :main walton.core | |
| :namespaces [walton.core, walton.integration]) |
This file contains hidden or 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
| ;; load paths | |
| (setq dotfiles-dir (file-name-directory | |
| (or (buffer-file-name) load-file-name))) | |
| (add-to-list 'load-path dotfiles-dir) | |
| (if (fboundp 'normal-top-level-add-subdirs-to-load-path) | |
| (let* ((my-lisp-dir "~/.emacs.d/elpa-to-submit") | |
| (default-directory my-lisp-dir)) | |
| (setq load-path (cons my-lisp-dir load-path)) |
This file contains hidden or 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
| (defn walton [#^String s] | |
| (let [count-result (rand-int (count (walton-doc s))) | |
| expr (nth (walton-doc s) count-result) | |
| code-text (first expr) | |
| result-text (second expr) | |
| expr-length (map count (map seq expr)) | |
| code-length (first expr-length) | |
| result-length (second expr-length) | |
| truncated-result []] | |
| (if (>= code-length 457) |
This file contains hidden or 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
| (defhtml application [text body] | |
| [:html | |
| [:head | |
| [:title text]] | |
| [:body | |
| [:h3 text] | |
| body]]) | |
| (defhtml code-list [body] | |
| [:ul body]) |
This file contains hidden or 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
| (def walton-web | |
| (app | |
| ["examples" text] | |
| {:get [(fn [req] (walton-doc* text))]} | |
| [#".*"] {:get ["all routes!"]})) |
This file contains hidden or 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
| (ns defn-test | |
| (:use clj-html.core | |
| [net.cgrand.moustache :only [app]] | |
| [ring.adapter.jetty :only [run-jetty]] | |
| [ring.util.response :only [response]])) | |
| (defhtml application [text body] | |
| [:html | |
| [:head | |
| [:title text]] |