This file contains hidden or 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
{ | |
"sensorID": "51183a1403641366a6609811", | |
"apiToken": "d21ba846-cf2d-45f6-8947-959184103ee8", | |
"organization": "Organization X", | |
"value": "42" | |
} | |
This file contains hidden or 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 [a 2 b 3 c (+ a b) d (+ c 7)] | |
c) ;; C-x C-e => 5 | |
(defn f [a b] (* a b)) | |
(f 5 2) ;; C-x C-e => 10 | |
(cond (= true false) 1 | |
(= false false) 2) ;; C-x C-e => 2 |
This file contains hidden or 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
(defproject dire "0.2.1" | |
:description "Erlang-style supervisor error handling for Clojure" | |
:url "https://github.com/MichaelDrogalis/dire" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:repositories {"stuart" "http://stuartsierra.com/maven2"} | |
:dependencies [[org.clojure/clojure "1.5.0-RC16"] | |
[org.clojure/tools.nrepl "0.2.0-RC1"] | |
[midje "1.4.0"] | |
[com.stuartsierra/lazytest "1.2.3"] |
This file contains hidden or 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
(with-pre-hook! #'download-images! | |
(fn [_ _] (println "Fetching images from Perion Corner..."))) | |
(with-pre-hook! #'zip-images! | |
(fn [_] (println "Zipping the images for the Sprite Generator..."))) | |
(with-pre-hook! #'create-css-contents! | |
(fn [_ _] (println "Generating the CSS file..."))) | |
(with-pre-hook! #'download-sprite-sheet! |
This file contains hidden or 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
;; Datomic example code | |
;; demonstrates various update scenarios, using a news database | |
;; that contains stories, users, and upvotes | |
;; grab an in memory database | |
(use '[datomic.api :only (q db) :as d]) | |
(def uri "datomic:mem://foo") | |
(d/create-database uri) | |
(def conn (d/connect uri)) |
This file contains hidden or 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 f [a] | |
(prn a)) | |
(defn g [h] | |
(h true)) | |
(g (fn [a] | |
(f a))) |
This file contains hidden or 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 :spec.class/create | |
:fn/params {[:name :string :param/doc "The name of the class."[ | |
[:location {[:x :double :param/doc "The x location of the element."] | |
[:y :double :param/doc "The y location of the element."]}]} | |
:fn/response {[:success :boolean :param/doc "The success of the operation."]} | |
:fn/example {:fn :spec.class/create | |
:params {:name "Cactus" | |
:location {:x 50 :y 60}}} | |
:fn/doc "Creates a new class element for a Class Diagram."}] |
This file contains hidden or 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 dire-example.functions) | |
(defn add-numbers [a b] | |
(+ a b)) | |
This file contains hidden or 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 clj-schema-dire-example.core | |
(:require [clj-schema.validation :refer :all] | |
[dire.core :refer :all])) | |
(defn create-user! [username] | |
(println "Creating the user.")) | |
(with-precondition! #'create-user! | |
:username-is-a-string | |
(fn [username] (empty? (validation-errors String username)))) |
This file contains hidden or 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 atom-example.core | |
(:require [dire.core :refer :all])) | |
(def x (atom [2])) | |
(def checker (constantly true)) ;;; Need some validator function to add the hooks to. | |
(with-precondition! #'checker | |
:all-even (fn [coll] (every? even? coll))) |