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
# Thanks to @jcarbo, @jwg2s, @jbender | |
# Rationale: | |
# Create classes of objects with a self-enforcing schemas, | |
# and the ability to track which fields have changed. Highly useful | |
# in modeling, validating, and serializing remote API endpoints, | |
# especially for PATCH updates. | |
# Features: |
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
;; Use cond-> to conditionally add keys to a map | |
;; http://grimoire.arrdem.com/1.6.0/clojure.core/cond-%3E/ | |
(let [a 3 | |
b nil | |
c false | |
d "word"] | |
(cond-> | |
{} |
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 fsm | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic])) | |
;; Encoding a Finite State Machine and recognizing strings in its language in Clojure core.logic | |
;; We will encode the following FSM: | |
;; | |
;; (ok) --+---b---> (fail) | |
;; ^ | |
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
;; in a cider repl | |
;; start system / webserver | |
(user/reset) | |
;; Start browser-connected repl | |
(require 'cljs.repl.browser) | |
(cemerick.piggieback/cljs-repl | |
:repl-env (cljs.repl.browser/repl-env :port 9000)) | |
;; Visit http://localhost:3000 in Chrome. |
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
(def box (atom nil)) | |
(def futures (atom nil)) | |
{:a "1" :b "2"} | |
[:a "1"] | |
[:b "2"] | |
(defn my-fn [{input-map :key some-var :a} name [x y z] ] |
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 save-file | |
"Saves a file to dropbox | |
dropbox component | |
data spittable data to save | |
file-label keyword file label | |
file-ext keyword file extension" | |
[dropbox data file-label file-ext] | |
(let [file-label (name file-label) | |
file-ext (name file-ext) | |
now (java.util.Date.) |
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 example.runner | |
(:require [taoensso.timbre :as timbre]))) | |
(timbre/refer-timbre) | |
(defn run-service | |
"Apply each member of a collection to a function. | |
Collect and return simple profiling info, | |
success and failures." |
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 hello-world.core | |
(:require [org.httpkit.server :refer [run-server]] | |
[compojure.core :refer (GET defroutes)] | |
[compojure.route :as route] | |
[hiccup.core :refer (html)] | |
[hiccup.page :refer (html5)] | |
[ring.middleware.resource :refer (wrap-resource)] | |
[ring.middleware.file-info :refer (wrap-file-info)])) | |
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 [a (System/nanoTime) | |
b (Thread/sleep 2301) | |
c (System/nanoTime)] | |
(.toMillis java.util.concurrent.TimeUnit/NANOSECONDS | |
(- c a))) ; => 2301 |
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
; NUMBERS | |
(+ 5 5) | |
(* 5 5) | |
(/ 5 5) | |
(- 5 5) | |
(/ 2 3) | |
(/ 2.2 3.3) |
NewerOlder