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
<plugin> | |
<groupId>com.theoryinpractise</groupId> | |
<artifactId>clojure-maven-plugin</artifactId> | |
<version>1.3.8</version> | |
<executions> | |
<execution> | |
<id>compile</id> | |
<phase>compile</phase> | |
<goals> | |
<goal>compile</goal> |
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
(let [ | |
rnd (send-command "status" "getPredictionRnd") | |
latest-rnd (send-command "prediction" "getLatestPredictionRnd" {:pooler_id pooler_id :sheet rnd}) | |
preds (send-command "prediction" "getPredictionsForMatchups" {:pooler_id pooler_id :sheet rnd :rnd latest-rnd})] | |
(if (or (nil? rnd) (= rnd 0)) | |
{:errors "rnd_is_nil_or_zero"} | |
(get-matchups | |
(cond | |
(seq preds) preds | |
(= rnd 1) (.query persistence "team_playoffs" {}) |
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
(fn [init & args] | |
(reduce | |
(fn [a [f b]] (f a b)) | |
init (partition 2 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
public Map swapKeys(Map map, Object key1, Object key2) { | |
Object val1 = map.get(key1); | |
map.put(key1, map.get(key2); | |
map.put(key2, val1); | |
return map; | |
} |
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 swap-keys [map key1 key2] | |
(assoc map key1 (map key2) key2 (map key1))) |
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 random-letter [] | |
(-> (rand-int 26) (+ 97) char)) | |
(defn random-digit [] | |
(rand-int 10)) | |
; for example, (generate-random-password "a1aa1a11") returns something like "z5qr9s42" | |
(defn generate-random-password [spec] | |
(-> #(if (= % \a) (random-letter) (random-digit)) (map spec) (apply str))) |
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 TimeTypeConverter extends DateTypeConverter { | |
private static final String[] TIME_FORMAT = { "HH:mm" }; | |
@Override | |
protected String[] getFormatStrings() { | |
return TIME_FORMAT; | |
} | |
} |
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
Something something = object.getSomething(); | |
if (something != null) { | |
SomeType[] someArray = something.getSomeArray(); | |
if (someArray != null) { | |
for (SomeType some : someArray) { | |
// call f(some) | |
} | |
} |