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
(def ts (time/formatters :date-time-no-ms)) | |
(defn git-hash [] | |
(let [p (.exec (Runtime/getRuntime) (into-array String ["/bin/sh" "-c" | |
"git rev-list --format=format:'%ct' --max-count=1 `git rev-parse HEAD`"]))] | |
(.waitFor p) | |
(let [s (-> (.getInputStream p) | |
slurp | |
string/trim) | |
_ (prn 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
(def logger (agent nil)) | |
(def logfile (java.io.FileWriter. "output.edn")) | |
(defn log [a x] | |
(binding [*out* logfile | |
*print-length* 200] | |
(prn x))) | |
(defn wrap-logging [hdlr] | |
(fn [req] |
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 lens [getter setter] | |
(fn [fmap vf in] | |
(fmap (partial setter in) | |
(vf (getter in))))) | |
(defn lupdate [lens f in] | |
(lens (fn [f a] (f a)) | |
f | |
in)) |
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- truth [then else] (then)) | |
(defn- falsehood [then else] (else)) | |
(def boolness {false falsehood nil falsehood}) | |
(defn if* [condition then-fn else-fn] | |
((get boolness condition truth) then-fn else-fn)) | |
(defmacro my-if [test then else] | |
`(if* ~test (fn [] ~then) (fn [] ~else))) |
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
package edntester; | |
import us.bpsm.edn.Keyword; | |
import us.bpsm.edn.parser.Parseable; | |
import us.bpsm.edn.parser.Parser; | |
import us.bpsm.edn.parser.Parsers; | |
import us.bpsm.edn.printer.Printers; | |
import java.util.ArrayList; |
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
{ | |
"big-feed-index": { | |
"mappings": { | |
"listings": { | |
"properties": { | |
"asin": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"categories": { |
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
{ | |
"amazon-cache": { | |
"mappings": { | |
"listings": { | |
"properties": { | |
"asin": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"categories": { |
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
# | |
#Fri Mar 20 11:05:40 CDT 2015 | |
root=/Users/eric/dw/ballot-scout | |
classpath=/Users/eric/dw/ballot-scout/test\:/Users/eric/dw/ballot-scout/dev-src\:/Users/eric/dw/ballot-scout/src\:/Users/eric/dw/ballot-scout/dev-resources\:/Users/eric/dw/ballot-scout/env-configs/ballot-scout/dev/resources\:/Users/eric/dw/ballot-scout/dev-resources\:/Users/eric/dw/ballot-scout/config\:/Users/eric/dw/ballot-scout/resources\:/Users/eric/dw/ballot-scout/target/classes\:/Users/eric/.m2/repository/ns-tracker/ns-tracker/0.2.1/ns-tracker-0.2.1.jar\:/Users/eric/.m2/repository/com/datomic/datomic-lucene-core/3.3.0/datomic-lucene-core-3.3.0.jar\:/Users/eric/.m2/repository/org/apache/pdfbox/fontbox/1.8.8/fontbox-1.8.8.jar\:/Users/eric/.m2/repository/clj-tuple/clj-tuple/0.1.7/clj-tuple-0.1.7.jar\:/Users/eric/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.1/jackson-databind-2.1.1.jar\:/Users/eric/.m2/repository/org/jgroups/jgroups/3.2.12.Final/jgroups-3.2.12.Final.jar\:/Users/eric/.m2/repository/org/apache/tomcat/tomcat-juli |
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
# | |
#Fri Mar 20 11:38:40 CDT 2015 | |
root=/Users/eric/dw/ballot-scout | |
classpath=/Users/eric/dw/ballot-scout/test\:/Users/eric/dw/ballot-scout/src\:/Users/eric/dw/ballot-scout/test-resources\:/Users/eric/dw/ballot-scout/config\:/Users/eric/dw/ballot-scout/resources\:/Users/eric/dw/ballot-scout/target/classes\:/Users/eric/.m2/repository/ns-tracker/ns-tracker/0.2.1/ns-tracker-0.2.1.jar\:/Users/eric/.m2/repository/com/datomic/datomic-lucene-core/3.3.0/datomic-lucene-core-3.3.0.jar\:/Users/eric/.m2/repository/org/apache/pdfbox/fontbox/1.8.8/fontbox-1.8.8.jar\:/Users/eric/.m2/repository/clj-tuple/clj-tuple/0.1.7/clj-tuple-0.1.7.jar\:/Users/eric/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.1/jackson-databind-2.1.1.jar\:/Users/eric/.m2/repository/org/jgroups/jgroups/3.2.12.Final/jgroups-3.2.12.Final.jar\:/Users/eric/.m2/repository/org/apache/tomcat/tomcat-juli/7.0.27/tomcat-juli-7.0.27.jar\:/Users/eric/.m2/repository/com/cemerick/piggieback/0.1.0/piggieback-0.1.0.jar\:/Users/eric/.m2/repository/com/cogni |
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
;; this one looks much cleaner, but it holds onto the heads of the lists | |
(defn filter-collecting [predicate collector & lists] | |
(let [tuples (apply map vector lists) | |
filtered (filter #(apply predicate %) tuples)] | |
(map #(apply collector %) filtered))) | |
;; less garbage, but uglier | |
(defn filter-collecting [predicate collector & lists] |
OlderNewer