Created from the plain text reference card on orgmode.org Download this file, and open it in Emacs org-mode!
| (defprotocol TradeTax | |
| (trade-tax [trade logic])) | |
| (defprotocol Commission | |
| (commission [trade logic])) | |
| (defrecord Trade [ref-no account instrument principal tax-fees | |
| unit-price quantity]) | |
| (defn calculate-tax [{:keys [principal]} logic] |
| (defun copy-current-line-position-to-clipboard () | |
| "Copy current line in file to clipboard as '</path/to/file>:<line-number>'" | |
| (interactive) | |
| (let ((path-with-line-number | |
| (concat (buffer-file-name) ":" (number-to-string (line-number-at-pos))))) | |
| (x-select-text path-with-line-number) | |
| (message (concat path-with-line-number " copied to clipboard")))) | |
| (define-key global-map (kbd "M-l") 'copy-current-line-position-to-clipboard) |
| ;; see http://stackoverflow.com/questions/17190334/getting-the-id-of-an-inserted-entity-in-diatomic | |
| (require '[datomic.api :as d]) | |
| (def uri "datomic:mem://test") | |
| (d/create-database uri) | |
| (def conn (d/connect uri)) | |
| ;; create an atribute | |
| (d/transact conn [{:db/id #db/id[:db.part/db] | |
| :db/ident :some/attribute | |
| :db/valueType :db.type/string |
The philosophy behind Documentation-Driven Development is a simple: from the perspective of a user, if a feature is not documented, then it doesn't exist, and if a feature is documented incorrectly, then it's broken.
- Document the feature first. Figure out how you're going to describe the feature to users; if it's not documented, it doesn't exist. Documentation is the best way to define a feature in a user's eyes.
- Whenever possible, documentation should be reviewed by users (community or Spark Elite) before any development begins.
- Once documentation has been written, development should commence, and test-driven development is preferred.
- Unit tests should be written that test the features as described by the documentation. If the functionality ever comes out of alignment with the documentation, tests should fail.
- When a feature is being modified, it should be modified documentation-first.
- When documentation is modified, so should be the tests.
Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
2015-01-29 Unofficial Relay FAQ
Compilation of questions and answers about Relay from React.js Conf.
Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.
Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).
We're working on a project that uses the Datomic Pull API to pull specific attributes out of Datomic entities. Here's an example of query that uses the Pull API:
(d/q '[:find [(pull ?e [:sales/deal_number :sales/deal_close_date :sales/state]) ...]
:in $ ?date
:where [?e :sales/deal_close_date ?d _ _] [(> ?d ?date)]]
db
(days-ago-at-midnight 1))| (defmacro condas-> | |
| "A mixture of cond-> and as-> allowing more flexibility in the test and step forms" | |
| [expr name & clauses] | |
| (assert (even? (count clauses))) | |
| (let [pstep (fn [[test step]] `(if ~test ~step ~name))] | |
| `(let [~name ~expr | |
| ~@(interleave (repeat name) (map pstep (partition 2 clauses)))] | |
| ~name))) |
| ;; please install web-mode | |
| ;; in your .emacs.d/init.el | |
| (add-to-list 'auto-mode-alist '(".*/react/.*\\.js[x]?\\'" . web-mode)) | |
| (setq web-mode-content-types-alist | |
| '(("jsx" . "/.*/react/.*\\.js[x]?\\'"))) |