Skip to content

Instantly share code, notes, and snippets.

View tangrammer's full-sized avatar
🏠
Working from home

Juan A. Ruz tangrammer

🏠
Working from home
View GitHub Profile
(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]
@drj42
drj42 / org-mode-reference-in.org
Created February 6, 2012 23:53
This is a cheat sheet for Emacs org-mode... in org-mode format!
@kristianhellquist
kristianhellquist / custom.el
Created July 10, 2012 09:50
Emacs, copy current file and line number to clipboard
(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)
@a2ndrade
a2ndrade / gist:5814355
Last active March 23, 2021 07:34
Datomic: Getting the id of an inserted entity
;; 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
@zsup
zsup / ddd.md
Last active November 9, 2024 06:01
Documentation-Driven Development (DDD)

Documentation-Driven Development

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.
@john2x
john2x / 00_destructuring.md
Last active August 23, 2024 07:45
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

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.

Vectors and Sequences

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.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@statonjr
statonjr / datomic-dynamic-find-clause.md
Last active April 14, 2021 22:28
Datomic Dynamic Find Clause

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))
@oliyh
oliyh / condas.clj
Created May 14, 2015 16:28
condas-> - A Clojure macro combining cond-> and as-> to give more flexibility in the test and step forms
(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)))
@mjason
mjason / init.el
Created September 25, 2015 05:48
react native emacs setting
;; 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]?\\'")))