This file contains hidden or 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
;; Benchmarks for different implementations of `for-map` | |
;; Can be run with `lein try proteus criterium` | |
;; See http://www.lexicallyscoped.com/2013/04/17/transients-in-clojure.html | |
;; for some relevant discussion. | |
(defn pairs-to-map-without-transient [pairs] | |
(reduce (fn [m [k v]] (assoc m k v)) {} pairs)) |
This file contains hidden or 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
/******************** | |
* TOOLTIP CSS | |
*/ | |
.nvtooltip { | |
position: absolute; | |
background-color: rgba(255,255,255,1); | |
padding: 10px; | |
border: 1px solid #ddd; |
You create a GraphGist by creating a GitHub Gist in AsciiDoc and enter the URL to it in the form on this page. Alternatively, you can put an AsciiDoc document in Dropbox and enter the public URL in the form.
This GraphGist shows the basics of using AsciiDoc syntax and a few additions for GraphGists. The additions are entered as comments on their own line. They are: //console for a query console; //hide, //setup and //output to configure a query; //graph and //table to visualize queries and show a result table.
Click on the Page Source button in the menu to see the source for this GraphGist.
This file contains hidden or 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
;; scratch buffer created 2012-10-31 at 20:48:06 | |
(in-package #:cl) | |
;;; the goal is to enable #+ and #- to ignore multiple expressions by | |
;;; supplying an additional numeric prefix | |
;;; zero is kind of pointless, but would be accepted, possibly with a | |
;;; warning, one is the default |
This file contains hidden or 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
user=> (def attrs '([:db/cardinality :db.cardinality/one] | |
[:db/doc "Documentation string for an entity."] | |
[:db/fulltext true] | |
[:db/ident :db/doc] | |
[:db/valueType :db.type/string])) | |
user=> attrs | |
([:db/cardinality :db.cardinality/one] [:db/doc "Documentation string for an | |
entity."] [:db/fulltext true] [:db/ident :db/doc] [:db/valueType :db.type/string]) |
This file contains hidden or 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
(defmacro defnpd | |
;; defn with default positional arguments | |
[name args & body] | |
(let [unpack-defaults | |
(fn [args] | |
(let [[undefaulted defaulted] (split-with (comp not vector?) args) | |
argcount (count args)] | |
(loop [defaulted defaulted | |
argset {:argnames (into [] undefaulted) | |
:application (into [] (concat undefaulted (map second defaulted)))} |
This file contains hidden or 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 new-class | |
[class-name parent methods] | |
(let [klass ((comp resolve symbol name) class-name)] | |
(fn [command & args] | |
(condp = command | |
:parent parent | |
:name klass | |
:method-names (keys methods) | |
:methods methods | |
:new (new-object klass) |
This file contains hidden or 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 wrap-fn | |
"Wrap or replace some function with your own function" | |
[qualifier wrapper] | |
(alter-var-root | |
qualifier | |
(fn [original-fn] | |
(fn [& caller-arguments] | |
(wrapper caller-arguments original-fn))))) | |
;; Replace your function implementation: |
This file contains hidden or 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 current-category-visited-products | |
[category-id] | |
;; | |
;; Implementation | |
;; | |
) |