Skip to content

Instantly share code, notes, and snippets.

View danlentz's full-sized avatar

Dan Lentz danlentz

View GitHub Profile
@qerub
qerub / for-map-benchmarks.clj
Created November 27, 2013 17:25
[Clojure] Benchmarks for different implementations of `for-map`
;; 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))
@danlentz
danlentz / d3.css
Created September 12, 2013 19:03 — forked from bobmonteverde/d3.css
/********************
* TOOLTIP CSS
*/
.nvtooltip {
position: absolute;
background-color: rgba(255,255,255,1);
padding: 10px;
border: 1px solid #ddd;
@danlentz
danlentz / GraphGist-Guide.adoc
Last active December 22, 2015 22:39 — forked from nawroth/GraphGist-Guide.adoc
GraphGist-Guide

Develop a Graph

There are Three APIs…​

Neo4j has a trio of programming interfaces, focused on different kinds of interaction.

api trio
  • Work with the Cypher query language over HTTP.

  • Discover raw graph primitives over REST.

How to create a GraphGist

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.

;; 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
@danlentz
danlentz / attrs.clj
Created September 9, 2013 17:33
clj-pprint
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])
@danlentz
danlentz / defnpd.clj
Created September 9, 2013 02:06 — forked from flyingmachine/defnpd.clj
defn with default positional arguments
(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)))}
@danlentz
danlentz / New-class.clj
Last active December 22, 2015 15:09
Jabberwobject based on Frumious?
(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)
(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:
(defn current-category-visited-products
[category-id]
;;
;; Implementation
;;
)