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
(defn revert [id attrs opts] | |
(sql/with-connection rev-log | |
(let [id (Integer/parseInt (last (re-split #"-" id))) | |
result (sql/with-query-results result | |
["UPDATE revisions | |
SET reverted_by = nextval('revision_id_seq'::regclass) | |
WHERE id=? | |
AND reverted_by IS NULL | |
returning reverted_by AS revision;" | |
id] |
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
(defn verify-table [table] | |
(sql/with-connection *db* | |
(sql/with-query-results results [(str "SELECT node_id, data FROM " table " WHERE data IS NOT NULL")] | |
(doseq [r results] | |
(try (json/parse-string (:data r)) | |
(catch Exception e | |
(println e) | |
(println "table:" table) | |
(println "node_id:" (:node_id r)) | |
(println "data:" (:data r)) |
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
(PUT "/:focus/:action" | |
{{type "focus" action "action"} :route-params | |
body :body | |
uri :uri | |
query-string :query-string | |
opts :query-params | |
:as request} | |
(let [nspace (symbol (str 'actions. type)) | |
action (parse-action action) | |
opts (assoc opts :uri (str uri "?" query-string))] |
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
(defmacro project-let [bindings & body] | |
`(binding [project {:name "project-stub", :version "0.0.0", :root "/home/project"}] | |
(let ~bindings | |
~@body))) | |
(deftest file-fn | |
(testing "single string" | |
(project-let [s "foo/bar/baz"] | |
(is (= (str (:root project) "/" s) | |
(.toString (file s)))))) |
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
lance:fulltext master$ cake test | |
---- | |
Finished in 9.07E-4 seconds. | |
lance:fulltext master$ cake test | |
---- | |
Finished in 7.4E-5 seconds. | |
lance:fulltext master$ mv test.bak test |
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
(defn get-env [] | |
(or (first (:env *opts*)) | |
(get *config* "env"))) | |
(defn create [port f & commands] | |
(let [commands (apply hash-map commands)] | |
(server-socket/create-server port | |
(fn [ins outs] | |
(binding [*in* (LineNumberingPushbackReader. (InputStreamReader. ins)) | |
*out* (OutputStreamWriter. outs) |
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
(defproject fulltext "0.0.1-SNAPSHOT" | |
:description "experimenting with fulltext search variants" | |
:dependencies [[clojure "1.2.0"] | |
[clojure-contrib "1.2.0"]] | |
:dev-dependencies [[swank-clojure "1.2.0"] | |
[clojure-contrib "1.2.0"] | |
[postgresql/postgresql "8.4-701.jdbc4"] | |
[org.clojars.lancepantz/clojure-solr "0.2.0"]] | |
:environments {:development {:db {:classname "org.postgresql.Driver" | |
:subprotocol "postgresql" |
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
#!/usr/bin/env cake | |
(println "hi") | |
(println "cake opts:" cake/*opts*) | |
(println "clojure opts:" *command-line-args*) | |
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
(deftask crawl | |
"learn to crawl" | |
{[me] :me} :when (= me "lance") | |
(println "opts:" *opts*) | |
(println "me:" me) | |
(println "learning to crawl")) | |
(deftask walk #{crawl} | |
"learning to walk" | |
(println "learning to walk")) |
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
(defmacro defile | |
"Define a file task. Uses the same syntax as deftask, however the task name | |
is a string representing the name of the file to be generated by the body. | |
Source files may be specified in the dependencies set, in which case | |
the file task will only be ran if the source is newer than the destination. | |
(defile \"main.o\" #{\"main.c\"} | |
(sh \"cc\" \"-c\" \"-o\" \"main.o\" \"main.c\"))" | |
[name & forms] | |
(let [{:keys [deps body doc]} (parse-task-opts forms) | |
{:keys [destruct pred actions]} (parse-body body) |
OlderNewer