Instantly share code, notes, and snippets.

View reactive-hangman.repl
(require '[cognitect.transcriptor :refer (check!)])
(require '[hangman.reactive-hangman :refer :all])
(comment "win case")
(-> (init-game-data "bigbear" 7)
(prefill-letters ["a"])
(handle-new-event [:guess "b"])
(handle-new-event [:guess "o"])
View hangman.clj
(defn hangman [secret-words letters]
(->> secret-words
(map str)
(every? (set letters))))
View group_address.clj
(defn group-amphoes [locations]
(->> locations
(group-by :amphoe)
(map (juxt first (comp #(mapv :district %) second)))
(into {})))
(defn group-provinces [locations]
(->> locations
(group-by :province)
(map (juxt first (comp group-amphoes second)))
View swap-group.clj
(->> {1 [:a :b], 2 [:a], 3 [:b], 4 [:b :c], 5 [:a], 6 [:a :c :e]}
(map (fn [[k v]] (zipmap v (repeat [k]))))
(apply merge-with into))
;=> {:a [1 2 5 6], :b [1 3 4], :c [4 6], :e [6]}
View transducer-walkthrough.clj
(ns playground.transducer)
(def f1 (comp #(map str %) #(filter even? %) #(map inc %))) ; right -> left
(def nums [4 7 8 9 5 3])
(f1 nums)
(defn f2 [x]
(map str (filter even? (map inc x))))
View deps.edn
{:paths ["."]
:deps {org.clojure/clojurescript
{:git/url "https://github.com/clojure/clojurescript"
:sha "3f4084efcb5cd92cceb8ca30765144691d8cfd7e"}}}
View deps.edn
{:paths ["."]
:deps {org.clojure/math.combinatorics {:mvn/version "0.1.4"}}}
View color-shades.edn
{"white" #{"anti-flash" "antique" "beige" "blond" "cornsilk" "cosmic latte" "cream" "eggshell"
"floral" "ghost" "honeydew" "isabelline" "ivory" "lavender blush" "lemon chiffon"
"linen" "magnolia" "mint cream" "navajo" "old lace" "papaya whip" "peach" "pearl"
"seashell" "snow" "splashed" "vanilla" "white" "smoke"}
"yellow" #{"amber" "apricot" "arylide" "aureolin" "beige" "buff" "chartreuse" "citrine" "cream"
"dark goldenrod" "ecru" "flax" "gold" "gold (metallic)" "goldenrod" "harvest gold"
"jasmine" "jonquil" "khaki" "lemon chiffon" "lion" "maize" "mikado" "mustard" "naples"
"navajo white" "old gold" "olive" "papaya whip" "saffron" "school bus" "selective"
"stil de grain" "straw" "sunglow" "vanilla" "yellow"}
"gray" #{"ash" "battleship" "black" "blue-gray" "cadet" "charcoal" "cool" "davy's" "gray"
View expand-set-values.clj
(defn collify [x-or-coll]
(if (coll? x-or-coll)
x-or-coll
[x-or-coll]))
(defn keyword->symbol [k]
(symbol (name k)))
(defmacro expand-set-values
[attributes]
View async.clj
(ns sof.async
(:require [ring.adapter.jetty :as jetty]
[clj-http.client :as client]
[ring.middleware.json :refer [wrap-json-response]]
[ring.util.response :refer [response]]))
(defn handler [request respond raise]
(client/get "http://example.com"
{:async? true}
(fn [response] (respond {:body "something"}))