Skip to content

Instantly share code, notes, and snippets.

View MichaelDrogalis's full-sized avatar

Michael Drogalis MichaelDrogalis

  • Confluent
  • Seattle, WA
View GitHub Profile
{
"sensorID": "51183a1403641366a6609811",
"apiToken": "d21ba846-cf2d-45f6-8947-959184103ee8",
"organization": "Organization X",
"value": "42"
}
(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
(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"]
(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!
;; 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))
(defn f [a]
(prn a))
(defn g [h]
(h true))
(g (fn [a]
(f a)))
@MichaelDrogalis
MichaelDrogalis / gist:5267905
Last active December 15, 2015 13:29
Draft of Jotspec autogenerated documentation.
[{: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."}]
(ns dire-example.functions)
(defn add-numbers [a b]
(+ a b))
(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))))
@MichaelDrogalis
MichaelDrogalis / gist:5276742
Last active December 15, 2015 14:48
Using Dire with Clojure's built in validator on Atoms.
(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)))