switch to updated participant-recent-conversations schema

--- src/er_cassandra/util/time.clj
+++ src/er_cassandra/util/time.clj
@@ -1,6 +1,19 @@
 (ns er-cassandra.util.time
   (:require
-   [clj-time.format :as f]))
+   [clj-time.core :as t]
+   [clj-time.coerce :as tc]
+   [clj-time.format :as f]
+   [clj-uuid :as uuid])
+  (:import
+   [java.util UUID]))
+
+;; make things work with v1 UUIDs
+(extend-protocol tc/ICoerce
+  UUID
+  (to-date-time [uuid]
+    (-> uuid
+        uuid/get-instant
+        tc/from-date)))

 (def timestamp-format (f/formatter "yyyy-MM-dd HH:mm:ssZ"))

@@ -10,4 +23,29 @@

 (defn unparse-timestamp
   [t]
-  (f/unparse timestamp-format t))
+  (->> t
+       tc/to-date-time
+       (f/unparse timestamp-format)))
+
+;; a format similar to the clojure #inst format which captures
+;; milliseconds and has no spaces
+(def timestamp-format-utc-millis (f/formatter "yyyy-MM-dd'T'HH:mm:ss.SSS"))
+
+(defn unparse-timestamp-utc-millis
+  [t]
+  (as-> t %
+    (tc/to-date-time %)
+    (t/to-time-zone % t/utc)
+    (f/unparse timestamp-format-utc-millis %)))
+
+(defn timeuuid-comparator
+  "cassandra compares timeuuids by first comparing their
+   timestamps and if they are equal comparing their
+   binary encodings - this does the same"
+  [timeuuid-a timeuuid-b]
+  (let [ts-a (-> timeuuid-a uuid/get-timestamp)
+        ts-b (-> timeuuid-b uuid/get-timestamp)
+        tsc (compare ts-a ts-b)]
+    (if (not= tsc 0)
+      tsc
+      (compare (str timeuuid-a) (str timeuuid-b)))))


resources.clj edited online with Bitbucket

--- resources/resources.clj
+++ resources/resources.clj
@@ -1,6 +1,6 @@
 {:detrit {:size 0.0
-          :max-size 100}
+          :max-size 1e4}
  :soil {:size 0.0
-        :max-size 100}
+        :max-size 1e4}
  :oxygen {:size 0.0
-          :max-size 1000}}
+          :max-size 1e5}}


add make-tree for bread-first

add make-tree for bread-first

--- test/osmium/core_test.clj
+++ test/osmium/core_test.clj
@@ -1,5 +1,6 @@
 (ns osmium.core-test
-  (:require [clojure.test :refer :all]
+  (:require [com.stuartsierra.component :as component]
+            [clojure.test :refer :all]
             [clj-webdriver.taxi :as taxi]
             [osmium.core :as o]
             [osmium.user :as user]
@@ -9,7 +10,6 @@
             [clojure.set :as set]
             [clojure.test.check.generators :as test-gen ]))

-
 (defmulti eval!* (fn [driver [type data]] type))

 ;; Navigation
@@ -73,14 +73,22 @@

 (defmulti eval! (fn [driver xs] (type (first xs))))

+(defmethod eval! nil [_ _])
+
 (defmethod eval! clojure.lang.PersistentVector
   [driver xs]
   (doseq [x xs]
     (eval! driver x)))

+(defonce last-exception (atom nil))
+
 (defmethod eval! clojure.lang.Keyword
   [driver x]
-  (eval!* driver x))
+  (try
+    (eval!* driver x)
+    (catch org.openqa.selenium.NoSuchElementException e
+      (reset! last-exception e)
+      (throw (Exception. (str "Couldn't find element for:" (pr-str x)))))))

 (defn walk-n-steps!
   "Generates an action and evals it until n actions or no possible actions,
@@ -98,6 +106,41 @@
              (conj actions action')
              (recur (dec n) (conj actions action'))))
          actions)))))
+
+(defn make-tree
+  "Generates a tree [action1-depth1 [[action1-depth-2 tree] [action2-depth2 tree]]]
+  by walking all the possible paths from root to leaf node. It restarts the system on each run,
+  reproduces the state by evaling path, finds the next level of actions, and recurs on all
+  of them.
+  - depth: of the tree
+  - system: system object to be restarted on each run
+  - driver: selenium driver object to use
+  - path all previous steps necessary to reproduce the state, (for root call = [])
+  - action: root action, ex. [:to 'localhost:30005']"
+  ([depth system driver]
+   (make-tree depth system driver [] [:to "localhost:3005"]))
+  ([depth system driver action]
+   (make-tree depth system driver [] action))
+  ([depth system driver path action]
+   ;; base case returns whatever root action was passed in
+   (if (zero? depth)
+     action
+     ;; start the system from scratch
+     (let [system' (component/start system)]
+       (try
+         ;; reproduce state up to here
+         (eval! driver path)
+         ;; find next level of actions
+         (let [actions (mapv (partial expand-action d) (find-actions driver))]
+           ;; stop the system and recur along all actions
+           (component/stop system')
+           (into [action]
+                 (mapv #(make-tree (dec depth) system driver (conj path %) %) actions)))
+         (finally
+           ;; if an exception is thrown and any Server object is left in started state,
+           ;; the port is bind and we have no way to stop it, need to restart the repl
+           (component/stop system')))))))
+

 ;; ======================================================================
 ;; Tests


Point people at the README after lein new

--- src/leiningen/new/chestnut.clj
+++ src/leiningen/new/chestnut.clj
@@ -157,5 +157,6 @@
                                 (render "spec/cljs/chestnut/core_spec.cljs" data)]))))

 (defn chestnut [name & opts]
-  (main/info "Generating fresh 'lein new' chestnut project.")
+  (main/info "Generating fresh Chestnut project.")
+  (main/info "README.md contains instructions to get you started.")
   (apply ->files (format-files-args name opts)))


started using parinfer

started using parinfer

--- src/stash_bot/core.cljs
+++ src/stash_bot/core.cljs
@@ -6,4 +6,4 @@
 (defn -main [& args]
   (println "Hello world!"))

-(set! *main-cli-fn* -main)+(set! *main-cli-fn* -main)


Start wiring up index updates on document load; currently, we're blocked by, of all things, https://github.com/korma/Korma/issues/297

--- src/doctopus/db.clj
+++ src/doctopus/db.clj
@@ -3,7 +3,7 @@
             [camel-snake-kebab.extras :refer [transform-keys]]
             [clj-time.coerce :refer [to-sql-time]]
             [clj-time.core :as clj-time]
-            [clojure.string :as string :refer [split-lines]]
+            [clojure.string :as str :refer [split-lines]]
             [doctopus.configuration :refer [server-config]]
             [korma.core :refer :all]
             [korma.db :refer [defdb postgres]]
@@ -41,7 +41,7 @@
   (prepare add-updated)
   (prepare (fn [{html-commands :html-commands :as tentacle}]
              (if html-commands
-               (assoc tentacle :html-commands (string/join "\n" html-commands))
+               (assoc tentacle :html-commands (str/join "\n" html-commands))
                tentacle)))
   (prepare ->snake-keys)
   (transform ->kebab-keys)
@@ -224,15 +224,37 @@
   (insert documents
           (values document)))

+;; Manually
+;; (let [sql (str/join ["UPDATE documents"
+;;                      "SET search_vector = to_tsvector('english', body)"
+;;                      "WHERE name = ?"] " ")]
+;;   (exec ))
+(defn update-document-index
+  "The documents table has a column of type tsvector, `search_vector', which is
+  indexed for Full Text Search; this function updates that column, for one
+  document (in the case that a single doc has been modified) or for all
+  documents (for use after loading in a large batch of new docs, for instance)."
+  ([]
+   (update documents
+           (set-fields {:search-vector (raw "to_tsvector('english', body)")})
+           (where {:uri [like "%html"]})))
+  ([document]
+   (update documents
+           (set-fields {:search-vector (raw "to_tsvector('english', body)")})
+           (where {:name (:name document)}))))
+
 (defn update-document!
-  [document]
+  [document update-index?]
   (log/info "Updating document named:" (:name document))
-  (update documents
-          (set-fields document)
-          (where {:name (:name document)})))
+  (let [res (update documents
+                    (set-fields document)
+                    (where {:name (:name document)}))]
+    (if update-index? (update-document-index))
+    res))

 (defn save-document!
-  [document]
-  (if-not (empty? (get-document-by-name (:name document)))
-    (update-document! document)
-    (create-document! document)))
+  ([document] (save-document! document true))
+  ([document update-index?]
+   (if-not (empty? (get-document-by-name (:name document)))
+     (update-document! document update-index?)
+     (create-document! document))))


Let's just make it one DC

Let's just make it one DC

--- test/clojure/clojurewerkz/cassaforte/schema_test.clj
+++ test/clojure/clojurewerkz/cassaforte/schema_test.clj
@@ -42,13 +42,13 @@
 (deftest test-create-alter-keyspace
   (alter-keyspace *session* "new_cql_keyspace"
                   (with {:durable-writes false
-                         :replication    {"class" "NetworkTopologyStrategy"
-                                          "dc1"   1
-                                          "dc2"   2}}))
+                         :replication    (array-map "class" "NetworkTopologyStrategy"
+                                                    "dc1"   1)}))
   (let [res (describe-keyspace *session* "new_cql_keyspace")]
     (is (= "new_cql_keyspace" (:keyspace_name res)))
     (is (= false (:durable_writes res)))
-    (is (= "{\"dc2\":\"2\",\"dc1\":\"1\"}" (:strategy_options res)))))
+    (is (= "{\"dc1\":\"1\"}" (:strategy_options res)))
+    (is (= "{\"dc1\":\"1\"}" (:strategy_options res)))))

 (deftest test-create-table-with-indices
   (create-table *session* :people


Fix `record-payment`

Fix `record-payment`

--- src/invadm/core.clj
+++ src/invadm/core.clj
@@ -58,8 +58,8 @@

 (defn serialize-invoice [invoice]
   (assoc invoice
-         "issue-date" (unparse-date (get invoice "issue-date"))))
-         ;; "payments" (map serialize-payment (get invoice "payments"))))
+         "issue-date" (unparse-date (get invoice "issue-date"))
+         "payments" (map serialize-payment (get invoice "payments"))))

 (defn parse-invoice [json]
   (add-convenience-fields (assoc json
@@ -109,8 +109,8 @@

 (defn parse-today-default [value]
   (cond
-    (nil? value) (unparse-date (t/now))
-    (string? value) value))
+    (nil? value) (t/now)
+    (string? value) (parse-date value)))

 (defn usage [options-summary]
   (->> ["invadm - an invoice manager"
@@ -169,8 +169,8 @@
         invoice (read-invoice id)]
     (write-invoice id (assoc invoice
                              "payments" (conj (get invoice "payments")
-                                              {:date (:paid-on options)
-                                               :amount (or (:amount options)
+                                              {"date" (:paid-on options)
+                                               "amount" (or (:amount options)
                                                            (get invoice "amount"))})))))

 (defn -main [& args]


use the cdn path for the favicon (on frontend)

--- src-cljs/frontend/favicon.cljs
+++ src-cljs/frontend/favicon.cljs
@@ -12,7 +12,7 @@
   (utils/swallow-errors
    (if (= color (get-color))
      (utils/mlog "Not setting favicon to same color")
-     (.setAttribute (favicon-link) "href" (str "/favicon-" color ".ico?v=28")))))
+     (.setAttribute (favicon-link) "href" (utils/cdn-path (str "/favicon-" color ".ico?v=28"))))))

 (defn reset! []
   ;; This seemed clever at the time, undefined is the default dark blue


refactor and sound files

refactor and sound files

--- src-cljs/minesweeper/core.cljs
+++ src-cljs/minesweeper/core.cljs
@@ -14,6 +14,10 @@
 (def playing (r/atom nil))
 ;; current time
 (def time-tick (r/atom 0))
+
+
+(defn set-tick[]
+  (reset! time-tick (.getTime (js/Date.))))

 ;; game status
 (def game-state
@@ -31,18 +35,18 @@
 (defn play-sound [result]
   (when (.-HTMLAudioElement js/window)
     (let [sounds {:failed "sad" :completed "success"}]
-    (println "playing " (sounds result))
+;;    (println "playing " (sounds result))
     (let [audio-obj (js/Audio. (str "sounds/" (sounds result) ".mp3"))]
     (reset! playing audio-obj)
     (.play audio-obj )))))

-(defn update-timer [state timer]
-  (let [game @state]
-    (println "timer triggered")
+(defn update-timer []
+  (let [game @game-state]
+;;    (println "timer triggered")
     (when-not (or (game :first) (game :end))
-      (println "Changed seconds")
-      (reset! timer (quot (.getTime (js/Date.)) 1000)))))
+;;      (println "Changed seconds")
+      (set-tick))))

 (defn stop-sound [] (when-let [ audio-obj @playing] (.pause audio-obj)))
@@ -88,6 +92,7 @@
    :mines mines
    :end false
    :first true
+   :start 0 ;;timestamp
    }))

 (defn all-open? [game]
@@ -155,7 +160,7 @@

 (defn first-click [game x y]
-  (reset! time-tick (quot (.getTime (js/Date.)) 1000))
+  (set-tick)
   (if (= 1 (get-in game [:board x y]) )
     (swap-cell game [x y] (find-space game))
     game))
@@ -165,7 +170,7 @@
   (let [game (if (game :first)
                (-> game
                 (first-click x y)
-                (assoc :start (quot (.getTime (js/Date.)) 1000))
+                (assoc :start (.getTime (js/Date.)) )
                 (assoc :first false))
                game) ]
     (condp = (get-in game [:state x y])
@@ -212,6 +217,7 @@

 (defn new-game! [difficulty]
   (stop-sound)
+  (reset! time-tick 0)
   (reset! game-state (apply init-game (difficulties difficulty))))

 (defn print-game [game]
@@ -271,12 +277,12 @@
 (defn format [n]
   (let [s (str n)]
     (str (apply str (repeat (- 3 (count s)) 0)) s)))
-(defn timer-component[app-state timer]
-  (println "trigger timer and rendering timer component ")
-  (js/setTimeout update-timer 200 app-state timer)
+(defn timer-component[]
+;;  (println "trigger timer and rendering timer component ")
+  (js/setTimeout update-timer 200)
   [:input#display {:type      "text"
                    :read-only true
-                   :value     (format (min 999 (- @timer (@app-state :start))))} ])
+                   :value     (format (min 999 (quot (- @time-tick (@game-state :start)) 1000)))} ])

 ;; UI components
@@ -288,7 +294,7 @@
                              :read-only true
                              :value (format (game :mines))} ]
             [:button#control {:on-click #(new-game! :beginner)} "\u263A" ]
-            (timer-component game-state time-tick)
+            (timer-component)
             ]]

         (for [y (range (game :y))]


increase max-total-depth from 4 to 5

increase max-total-depth from 4 to 5

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -11,7 +11,7 @@
                                         ref? remove-false remove-top-values-log
                                         strip-refs show-spec unify unifyc)]))
 ;; during generation, will not search deeper than this:
-(def ^:const max-total-depth 4)
+(def ^:const max-total-depth 5)

 (declare add-complement)
 (declare lexemes-before-phrases)


cleanup unused :refers

cleanup unused :refers

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -9,7 +9,7 @@
    [clojure.string :as string]
    [dag_unify.core :refer (copy dissoc-paths get-in fail? fail-path
                                         ref? remove-false remove-top-values-log
-                                        strip-refs show-spec unify unifyc
+                                        strip-refs unify unifyc

                                         ;; temporary: until we move (truncate) from here to dag_unify.
                                         deserialize serialize


enforce a max depth on trees

enforce a max depth on trees

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -10,6 +10,7 @@
 ;; the more likely we'll first generate leaves
 ;; (terminal nodes) rather than trees.
 (def ^:const branching-factor 5)
+(def ^:const max-depth 5)
 (def ^:const branch? #(let [result (= 0 (rand-int (+ % branching-factor)))]
                         (log/debug (str "branch at: " % "? => " result))
                         result))
@@ -183,6 +184,8 @@
          (grow
           (let [children
                 (cond
+                  (> depth max-depth) []
+
                   (= true (u/get-in child-spec [:phrasal]))
                   (child-trees)


more simplification

more simplification

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -73,10 +73,11 @@
   (mapfn #(let [bolt (assoc-in bolt path %)]
             (if (= false (get-in % [:phrasal]))
               [bolt]
-              (if truncate
-                (truncate
-                 (add-bolt-at top-bolt bolt path % model depth max-depth truncate? take-n) [path] model)
-                (add-bolt-at top-bolt bolt path % model depth max-depth truncate? take-n))))
+              (let [result
+                    (add-bolt-at top-bolt bolt path % model depth max-depth truncate? take-n)]
+                (if truncate
+                  (truncate result [path] model)
+                  result))))
          bolts-at))

 (defn add-comps


+(defn analyze [surface-form]): use model from babel.directory

--- src/babel/italiano.cljc
+++ src/babel/italiano.cljc
@@ -41,6 +41,9 @@
 (defn analyze
   "analyze a word: as opposed to parsing which is multi-word."
   ;; TODO: should take a language model, not a lexicon
+  ([surface-form]
+   (let [model @@(get babel.directory/models :it)]
+     (analyze surface-form model)))
   ([surface-form model]
    (morph/analyze surface-form (:lexicon model))))


It's a seq, not a vec

It's a seq, not a vec

--- src/caesium/binding.clj
+++ src/caesium/binding.clj
@@ -211,7 +211,7 @@
   the data in metadata-annotated form anyway (both to create the
   interface and to bind fns to vars).

-  This has to be a vec and not a map, because the same key (symbol,
+  This has to be a seq and not a map, because the same key (symbol,
   method name) might occur with multiple values (e.g. when binding the
   same char* fn with different JVM byte types)."
   (mapcat permuted-byte-types raw-bound-fns))


support --cake flag in eval

support --cake flag in eval

--- src/cake/tasks/eval.clj
+++ src/cake/tasks/eval.clj
@@ -16,9 +16,11 @@
 (deftask eval #{compile-java}
   "Eval the given forms in the project JVM."
   "Read a form from stdin for each - provided."
-  {forms :eval}
-  (bake [forms (map read-form forms)]
-        (eval `(do ~@forms))))
+  {forms :eval cake? :cake}
+  (if cake?
+    (eval `(do ~@(map read-form forms)))
+    (bake [forms (map read-form forms)]
+      (eval `(do ~@forms)))))

 (deftask filter #{compile-java}
   "Thread each line in stdin through the given forms, printing the results."


Improved docstrings.

Improved docstrings.

--- src/cats/core.cljc
+++ src/cats/core.cljc
@@ -209,20 +209,20 @@
     Let see one example for understand how it works, this is
     a code using bind for compose few number of operations:

-    (bind (just 1)
-    (fn [a]
-    (bind (just (inc a))
-    (fn [b]
-    (return (* b 2))))))
-    ;=> #<Just [4]>
+        (bind (just 1)
+        (fn [a]
+        (bind (just (inc a))
+        (fn [b]
+        (return (* b 2))))))
+        ;=> #<Just [4]>

     Now see how this code can be more clear if you
     are using mlet macro for do it:

-    (mlet [a (just 1)
-    b (just (inc a))]
-    (return (* b 2)))
-    ;=> #<Just [4]>
+        (mlet [a (just 1)
+        b (just (inc a))]
+        (return (* b 2)))
+        ;=> #<Just [4]>
     "
     [bindings & body]
     (when-not (and (vector? bindings)
@@ -243,16 +243,16 @@
     "Lifts a function with the given fixed number of arguments to a
     monadic context.

-    (def monad+ (lift-m 2 +))
-
-    (monad+ (maybe/just 1) (maybe/just 2))
-    ;; => <Just [3]>
-
-    (monad+ (maybe/just 1) (maybe/nothing))
-    ;; => <Nothing>
-
-    (monad+ [0 2 4] [1 2])
-    ;; => [1 2 3 4 5 6]
+        (def monad+ (lift-m 2 +))
+
+        (monad+ (maybe/just 1) (maybe/just 2))
+        ;; => <Just [3]>
+
+        (monad+ (maybe/just 1) (maybe/nothing))
+        ;; => <Nothing>
+
+        (monad+ [0 2 4] [1 2])
+        ;; => [1 2 3 4 5 6]
     "
     [n f]
     (let [val-syms (repeatedly n gensym)


Minor simplification.

Minor simplification.

--- src/exp/sahucs.clj
+++ src/exp/sahucs.clj
@@ -74,17 +74,17 @@

 (declare get-sa-node)
-(defn get-sanode-entry [cache state reward-to-state actions dijkstra? parent-cycle-level]
+(defn get-sanode-entry [cache state reward-to-state actions parent-cycle-level]
   (make-sanode-entry state
    (when (and (seq actions)
               (not (and parent-cycle-level
                         (when-let [b-level (hierarchy/cycle-level (first actions) state)]
                           (assert (<= b-level parent-cycle-level))
                           (= b-level parent-cycle-level)))))
-     (get-sa-node cache state (first actions) dijkstra?))
+     (get-sa-node cache state (first actions)))
    reward-to-state actions))

-(defn get-sa-node [#^HashMap cache s a dijkstra?]
+(defn get-sa-node [#^HashMap cache s a]
   "Create a new sa-node, or returned the cached copy if it exists."
   (let [context (env/precondition-context a s)]
     (util/cache-with cache [(env/action-name a) (env/extract-context s context)]
@@ -123,14 +123,14 @@
                       (doseq [ref (hierarchy/immediate-refinements (first b-ra) b-s)]
 ;                        (println (map env/action-name ref) (map env/action-name b-ra))
                         (queues/pq-add! (:queue node)
-                                        (get-sanode-entry cache b-s b-rts (concat ref (next b-ra)) dijkstra? cycle-level)
+                                        (get-sanode-entry cache b-s b-rts (concat ref (next b-ra)) cycle-level)
                                         (- b-rts)))
                       (queues/g-pq-remove!  (:queue node) entry)
                       (recur new-results))
                 :else          ;; Normal intermediate node.
                   (let [rec (expand-sa-node b-sa cache rec-next-best b-s b-rts (- 0 neg-reward b-rts) dijkstra?)]
                     (doseq [[ss sr] (:result-map rec)]
-                      (queues/g-pq-add! (:queue node) (get-sanode-entry cache ss sr (next b-ra) dijkstra? cycle-level) (- sr)))
+                      (queues/g-pq-add! (:queue node) (get-sanode-entry cache ss sr (next b-ra) cycle-level) (- sr)))
                     (if (> (:cutoff rec) Double/NEGATIVE_INFINITY)
                       (queues/g-pq-replace! (:queue node) entry (- 0 b-rts (:cutoff rec)))
                       (queues/g-pq-remove!  (:queue node) entry))
@@ -146,7 +146,7 @@
   (let [e     (hierarchy/env henv)
         cache (HashMap.)
         init  (env/initial-state e)
-        root  (get-sa-node cache init (hierarchy/TopLevelAction e [(hierarchy/initial-plan henv)]) dijkstra?)]
+        root  (get-sa-node cache init (hierarchy/TopLevelAction e [(hierarchy/initial-plan henv)]))]
     (loop [cutoff 0 last-cutoff 0]
       (let [result (expand-sa-node root cache cutoff init 0.0 last-cutoff dijkstra?)]
         (cond (not (empty? (:result-map result)))


specify {:reflexive false}

specify {:reflexive false}

--- test/babel/test/en.cljc
+++ test/babel/test/en.cljc
@@ -205,6 +205,7 @@

 (deftest in-front-of
   (let [expr (generate {:synsem {:cat :prep
+                                 :reflexive false
                                  :sem {:pred :in-front-of
                                        :obj {:pred :table
                                              :mod '()


add to compare generated files

add to compare generated files

--- test/cljam/t_sorter.clj
+++ test/cljam/t_sorter.clj
@@ -13,6 +13,12 @@

 (def tmp-shuffled-sam-file (str temp-dir "/" "tmp.shuffled.sam"))
 (def tmp-shuffled-bam-file (str temp-dir "/" "tmp.shuffled.bam"))
+
+(def tmp-coordinate-sorted-sam-file-2 (str temp-dir "/" "tmp.coordinate.sorted.2.sam"))
+(def tmp-coordinate-sorted-bam-file-2 (str temp-dir "/" "tmp.coordinate.sorted.2.bam"))
+
+(def tmp-queryname-sorted-sam-file-2 (str temp-dir "/" "tmp.queryname.sorted.2.sam"))
+(def tmp-queryname-sorted-bam-file-2 (str temp-dir "/" "tmp.queryname.sorted.2.bam"))

 (defn- prepare-shuffled-files!
   []
@@ -54,20 +60,29 @@
         (with-reader sorter/sort-order tmp-queryname-sorted-sam-file) =future=> sorter/order-queryname
         (with-reader sorter/sort-order tmp-queryname-sorted-bam-file) =future=> sorter/order-queryname
         ;; tests by shuffled files (its may sorted by chance)
-        (with-reader sorter/sort-by-pos tmp-shuffled-sam-file tmp-coordinate-sorted-sam-file) => anything
-        (with-reader sorter/sort-by-pos tmp-shuffled-bam-file tmp-coordinate-sorted-bam-file) => anything
-        (with-reader sorter/sort-by-qname tmp-shuffled-sam-file tmp-coordinate-sorted-sam-file) =future=> anything
-        (with-reader sorter/sort-by-qname tmp-shuffled-bam-file tmp-coordinate-sorted-bam-file) =future=> anything
+        (with-reader sorter/sort-by-pos tmp-shuffled-sam-file tmp-coordinate-sorted-sam-file-2) => anything
+        (with-reader sorter/sort-by-pos tmp-shuffled-bam-file tmp-coordinate-sorted-bam-file-2) => anything
+        (with-reader sorter/sort-by-qname tmp-shuffled-sam-file tmp-coordinate-sorted-sam-file-2) =future=> anything
+        (with-reader sorter/sort-by-qname tmp-shuffled-bam-file tmp-coordinate-sorted-bam-file-2) =future=> anything
         (with-reader sorter/sorted-by? tmp-shuffled-sam-file) => anything
         (with-reader sorter/sorted-by? tmp-shuffled-bam-file) => anything
-        (with-reader sorter/sorted-by? tmp-coordinate-sorted-sam-file) => truthy
-        (with-reader sorter/sorted-by? tmp-coordinate-sorted-bam-file) => truthy
-        (with-reader sorter/sorted-by? tmp-queryname-sorted-sam-file) =future=> truthy
-        (with-reader sorter/sorted-by? tmp-queryname-sorted-bam-file) =future=> truthy
+        (with-reader sorter/sorted-by? tmp-coordinate-sorted-sam-file-2) => truthy
+        (with-reader sorter/sorted-by? tmp-coordinate-sorted-bam-file-2) => truthy
+        (with-reader sorter/sorted-by? tmp-queryname-sorted-sam-file-2) =future=> truthy
+        (with-reader sorter/sorted-by? tmp-queryname-sorted-bam-file-2) =future=> truthy
         (with-reader sorter/sort-order tmp-shuffled-sam-file) => #(#{:queryname :coordinate :unsorted :unknown} %)
         (with-reader sorter/sort-order tmp-shuffled-bam-file) => #(#{:queryname :coordinate :unsorted :unknown} %)
-        (with-reader sorter/sort-order tmp-coordinate-sorted-sam-file) => sorter/order-coordinate
-        (with-reader sorter/sort-order tmp-coordinate-sorted-bam-file) => sorter/order-coordinate
-        (with-reader sorter/sort-order tmp-queryname-sorted-sam-file) =future=> sorter/order-queryname
-        (with-reader sorter/sort-order tmp-queryname-sorted-bam-file) =future=> sorter/order-queryname
+        (with-reader sorter/sort-order tmp-coordinate-sorted-sam-file-2) => sorter/order-coordinate
+        (with-reader sorter/sort-order tmp-coordinate-sorted-bam-file-2) => sorter/order-coordinate
+        (with-reader sorter/sort-order tmp-queryname-sorted-sam-file-2) =future=> sorter/order-queryname
+        (with-reader sorter/sort-order tmp-queryname-sorted-bam-file-2) =future=> sorter/order-queryname
+        ;; compare generated files
+        (= (slurp tmp-coordinate-sorted-sam-file)
+           (slurp tmp-coordinate-sorted-sam-file-2)) => truthy
+        (= (slurp tmp-coordinate-sorted-bam-file)
+           (slurp tmp-coordinate-sorted-bam-file-2)) => truthy
+        (= (slurp tmp-queryname-sorted-sam-file)
+           (slurp tmp-queryname-sorted-sam-file-2)) =future=> truthy
+        (= (slurp tmp-queryname-sorted-bam-file)
+           (slurp tmp-queryname-sorted-bam-file-2)) =future=> truthy
         ))


added a type-inferrence implicit (a variant is useful in latte-sets)

--- src/latte/core.clj
+++ src/latte/core.clj
@@ -624,6 +624,11 @@
                           :body (s/* any?)))

+(defimplicit the-type-of
+  "Replaces the provided term by its inferred type."
+  [def-env ctx [term typ]]
+  typ)
+
 (defmacro defimplicit*
   [& args]
   (let [conf-form (s/conform ::implicit* args)]
@@ -732,7 +737,7 @@
 ;;}

 (defmacro type-of
-  "Give the type of a term `t` in a context at the top-levle.
+  "Give the type of a term `t` in a context at the top-level.
   To only parse the term use [[term]]."
   [& args]
   (let [def-env defenv/empty-env


deal with multiple positions for Metadata versions 8 and 10

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@7205 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- plugins/DataBrowser/src/org/micromanager/browser/core.clj
+++ plugins/DataBrowser/src/org/micromanager/browser/core.clj
@@ -244,7 +244,10 @@
         {"Comment" (get-in d+c ["Comments" "Summary"])
          "FrameComments" (dissoc (get d+c "Comments") "Summary")})
       (let [data-dir (File. data-set)
-            path (if (pos? (get raw-summary-map "Positions"))
+            position-count (get raw-summary-map "Positions")
+            position (get raw-summary-map "Position")
+            path (if (or (not (empty? position))
+                         (and position-count (pos? position-count)))
                    (get-file-parent data-dir)
                    (.getAbsolutePath data-dir))]
         {"Path"     path
@@ -266,12 +269,11 @@
                 (try
                   (Thread/sleep 5)
                   (let [location (.take pending-locations)]
-                    (if-not (= location pending-locations)
-                      (do (doseq [data-set (find-data-sets location)]
-                           ; (println "data-set:" data-set)
-                            (.put pending-data-sets [data-set location]))
-                          (recur))
-                    nil))
+                    (when-not (= location pending-locations)
+                      (doseq [data-set (find-data-sets location)]
+                       ; (println "data-set:" data-set)
+                        (.put pending-data-sets [data-set location]))
+                        (recur)))
                   (catch Exception e nil)))))
           "data browser scanning thread") .start))


fix vec create

fix vec create

--- src/neuseg/dbn.clj
+++ src/neuseg/dbn.clj
@@ -1,6 +1,7 @@
 (ns neuseg.dbn
   (:use [clojure.core.matrix :only [set-current-implementation new-vector]])
-  (:import (com.guokr.dbn DBN)))
+  (:import (com.guokr.dbn DBN)
+           (mikera.vectorz Vectorz)))

 (set-current-implementation :vectorz)

@@ -8,7 +9,7 @@
   (/ (+ 1 val) 2))

 (defn- vectorize [line dim]
-  (new-vector (map #(normalize (Double. %)) (clojure.string/split line #" ")) dim))
+  (Vectorz/create (double-array (map #(normalize (Double. %)) (clojure.string/split line #" ")))))

 (defn create [layers]
   (DBN. (int-array layers)))


Fixed environment variables lookup for Jelastic.

--- src/notes/paas.clj
+++ src/notes/paas.clj
@@ -34,12 +34,12 @@
 ;-- Jelastic

 (defn is-jelastic? []
-  (= "jelastic" (str (System/getenv "environment"))))
+  (= "jelastic" (str (System/getProperty "environment"))))

 (defn jelastic-uri [uid pwd]
   "Get Jelastic MongoDB URI. 'uid' and 'pwd' are ignored, defined in
   jelastic environemnt configuration file."
-  (str (System/getenv "mongo_url")))
+  (str (System/getProperty "mongo_url")))

 ;-- Heroku


Use timestamp for author entry on entry import.

--- src/oc/storage/util/import.clj
+++ src/oc/storage/util/import.clj
@@ -60,10 +60,13 @@
         timestamp (:created-at entry)
         slug (:topic-slug entry)
         entry-author (or (first (:author entry)) author)
-        author (assoc entry-author :teams [(:team-id org)])]
+        author (assoc entry-author :teams [(:team-id org)])
+        entry (entry/->entry conn board-uuid slug entry author)
+        entry-author (first (:author entry))
+        fixed-timestamp-author (assoc entry-author :updated-at timestamp)
+        fixed-entry (assoc entry :author [fixed-timestamp-author])]
     (println (str "Creating entry for " slug " topic at " timestamp " on board '" (:name board) "'"))
-    (db-common/create-resource conn entry/table-name
-      (entry/->entry conn board-uuid slug entry author) timestamp)))
+    (db-common/create-resource conn entry/table-name fixed-entry timestamp)))

 (defn- import-board [conn org board author]
   (println (str "Creating board '" (:name board) "'."))


Removing debug print.

Removing debug print.

--- src/overtone/gui/pianoroll.clj
+++ src/overtone/gui/pianoroll.clj
@@ -145,7 +145,6 @@

         (doseq [[x y] (keys notes)]
           (when (= x index)
-            (print "inst: " (+ offset y))
             (at (metro beat) (inst (+ offset y)))))

         (apply-at (metro next-beat) #'piano-player


Fixed formatting and null pointer exception.

--- src/overtunes/songs/before.clj
+++ src/overtunes/songs/before.clj
@@ -101,15 +101,11 @@
   )
 )

-(defn n-times [n items]
-  (flatten (repeat n items))
-)
+(defn n-times [n items] (flatten (repeat n items)))

-(defn play [chords metro] (
-  ( do
-    (play-melody (n-times (/ (count chords) 2.5) melody) metro (metro))
-    (play-progression (concat chords finish) metro (metro))
-  )
+(defn play [chords metro] ( do
+  (play-melody (n-times (/ (count chords) 2.5) melody) metro (metro))
+  (play-progression (concat chords finish) metro (metro))
 ))

 (defn full-version [] (play (concat start middle start middle variation) metro))


Add a way to sneak a :key or :ref arg through quiescent.

Use a map as a second arg with keys :react/key or :react/ref.

--- src/quiescent.cljs
+++ src/quiescent.cljs
@@ -64,7 +64,12 @@
                  (q/set-prop! -componentWillUnmount (:componentWillUnmount m)))
         react-component (.createClass js/React react-map)
         q-wrapper (fn [value & static-args]
-                    (react-component #js {:value value :statics static-args}))]
+                    (let [props #js {:value value :statics static-args}]
+                      (when-let [key (get (first static-args) :react/key)]
+                        (aset props "key" key))
+                      (when-let [ref (get (first static-args) :react/ref)]
+                        (aset props "ref" ref))
+                      (react-component props)))]
     (when-let [displayName (.-displayName react-map)]
       (set! (.-displayName q-wrapper) displayName))
     (when-let [example (:exampleArg m)]


80-character fix

80-character fix

--- src/clj_http/client.clj
+++ src/clj_http/client.clj
@@ -63,7 +63,8 @@
   (apply (ns-resolve (symbol "cheshire.core") (symbol "decode")) args))

 (defn ^:dynamic json-decode-strict
-  "Resolve and apply cheshire's json decoding dynamically (with lazy parsing disabled)."
+  "Resolve and apply cheshire's json decoding dynamically (with lazy parsing
+  disabled)."
   [& args]
   {:pre [json-enabled?]}
   (apply (ns-resolve (symbol "cheshire.core") (symbol "decode-strict")) args))


Eliminate a few more reflection warnings

--- src/clj_http/client.clj
+++ src/clj_http/client.clj
@@ -253,17 +253,15 @@
   Apache Entity. Currently supports Strings, Files, InputStreams
   and byte-arrays."
   [client]
-  (fn [{:keys [body body-encoding length] :as req}]
+  (fn [{:keys [body body-encoding length] :or {^String body-encoding "UTF-8"} :as req}]
     (if body
       (cond
        (string? body)
-       (client (-> req (assoc :body (StringEntity. body (or body-encoding
-                                                            "UTF-8"))
+       (client (-> req (assoc :body (StringEntity. ^String body ^String body-encoding)
                               :character-encoding (or body-encoding
                                                       "UTF-8"))))
        (instance? File body)
-       (client (-> req (assoc :body (FileEntity. body (or body-encoding
-                                                          "UTF-8")))))
+       (client (-> req (assoc :body (FileEntity. ^File body ^String body-encoding))))

        ;; A length of -1 instructs HttpClient to use chunked encoding.
        (instance? InputStream body)


another ^not-native type-hint, perf boost for IndexedSeq case (normal invocation) and apply case when given given IndexedSeq

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -1742,7 +1742,7 @@
                       (.push arr (-first xs))
                       (recur (-next xs)))
                     arr))))]
-    (loop [i (alength arr) r ()]
+    (loop [i (alength arr) ^not-native r ()]
       (if (> i 0)
         (recur (dec i) (-conj r (aget arr (dec i))))
         r))))


* src/cljs/cljs/core.cljs: 20 args + rest

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -113,8 +113,7 @@
     [this a b c d e f g h i j k l m n o p q]
     [this a b c d e f g h i j k l m n o p q s]
     [this a b c d e f g h i j k l m n o p q s t]
-    [this a b c d e f g h i j k l m n o p q s t u]
-    [this a b c d e f g h i j k l m n o p q s t u rest]))
+    [this a b c d e f g h i j k l m n o p q s t rest]))

 (defprotocol ICounted
   (-count [coll] "constant time count"))


update index descriptions

update index descriptions

--- src/cljsbin/routes.cljs
+++ src/cljsbin/routes.cljs
@@ -53,10 +53,12 @@
           [:ul (map render-endpoint (second routes))]
           [:h2#DESCRIPTION "DESCRIPTION"]
           [:p
-           "Testing an HTTP Library can become difficult sometimes. "
-           [:a {:href "http://requestb.in"} "RequestBin"]
-           " is fantastic for testing POST requests, but doesn't let you control the response. This exists to cover all kinds of HTTP scenarios. Additional endpoints are being considered."]
-          [:p "All endpoint responses are JSON-encoded."]
+           "cljsbin is a ClojureScript clone of "
+           [:a {:href "https://httpbin.org"} "httpbin"]
+           " that runs on Node.js. It provides an API to test common HTTP features and operations (request methods, headers, redirects, etc.)."]
+          [:p "cljsbin is implemented using the "
+           [:a {:href "https://github.com/macchiato-framework/"} "Macchiato web framework"]
+           " for ClojureScript."]
           [:h2#EXAMPLES "EXAMPLES"]
           [:h3#-curl-http-cljsbin-org-ip "$ curl http://cljsbin.org/ip"]
           [:pre [:code "{\"origin\": \"24.127.96.129\"}\n"]]
@@ -68,9 +70,9 @@
           [:pre [:code "HTTP/1.1 418 I'M A TEAPOT\nServer: nginx/0.7.67\nDate: Mon, 13 Jun 2011 04:25:38 GMT\nConnection: close\nx-more-info: http://tools.ietf.org/html/rfc2324\nContent-Length: 135\n"]]
           [:h3#-curl-https-httpbin-org-get-show_env-1 "$ curl https://cljsbin.org/get?show_env=1"]
           [:pre [:code "{\n  \"headers\": {\n    \"Content-Length\": \"\",\n    \"Accept-Language\": \"en-US,en;q=0.8\",\n    \"Accept-Encoding\": \"gzip,deflate,sdch\",\n    \"X-Forwarded-Port\": \"443\",\n    \"X-Forwarded-For\": \"109.60.101.240\",\n    \"Host\": \"cljsbin.org\",\n    \"Accept\": \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n    \"User-Agent\": \"Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.83 Safari/535.11\",\n    \"X-Request-Start\": \"1350053933441\",\n    \"Accept-Charset\": \"ISO-8859-1,utf-8;q=0.7,*;q=0.3\",\n    \"Connection\": \"keep-alive\",\n    \"X-Forwarded-Proto\": \"https\",\n    \"Cookie\": \"_gauges_unique_day=1; _gauges_unique_month=1; _gauges_unique_year=1; _gauges_unique=1; _gauges_unique_hour=1\",\n    \"Content-Type\": \"\"\n  },\n  \"args\": {\n    \"show_env\": \"1\"\n  },\n  \"origin\": \"109.60.101.240\",\n  \"url\": \"http://cljsbin.org/get?show_env=1\"\n}\n"]]
-          ;; [:h2#Installing-and-running-from-PyPI "Installing and running from GitHub"]
-          ;; [:p "You can install httpbin as a library from PyPI and run it as a WSGI app.  For example, using Gunicorn:"]
-          ;; [:pre [:code.bash "$ pip install httpbin\n$ gunicorn httpbin:app\n"]]
+          [:h2#Installing-and-running "Installing and running from GitHub"]
+          [:p "You can install httpbin from the source at GitHub and run it with leiningen and node:"]
+          [:pre [:code.bash "$ git clone git@github.com:facundoolano/cljsbin.git .\n$ lein package\n$ npm start\n"]]
           [:h2#AUTHOR "AUTHOR"]
           [:p "Implemented by " [:a {:href "http://github.com/facundoolano"} "Facundo Olano"]" based on " [:a {:href "https://httpbin.org"} "httpbin.org"]  "."]
           [:h2#SEE-ALSO "SEE ALSO"]


Fix argument name.

Fix argument name.

--- src/cljx/quil/core.cljx
+++ src/cljx/quil/core.cljx
@@ -2788,10 +2788,10 @@
    (.-pixels img))

   #+cljs
-  ([proc]
-   (.loadPixels proc)
-   (let [pix-array (.toArray (.-pixels proc))]
-     (set! (.-stored-pix-array proc) pix-array)
+  ([img]
+   (.loadPixels img)
+   (let [pix-array (.toArray (.-pixels img))]
+     (set! (.-stored-pix-array img) pix-array)
      pix-array)))

 (defn
@@ -4365,11 +4365,11 @@
   #+clj ([^PImage img] (.updatePixels img))

   #+cljs
-  ([proc]
-   (when-let [pix-array (.-stored-pix-array proc)]
-     (.set (.-pixels proc) pix-array)
-     (set! (.-stored-pix-array proc) nil))
-   (.updatePixels proc)))
+  ([img]
+   (when-let [pix-array (.-stored-pix-array img)]
+     (.set (.-pixels img) pix-array)
+     (set! (.-stored-pix-array img) nil))
+   (.updatePixels img)))

 (defn
   ^{:requires-bindings true


Fixed issue #36: Add support for displaying special error page with error description.

--- src/clouseau/server.clj
+++ src/clouseau/server.clj
@@ -228,6 +228,25 @@
         [:div {:class "alert alert-danger"} "Not found"]
         [:div {:class "alert alert-success"} description]))

+(defn render-error-page
+    "Render error page with a 'back' button."
+    [package user-name message]
+    (page/xhtml
+        (render-html-header "")
+        [:body
+            [:div {:class "container"}
+                (render-navigation-bar-section package user-name)
+                [:div {:class "col-md-10"}
+                    [:h2 "Sorry, error occured in Clouseau"]
+                    [:p message]
+                    [:button {:class "btn btn-primary" :onclick "window.history.back()" :type "button"} "Back"]
+                ]
+                [:br][:br][:br][:br]
+                (render-footer)
+            ] ; </div class="container">
+        ] ; </body>
+    ))
+
 (defn package?
     [package]
     (and package (not (empty? package))))


For #77 eliminate debug printing

For #77 eliminate debug printing

--- Clojure/src/ambly/repl/jsc.clj
+++ Clojure/src/ambly/repl/jsc.clj
@@ -372,8 +372,7 @@
          (string? endpoint-address) (number? endpoint-port)]}
   (let [webdav-mount-point (str "/Volumes/Ambly-" (format "%08X" (hash bonjour-name)))
         output-dir (io/file webdav-mount-point)
-        webdav-endpoint (create-http-url endpoint-address endpoint-port)
-        _ (println webdav-endpoint)]
+        webdav-endpoint (create-http-url endpoint-address endpoint-port)]
     (when-not (umount-webdav webdav-mount-point)
       (throw (IOException. (str "Unable to unmount previous WebDAV mount at " webdav-mount-point))))
     (loop [tries 1]


factor out update functions, types in data-structures, value functions.

--- src/databinder/core.clj
+++ src/databinder/core.clj
@@ -49,105 +49,76 @@

 (defn uuid [] (str "urn:uuid:" (java.util.UUID/randomUUID)))

-(def db (uris "http://logangilmour.com/data-binder#" :rank :root :binds :bindo  :haschild :contains :projects :path))
+(def db (uris "http://logangilmour.com/data-binder#" :rank :root :binds :bindo  :haschild :container :relator :contains :projects :path))

 (def funcs
   {:projector
-   {:resource (fn [uri binding active url meta vals]
-                (let [s (apply str vals)]
-                  (hic/html [:li  {:class (if active "active" "")
-
-                                   :data-uri uri}
-                             [:a.projector-binding {
-                                                    :href url
-                                                    :data-uri uri
-                                      :data-binding binding
-                                      } (if (re-matches #"^\s*$" s) "untitled" s)]])))
-    :value (fn [parent uri binding meta val]
-             uri)
-    :update nil
-    :type :relator}
+   (fn [uri binding active url meta vals]
+     (let [s (apply str vals)]
+       (hic/html [:li  {:class (if active "active" "")
+
+                        :data-uri uri}
+                  [:a.projector-binding {
+                                         :href url
+                                         :data-uri uri
+                                         :data-binding binding
+                                         } (if (re-matches #"^\s*$" s) "untitled" s)]])))
    :column8
-   {:display (fn [meta vals]
-               (hic/html [:div.span8 vals]))
-    :type :container}
+   (fn [uri binding active url meta vals]
+     (hic/html [:div.span8 vals]))
+
    :column4
-   {:display (fn [meta vals]
-               (hic/html [:div.span4 vals]))
-    :type :container}
+   (fn [uri binding active url meta vals]
+     (hic/html [:div.span4 vals]))
    :row
-   {:display (fn [meta vals]
-               (hic/html [:div.row vals]))
-    :type :container}
+   (fn [uri binding active url meta vals]
+     (hic/html [:div.row vals]))

    :list
-   {:resource (fn [uri binding active url meta vals]
-                (hic/html
-                          [:ul {:class "list-binding nav nav-list"
-                                             :data-uri uri
-                                :data-binding binding
-                                :data-description (:description meta)}
-                           [:li.nav-header (:title meta)]
-                           vals]
-                          [:a
-                           {:href "#"
-                            :class "list-add-binding btn"
-                            :data-uri uri
-                            :data-binding binding} "Create"]))
-    :value (fn [parent uri binding meta val]
-             (hic/html val))
-
-    :update (fn [uri pred data]
-              {:type "create" :uri uri :predicate pred :value (uuid)})
-    :type :relator}
+   (fn [uri binding active url meta vals]
+     (hic/html
+      [:ul {:class "list-binding nav nav-list"
+            :data-uri uri
+            :data-binding binding
+            :data-description (:description meta)}
+       [:li.nav-header (:title meta)]
+       vals]
+      [:a
+       {:href "#"
+        :class "list-add-binding btn"
+        :data-uri uri
+        :data-binding binding} "Create"]))

    :deleter
-   {:resource (fn [uri binding active url meta vals]
-                (hic/html [:a.remove-binding
-                                 {:href "#"
-                                  :data-uri uri
-                                  :data-binding binding
-                                  :data-value (apply str vals)} (:title meta)]))
-    :value (fn [parent uri binding meta val]
-             val)
-
-    :update (fn [uri pred data]
-              {:type "delete" :uri uri :predicate pred :value data})
-    :type :relator}
+   (fn [uri binding active url meta vals]
+     (hic/html [:a.remove-binding
+                {:href "#"
+                 :data-uri uri
+                 :data-binding binding
+                 :data-value (apply str vals)} (:title meta)]))

    :paragraph
-   {:resource (fn [uri binding active url meta vals]
-                (hic/html [:p {:data-uri uri
-                       :data-binding binding
-                       :data-description (:description meta)}
-                   (:title meta) ": " vals]))
-    :value (fn [parent uri binding meta val]
-             (hic/html val))
-    :update nil
-    :type :relator}
+   (fn [uri binding active url meta vals]
+     (hic/html [:p {:data-uri uri
+                    :data-binding binding
+                    :data-description (:description meta)}
+                (:title meta) ": " vals]))

    :text-field
-   {:resource (fn [uri binding active url meta vals]
-                (hic/html [:label (str (:title meta) " ")
-                   [:input {:type "text"
-                            :class "text-field-binding"
-                            :data-uri uri
-                            :data-binding binding
-                            :data-description (:description meta)
-                            :value (apply str vals)}]]))
-    :value (fn [parent uri binding meta val]
-             (hic/html val))
-    :update (fn [uri pred data]
-              {:type "update" :uri uri :predicate pred :value data})
-    :type :relator}
+   (fn [uri binding active url meta vals]
+     (hic/html [:label (str (:title meta) " ")
+                [:input {:type "text"
+                         :class "text-field-binding"
+                         :data-uri uri
+                         :data-binding binding
+                         :data-description (:description meta)
+                         :value (apply str vals)}]]))
+
    :h1
-   {:display (fn [meta vals]
-               (hic/html [:h1 vals]))
-    :type :container}})
-
-(def functions (apply assoc {} (flatten (map (fn [key] [(str "http://logangilmour.com/data-binder#" (name key)) (get funcs key)]) (keys funcs)))))
-
-(merge db (apply uris "http://logangilmour.com/data-binder#" (keys funcs)))
+   (fn [uri binding active url meta vals]
+     (hic/html [:h1 vals]))})
+
+(def functions (apply assoc {} (flatten (map (fn [key] [(str "http://logangilmour.com/bootstrap-widgets#" (name key)) (get funcs key)]) (keys funcs)))))

 (defn relator [statement model resource]
@@ -165,12 +136,6 @@

 ;;TODO projectors url should bind itself some stuff so it knows its unique values and its name

-(defn bound-func [binding model]
-  (get functions
-       (.getURI
-        (.getObject
-         (.getProperty model binding (prop "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))))))
-
 (defn literalize [res]
   (if (.isLiteral res)
     (.getString (.asLiteral res))
@@ -261,7 +226,7 @@

 (defn parse-uri [uri]
   (let [parts (filter (comp not (partial re-matches #"^\s*$")) (clojure.string/split uri #"/"))]
-    (println "'" uri"'\n\n\n!!!!!!!\n\n\n\n" parts)
+
     (if (empty? parts)
      {}
      (apply assoc {} parts))))
@@ -278,66 +243,54 @@
                            (relate-right model (prop (:haschild db)) binding)))

         projector (first (relate-left model (prop (:projects db)) binding)) ;;TODO only works for container pointed at by projector for now.
-        path (and projector (first (relate-right model (prop (:path db)) projector)))
-
-        bindable (bound-func binding model)
-
-        type (:type bindable)
+        path (if projector (first (relate-right model (prop (:path db)) projector)))
+
+        bindable (first (relate-right model (prop "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") binding))
+
+        types (set (map #(.toString %) (relate-right model (prop "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") binding)))
+
+        func (reduce (fn [accum val] (or accum (get functions val))) nil types)

         new-url-parts (if path
                   (conj url-parts (.getString (.asLiteral path)))
                   url-parts)

         sub-calls (map (fn [child] (s-rec child model url-parts)) children) ;; make the next part of the tree
-        meta-data (get-meta-data binding model)]
+        meta-data (get-meta-data binding model)
+        myp (first (relate-right model (prop (:path db)) binding))
+        mypath (if myp (.getString (.asLiteral myp)))]

     (cond
-          (= type :relator)
-
-          (let [statement (get-bound binding model) ;; fuckery for binding
-                relation-getter (fn [data resource] (relator statement data resource))
-                child-func (:value bindable)
-                parent-func (:resource bindable)
-                myp (first (relate-right model (prop (:path db)) binding))
-                mypath (and myp (.getString (.asLiteral myp)))
-                ]
-            (fn [data child resource url built-url]
-
-              (let [related (if child   ;; get sub-resources (a single one if partial rendering)
-                              (seq [child])
-                              (relation-getter data resource))
-                    func (if child ;; get the bound function
-                           (fn [uri bind active url meta vals]
-                             (let [val (first vals)]
-                               (child-func
-                                uri (:uri val) bind meta (:html val))))
-                           (fn [uri bind active url meta vals]
-                             (parent-func
-                              uri bind active url meta
-                              (map (fn [val] (child-func
-                                             uri (:uri val) bind meta (:html val))) vals))))
-                    current (and mypath (get (parse-uri url) mypath))
-                    active (and mypath (= current (.getURI resource)))
-                    myurl (and mypath (str built-url mypath "/" (.getURI resource) "/")) ]
-                (func (.getURI resource) ;; apply the bound function to the thing, the binding that points at the funtion, meta-data, and the finished children (should be ordered by now).
-                      (.getURI binding)
-                      active
-                      (or myurl built-url)
-                      meta-data
-                      (map (fn [val] {:uri (first val) :html (second val)})
-                           (map vector
-                                (map #(.toString %) related) ;; TODO this is a little sketchy
-                                (if (empty? sub-calls)
-                                  (map literalize related)
-                                  (map seq (apply map vector (map (fn [sub-call]
-                                                                    (map
-                                                                     (fn [val] (sub-call data nil val url built-url))
-                                                                     related))
-                                                                  sub-calls))))))))))
-          (= type :container)
+     (contains? types (db :relator))
+
+     (let [statement (get-bound binding model) ;; fuckery for binding
+           relation-getter (fn [data resource] (relator statement data resource))]
+       (fn [data child resource url built-url]
+
+         (let [related (if child   ;; get sub-resources (a single one if partial rendering)
+                         (seq [child])
+                         (relation-getter data resource))
+               current (if mypath (get (parse-uri url) mypath))
+               active (if mypath (= current (.getURI resource)))
+               myurl (if mypath (str built-url mypath "/" (.getURI resource) "/"))
+               vals (if (empty? sub-calls)
+                   (map literalize related)
+                   (map seq (apply map vector (map (fn [sub-call]
+                                                     (map
+                                                      (fn [val] (sub-call data nil val url built-url))
+                                                      related))
+                                                   sub-calls))))]
+           (if child
+             (hic/html vals) ;;TODO extract this business... maybe?
+             (func (.getURI resource) ;; apply the bound function to the thing, the binding that points at the funtion, meta-data, and the finished children (should be ordered by now).
+                   (.getURI binding)
+                   active
+                   (or myurl built-url)
+                   meta-data
+                   vals)))))
+     (contains? types (db :container)) ;;TODO make it so we can project from a container.
           (fn [data child resource url built-url]
-            (let [func (:display bindable)
-                  ppath (and path (.getString (.asLiteral path)))
+            (let [ppath (if path (.getString (.asLiteral path)))
                   p (get (parse-uri url) ppath)
                   projected (if (and p (res p))
                               (if (.containsResource data (res p))
@@ -347,12 +300,20 @@
               (if ppath
                 (if projected
                   (func
+                   (.getURI resource)
+                   (.getURI binding)
+                   nil
+                   built-url
                    meta-data
                    (map (fn [sub-call] (sub-call data nil projected url (str built-url ppath "/" (.getURI resource) "/"))) sub-calls))
                   "")
                 (func
-                   meta-data
-                   (map (fn [sub-call] (sub-call data nil resource url built-url)) sub-calls))
+                 (.getURI resource)
+                 (.getURI binding)
+                 nil
+                 built-url
+                 meta-data
+                 (map (fn [sub-call] (sub-call data nil resource url built-url)) sub-calls))
                 ))))))

 (defn select [model subject predicate object]
@@ -384,47 +345,39 @@
                   (relate-right model (prop (:projects db)) binding))

         projector (first (relate-left model (prop (:projects db)) binding))
-        ppath (and projector (first (relate-left model (prop (:path db)) projector)))
-
-        bindable (bound-func binding model)
-
-        type (:type bindable)
+        ppath (if projector (first (relate-left model (prop (:path db)) projector)))
+
+        types (set (map #(.toString %) (relate-right model (prop "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") binding)))
+
         path (first (relate-right model (prop (:path db)) binding))
-        onpath (and path (get uri (.getString (.asLiteral path))))
+        onpath (if path (get uri (.getString (.asLiteral path))))

         subs
-        (if (= type :projector)
-          (if onpath
-            (map (fn [child] (qb child model uri)) children)
-            '())
-          (map (fn [child] (qb child model uri)) children))]
-
-    (cond (= type :relator)
-          (let [statement (get-bound binding model)
-
-                binder (.getURI (.getPredicate statement))
-                predicate (.asResource (.getObject statement))
-                reverse (= binder (db :binds))]
-            [{:pred (.getURI predicate) :rev reverse :type :relator} subs])
-
-          (= type :projector)
+        (if path
+         (if onpath
+           (map (fn [child] (qb child model uri)) children)
+           '())
+         (map (fn [child] (qb child model uri)) children))]
+    (println types "=" (db :container) " or " (db :relator))
+    (cond (contains? types (db :relator))
           (let [statement (get-bound binding model)
                 binder (.getURI (.getPredicate statement))
-                predicate (.asResource (.getObject statement))
+                predicate (.asResource (.getObject statement)) ;;TODO handle type thing with path thing
                 reverse (= binder (db :binds))]
-            [{:pred (.getURI predicate) :rev reverse :path onpath :type :projector} subs])
-
-          (= type :container)
-          subs
+            (println "got here 1")
+            [{:pred (.getURI predicate) :rev reverse :path onpath} subs])
+
+          (contains? types (db :container))
+          (do (println "got here 2")
+            subs)
           )))

-(defn qbuild [view-data uri]
-  (let [inf (. ModelFactory createRDFSModel view-data)
-            root (.asResource (.getObject (.getProperty inf
+(defn qbuild [inf uri]
+  (let [root (.asResource (.getObject (.getProperty inf
                                                         (res (:root db))
                                                         (prop (:haschild db)))))
         init (qb root inf uri)
@@ -488,8 +441,11 @@
         qm (new QuerySolutionMap)]
     (doall (map (fn [key] (.add qm (str key) (res (get vals key)))) (keys vals)))
     qm))
-(defn build-query [inf uri]
-  (let [query  (qbuild inf (parse-uri uri))
+
+(defn uni [] (. ModelFactory createRDFSModel (.union (to-model example-view) (to-model widgets))))
+(defn build-query [view-data widget-data uri]
+  (let [inf (. ModelFactory createRDFSModel (.union view-data widget-data))
+        query  (qbuild inf (parse-uri uri))
         qm (query-map query)
         s (str "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@@ -504,7 +460,7 @@
     (.add qm "root" (res "http://logangilmour.com/example-ontology#person"))  ;; TODO DIRTY DIRTY HACKS

     (let [done (.toString (new ParameterizedSparqlString s qm))]
-      ;;(println (render-query query false) "\n\n\n" (render-graph query) "\n\n\n" done)
+      (println (render-query query false) "\n\n\n" (render-graph query) "\n\n\n" done)
       (.execConstruct
        (. QueryExecutionFactory sparqlService
           "http://localhost:8000/sparql/"
@@ -569,10 +525,10 @@
           (iterator-seq (.listStatements inf nil (prop (:bindo db)) predicate))))

-(defn serializer
-  ([view-data]
-
-      (let [inf (. ModelFactory createRDFSModel view-data)
+(defn serializer ;;TODO make this build sub-serializers that work for sub-projections
+  ([view-data widget-data]
+
+     (let [inf (. ModelFactory createRDFSModel (.union view-data widget-data))
             root (.asResource (.getObject (.getProperty inf
                                                         (res (:root db))
                                                         (prop (:haschild db)))))]
@@ -580,20 +536,19 @@
         (fn [data resource uri]
           ((s-rec root inf []) data nil resource uri "/view/"))
         ))
-  ([view-data binding]
-
-      (let [inf (. ModelFactory createRDFSModel view-data)]
-
+  ([view-data widget-data binding]
+
+     (let [inf (. ModelFactory createRDFSModel (.union view-data widget-data))]
         (fn [data child resource uri] ((s-rec binding inf []) data child resource uri "/view/"))
         )))

-(defn syncer [inf]
+(defn syncer [inf widget-data]
   (fn [command url]

     (let [predicate (res (:predicate command))
           binders (get-all-bindings inf predicate)
           bindings (map #(.getSubject %) binders)
-          views (map (partial serializer inf) bindings)]
+          views (map (partial serializer inf widget-data) bindings)]

       (map (fn [binder]

@@ -605,8 +560,8 @@
                 (or (= (:type command) "update") (= (:type command) "create"))
                 (assoc command
                   :value
-                  ((serializer inf binding)
-                   (build-query inf url)
+                  ((serializer inf widget-data binding)
+                   (build-query inf widget-data url)
                    (if (= (:type command) "update")
                      (plit (:value command))
                      (res (:value command)))
@@ -625,20 +580,29 @@

       )))
+
+(defn commander [uri pred data type]
+  (cond (= type "update")
+        {:uri uri :predicate pred :value data :type type}
+        (= type "create")
+        {:uri uri :predicate pred :value (uuid) :type type}
+        (= type "delete")
+        {:urd uri :predicate pred :value data :type type}))
+
 (defn editor [inf]
   (fn [message]
     (let [uri (:uri message)
           binding (res (:binding message))
           data (:data message)
+          type (:type message)
           statement (get-bound binding inf)
-          func (:update (bound-func binding inf))
           binder (.getURI (.getPredicate statement))
           predicate (.asResource (.getObject statement))
           pred (.getURI predicate)
           resource (res uri) ;;TODO HERE make a serializer for each binding, then use them to populate action with html if this is an htmlable type thing. Consider moving to a pure update based strategy, as then we don't need javascript that's so complicated on the client side. We just regenerate any part of the view that's changed at any time. However, this means things like chat-rooms are not really viable.
           reverse (= binder (db :binds))
           ;;graph-store (. GraphStoreFactory create model)
-          command (func uri pred data)
+          command (commander uri pred data type)
           update (query-builder command reverse)]
       (doall (map (fn [up]
                     (client/post "http://localhost:8000/update/" {:form-params {:update up}})) update))
@@ -653,11 +617,12 @@
 @prefix ex: <http://logangilmour.com/example-view#> .
 @prefix ont: <http://logangilmour.com/example-ontology#> .
 @prefix dc: <http://purl.org/dc/elements/1.1/> .
+@prefix w: <http://logangilmour.com/bootstrap-widgets#> .

 data:root data:haschild ex:person-manager .

 ex:person-manager
-  rdf:type data:row ;
+  rdf:type w:row ;
   dc:title \"The Application\" ;
   dc:description \"Here we are\" ;
   data:haschild ex:person-list-container ;
@@ -665,18 +630,18 @@

 ex:person-list-container
   data:haschild ex:person-list ;
-  rdf:type data:column4 ;
+  rdf:type w:column4 ;
   data:rank 1 .

 ex:person-list
-  rdf:type data:list ;
+  rdf:type w:list ;
   data:binds rdf:type ;
   dc:title \"List of People\" ;
   dc:description \"A list of people contained within the application\" ;
   data:haschild ex:person-projector .

 ex:person-projector
-  rdf:type data:projector ;
+  rdf:type w:projector ;
   data:path \"test\" ;
   data:bindo ont:name ;
   dc:title \"select\" ;
@@ -684,14 +649,14 @@
   data:projects ex:person-container .

 ex:person-container
-  rdf:type data:column8 ;
+  rdf:type w:column8 ;
   dc:title \"Person\" ;
   dc:description \"A person\" ;
   data:rank 2 .

 ex:person-container data:haschild ex:person-name-container , ex:person-age , ex:pets-list ,  ex:person-deleter .

-ex:person-deleter rdf:type data:deleter ;
+ex:person-deleter rdf:type w:deleter ;
                   data:bindo rdf:type ;
                   dc:title \"Remove\" ;
                   dc:description \"Permanently delete a person from the database\" .
@@ -700,40 +665,50 @@
   data:haschild ex:person-name ;
   dc:title \"thing\" ;
   dc:description \"stuff\" ;
-  rdf:type data:h1 .
-
-ex:person-name rdf:type data:text-field ;
+  rdf:type w:h1 .
+
+ex:person-name rdf:type w:text-field ;
                data:rank 5 ;
                data:bindo ont:name ;
                dc:title \"Name\" ;
                dc:description \"The name of a person\" .

-ex:person-age rdf:type data:text-field ;
+ex:person-age rdf:type w:text-field ;
               data:rank 4 ;
               data:bindo ont:age ;
               dc:title \"Age\" ;
               dc:description \"The age of a person\".

-ex:pets-list rdf:type data:list ;
+ex:pets-list rdf:type w:list ;
              data:bindo ont:haspet ;
              dc:title \"Pets\" ;
              dc:description \"A list of the pets a person has\" .

 ")

-(def mini-view
+(def widgets
   "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 @prefix data: <http://logangilmour.com/data-binder#> .
-@prefix ex: <http://logangilmour.com/example-view#> .
-@prefix ont: <http://logangilmour.com/example-ontology#> .
-
-data:root data:haschild ex:person-name .
-
-ex:person-name rdf:type data:paragraph .
-
-ex:person-name data:bindo ont:name .
-
+@prefix w: <http://logangilmour.com/bootstrap-widgets#> .
+
+w:projector rdfs:subClassOf data:relator .
+
+w:column8 rdfs:subClassOf data:container .
+
+w:column4 rdfs:subClassOf data:container .
+
+w:row rdfs:subClassOf data:container .
+
+w:list rdfs:subClassOf data:relator .
+
+w:deleter rdfs:subClassOf data:relator .
+
+w:paragraph rdfs:subClassOf data:relator .
+
+w:text-field rdfs:subClassOf data:relator .
+
+w:h1 rdfs:subClassOf data:container .
 ")

 (def data-binder "
@@ -825,7 +800,7 @@

 (def broadcast-channel (permanent-channel))
 (def edit (editor (to-model example-view)))
-(def syn (syncer (to-model example-view)))
+(def syn (syncer (to-model example-view) (to-model widgets)))

 (def channels (atom {}))
@@ -863,7 +838,7 @@
 (defroutes main-routes
   (GET "/async/*" [] (wrap-aleph-handler chat-handler))
   (GET "/view/*" [*]
-       (page ((serializer (to-model example-view)) (build-query (to-model example-view) *) (res "http://logangilmour.com/example-ontology#person") *)))
+       (page ((serializer (to-model example-view) (to-model widgets)) (build-query (to-model example-view) (to-model widgets) *) (res "http://logangilmour.com/example-ontology#person") *)))
   (route/resources "/")
   (route/not-found "Page not found"))


set is more idiomatic than (into #{} ...)

--- src/desdemona/query.clj
+++ src/desdemona/query.clj
@@ -24,7 +24,7 @@
   [logic-query]
   (->> (flatten logic-query)
        (filter free-sym?)
-       (into #{})))
+       set))

 (defn ^:private generate-logic-query
   "Expands a query and events to a core.logic program that executes


Fix index.html content type

Fix index.html content type

--- src/fixthebuild/app.clj
+++ src/fixthebuild/app.clj
@@ -2,12 +2,13 @@
   (:require [integrant.core :as ig]
             [compojure.core :refer :all]
             [ring.middleware.defaults :refer :all]
-            [ring.util.response :refer [resource-response]]))
+            [ring.util.response :refer [header resource-response]]))

 (defroutes
   app
   (GET "/" []
-    (resource-response "index.html" {:root "public"})))
+    (-> (resource-response "index.html" {:root "public"})
+        (header "Content-Type" "text/html"))))

 (defn- make-handler []
   (wrap-defaults app site-defaults))


rough structure in place

rough structure in place

--- src/flo_invest/core.clj
+++ src/flo_invest/core.clj
@@ -20,6 +20,17 @@
                                                  "Income" :incomestatement
                                                  "Key" :keyratios} (parts 1))  :file f})))

+(defn- slurp-csv [type struct]
+(parse-csv (slurp ((first (clojure.set/select #(= (:type %) type) struct)) :file))))
+
+(defn- parse-income [income]
+  (for [line income
+        :when (= "Revenue" (first line))]
+    {:annual_sales (* 1e6 (Double/parseDouble (nth line (- (count line) 2) Double/NaN)))}))
+
+(defn- parse-balance [balance] {})
+(defn- parse-keyratios [keyratios] {})
+
 (defn load [file-data]
   (let [balance_dict  {"Total current assets" :current_assets
                        "Total current liabilities" :current_liabilities
@@ -41,10 +52,14 @@
                  :isin ((first file-data) :isin)
                  }
         file-data-set (set file-data)
-        income     (clojure.set/select #(= (:type %) :incomestatement) file-data-set)
-        balance     (clojure.set/select #(= (:type %) :balancesheet) file-data-set)
-        keyratios     (clojure.set/select #(= (:type %) :keyratios) file-data-set)
+        income (slurp-csv :incomestatement file-data-set)
+        balance (slurp-csv :balancesheet file-data-set)
+        keyratios (slurp-csv :keyratios file-data-set)
         ]
-
-    inputs
-  ))+    (apply merge (cons inputs
+                       (concat
+                       (parse-income income)
+                       (parse-balance balance)
+                       (parse-keyratios keyratios)
+                       )))
+    ))


Update tabular.clj

Update tabular.clj

--- src/grafter/tabular.clj
+++ src/grafter/tabular.clj
@@ -139,6 +139,8 @@
     (make-dataset filtered-rows
                   (column-names dataset))))

+;; This type hint is actually correct as APersistentVector implements .indexOf
+;; from java.util.List.
 (defn- col-position [^java.util.List column-names col]
   (if-let [canonical-col (resolve-col-id col column-names ::not-found)]
     (let [val (.indexOf column-names canonical-col)]


update

update

--- src/grafter/tabular.clj
+++ src/grafter/tabular.clj
@@ -285,19 +285,30 @@
         (make-dataset (column-names dataset)))))

+(defn swap
+"Takes two column names and swaps each column"
+
+  ([dataset first-col second-col]
+  (let [swapper (fn [v i j]
+                  (-> v
+                      (assoc i (v j))
+                      (assoc j (v i))))
+        data (:rows dataset)
+        header (column-names dataset)]
+    (-> header
+        (swapper (col-position header first-col)
+                 (col-position header second-col))
+        (make-dataset data))))
+  ([dataset first-col second-col & more]
+   (if (seq more)
+     (reduce (fn [ds [f s]]
+               (apply swap f s more)) (swap dataset first-col second-col)
+             more)
+     (swap dataset first-col second-col))
+   )
+  )
+
 (comment
-
-  (defn swap [csv col-map]
-    "Takes a map from column_id -> column_id (int -> int) and swaps each
-column."
-
-    (map (fn [row]
-           (reduce (fn swaper [acc [cola colb]]
-                     (-> row
-                         (assoc cola (row colb))
-                         (assoc colb (row cola))))
-                   [] col-map))
-         csv))

 (defn select-columns
   ([srange row]


Added optimization for type-hinted strings

--- src/hiccup/compiler.clj
+++ src/hiccup/compiler.clj
@@ -90,6 +90,12 @@
   (if-let [hint (-> x meta :tag)]
     (not (isa? (eval hint) type))))

+(defn- hint?
+  "True if x is hinted to be the supplied type."
+  [x type]
+  (if-let [hint (-> x meta :tag)]
+    (isa? (eval hint) type)))
+
 (defn- uneval?
   "True if x is an unevaluated form or symbol."
   [x]
@@ -154,4 +160,5 @@
     (cond
       (vector? c)  (compile-tag c)
       (literal? c) c
-      :else        `(render-html ~c))))
+      (hint? c String) c
+      :else `(render-html ~c))))


working with get and set from 3rd party client

--- src/poky/protocol/memcache.clj
+++ src/poky/protocol/memcache.clj
@@ -29,22 +29,15 @@

 ;get <key>*\r\n
 ;gets <key>*\r\n
-
-; this doesn't work as expected (for this protocol), because the last repeated element will also be
-; delimited.
-(defcodec KEYS (repeated (string :utf-8 :delimiters [" "])
-                         :delimiters ["\r\n" " "]))
-
 (defcodec GET ["get" CR])
 (defcodec GETS ["gets" CR])

-(defcodec VALUE ["VALUE" K V V CR CR])
-;VALUE <key> <flags> <bytes> [<cas unique>]\r\n
-;<data block>\r\n
-;...
+;VALUE <key> <flags> <bytes> [<cas unique>]\r\n<data block>\r\n
+;VALUE <key> <flags> <bytes>\r\n<data block>\r\n
+(defcodec VALUE ["VALUE" K V CR CR])

+;END\r\n
 (defcodec END ["END"])
-;END\r\n

 (defcodec ERRC CR)

@@ -53,21 +46,17 @@
   (println (format "body->h: '%s' '%s'" body (first body)))
   (first body))

-
-
 (defn h->b [hd]
   "Called when decoding. Determines how to construct the body."
   (println (format "header h->b: '%s'" hd))
     (case hd
-      "gets" GETS
-      "get"  GET
-      "set" SET
-      "VALUE" VALUE
+      "gets"   GETS
+      "get"    GET
+      "set"    SET
+      "VALUE"  VALUE
       "STORED" STORED
-      "END" END
+      "END"    END
           ERRC))
-
-

 (defn b->h
   "Called when encoding. Determines the header that is generated."
@@ -75,13 +64,9 @@
   (println (format "b->h '%s'" body))
   (first body))

-(defn memcache-pre-encode [req]
-  (println (format "memcache-pre-encode '%s'" req))
-  req)
+(defn memcache-pre-encode [req] req)

-(defn memcache-post-decode [res]
-  (println (format "memcache-post-decode '%s'" res))
-  res)
+(defn memcache-post-decode [res] res)

 (defcodec MEMCACHE (compile-frame
                      (header CMD h->b b->h)
@@ -110,23 +95,19 @@
 (defn cmd-gets-keys [decoded]
   (clojure.string/split (first (rest decoded)) #" "))

-(defn debug-response [ch msg r]
-  (do
-    (println msg r)
-    (map #(enqueue ch %) r)))

-(defn test-handle [ch ci cmd]
+(defn memcache [ch ci cmd]
     (println "Processing command: " (first cmd) " from " ci)
     (condp = (first cmd)
-      "SET" (enqueue ch ["STORED"])
-      "GET" (do (enqueue ch ["VALUE" "abc" "123"]) (enqueue ch ["END" ""]))
-      "GETS" (do (enqueue ch ["VALUE" "abc" "123"]) (enqueue ch ["END" ""]))
+      "set" (enqueue ch ["STORED"])
+      "get" (do (enqueue ch ["VALUE" "abc" "0" "3" "123"]) (enqueue ch ["END"]))
+      "gets" (do (enqueue ch ["VALUE" "abc" "0" "3" "123"]) (enqueue ch ["END"]))
       (enqueue ch "error")))

 (defn handler
   [ch ci]
-  (receive-all ch (partial test-handle ch ci)))
+  (receive-all ch (partial memcache ch ci)))

-
-;(def s (start-tcp-server handler {:port 10000 :frame MEMCACHE}))
+(defn start-server [port]
+  (start-tcp-server handler {:port port :frame MEMCACHE}))


Correct error in example in docstring

Correct error in example in docstring

--- src/reagent/impl/template.cljs
+++ src/reagent/impl/template.cljs
@@ -236,7 +236,7 @@

   is the same as:

-      [:nav.navbar [:div.container [:div.navbar-header [:a.navbar-bran {:href \"...\"} \"Home\"]]]]
+      [:nav.navbar [:div.container [:div.navbar-header [:a.navbar-brand {:href \"...\"} \"Home\"]]]]

   tags - the original keyword split at '>'
   hiccup-form - the original hiccup form (a keyword in the first position)"


In search queries, return data-source for kritis too.

--- src/kosha/db/search.clj
+++ src/kosha/db/search.clj
@@ -14,7 +14,7 @@
 (defn kritis
   "Retrieves n ragams from the db in order of similarity to the query."
   [kriti n]
-  (let [q  ["SELECT kriti_id AS id, name, composer, taala, language, similarity_score(name, ?) AS similarity, 'kriti' AS type
+  (let [q  ["SELECT kriti_id AS id, name, composer, taala, language, similarity_score(name, ?) AS similarity, data_source, 'kriti' AS type
              FROM kritis
              ORDER BY similarity_score(name, ?)
              DESC LIMIT ?; "


Some code cleanup for consistency, and made it so hypens are replaced with underscores in file names and directories.

--- src/cake/tasks/new.clj
+++ src/cake/tasks/new.clj
@@ -14,13 +14,18 @@

 (def template-dir (file "~" ".cake" "templates"))

-(defn rename-dirs [root project]
+(defn rename-files [root project]
   (log "Renaming directories with +project+ in their name")
   (doseq [old-file (reverse (sort-by (comp count str) (file-seq root)))
           :let [name (.getName old-file)
-                replaced (.replace name "+project+" project)]
+                replaced (.replace name "+project+" (.replace project "-" "_"))]
           :when (not= name replaced)]
     (.renameTo old-file (file (.getParent old-file) replaced))))
+
+(defn scan-replace-contents [files project]
+  (log (str "Replacing +project+ with '" project "' in all files."))
+  (doseq [f (filter #(.isFile %) files)]
+    (spit f (.replace (slurp f) "+project+" project))))

 (defn template-new [project template]
   (let [root (file *pwd* project)]
@@ -29,11 +34,8 @@
       (do
         (log (str "Creating a new project based on ~/cake/templates/" template))
         (ant Copy {:todir root} (add-fileset {:dir (str (file template-dir template))}))
-        (rename-dirs root project)
-        (let [files (file-seq root)]
-          (log (str "Replacing +project+ with '" project "' in all files."))
-          (doseq [f (filter #(.isFile %) files)]
-            (spit f (.replace (slurp f) "+project+" project))))))))
+        (rename-files root project)
+        (scan-replace-contents (file-seq root) project)))))

 (defn create-template [template]
   (log (str "Creating template directory: ~/.cake/templates/" template))


Adds multiprovider support on some methods.

--- src/loudmoauth/core.clj
+++ src/loudmoauth/core.clj
@@ -18,10 +18,11 @@

 ;Here we pass the name of our provider, :spotify or "spotify" or whatever
 (defn refresh-token
-  []
+  ([] (lma/get-tokens (first @lma/app-state)))
   "In case of emergency token refresh, we supply this function."
-  (lma/get-tokens @lma/app-state))
+  ([provider] ( lma/get-tokens (provider @lma/app-state))))

+;Should we just init everything at once.
 (defn init
   "Init oauth token request cycle."
   []
@@ -42,10 +43,13 @@
     "No user interaction nescessary."))

 ;We can totally get away with only rewriting this namespace, just make each function take a keyword as argument, no argument, give us first in list.
+;What do we do if we don't have provider name as key:value?"
 (defn set-oauth-params
   "Set oauth-parameters for use in call to get token"
   [params]
-  (let [old-app-state @lma/app-state]
+  (let [old-app-state @lma/app-state
+        provider-name (:provider params)
+        ]
     (->>
       (if-not (:response-type params)
         (lma/add-response-type "code" params)
@@ -53,10 +57,10 @@
       (lma/add-state)
       (merge old-app-state)
       (lma/add-encoded-auth-string)
-      (reset! lma/app-state))))
+      (swap! lma/app-state assoc provider-name))))

 ;Here we either supply our key or don't. If no key, just return (first tokens)
 (defn oauth-token
   "Retreive oauth token for use in authentication call"
-  []
-  (:access_token @lma/app-state))
+  ([] (:access_token (first @lma/app-state)))
+  ([provider] (provider @lma/app-state)))


Default the language to "de"

Default the language to "de"

--- src/mdr2/production.clj
+++ src/mdr2/production.clj
@@ -57,6 +57,7 @@
   "Return default meta data"
   []
   {:date (to-date (t/now))
+   :language "de"
    :identifier (uuid)
    :volumes 1
    :type "Text"


parse markdown files like source files

parse markdown files like source files

--- src/me/panzoo/story.clj
+++ src/me/panzoo/story.clj
@@ -155,6 +155,7 @@
    :vimscript ["\"" "shBrushVimscript.js"]
    :vb ["'" "shBrushVb.js"]
    :vbnet ["'" "shBrushVb.js"]
+   :markdown ["" nil]
    })

 (def language-aliases
@@ -177,7 +178,8 @@
    :rb :ruby
    :sass :scss
    :vimscript :vim
-   :vbnet :vb})
+   :vbnet :vb
+   :md :markdown})

 ; ### Pegdown instances
@@ -648,7 +650,7 @@
           (if (#{:markdown :md} *language*)

 ; A markdown file is a special case. It is treated as a single comment block.
-            (html<- [:comment (slurp path)])
+            (each html<- (gather-lines (read-lines path)))
             (do
               (maybe-associate-brush path *language*)


Update driver.clj

Update driver.clj

--- src/metabase/driver.clj
+++ src/metabase/driver.clj
@@ -44,7 +44,7 @@
    :username-incorrect                 "Looks like your username is incorrect."
    :username-or-password-incorrect     "Looks like the username or password is incorrect."})

-(def analyze-table-schema
+(def AnalyzeTable
   "Schema for the expected output of `analyze-table`."
   {:rows   schema/Int
    :fields [{:name            schema/Str
@@ -54,7 +54,7 @@
              :preview-display schema/Bool
              :pk?             schema/Bool}]})

-(def describe-table-schema
+(def DescribeTable
   "Schema for the expected output of `describe-table`."
   {:name   schema/Str
    :schema (schema/maybe schema/Str)
@@ -65,12 +65,12 @@
               :pk?                                 schema/Bool
               (schema/optional-key :nested-fields) #{(schema/recursive #'describe-table-schema)}}}})

-(def describe-database-schema
+(def DescribeDatabase
   "Schema for the expected output of `describe-database`."
   {:tables #{{:name   schema/Str
               :schema (schema/maybe schema/Str)}}})

-(def describe-table-fks-schema
+(def DescribeTableFKs
   "Schema for the expected output of `describe-table-fks`."
   #{{:fk-column-name   schema/Str
      :dest-table       {:name   schema/Str


include stats and description in mastery transform

--- src/mimic/masteries.clj
+++ src/mimic/masteries.clj
@@ -1,5 +1,5 @@
 (ns mimic.masteries
-  (require [com.rpl.specter :as s :refer [ALL LAST]]
+  (require [com.rpl.specter :as s :refer [ALL VAL LAST]]
            [clojure.java.io :as io]
            [environ.core :refer [env]]
            [clj-lolapi.query :as query]
@@ -51,11 +51,18 @@

 (defn transform-mastery
-  [[masteryId {:keys [id name ranks]}]]
-  {masteryId
-   {:name      name
-    :id        id
-    :maxPoints ranks}})
+  [[masteryId {:keys [id name ranks description]}]]
+  (let [stats (->> mastery-stats
+                  (s/select [ALL VAL :name #(= % name)])
+                  first
+                  first)]
+    {masteryId
+     (merge
+       stats
+       {:name      name
+        :id        id
+        :description description
+        :maxPoints ranks})}))

 (defonce masteries-db
   (if (env :riot-api-key)


Adapt code to use buddy-core crypto primitives.

--- src/buddy/sign/jwe.clj
+++ src/buddy/sign/jwe.clj
@@ -79,154 +79,6 @@
 (defmethod generate-iv :a192gcm [_] (nonce/random-bytes 12))
 (defmethod generate-iv :a256gcm [_] (nonce/random-bytes 12))

-(defn calculate-aad-length
-  [aad]
-  (let [length (* (count aad) 8)
-        buffer (ByteBuffer/allocate 8)]
-    (.putLong buffer length)
-    (.array buffer)))
-
-(defn extract-encryption-key
-  [secret algorithm]
-  {:pre [(bytes/bytes? secret)]}
-  (case algorithm
-    :a128cbc-hs256 (bytes/slice secret 16 32)
-    :a192cbc-hs384 (bytes/slice secret 24 48)
-    :a256cbc-hs512 (bytes/slice secret 32 64)))
-
-(defn extract-authentication-key
-  [secret algorithm]
-  {:pre [(bytes/bytes? secret)]}
-  (case algorithm
-    :a128cbc-hs256 (bytes/slice secret 0 16)
-    :a192cbc-hs384 (bytes/slice secret 0 24)
-    :a256cbc-hs512 (bytes/slice secret 0 32)))
-
-(defn- generate-authtag
-  [{:keys [algorithm ciphertext authkey iv aad]}]
-  (let [al (calculate-aad-length aad)
-        data (bytes/concat aad iv ciphertext al)
-        fulltag (hmac/hash data authkey algorithm)
-        truncatesize (quot (count fulltag) 2)]
-    (bytes/slice fulltag 0 truncatesize)))
-
-(defn- verify-authtag
-  [tag params]
-  (let [tag' (generate-authtag params)]
-    (bytes/equals? tag tag')))
-
-(defmulti aead-encrypt :algorithm)
-
-(defmethod aead-encrypt :a128cbc-hs256
-  [{:keys [algorithm plaintext secret iv aad] :as params}]
-  {:pre [(keylength? secret 32)
-         (ivlength? iv 16)]}
-  (let [cipher (crypto/block-cipher :aes :cbc)
-        encryptionkey (extract-encryption-key secret algorithm)
-        authkey (extract-authentication-key secret algorithm)
-        ciphertext (encrypt-cbc cipher plaintext encryptionkey iv)
-        tag (generate-authtag {:algorithm :sha256
-                               :ciphertext ciphertext
-                               :authkey authkey
-                               :aad aad
-                               :iv iv})]
-    [ciphertext tag]))
-
-(defmethod aead-encrypt :a192cbc-hs384
-  [{:keys [algorithm plaintext secret iv aad] :as params}]
-  {:pre [(keylength? secret 48)
-         (ivlength? iv 16)]}
-  (let [cipher (crypto/block-cipher :aes :cbc)
-        encryptionkey (extract-encryption-key secret algorithm)
-        authkey (extract-authentication-key secret algorithm)
-        ciphertext (encrypt-cbc cipher plaintext encryptionkey iv)
-        tag (generate-authtag {:algorithm :sha384
-                               :ciphertext ciphertext
-                               :authkey authkey
-                               :aad aad
-                               :iv iv})]
-    [ciphertext tag]))
-
-(defmethod aead-encrypt :a256cbc-hs512
-  [{:keys [algorithm plaintext secret iv aad] :as params}]
-  {:pre [(keylength? secret 64)
-         (ivlength? iv 16)]}
-  (let [cipher (crypto/block-cipher :aes :cbc)
-        encryptionkey (extract-encryption-key secret algorithm)
-        authkey (extract-authentication-key secret algorithm)
-        ciphertext (encrypt-cbc cipher plaintext encryptionkey iv)
-        tag (generate-authtag {:algorithm :sha512
-                               :ciphertext ciphertext
-                               :authkey authkey
-                               :aad aad
-                               :iv iv})]
-    [ciphertext tag]))
-
-(defmethod aead-encrypt :a128gcm
-  [{:keys [algorithm plaintext secret iv aad] :as params}]
-  {:pre [(keylength? secret 16) (ivlength? iv 12)]}
-  (encrypt-gcm plaintext secret iv aad))
-
-(defmethod aead-encrypt :a192gcm
-  [{:keys [algorithm plaintext secret iv aad] :as params}]
-  {:pre [(keylength? secret 24) (ivlength? iv 12)]}
-  (encrypt-gcm plaintext secret iv aad))
-
-(defmethod aead-encrypt :a256gcm
-  [{:keys [algorithm plaintext secret iv aad] :as params}]
-  {:pre [(keylength? secret 32) (ivlength? iv 12)]}
-  (encrypt-gcm plaintext secret iv aad))
-
-(defmulti aead-decrypt :algorithm)
-
-(defmethod aead-decrypt :a128cbc-hs256
-  [{:keys [algorithm authtag ciphertext secret iv] :as params}]
-  {:pre [(keylength? secret 32)
-         (ivlength? iv 16)]}
-  (let [cipher (crypto/block-cipher :aes :cbc)
-        encryptionkey (extract-encryption-key secret algorithm)
-        authkey (extract-authentication-key secret algorithm)]
-    (when-not (verify-authtag authtag (assoc params :authkey authkey :algorithm :sha256))
-      (throw+ {:type :validation :cause :authtag :message "Message seems corrupt or manipulated."}))
-    (decrypt-cbc cipher ciphertext encryptionkey iv)))
-
-(defmethod aead-decrypt :a192cbc-hs384
-  [{:keys [algorithm authtag ciphertext secret iv] :as params}]
-  {:pre [(keylength? secret 48)
-         (ivlength? iv 16)]}
-  (let [cipher (crypto/block-cipher :aes :cbc)
-        encryptionkey (extract-encryption-key secret algorithm)
-        authkey (extract-authentication-key secret algorithm)]
-    (when-not (verify-authtag authtag (assoc params :authkey authkey :algorithm :sha384))
-      (throw+ {:type :validation :cause :authtag :message "Message seems corrupt or manipulated."}))
-    (decrypt-cbc cipher ciphertext encryptionkey iv)))
-
-(defmethod aead-decrypt :a256cbc-hs512
-  [{:keys [algorithm authtag ciphertext secret iv] :as params}]
-  {:pre [(keylength? secret 64)
-         (ivlength? iv 16)]}
-  (let [cipher (crypto/block-cipher :aes :cbc)
-        encryptionkey (extract-encryption-key secret algorithm)
-        authkey (extract-authentication-key secret algorithm)]
-    (when-not (verify-authtag authtag (assoc params :authkey authkey :algorithm :sha512))
-      (throw+ {:type :validation :cause :authtag :message "Message seems corrupt or manipulated."}))
-    (decrypt-cbc cipher ciphertext encryptionkey iv)))
-
-(defmethod aead-decrypt :a128gcm
-  [{:keys [algorithm authtag ciphertext secret iv aad] :as params}]
-  {:pre [(keylength? secret 16) (ivlength? iv 12)]}
-  (decrypt-gcm ciphertext authtag secret iv aad))
-
-(defmethod aead-decrypt :a192gcm
-  [{:keys [algorithm authtag ciphertext secret iv aad] :as params}]
-  {:pre [(keylength? secret 24) (ivlength? iv 12)]}
-  (decrypt-gcm ciphertext authtag secret iv aad))
-
-(defmethod aead-decrypt :a256gcm
-  [{:keys [algorithm authtag ciphertext secret iv aad] :as params}]
-  {:pre [(keylength? secret 32) (ivlength? iv 12)]}
-  (decrypt-gcm ciphertext authtag secret iv aad))
-
 (defn- encode-claims
   [claims zip opts]
   (let [additional (-> (select-keys opts [:exp :nbf :iat :iss :aud])
@@ -260,6 +112,111 @@
       (throw+ {:type :validation :cause :max-age
                :message (format "Token is older than max-age (%s)" max-age)}))
     claims))
+
+(defmulti aead-encrypt :algorithm)
+(defmulti aead-decrypt :algorithm)
+
+(defmethod aead-encrypt :a128cbc-hs256
+  [{:keys [algorithm plaintext secret iv aad] :as params}]
+  (let [result (crypto/encrypt* {:algorithm :aes128-cbc-hmac-sha256 :input plaintext
+                                 :key secret :iv iv :aad aad})
+        resultlen (count result)
+        ciphertext (bytes/slice result 0 (- resultlen 16))
+        tag (bytes/slice result (- resultlen 16) resultlen)]
+    [ciphertext tag]))
+
+(defmethod aead-decrypt :a128cbc-hs256
+  [{:keys [algorithm authtag ciphertext secret iv aad] :as params}]
+  (crypto/decrypt* {:algorithm :aes128-cbc-hmac-sha256
+                    :input (bytes/concat ciphertext authtag)
+                    :key secret
+                    :iv iv
+                    :aad aad}))
+
+(defmethod aead-encrypt :a192cbc-hs384
+  [{:keys [algorithm plaintext secret iv aad] :as params}]
+  (let [result (crypto/encrypt* {:algorithm :aes192-cbc-hmac-sha384 :input plaintext
+                                 :key secret :iv iv :aad aad})
+        resultlen (count result)
+        ciphertext (bytes/slice result 0 (- resultlen 24))
+        tag (bytes/slice result (- resultlen 24) resultlen)]
+    [ciphertext tag]))
+
+(defmethod aead-decrypt :a192cbc-hs384
+  [{:keys [algorithm authtag ciphertext secret iv aad] :as params}]
+  (crypto/decrypt* {:algorithm :aes192-cbc-hmac-sha384
+                    :input (bytes/concat ciphertext authtag)
+                    :key secret
+                    :iv iv
+                    :aad aad}))
+
+(defmethod aead-encrypt :a256cbc-hs512
+  [{:keys [algorithm plaintext secret iv aad] :as params}]
+  (let [result (crypto/encrypt* {:algorithm :aes256-cbc-hmac-sha512 :input plaintext
+                                 :key secret :iv iv :aad aad})
+        resultlen (count result)
+        ciphertext (bytes/slice result 0 (- resultlen 32))
+        tag (bytes/slice result (- resultlen 32) resultlen)]
+    [ciphertext tag]))
+
+(defmethod aead-decrypt :a256cbc-hs512
+  [{:keys [algorithm authtag ciphertext secret iv aad] :as params}]
+  (crypto/decrypt* {:algorithm :aes256-cbc-hmac-sha512
+                    :input (bytes/concat ciphertext authtag)
+                    :key secret
+                    :iv iv
+                    :aad aad}))
+
+(defmethod aead-encrypt :a128gcm
+  [{:keys [algorithm plaintext secret iv aad] :as params}]
+  (let [result (crypto/encrypt* {:algorithm :aes128-gcm :input plaintext
+                                 :key secret :iv iv :aad aad})
+        resultlen (count result)
+        ciphertext (bytes/slice result 0 (- resultlen 16))
+        tag (bytes/slice result (- resultlen 16) resultlen)]
+    [ciphertext tag]))
+
+(defmethod aead-decrypt :a128gcm
+  [{:keys [algorithm authtag ciphertext secret iv aad] :as params}]
+  (crypto/decrypt* {:algorithm :aes128-gcm
+                    :input (bytes/concat ciphertext authtag)
+                    :key secret
+                    :iv iv
+                    :aad aad}))
+
+(defmethod aead-encrypt :a192gcm
+  [{:keys [algorithm plaintext secret iv aad] :as params}]
+  (let [result (crypto/encrypt* {:algorithm :aes192-gcm :input plaintext
+                                 :key secret :iv iv :aad aad})
+        resultlen (count result)
+        ciphertext (bytes/slice result 0 (- resultlen 16))
+        tag (bytes/slice result (- resultlen 16) resultlen)]
+    [ciphertext tag]))
+
+(defmethod aead-decrypt :a192gcm
+  [{:keys [algorithm authtag ciphertext secret iv aad] :as params}]
+  (crypto/decrypt* {:algorithm :aes192-gcm
+                    :input (bytes/concat ciphertext authtag)
+                    :key secret
+                    :iv iv
+                    :aad aad}))
+
+(defmethod aead-encrypt :a256gcm
+  [{:keys [algorithm plaintext secret iv aad] :as params}]
+  (let [result (crypto/encrypt* {:algorithm :aes256-gcm :input plaintext
+                                 :key secret :iv iv :aad aad})
+        resultlen (count result)
+        ciphertext (bytes/slice result 0 (- resultlen 16))
+        tag (bytes/slice result (- resultlen 16) resultlen)]
+    [ciphertext tag]))
+
+(defmethod aead-decrypt :a256gcm
+  [{:keys [algorithm authtag ciphertext secret iv aad] :as params}]
+  (crypto/decrypt* {:algorithm :aes256-gcm
+                    :input (bytes/concat ciphertext authtag)
+                    :key secret
+                    :iv iv
+                    :aad aad}))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Public Api


Add `:skip-validation` option to jwt functions.

--- src/buddy/sign/jwt.clj
+++ src/buddy/sign/jwt.clj
@@ -39,8 +39,8 @@

   `:now` is an integer POSIX time and defaults to the current time.
   `:leeway` is an integer number of seconds and defaults to zero."
-  [claims {:keys [max-age iss aud now leeway allow-expired]
-           :or {now (util/now) leeway 0 allow-expired false}}]
+  [claims {:keys [max-age iss aud now leeway]
+           :or {now (util/now) leeway 0}}]
   (let [now (util/to-timestamp now)]

     ;; Check the `:iss` claim.
@@ -60,8 +60,7 @@
                       {:type :validation :cause :aud})))

     ;; Check the `:exp` claim.
-    (when (and (:exp claims) (<= (:exp claims) (- now leeway))
-            (not allow-expired))
+    (when (and (:exp claims) (<= (:exp claims) (- now leeway)))
       (throw (ex-info (format "Token is expired (%s)" (:exp claims))
                       {:type :validation :cause :exp})))

@@ -103,16 +102,18 @@
    {:pre [(map? claims)]}
    (let [payload (-> (prepare-claims claims opts)
                      (json/generate-string))]
-     (jws/sign payload pkey (merge opts {:typ "JWT"})))))
+     (jws/sign payload pkey opts))))

 (defn unsign
   ([message pkey] (unsign message pkey {}))
-  ([message pkey opts]
+  ([message pkey {:keys [skip-validation] :or {skip-validation false} :as opts}]
    (try
-     (-> (jws/unsign message pkey opts)
-         (codecs/bytes->str)
-         (json/parse-string true)
-         (validate-claims opts))
+     (let [claims (-> (jws/unsign message pkey opts)
+                      (codecs/bytes->str)
+                      (json/parse-string true))]
+       (if skip-validation
+         claims
+         (validate-claims claims opts)))
      (catch com.fasterxml.jackson.core.JsonParseException e
        (throw (ex-info "Message seems corrupt or manipulated."
                        {:type :validation :cause :signature}))))))
@@ -123,16 +124,18 @@
    {:pre [(map? claims)]}
    (let [payload (-> (prepare-claims claims opts)
                      (json/generate-string))]
-     (jwe/encrypt payload pkey (merge opts {:typ "JWT"})))))
+     (jwe/encrypt payload pkey opts))))

 (defn decrypt
   ([message pkey] (decrypt message pkey nil))
-  ([message pkey opts]
+  ([message pkey {:keys [skip-validation] :or {skip-validation false} :as opts}]
    (try
-     (-> (jwe/decrypt message pkey opts)
-         (codecs/bytes->str)
-         (json/parse-string true)
-         (validate-claims opts))
+     (let [claims (-> (jwe/decrypt message pkey opts)
+                      (codecs/bytes->str)
+                      (json/parse-string true))]
+       (if skip-validation
+         claims
+         (validate-claims claims opts)))
      (catch com.fasterxml.jackson.core.JsonParseException e
        (throw (ex-info "Message seems corrupt or manipulated."
                        {:type :validation :cause :signature}))))))