Instantly share code, notes, and snippets.

View make_idempotent.js
// takes a function of one or more arguments
// the first argument has to be the id
function make_idempotent(f) {
const already_performed = {};
return function(id, ...args) {
if(already_performed[id])
return {status: "already performed"};
already_performed[id] = true;
return {
View spect_test_core.clj
(ns spec-test.core
(:require [clojure.spec.alpha :as spec]))
(defn paircat' [[a1 a2] [b1 b2]]
[(concat a1 b1) (concat a2 b2)])
(defn paircat [& pairs]
(reduce paircat' [[] []] pairs))
(defn mappaircat [f coll]
View clojurescriptboot.md

Boot

Boot is another build tool for Clojure. If you're using it, there is a ClojureScript build task called [boot-cljs].

In your boot.boot file, add this dependency (check [Clojars][clojarsboot] for the latest version):

View app.properties
#
#Fri Mar 20 11:38:40 CDT 2015
root=/Users/eric/dw/ballot-scout
classpath=/Users/eric/dw/ballot-scout/test\:/Users/eric/dw/ballot-scout/src\:/Users/eric/dw/ballot-scout/test-resources\:/Users/eric/dw/ballot-scout/config\:/Users/eric/dw/ballot-scout/resources\:/Users/eric/dw/ballot-scout/target/classes\:/Users/eric/.m2/repository/ns-tracker/ns-tracker/0.2.1/ns-tracker-0.2.1.jar\:/Users/eric/.m2/repository/com/datomic/datomic-lucene-core/3.3.0/datomic-lucene-core-3.3.0.jar\:/Users/eric/.m2/repository/org/apache/pdfbox/fontbox/1.8.8/fontbox-1.8.8.jar\:/Users/eric/.m2/repository/clj-tuple/clj-tuple/0.1.7/clj-tuple-0.1.7.jar\:/Users/eric/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.1/jackson-databind-2.1.1.jar\:/Users/eric/.m2/repository/org/jgroups/jgroups/3.2.12.Final/jgroups-3.2.12.Final.jar\:/Users/eric/.m2/repository/org/apache/tomcat/tomcat-juli/7.0.27/tomcat-juli-7.0.27.jar\:/Users/eric/.m2/repository/com/cemerick/piggieback/0.1.0/piggieback-0.1.0.jar\:/Users/eric/.m2/repository/com/cogni
View app.properties
#
#Fri Mar 20 11:05:40 CDT 2015
root=/Users/eric/dw/ballot-scout
classpath=/Users/eric/dw/ballot-scout/test\:/Users/eric/dw/ballot-scout/dev-src\:/Users/eric/dw/ballot-scout/src\:/Users/eric/dw/ballot-scout/dev-resources\:/Users/eric/dw/ballot-scout/env-configs/ballot-scout/dev/resources\:/Users/eric/dw/ballot-scout/dev-resources\:/Users/eric/dw/ballot-scout/config\:/Users/eric/dw/ballot-scout/resources\:/Users/eric/dw/ballot-scout/target/classes\:/Users/eric/.m2/repository/ns-tracker/ns-tracker/0.2.1/ns-tracker-0.2.1.jar\:/Users/eric/.m2/repository/com/datomic/datomic-lucene-core/3.3.0/datomic-lucene-core-3.3.0.jar\:/Users/eric/.m2/repository/org/apache/pdfbox/fontbox/1.8.8/fontbox-1.8.8.jar\:/Users/eric/.m2/repository/clj-tuple/clj-tuple/0.1.7/clj-tuple-0.1.7.jar\:/Users/eric/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.1/jackson-databind-2.1.1.jar\:/Users/eric/.m2/repository/org/jgroups/jgroups/3.2.12.Final/jgroups-3.2.12.Final.jar\:/Users/eric/.m2/repository/org/apache/tomcat/tomcat-juli
View Mapping.json
{
"amazon-cache": {
"mappings": {
"listings": {
"properties": {
"asin": {
"type": "string",
"index": "not_analyzed"
},
"categories": {
View mapping.json
{
"big-feed-index": {
"mappings": {
"listings": {
"properties": {
"asin": {
"type": "string",
"index": "not_analyzed"
},
"categories": {
View EdnTester.java
package edntester;
import us.bpsm.edn.Keyword;
import us.bpsm.edn.parser.Parseable;
import us.bpsm.edn.parser.Parser;
import us.bpsm.edn.parser.Parsers;
import us.bpsm.edn.printer.Printers;
import java.util.ArrayList;
View unconditional.clj
(defn- truth [then else] (then))
(defn- falsehood [then else] (else))
(def boolness {false falsehood nil falsehood})
(defn if* [condition then-fn else-fn]
((get boolness condition truth) then-fn else-fn))
(defmacro my-if [test then else]
`(if* ~test (fn [] ~then) (fn [] ~else)))
View lens.clj
(defn lens [getter setter]
(fn [fmap vf in]
(fmap (partial setter in)
(vf (getter in)))))
(defn lupdate [lens f in]
(lens (fn [f a] (f a))
f
in))