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
;; here only data used in filtering. | |
(def docs [{:schema {:info {:name "party"}}} | |
{:schema {:info {:name "bonus"}}} | |
{:schema {:info {:name "party"}}}]) | |
;; anonymous function with get-in (72) | |
(filter (fn [doc] (= "party" (get-in doc [:schema :info :name]))) docs) | |
;; anonymous function & threading (66) | |
(filter (fn [doc] (-> doc :schema :info :name (= "party"))) docs) |
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
(ns tron.kekkonen) | |
(defn addv [a b] (mapv + a b)) | |
(defn turn-left [[dx dy]] [dy (- dx)]) | |
(defn turn-right [[dx dy]] [(- dy) dx]) | |
(defn left? [old-dir new-dir] (= (turn-right new-dir) old-dir)) | |
(defn president | |
[turn & [primary-goal :as original-goals]] | |
(fn [look {:keys [pos dir goals] :or {dir (or primary-goal [0 1]) |
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
{:user {:plugins [[lein2-eclipse "2.0.0"] | |
[lein-idea "1.0.1"]]}} |
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 domain | |
case class Person(id: Option[Long] = None, email: Option[String] = None, firstName: String, lastName: 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
(require '[clojure.walk :as walk]) | |
(defn keywordize-request | |
[handler] | |
(fn [request] | |
(handler | |
(walk/keywordize-keys request)))) |
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
; option1: Liberator-like | |
(GET "/pizzas" [] | |
:return [Pizza] | |
:summary "Gets all Pizzas" | |
:notes "'nuff said." | |
:nickname "getPizzas" | |
(response (get-pizzas))) | |
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
;; play with the latest | |
lein try metosin/ring-swagger | |
; nREPL server started on port 63138 on host 127.0.0.1 | |
; REPL-y 0.3.0 | |
; Clojure 1.5.1 | |
; Docs: (doc function-name-here) | |
; (find-doc "part-of-name-here") | |
; Source: (source function-name-here) | |
; Javadoc: (javadoc java-object-or-class-here) |
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
lein repl | |
;; nREPL server started on port 50058 on host 127.0.0.1 | |
;; REPL-y 0.3.0 | |
;; Clojure 1.5.1 | |
;; Docs: (doc function-name-here) | |
;; (find-doc "part-of-name-here") | |
;; Source: (source function-name-here) | |
;; Javadoc: (javadoc java-object-or-class-here) | |
;; Exit: Control+D or (exit) or (quit) | |
;; Results: Stored in vars *1, *2, *3, an exception in *e |
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 '[schema.core :as s]) | |
(require '[plumbing.core :refer :all]) | |
(defn path-vals | |
"Returns vector of tuples containing path vector to the value and the value." | |
[m] | |
(letfn | |
[(pvals [l p m] | |
(reduce | |
(fn [l [k v]] |
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
lein try metosin/ring-swagger | |
;nREPL server started on port 62925 on host 127.0.0.1 | |
;REPL-y 0.3.0 | |
;Clojure 1.5.1 | |
user=> (require '[ring.swagger.schema :refer :all]) | |
nil | |
user=> (defmodel Neiti {:aika org.joda.time.LocalDate}) |
OlderNewer