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 *expected-selectors* [[:id] [:published] [:updated] | |
[[:link (e/attr= :rel "edit")]] | |
[[:link (e/attr= :rel "alternate")]]]) | |
(def *entry-template* (e/xml-resource "templates/entry.xml")) | |
(defn normalize-entry [entry] | |
(e/transform entry [:entry] | |
(e/do-> | |
(for [sel (filter #(empty? (e/select entry %)) *expected-selectors*)] |
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
How can I remove the repetition found in the last two lines? | |
(require '[net.cgrand.enlive-html :as e]) | |
(e/at entry | |
[:id] (e/content id) | |
[#{:published :updated}] (e/content (str pub-date)) | |
[[:link (e/attr= :rel "edit")]] (e/set-attr :href (str edit-url)) | |
[[:link (e/attr= :rel "alternate")]] (e/set-attr :href (str edit-url))))) |
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
(require '[clj-time.format :as tf]) | |
(defn format-month [month] | |
(let [letter-fmt (tf/formatter "MMM") | |
num-fmt (tf/formatter "MM") | |
converter (fn [month from-fmt to-fmt] | |
(->> month | |
(tf/parse from-fmt) | |
(tf/unparse to-fmt) |
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
public class FieldLengthIT extends BaseTest { | |
@Factory(dataProvider = "fieldLengths") | |
public Object[] createTest(String fieldName, Integer length) { | |
return new Object[] { | |
new FieldLengthTst<EntityCollection>(fieldName, length, | |
client, ecBuilder.build()) | |
}; | |
} |
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
(require '[datomic.api :as d]) | |
(defn maybe-assoc [m k v] | |
(if v (assoc m k v) m)) | |
(defmacro defn-db [name & args] | |
(let [[doc-string & args] (if (string? (first args)) args (cons nil args)) | |
[attr-map & args] (if (map? (first args)) args (cons {} args)) | |
[[& params] & body] args |