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 kc.datomic | |
"Datomic utility functions | |
Usage Notes: | |
Some functions in this namespace take sequences of facts and return them modified in some way. Some up-front modifications are useful for those functions, like replacing all map-form facts with vector-form facts. In order to avoid doing these modifications repeatedly to same the same set of facts (which would be harmless but wasteful), two versions of these functions exist: a \"safe\" version that does those up-front modifications, and an \"unsafe\" version that expects those modifications to already have been performed. The unsafe versions are named like the safe ones, but with a single quote appended. | |
TODO: | |
- consider implementing all fns that branch based on operation as multimethods | |
These fns mostly support :db/add, :db/retract :db.fn/retractEntity, :db.fn/cas, |
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
# Add these to your .bash_profile / .zshrc / etc. | |
# Starts a Clojure repl | |
function rebel-clj() { | |
clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.4\"} $@}}" -m rebel-readline.main | |
} | |
# Starts a browser REPL | |
function rebel-cljs() { | |
clojure -Sdeps "{:deps {com.bhauman/figwheel-main {:mvn/version \"0.1.7\"} com.bhauman/rebel-readline-cljs {:mvn/version \"0.1.4\"} $@}}" -m figwheel.main |
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
### prerequisites | |
sudo yum groupinstall "Development Tools" | |
git --version | |
gcc --version | |
bash --version | |
python --version # (system) | |
sudo yum install -y openssl-devel readline-devel zlib-devel | |
sudo yum update | |
### install `pyenv` |
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
{:paths ["."] | |
:deps {clansi/clansi {:mvn/version "1.0.0"}}} |
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
;; I think it would be a mistake to introduce temporal coupling to prevent typos. | |
;; The example program below lets you identify "missing" keys specs at | |
;; the time and place of your choosing, and then handle them as you | |
;; deem appropriate, without imposing those decisions on other | |
;; users of spec. | |
(require '[clojure.spec.alpha :as s] | |
'[clojure.set :as set]) |
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 '[cemerick.url :as url] | |
'[clojure.spec.alpha :as s] | |
'[clojure.spec.gen.alpha :as gen] | |
'[clojure.string :as string]) | |
(def non-empty-string-alphanumeric | |
"Generator for non-empty alphanumeric strings" | |
(gen/such-that #(not= "" %) | |
(gen/string-alphanumeric))) |
A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.
How to use:
- The link in the table of content jumps at the copy of the answer on this page.
- The link on the answer itself points back at the original post.
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 '[datomic.api :as d]) | |
(def conn-uri "datomic:dev://localhost:4334/my-db") | |
;; This is normally how you would get a list of tx-ids outside a query. | |
;; However, there is some concern that this is not lazy. (I am pretty sure, | |
;; but not certain, that reading the tx-log is lazy.) | |
(-> conn-uri d/connect d/log (d/tx-range nil nil) | |
(->> (map :t) (take 10))) |
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
;; [cljsjs/react-virtualized "7.11.8-1" :exclusions [cljsjs/react]] | |
(ns react-virtualized.example | |
(:require [cljsjs.react-virtualized] | |
[clojure.string] | |
goog.date.DateTime | |
[reagent.core :as r])) | |
(defn fmt-value [v] | |
(cond |