Bring counting back

Bring counting back

--- src/clojure/clojurewerkz/cassaforte/cql.clj
+++ src/clojure/clojurewerkz/cassaforte/cql.clj
@@ -17,7 +17,8 @@
    for key operations built on top of CQL."
   (:refer-clojure :exclude [update])
   (:require [clojurewerkz.cassaforte.new-query-api :as new-query-api]
-            [clojurewerkz.cassaforte.client :as cc])
+            [clojurewerkz.cassaforte.client :as cc]
+            [clojurewerkz.cassaforte.query.dsl :as dsl])
   (:import com.datastax.driver.core.Session))

 ;;
@@ -256,32 +257,19 @@
 ;; Higher level DB functions
 ;;

-(defn get-one
-  "Executes query to get exactly one result. Does not add `limit` clause to the query, this is
-   a convenience function only. Please use `limit` clause if you execute queries that potentially
-   return more than a single result.
+(defn perform-count
+  "Helper function to perform count on a table with given query. Count queries are slow in Cassandra,
+   in order to get a rough idea of how many items you have in certain table, use `nodetool cfstats`,
+   for more complex cases, you can wither do a full table scan or perform a count with this function,
+   please note that it does not have any performance guarantees and is potentially expensive.

    Doesn't work as a prepared query."
-  [^Session session & query-params]
-  (first
-   (cc/execute session
-               (apply new-query-api/select query-params))))
-
-;; (defn perform-count
-;;   "Helper function to perform count on a table with given query. Count queries are slow in Cassandra,
-;;    in order to get a rough idea of how many items you have in certain table, use `nodetool cfstats`,
-;;    for more complex cases, you can wither do a full table scan or perform a count with this function,
-;;    please note that it does not have any performance guarantees and is potentially expensive.
-
-;;    Doesn't work as a prepared query."
-;;   [^Session session table & query-params]
-;;   (assert (not cc/*prepared-statement*) "Count query can't be executed as a prepared query")
-;;   (:count
-;;    (first
-;;     (select session table
-;;             (cons
-;;              (q/columns (q/count*))
-;;              query-params)))))
+  [^Session session table & query-params]
+
+  (println query-params)
+  (:count
+   (first
+    (apply select session table (dsl/count-all) query-params))))

 ;;
 ;; Higher-level helper functions for schema


:nail_care:

--- src/com/wsscode/pathom/connect/planner.cljc
+++ src/com/wsscode/pathom/connect/planner.cljc
@@ -534,19 +534,22 @@
    {::keys [unreachable-syms
             unreachable-attrs]}
    env]
-  (let [syms (into unreachable-syms (collect-syms graph env (get-root-node graph)))
-        syms (into (::unreachable-syms previous-graph) syms)]
+  (let [syms (->> (collect-syms graph env (get-root-node graph))
+                  (into unreachable-syms)
+                  (into (::unreachable-syms previous-graph)))]
     (cond-> (assoc previous-graph
               ::unreachable-syms syms
               ::unreachable-attrs unreachable-attrs)
       (set/subset? (all-attribute-resolvers env (pc-attr env)) syms)
       (update ::unreachable-attrs conj (pc-attr env)))))

-(defn compute-missing-chain [graph {::keys [previous-graph] :as env} missing]
+(defn compute-missing-chain
+  "Start a recursive call to process the dependencies required by the resolver. It
+  sets the ::run-next data at the env, it will be used to link the nodes after they
+  are created in the process."
+  [graph {::keys [previous-graph] :as env} missing]
   (if (seq missing)
-    (let [root-node (get-root-node graph)
-
-          {::keys [index-attrs] :as graph'}
+    (let [{::keys [index-attrs] :as graph'}
           (compute-run-graph*
             (dissoc graph ::root)
             (-> env


Add explanatory comment.

Add explanatory comment.

--- src/afterglow/core.clj
+++ src/afterglow/core.clj
@@ -57,7 +57,7 @@
                                                 :backlog 5})}})
     (timbre/merge-config!  {:appenders {:rotor {:min-level :info}}})

-
+    ;; Disable Selmer's template cache in development mode
     (if (env :dev) (parser/cache-off!))

     (reset! initialized true)))


New weapon system.

New weapon system.

--- src/asteroids/core.clj
+++ src/asteroids/core.clj
@@ -37,11 +37,16 @@
 (def debris-life-millis 3000)

 (def ammunition-types {:projectile {:size         (/ ship-size 10)
+                                    :shape        [[-1.0 -5.0] [1.0 -5.0] [0.0 1.0]]
+                                    :color        (Color. 250 50 10)
                                     :speed        2.5
                                     :acceleration 0
                                     :damage       3
                                     :cooldown     300}
                        :missile    {:size         (/ ship-size 3)
+                                    :shape          [[0.0 1.0] [0.5 -1.0] [0.5 -3.5] [1.0 -4.5] [0.5 -4.5] [0.25 -4.25]
+                                                     [-0.25 -4.25] [-0.5 -4.5] [-1.0 -4.5] [-0.5 -3.5] [-0.5 -1.0]]
+                                    :color          (Color. 10 50 250)
                                     :speed        0
                                     :acceleration 3
                                     :damage       30
@@ -51,8 +56,8 @@
               (int \A) {:rotation (- ship-rotation-speed)}
               (int \D) {:rotation ship-rotation-speed}
               (int \W) {:acceleration ship-acceleration}
-              (int \J) {:fire-missile true}
-              (int \K) {:shoot true}})
+              (int \J) {:fire-weapon :launcher}
+              (int \K) {:fire-weapon :machinegun}})

 ; END: constants

@@ -85,37 +90,41 @@

 (declare fill-polygon draw-polygon fill-circle draw-circle)

+(defn create-weapon [ammunition-type]
+  {:ammunition-type ammunition-type
+   :cooldown        0
+   :shooting?       false})
+
 (defn create-ship []
-  {:type                      :ship
-
-   :size                      ship-size
-   :shape                     [[-0.143 1.0] [0.143 1.0] [0.429 0.429] [1.0 0.143] [1.0 -1.0] [0.429 -0.714]
-                               [0.143 -1.0] [-0.143 -1.0] [-0.429 -0.714] [-1.0 -1.0] [-1.0 0.143] [-0.429 0.429]]
-   :color                     (Color. 160 160 150)
-   :paint-method              fill-polygon
-
-   :cockpit-shape             [[-0.143 0.714] [0.143 0.714] [0.286 -0.143] [-0.286 -0.143]]
-   :cockpit-color             (Color. 0 0 80)
-
-   :shots                     []
-   :shooting?                 false
-   :millis-since-last-shot    0
-   :millis-since-last-missile 0
-
-   :position                  [(/ width 2) (/ height 2)]
-   :speed                     [0 0]
-   :acceleration              0
-
-   :direction                 0
-   :rotation-speed            0
-   :rotation                  #{}
-
-   :life                      ship-life
-   :life-colors               {0 (Color. 255 0 0)
-                               1 (Color. 255 80 75)
-                               2 (Color. 250 160 75)
-                               3 (Color. 160 160 150)}
-   :collidable?               false                         ; is set to ship-damage at first movement / shooting
+  {:type           :ship
+
+   :size           ship-size
+   :shape          [[-0.143 1.0] [0.143 1.0] [0.429 0.429] [1.0 0.143] [1.0 -1.0] [0.429 -0.714]
+                    [0.143 -1.0] [-0.143 -1.0] [-0.429 -0.714] [-1.0 -1.0] [-1.0 0.143] [-0.429 0.429]]
+   :color          (Color. 160 160 150)
+   :paint-method   fill-polygon
+
+   :cockpit-shape  [[-0.143 0.714] [0.143 0.714] [0.286 -0.143] [-0.286 -0.143]]
+   :cockpit-color  (Color. 0 0 80)
+
+   :weapons        {:machinegun (create-weapon :projectile)
+                    :launcher   (create-weapon :missile)}
+   :shots          []
+
+   :position       [(/ width 2) (/ height 2)]
+   :speed          [0 0]
+   :acceleration   0
+
+   :direction      0
+   :rotation-speed 0
+   :rotation       #{}
+
+   :life           ship-life
+   :life-colors    {0 (Color. 255 0 0)
+                    1 (Color. 255 80 75)
+                    2 (Color. 250 160 75)
+                    3 (Color. 160 160 150)}
+   :collidable?    false                                    ; is set to ship-damage at first movement / shooting
    })

 (defn create-circle
@@ -138,56 +147,26 @@
     :collidable?    'whatever
     }))

-(defn create-projectile
-  ([pos dir speed]
-   {:type           :projectile
-
-    :size           (-> ammunition-types :projectile :size)
-    :shape          [[-1.0 -5.0] [1.0 -5.0] [0.0 1.0]]
-    :color          (Color. 250 50 10)
-    :paint-method   fill-polygon
-
-    :position       pos
-    :speed          speed
-    :acceleration   0
-
-    :direction      dir
-    :rotation-speed 0
-
-    :collidable?    (-> ammunition-types :projectile :damage)
-    })
-  ([{:keys [position size direction speed] :as ship}]
-   (let [dir-vec (m/rotate-vec direction [0 1])
-         position (m/vec+vec position (m/num*vec size dir-vec))
-         speed (m/vec+vec speed (m/num*vec (-> ammunition-types :projectile :speed) dir-vec))]
-     (create-projectile position direction speed))))
-
-(defn create-missile
-  ([pos dir speed]
-   {:type           :missile
-
-    :size           (-> ammunition-types :missile :size)
-    :shape          [[0.0 1.0] [0.5 -1.0] [0.5 -3.5] [1.0 -4.5] [0.5 -4.5] [0.25 -4.25]
-                     [-0.25 -4.25] [-0.5 -4.5] [-1.0 -4.5] [-0.5 -3.5] [-0.5 -1.0]]
-    :color          (Color. 10 50 250)
-    :paint-method   fill-polygon
-
-    :position       pos
-    :speed          speed
-    :acceleration   (-> ammunition-types :missile :acceleration)
-
-    :direction      dir
-    :rotation-speed 0
-
-    :collidable?    (-> ammunition-types :missile :damage)
-    })
-  ([{:keys [position size direction speed] :as ship}]
-   (let [dir-vec (m/rotate-vec direction [0 1])
-         missile-position (m/vec+vec position (m/num*vec size dir-vec))
-         missile-speed (m/vec+vec speed (m/num*vec (-> ammunition-types :missile :speed) dir-vec))]
-     (create-missile missile-position direction missile-speed))))
-
-
+(defn create-shot [ammunition-type {:keys [position size direction speed] :as ship}]
+  (let [dir-vec (m/rotate-vec direction [0 1])
+        position (m/vec+vec position (m/num*vec size dir-vec))
+        speed (m/vec+vec speed (m/num*vec (-> ammunition-types ammunition-type :speed) dir-vec))
+        ammunition (get ammunition-types ammunition-type)]
+    {:type           ammunition-type
+
+     :size           (:size ammunition)
+     :shape          (:shape ammunition)
+     :color          (:color ammunition)
+     :paint-method   fill-polygon
+
+     :position       position
+     :speed          speed
+     :acceleration   (:acceleration ammunition)
+
+     :direction      direction
+     :rotation-speed 0
+
+     :collidable?    (:damage ammunition)}))

 (defn create-asteroid
   ([size pos speed]
@@ -354,18 +333,26 @@
 ; Actions
 ; ----------------------------------------------------------------------

-(defn shoot [{:keys [shots shooting? millis-since-last-shot firing? millis-since-last-missile] :as ship}]
-  (let [millis-since-last-shot (+ turn-millis millis-since-last-shot)
-        millis-since-last-missile (+ turn-millis millis-since-last-missile)
-        shoots? (and shooting? (>= millis-since-last-shot (-> ammunition-types :projectile :cooldown)))
-        shots (if shoots? (conj shots (create-projectile ship)) shots)
-        fires? (and firing? (>= millis-since-last-missile (-> ammunition-types :missile :cooldown)))
-        shots (if fires? (conj shots (create-missile ship)) shots)]
-    (when shoots? (play-sound "projectile-fired"))
-    (when fires? (play-sound "missile-fired"))
-    (assoc ship :millis-since-last-shot (if shoots? 0 millis-since-last-shot)
-                :millis-since-last-missile (if fires? 0 millis-since-last-missile)
-                :shots shots)))
+(defn toggle-shooting [{:keys [weapons] :as ship} weapon-type activate?]
+  (if (contains? weapons weapon-type)
+    (-> ship
+        (assoc-in [:weapons weapon-type :shooting?] activate?)
+        (assoc :collidable? ship-damage))
+    ship))
+
+(defn fire-weapon [{:keys [shots] :as ship}
+                   [weapon-type {:keys [ammunition-type cooldown shooting?] :as weapon}]]
+  (let [cooldown (if (> cooldown turn-millis) (- cooldown turn-millis) 0)
+        shoots? (and shooting? (= cooldown 0))
+        cooldown (if shoots? (-> ammunition-types ammunition-type :cooldown) cooldown)
+        shots (if shoots? (conj shots (create-shot ammunition-type ship)) shots)]
+    (when shoots? (play-sound (str (name ammunition-type) "-fired")))
+    (-> ship
+        (assoc-in [:weapons weapon-type :cooldown] cooldown)
+        (assoc :shots shots))))
+
+(defn shoot [{:keys [weapons] :as ship}]
+  (reduce fire-weapon ship weapons))

 (defn basic-move
   ([{:keys [direction rotation-speed speed acceleration position] :as object} wrap?]
@@ -433,11 +420,10 @@
       (ref-set asteroids asteroids*))))

 (defn do-action!
-  ([ship {:keys [acceleration rotation shoot fire-missile] :as action} activate?]
+  ([ship {:keys [acceleration rotation fire-weapon] :as action} activate?]
    (when acceleration (dosync (alter ship assoc :acceleration (if activate? acceleration 0) :collidable? ship-damage)))
    (when rotation (dosync (alter ship set-rotation rotation activate?)))
-   (when shoot (dosync (alter ship assoc :shooting? activate? :collidable? ship-damage)))
-   (when fire-missile (dosync (alter ship assoc :firing? activate? :collidable? ship-damage))))
+   (when fire-weapon (dosync (alter ship toggle-shooting fire-weapon activate?))))
   ([ship action]
    (do-action! ship action true)))


Added verbosity switch for pcbo

Added verbosity switch for pcbo

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/contrib/algorithms/parallel_cbo.clj
+++ src/conexp/contrib/algorithms/parallel_cbo.clj
@@ -21,15 +21,18 @@
 ;;;

 (define-external-program pcbo-external
-  pcbo :threads :depth :min-support :input-file :fcalgs :output-file)
+  pcbo :threads :depth :min-support :verbosity :input-file :fcalgs :output-file)
 (alter-meta! (var pcbo-external) assoc :private true)

 (defn- pcbo
   "Runs pcbo and returns the file where the concepts have been written
   to."
-  [threads depth min-support context]
+  [threads depth min-support verbosity context]
   (let [^java.io.File output-file (tmpfile)]
-    (pcbo-external (str "-P" threads) (str "-L" depth) (str "-S" (float (* min-support 100)))
+    (pcbo-external (str "-P" threads)
+                   (str "-L" depth)
+                   (str "-S" (float (* min-support 100)))
+                   (str "-V" verbosity)
                    context (.getAbsolutePath output-file))
     output-file))

@@ -47,15 +50,15 @@
                                         :when (contains? (incidence ctx)
                                                          [(nth object-vector g)
                                                           (nth attribute-vector m)])])]
-    [(make-context new-objects new-attributes new-incidence)
-     object-vector
+    [(make-context new-objects new-attributes new-incidence),
+     object-vector,
      attribute-vector]))

 (defn context-intents
   "Computes the intents of context using parallel close-by-one (CbO)."
   [threads depth min-support context]
   (let [[ctx _ att-vec] (to-fcalgs-context context),
-        output-file     (pcbo threads depth min-support ctx),
+        output-file     (pcbo threads depth min-support 1 ctx),
         intents         (line-seq (reader output-file)),
         transform-back  #(string-to-ints att-vec %)]
     (if (= "" (first intents))
@@ -65,7 +68,10 @@
 (defn count-context-intents
   "Counts the intents of context using parallel close-by-one (CbO)."
   [threads depth min-support context]
-  (count (line-seq (reader (pcbo threads depth min-support (first (to-fcalgs-context context)))))))
+  (-> (pcbo threads depth min-support 1 (first (to-fcalgs-context context)))
+      reader
+      line-seq
+      count))

 ;;;


Integrated solutions.

Integrated solutions.

--- src/main/cljc/clojure_club/sudoku/core.cljc
+++ src/main/cljc/clojure_club/sudoku/core.cljc
@@ -2,6 +2,7 @@
   (:require
     [clojure.string :as cs]
     [clojure-club.sudoku.mbastian :as mbastian]
+    [clojure-club.sudoku.mgrimm :as mgrimm]
     [clojure-club.sudoku.jstrength :as jstrength]
     [clojure-club.sudoku.example-problems :as ex]
     [taoensso.tufte :as tufte :refer (defnp p profiled profile)]
@@ -32,8 +33,15 @@
 #_(profile
   {:dynamic? true}
   (dotimes [_ 5]
-    (p :mbastian (doall (map mbastian/solve ex/all-example-problems)))))
-#_(profile
-    {:dynamic? true}
-    (dotimes [_ 5]
-      (p :mbastian (doall (map jstrength/solve ex/all-example-problems)))))
+    ;(p :mbastian (doall (map mbastian/solve ex/all-example-problems)))
+    ;(p :jstrength (doall (map jstrength/solve ex/all-example-problems)))
+    ;(p :mbastian-easy (doall (mbastian/solve ex/easy)))
+    ;(p :mgrimm-easy (doall (mgrimm/solve ex/easy)))
+    ;(p :jstrength-easy (doall (jstrength/solve ex/easy)))
+    ;(p :mbastian-hard (doall (mbastian/solve ex/hard)))
+    ;(p :mgrimm-hard (doall (mgrimm/solve ex/hard)))
+    ;(p :jstrength-hard (doall (jstrength/solve ex/hard)))
+    ;(p :mbastian-hard-17 (doall (mbastian/solve ex/hard-17)))
+    ;(p :mgrimm-hard-17 (doall (mgrimm/solve ex/hard-17)))
+    ;(p :jstrength-hard-17 (doall (jstrength/solve ex/hard-17)))
+    ))


Have to be on system realm before realms-list works.

--- src/cbfg/world/t2.cljs
+++ src/cbfg/world/t2.cljs
@@ -60,15 +60,19 @@
         [server-state (assoc (dissoc m :pswd) :status :invalid)])
       [server-state (assoc (dissoc m :pswd) :status :invalid)])
     "realms-list"
-    (if-let [{:keys [realm user]} m]
-      (do (act-loop realms-list actx [realm-keys (keys (:realms server-state))]
-                    (if-let [realm-key (first realm-keys)]
-                      (do (aput realms-list (:res-ch m)
-                                (assoc m :status :ok :more true :value realm-key))
-                          (recur (rest realm-keys)))
-                      (aput-close realms-list (:res-ch m)
-                                  (assoc m :status :ok))))
-          [server-state nil])
+    (if-let [{:keys [lane-realm lane-user]} m]
+      (let [realm-keys (if (and (= lane-realm "_system")
+                                (= lane-user "admin"))
+                         (keys (:realms server-state))
+                         [lane-realm])]
+        (act-loop realms-list actx [realm-keys realm-keys]
+                  (if-let [realm-key (first realm-keys)]
+                    (do (aput realms-list (:res-ch m)
+                              (assoc m :status :ok :more true :value realm-key))
+                        (recur (rest realm-keys)))
+                    (aput-close realms-list (:res-ch m)
+                                (assoc m :status :ok))))
+        [server-state nil])
       [server-state (assoc m :status :not-authenticated)])
     nil))

@@ -82,7 +86,8 @@
     [lane-state (assoc m :status :ok :value lane-state)]
     "realms-list"
     (do (msg-put actx :server-state-ch
-                 (assoc m :realm (:realm lane-state) :user (:user lane-state)))
+                 (assoc m :lane-realm (:realm lane-state)
+                        :lane-user (:user lane-state)))
         [lane-state nil])
     nil))


Added key-compression-map into metadata

Added key-compression-map into metadata

--- src/cfpb/qu/loader.clj
+++ src/cfpb/qu/loader.clj
@@ -19,7 +19,8 @@
     [core :as mongo :refer [with-db get-db]]
     [query :as q]
     [collection :as coll]
-    [joda-time]]
+    [joda-time]
+    [key-compression :refer [compression-map]]]
    [cfpb.qu.util :refer :all]
    [cfpb.qu.query.where :as where]
    [cfpb.qu.data :refer :all])
@@ -85,10 +86,20 @@
 (defn save-dataset-definition
   "Save the definition of a dataset into the 'metadata' database."
   [name definition]
-  (with-db (get-db "metadata")
-    (coll/update "datasets" {:name name}
-                 (assoc definition :name name :last-modified (now))
-                 :upsert true)))
+  (let [definition (assoc definition
+                     :name name
+                     :last-modified (now))
+        definition (reduce (fn [def [slice sdef]]
+                             (assoc-in def
+                                       [:compression-map slice]
+                                       (compression-map (slice-columns sdef))))
+                           definition
+                           (:slices definition))
+        definition (dissoc definition :tables)]
+    (with-db (get-db "metadata")
+      (coll/update "datasets" {:name name}
+                   definition
+                   :upsert true))))

 (defmulti cast-value (fn [_ valuedef] (:type valuedef)))


more cards implementations

more cards implementations

--- src/clj/game/cards.clj
+++ src/clj/game/cards.clj
@@ -135,6 +135,11 @@
                               :trace {:base 5 :msg "give the Runner 1 tag"
                                       :effect (effect (gain :runner :tag 1))}}}}

+   "Bioroid Efficiency Research"
+   {:choices {:req #(and (= (:type %) "ICE") (has? % :subtype "Bioroid") (not (:rezzed %)))}
+    :msg (msg "rez " (:title target) " at not cost")
+    :effect (effect (rez target {:no-cost true}))}
+
    "Blue Level Clearance"
    {:effect (effect (gain :credit 5) (draw 2))}

@@ -182,6 +187,11 @@
     :msg (msg "increase the rez cost of the 1st unrezzed ice approached by " target " [Credits]")
     :effect (effect (resolve-ability {:prompt "Choose a server" :choices (req servers)
                                       :effect (effect (run target nil card))} card nil))}
+
+   "Broadcast Square"
+   {:abilities [{:label "Trace 3 - Avoid taking a bad publicity"
+                 :trace {:base 3 :msg "avoid taking a bad publicity"
+                         :effect (effect (lose :bad-publicity 1))}}]}

    "Cache"
    {:abilities [{:counter-cost 1 :effect (effect (gain :credit 1)) :msg "gain 1 [Credits]"}]
@@ -1110,6 +1120,11 @@
                             (resolve-ability ref %2 {:msg "gain 1 [Credits]" :once :per-turn
                                                     :effect (effect (gain :credit 1))} %3 nil))))
     :leave-play #(remove-watch % :order-of-sol)}
+
+   "Paintbrush"
+   {:abilities [{:cost [:click 1] :msg (msg "give " (:title target)
+                                            " sentry, code gate and barrier until the end of next run this turn")
+                 :choices {:req #(and (= (first (:zone %)) :servers) (has? % :type "ICE") (:rezzed %))}}]}

    "Panic Button"
    {:init {:root "HQ"} :abilities [{:cost [:credit 1] :effect (effect (draw))
@@ -1499,6 +1514,14 @@
                                                     (move state :runner card :scored nil))
                                                 (damage state :corp :net dmg))))}
                               card targets))}}
+
+   "Shipment from SanSan"
+   {:choices ["0", "1", "2"] :prompt "How many advancement tokens?"
+    :effect (req (let [c (Integer/parseInt target)]
+                   (resolve-ability state side
+                    {:choices {:req #(or (= (:type %) "Agenda") (:advanceable %))}
+                     :msg (msg "add " c " advancement tokens on a card")
+                     :effect (effect (add-prop :corp target :advance-counter c))} card nil)))}

    "Shock!"
    {:access {:msg "do 1 net damage" :effect (effect (damage :net 1))}}
@@ -1578,6 +1601,9 @@
    "Spooned"
    {:prompt "Choose a server" :choices (req servers) :effect (effect (run target))}

+   "Starlight Crusade Funding"
+   {:events {:runner-turn-begins {:msg "lose [Click]" :effect (effect (lose :click 1))}}}
+
    "Stim Dealer"
    {:events {:runner-turn-begins
              {:effect #(if (>= (:counter %3) 2)
@@ -2613,9 +2639,4 @@

    "The Source"
    {:events {:agenda-scored (effect (trash card)) :agenda-stolen (effect (trash card))}}
-
-   "Bioroid Efficiency Research"
-   {:choices {:req #(and (= (:type %) "ICE") (has? % :subtype "Bioroid") (not (:rezzed %)))}
-    :msg (msg "rez " (:title target) " at not cost")
-    :effect (effect (rez target {:no-cost true}))}
 })


Initial basic https support

Initial basic https support

--- src/clj_http/core2.clj
+++ src/clj_http/core2.clj
@@ -7,11 +7,14 @@
             [clojure.pprint])
   (:import (java.io ByteArrayOutputStream File FilterInputStream InputStream)
            (java.net URI)
+           (javax.net.ssl SSLContext)
            (org.apache.http HttpHost)
            (org.apache.http.client.methods HttpGet)
            (org.apache.http.client.protocol HttpClientContext)
            (org.apache.http.config RegistryBuilder)
            (org.apache.http.conn.routing HttpRoute)
+           (org.apache.http.conn.ssl BrowserCompatHostnameVerifier
+                                     SSLConnectionSocketFactory SSLContexts)
            (org.apache.http.conn.socket PlainConnectionSocketFactory)
            (org.apache.http.impl.client HttpClients)
            (org.apache.http.impl.conn PoolingHttpClientConnectionManager)))
@@ -20,9 +23,17 @@
   ;; TODO add proxy support
   (HttpRoute. (HttpHost. "www.google.com" 80 "https")))

+(defn ssl-context []
+  (SSLContexts/createSystemDefault))
+
+(defn hostname-verifier []
+  (BrowserCompatHostnameVerifier.))
+
 (defn registry-builder []
   (-> (RegistryBuilder/create)
       (.register "http" PlainConnectionSocketFactory/INSTANCE)
+      (.register "https" (SSLConnectionSocketFactory.
+                          (ssl-context) (hostname-verifier)))
       (.build)))

 (defn pooling-conn-mgr []
@@ -34,18 +45,19 @@
       (.build)))

 (defn http-get []
-  (HttpGet. "http://www.google.com"))
+  (HttpGet. "https://www.google.com"))

 (defn http-context []
   (HttpClientContext/create))

-(defn request [{:keys [] :as req}]
+(defn request [{:keys [cookie-store] :as req}]
   (let [conn-mgr (pooling-conn-mgr)
         client (http-client conn-mgr)
         context (http-context)
         get-req (http-get)
         response (.execute client get-req context)
         entity (.getEntity response)]
+    ;; TODO response, conn-mgr, and client needs to be closed
     {:body (.getContent entity)
      :length (.getContentLength entity)
      :chunked? (.isChunked entity)


Undo whitespace changes

Undo whitespace changes

This will not make `git blame` more useful, but it will make the diff
more readable when merging into master. The best thing to do would be to
go back and modify commit 015d591836425f3ba6e3256a0e8480c3ae399f07 to
not introduce the whitespace, but I'm not sure that we can do that at
this point.

--- src/clojush/random.clj
+++ src/clojush/random.clj
@@ -58,24 +58,24 @@
                    (and
                     track-instruction-maps
                     random-insertion) (conj :random-insertion))]
-     (zipmap markers
-             (map (fn [marker]
-                    (case marker
-                      :instruction (let [element (lrand-nth atom-generators)]
-                                     (if (fn? element)
-                                       (let [fn-element (element)]
-                                         (if (fn? fn-element)
-                                           (fn-element)
-                                           fn-element))
-                                       element))
-                      :close (random-closes close-parens-probabilities)
-                      :silent (if (< (lrand) silent-instruction-probability)
-                                true
-                                false)
-                      :random-insertion true
-                      :uuid (java.util.UUID/randomUUID)
-                      ))
-                  markers)))))
+      (zipmap markers
+              (map (fn [marker]
+                     (case marker
+                       :instruction (let [element (lrand-nth atom-generators)]
+                                      (if (fn? element)
+                                        (let [fn-element (element)]
+                                          (if (fn? fn-element)
+                                            (fn-element)
+                                            fn-element))
+                                        element))
+                       :close (random-closes close-parens-probabilities)
+                       :silent (if (< (lrand) silent-instruction-probability)
+                                 true
+                                 false)
+                       :random-insertion true
+                       :uuid (java.util.UUID/randomUUID)
+                       ))
+                   markers)))))

 (defn random-plush-genome-with-size
   "Returns a random Plush genome containing the given number of points."


CMR-983: Added a test.

CMR-983: Added a test.

--- umm-lib/test/cmr/umm/test/validation/collection.clj
+++ umm-lib/test/cmr/umm/test/validation/collection.clj
@@ -163,7 +163,19 @@
            :boolean "bar" :value ["Value [bar] is not a valid value for type [:boolean]."]
            :date "bar" :value ["Value [bar] is not a valid value for type [:date]."]
            :time "bar" :value ["Value [bar] is not a valid value for type [:time]."]
-           :datetime "bar" :value ["Value [bar] is not a valid value for type [:datetime]."]))))
+           :datetime "bar" :value ["Value [bar] is not a valid value for type [:datetime]."]))
+
+    (testing "multiple invalid values"
+      (assert-multiple-invalid
+        (coll-with-psas [{:name "foo" :data-type :float :value "str"}
+                         {:name "bar" :data-type :float :value "1.0"}
+                         {:name "baz" :data-type :int :value "1.0"}])
+        [{:path [:product-specific-attributes 0]
+          :errors
+          ["Value [str] is not a valid value for type [:float]."]}
+         {:path [:product-specific-attributes 2]
+          :errors
+          ["Value [1.0] is not a valid value for type [:int]."]}]))))

 (deftest collection-projects-validation
   (let [c1 (c/map->Project {:short-name "C1"})


add multimethod benchmark

add multimethod benchmark

--- benchmark/cljs/benchmark_runner.cljs
+++ benchmark/cljs/benchmark_runner.cljs
@@ -298,4 +298,8 @@

 (println "\n")

-
+(println ";; multimethods")
+(defmulti simple-multi identity)
+(defmethod simple-multi :foo [x] x)
+(simple-benchmark [] (simple-multi :foo) 100000)
+(println "\n")


minor

minor

--- cljs-cheatsheet/cljs_cheatsheet/tooltips.cljs
+++ cljs-cheatsheet/cljs_cheatsheet/tooltips.cljs
@@ -12,6 +12,7 @@
 (def left-arrow-class "left-arr-42ea1")
 (def right-arrow-class "right-arr-d3345")
 (def arrow-classes (str left-arrow-class " " right-arrow-class))
+(def animation-speed "fast")

 ;;------------------------------------------------------------------------------
 ;; Helper
@@ -102,10 +103,10 @@
     (.css $tooltip-el (js-obj
       "left" left
       "top" top))
-    (.fadeIn $tooltip-el "fast")))
+    (.fadeIn $tooltip-el animation-speed)))

 (defn- hide-all-tooltips! []
-  (.fadeOut ($ tooltip-sel) "fast"))
+  (.fadeOut ($ tooltip-sel) animation-speed))

 ;;------------------------------------------------------------------------------
 ;; Hovered Tooltip Coordinates


Support nested contexts/describes

Support nested contexts/describes

--- src/main/clojure/com/stuartsierra/lazytest.clj
+++ src/main/clojure/com/stuartsierra/lazytest.clj
@@ -1,7 +1,9 @@
 (ns com.stuartsierra.lazytest
   (:use [com.stuartsierra.lazytest.arguments :only (get-arg get-options seconds
-						    standard-metadata or-nil)]
+						    standard-metadata or-nil
+						    firsts)]
         [com.stuartsierra.lazytest.groups :only (new-group group?)]
+        [com.stuartsierra.lazytest.contexts :only (new-context context?)]
         [com.stuartsierra.lazytest.attach :only (add-group all-groups)]
         [com.stuartsierra.lazytest.plan :only (flat-plan)]
 	[com.stuartsierra.lazytest.run :only (run)]))
@@ -33,6 +35,33 @@
   (vec (sort-by #(::order (meta %))
                 (filter #(::local (meta %)) (keys env)))))

+(defmacro context
+  "Creates a context object, using existing local contexts.
+  bindings is a vector from symbols to parent contexts"
+  [bindings & bodies]
+  {:pre [(vector? bindings)
+         (even? (count bindings))]}
+  (let [locals (vec (concat (find-locals &env) (firsts bindings)))
+        contexts (vec (concat (find-locals &env) (seconds bindings)))
+        [before-body divider after-body] (partition-by #(= :after %) bodies)
+        before-fn `(fn ~locals ~@before-body)
+        after-fn (when after-body
+                   (let [[state & after-body] after-body]
+                     (assert (symbol? state))
+                     `(fn ~(apply vector state locals) ~@after-body)))]
+    `(new-context ~contexts ~before-fn ~after-fn)))
+
+(defmacro defcontext
+  "Defines a named context.  body begins with an optional doc string,
+  followed by key-value option pairs, followed by the before and after
+  functions as in 'context'."
+  [name & body]
+  (let [[docstring body] (get-arg string? body)
+        [options body] (get-options body)
+        bindings (:given options [])]
+    `(def ~name (with-meta (context ~bindings ~@body)
+                  '~(standard-metadata &form docstring name)))))
+
 (defmacro describe [& args]
   (let [[sym args] (get-arg symbol? args)
 	[doc args] (get-arg string? args)
@@ -60,6 +89,10 @@
 (defn run-tests [& args]
   (run (apply flat-plan (all-groups) args)))

+(defn clear-tests "Delete all tests in the current namespace"
+  []
+  (intern *ns* (with-meta '*lazytest-groups* {:private true}) #{}))
+
 (defmacro thrown?
   "Returns true if body throws an instance of class c."
   [c & body]


Allow metronome to be a variable parameter.

--- src/afterglow/effects/params.clj
+++ src/afterglow/effects/params.clj
@@ -9,7 +9,8 @@
   (:require [afterglow.rhythm :refer [metro-snapshot]]
             [clojure.math.numeric-tower :as math]
             [com.evocomputing.colors :as colors]
-            [taoensso.timbre :refer [error]]))
+            [taoensso.timbre :refer [error]])
+  (:import [afterglow.rhythm Metronome]))

 (defprotocol IParam
   "A dynamic parameter which gets evaluated during the run of a light show,
@@ -112,10 +113,10 @@

 (defn- oscillator-resolver-internal
   "Handles the calculation of an oscillator based on dynamic parameter
-  values for at least one of min and max"
-  [show params-snapshot min-arg max-arg osc osc-snapshot]
-  (let [min (resolve-param min-arg show params-snapshot)
-        max (resolve-param max-arg show params-snapshot)
+  values for at least one of min and max."
+  [show params-snapshot min max osc osc-snapshot]
+  (let [min (resolve-param min show params-snapshot)
+        max (resolve-param max show params-snapshot)
         range (- max min)]
     (if (neg? range)
       (do
@@ -226,14 +227,6 @@
   ([value show type-expected default param-name]
    `(bind-keyword-param-internal ~value ~show ~type-expected ~default ~param-name)))

-;; TODO Come up with a way to read and write parameters. Some kind of DSL for these builders.
-;; Was thinking could do it through defrecord, but that seems not flexible enough. Will also
-;; need a DSL for oscillators, of course. And will want to add dynamic oscillators which
-;; themselves support this kind of deferred parameters. Maybe a string format for oscillator
-;; specifications? Actually, leaning towards a build-oscillator-param which resolves to an
-;; oscillator, so make that a protocol too, and have the builder take the name and osc
-;; parameters, which can all be dynamic. Make a metronome param too, so they can come out
-;; of the show variables.
 (defn build-oscillated-param
   "Returns a number parameter that is driven by an oscillator. By
   default will be frame-dynamic, since it oscillates, but if you make
@@ -242,8 +235,9 @@
   oscillator's range."
   [show osc & {:keys [min max metronome frame-dynamic] :or {min 0 max 255 frame-dynamic true}}]
   (let [min (bind-keyword-param min show Number 0)
-        max (bind-keyword-param max show Number 255)]
-    (if-not (some (partial satisfies? IParam) [min max])
+        max (bind-keyword-param max show Number 255)
+        metronome (bind-keyword-param metronome show Metronome (:metronome show))]
+    (if-not (some (partial satisfies? IParam) [min max metronome])
       ;; Optimize the simple case of all constant parameters
       (let [range (- max min)
             dyn (boolean frame-dynamic)
@@ -262,7 +256,8 @@
       (let [dyn (boolean frame-dynamic)
             eval-fn (if (some? metronome)
                       (fn [show snapshot]
-                        (oscillator-resolver-internal show snapshot min max osc (metro-snapshot metronome)))
+                        (oscillator-resolver-internal show snapshot min max osc
+                                                      (metro-snapshot (resolve-param metronome show snapshot))))
                       (fn [show snapshot]
                         (oscillator-resolver-internal show snapshot min max osc snapshot)))]
         (reify IParam


Blow away namespace on compiler to avoid state problems

--- src/aurora/compiler/datalog.cljs
+++ src/aurora/compiler/datalog.cljs
@@ -1,3 +1,5 @@
+(aset js/aurora.compiler "datalog" nil)
+
 (ns aurora.compiler.datalog
   (:require [clojure.set :refer [union intersection difference subset?]]
             [aurora.compiler.match :as match])


Macros: Add more words.

Macros: Add more words.

--- test/com/nomistech/clojure_the_language/macros/examples.clj
+++ test/com/nomistech/clojure_the_language/macros/examples.clj
@@ -4,14 +4,22 @@
 ;;;; ___________________________________________________________________________
 ;;;; Macro basics

-;;;; Macros -- key points
+;;;; Macros -- key points:
 ;;;;
 ;;;; - Macros allow us to arbitrarily transform code.
 ;;;;
 ;;;; - Macros transform code that the programmer writes
-;;;;   into code that the compiler can process
+;;;;   into code that the compiler can process.
 ;;;;
 ;;;; - Macros use code as data.
+;;;;
+;;;; - Clojure and other Lisps are homoiconic:
+;;;;   - Code is represented by data structures, not as sequences
+;;;;     of characters.
+;;;;   - Clojure is defined in terms of the evaluation of data structures,
+;;;;     not in terms of the syntax of character streams.
+;;;;
+;;;; - The full power of the language is available when defining a macro.

 ;;;; ___________________________________________________________________________
 ;;;; Simple rearranging of arguments.
@@ -135,3 +143,9 @@
 ;;;; Look at examples:
 ;;;; e.g. `and`, `or`, `let`, `cond`, `while`, `letfn`, `with-redefs`, `->`,
 ;;;;      `->>`, `as->`.
+
+;;;; ___________________________________________________________________________
+
+;;;; TODO:
+;;;; - Capture
+;;;; - ...# symbols


proper docstrings added to zip

proper docstrings added to zip

--- lambdalf-lib/src/main/clojure/alfresco/zip.clj
+++ lambdalf-lib/src/main/clojure/alfresco/zip.clj
@@ -1,7 +1,7 @@
 (ns alfresco.zip
   (:require [clojure.zip :as z]
-             [alfresco.model :as m]
-             [alfresco.nodes :as n]))
+            [alfresco.model :as m]
+            [alfresco.nodes :as n]))

 (defn branch?
   "Verifies if the current location can have children.


add :thread-pool-size argument to connect-loop-with-thread-pool

--- src/brainbot/nozzle/mqhelper.clj
+++ src/brainbot/nozzle/mqhelper.clj
@@ -68,7 +68,8 @@

 (defn connect-loop-with-thread-pool
-  [rmq-settings handle-connection]
+  [rmq-settings handle-connection &{:keys [thread-pool-size]
+                                    :or {thread-pool-size 500}}]
   (let [thread-pool (Executors/newFixedThreadPool 500)
         connect (partial connect-with-thread-pool rmq-settings thread-pool)]
     (connect-loop


Fix scrollbar appearing in messages with code blocks

--- src/braid/core/client/ui/styles/thread.cljs
+++ src/braid/core/client/ui/styles/thread.cljs
@@ -95,7 +95,7 @@
   [:>.messages
    {:position "relative"
     :overflow-y "auto"
-    :padding [[0 pad]]}])
+    :overflow-x "hidden"}])

 (defn thread [pad]
   [:>.thread


Add wrapper for navigation items

Add wrapper for navigation items

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -6,7 +6,6 @@
             [discuss.clipboard :as clipboard]
             [discuss.communication :as com]
             [discuss.utils.extensions]
-            [discuss.find :as find]
             [discuss.history :as history]
             [discuss.utils.common :as lib]
             [discuss.utils.views :as vlib]
@@ -171,16 +170,23 @@
                                          :onClick   #(com/dispatch-add-action statement (lib/get-selection))}
                                     "Submit"))))))

+(defn- build-with-buttons
+  "Add navigation buttons to the provided view."
+  [view data]
+  (dom/div nil
+           (om/build view data)
+           (control-elements)))
+
 (defn view-dispatcher
   "Dispatch current template in main view by the app state."
   [data]
   (let [view (lib/current-view)]
     (cond
-      (= view :login) (om/build login-form {})
-      (= view :reference-agree-disagree) (om/build ref/agree-disagree-view {})
-      (= view :reference-dialog) (om/build ref/dialog-view {})
-      (= view :reference-usages) (om/build ref/usages-view {})
-      (= view :reference-create) (om/build ref/create-overview data)
+      (= view :login) (build-with-buttons login-form {})
+      (= view :reference-agree-disagree) (build-with-buttons ref/agree-disagree-view {})
+      (= view :reference-dialog) (build-with-buttons ref/dialog-view {})
+      (= view :reference-usages) (build-with-buttons ref/usages-view {})
+      (= view :reference-create) (build-with-buttons ref/create-overview data)
       :else (discussion-elements data))))

 (defn main-content-view


Make main dialogue view collapsibe

Make main dialogue view collapsibe

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -228,8 +228,15 @@
                (dom/h4 nil
                        (vlib/logo)
                        " "
-                       (get-in data [:layout :title]))
-               (main-content-view data)))))
+                       (dom/span #js {:className     "pointer"
+                                      :data-toggle   "collapse"
+                                      :data-target   (str "#" (lib/prefix-name "dialogue-collapse"))
+                                      :aria-expanded "true"
+                                      :aria-controls (lib/prefix-name "dialogue-collapse")}
+                                 (get-in data [:layout :title])))
+               (dom/div #js {:className "collapse in"
+                             :id        (lib/prefix-name "dialogue-collapse")}
+                        (main-content-view data))))))

 (defn reference-view [reference owner]
   (reify


Assign the library signature before setting the state to catalogued

The prod/set-state-cataloged! function persists the production as it
is passed to it, so we need to update the library signature before
handing the production to it.

--- src/clj/mdr2/routes/services.clj
+++ src/clj/mdr2/routes/services.clj
@@ -133,7 +133,9 @@
                            (cond
                              (nil? p) (not-found)
                              (not= (:state p) "encoded") (conflict {:status-text "Only encoded productions can be assigned a library signature"})
-                             :else (let [p (prod/set-state-cataloged! p)]
+                             :else (let [p (-> p
+                                            (assoc :library_signature library_signature)
+                                            prod/set-state-cataloged!)]
                                      (if-not (nom/anomaly? p)
                                        (no-content)
                                        (bad-request {:status-text


another migrations fix

another migrations fix

--- src/clj_crud/system/database.clj
+++ src/clj_crud/system/database.clj
@@ -64,9 +64,9 @@
                  (->> migrations/migrations
                       reverse
                       (drop-while (fn [[migration-version migration]]
-                                    (< current-version migration-version)))
+                                    (<= current-version migration-version)))
                       (take-while (fn [[migration-version migration]]
-                                    (<= to-version migration-version)))
+                                    (< to-version migration-version)))
                       (map (juxt first (comp :down second))))
                  :else nil)]
        (info "todo" current-version to-version todo)
@@ -76,7 +76,8 @@
               (update-current-version conn migration-version)
               (catch Exception e
                 (error "Migration " migration-version " failed: " e (with-out-str (.printStackTrace e)))
-                (throw e)))))))
+                (throw e))))
+       (update-current-version conn to-version))))

 (defrecord DevMigrator [database]
   component/Lifecycle


+ default ideas,added sample content

+ default ideas,added sample content

--- src/clj_gamification/handler.clj
+++ src/clj_gamification/handler.clj
@@ -53,15 +53,28 @@
 (defn page-team-idea [team-id idea published]
   "Form to submit name of team's gamification idea"
   (page
-   "Idea"                               ; TODO better title
+   "Idea"
    (when published
      [:p.text-success "Your idea has been published"])
    [:form {:action (str "/team/" team-id "/idea"), :method "post"}
-    [:label (str "Publish team " team-id "'s gamification idea:")
-     [:br]
-     [:input {:type "text", :name "idea", :value idea,
-              :autofocus "true",
-              :title "Describe your idea"}]]
+    [:h1 (str "Publish team " team-id "'s gamification idea:")]
+    [:br]
+    (let [ideas ["Increase trashbin usage in parks." "Increase e-book reading platform usage." "Increase consumption of vegetables." "Increase motivation to try/learn new stuff."]]
+      [:ul.unstyled
+       (map (fn [id] [:li [:label.radio
+                          [:input {:type "radio", :name "idea", :value id}]
+                          " "
+                          id]
+                     [:br]])
+            ideas)
+       [:li
+        [:label.radio
+         [:input#custIdeaIn {:type "radio", :name "idea"}
+          [:input {:type "text", :value idea,
+                   :autofocus "true",
+                   :placeholder "Your own idea",
+                   :title "Describe your idea"
+                   :onchange "document.getElementById('custIdeaIn').value=this.value;"}]]]]])
     [:button.btn {:type "submit"} "Publish"]]
    await-voting-html
    ))
@@ -72,10 +85,11 @@
    "Teams"
    (include-changepoll-js)
    [:h1 "Teams & Topics"]
-   [:p "TODO: 10min countdown"]          ; TODO counter, sort by ID
-   [:ul (map
-      (fn [[id idea]] [:li "#" id ": " idea])  ; TODO show picture, format the list nicely
-      teams)]
+   [:p [:strong "You have 10 min for brainstorming"]]          ; TODO counter, sort by ID
+   [:p "Teams:"]
+   [:ol (map
+      (fn [[id idea]] [:li "#" id ": " idea])  ; TODO show picture
+      (sort-by first teams))]
    [:h4 "Ideas structuring tip: D6"]
    [:ol
     [:li "DEFINE business objectives: ..."]
@@ -123,7 +137,8 @@
   (page
    "GameMaster Control"
    [:h1 "You control the game!"]
-   [:p "Your mission, should you decide to accept it: TODO:describe"] ; TODO Hide when read?
+   [:p "Your mission, should you decide to accept it: Challenge the participants to group and brainstorm in 10 min interesting gamification ideas, present them, and then vote for the best one."]
+   [:p "Use the buttons below in order to move between the phases, changing what's shown on the projector."] ; TODO Hide when read?
    [:h2 "Controls"]
    (letfn [(button [cmd label]
              [:button.btn.btn-large
@@ -155,7 +170,9 @@
   (page "Projector"
         (include-changepoll-js)
         [:h1 "The Gamification Challenge"]
-        [:p "Your task is ..."]))
+        [:p "Gamification in praxis! Group with the people around and brainstorm a cool way to gamify a common task/problem. Describe briefly your idea to the other teams and vote for the best one."]
+        [:p "Some ideas for what to increase via gamification: Trashbin usage in parks. E-book reading platform usage. Consumption of vegetables. Motivation to try/learn new stuff. (Listed also on the team registration page.)"]
+        [:p "Be quick: The 1st and 3rd registered teams get a nice surprise!"]))

 (defn page-projector-voting-ongoing []
   (page "Projector"
@@ -165,7 +182,6 @@

 (defn has-voted? [{:keys [remote-addr session]}]
   (or
-   ;(@voter-ips remote-addr) ; TODO disabled for easier testing from 1 pc
    (:voted? session)))

 (defn show-page-for-step [{:keys [teams state]}
@@ -236,6 +252,7 @@
                      (page-team-idea id idea published)))
               (POST "/:id/idea" [id idea]
                     (let [id (toint id)]
+                      (info (str "idea posted: " idea))
                       (swap! teams assoc id idea) ; TODO notify visibly that the idea has been published; notify /teams page
                       (redirect (str "/team/" id "?published=true")))))
      (GET "/teams" []
@@ -264,7 +281,7 @@
             :teams (page-teams @teams)
             :voting (page-projector-voting-ongoing)
             :results (page-vote-results @teams @votes)))
-     (context "/command" [] ; GameMaster posts commands here (TODO? check it really is gm)
+     (context "/command" [] ; GameMaster posts commands here
               (POST "/show-task" [] (str (compare-and-set! projector :prestart :task)))
               (POST "/start-brainstorming" [] (str (compare-and-set! projector :task :teams)))
               (POST "/start-voting" [] (str (and


ENH: chapter 6, part 3: memoization

ENH: chapter 6, part 3: memoization

--- src/clj_prj03/ch6_functional.clj
+++ src/clj_prj03/ch6_functional.clj
@@ -103,3 +103,20 @@
   [f g]
   (fn [& args]
     (f (apply g args))))
+
+(+ (+ 5 8))
+
+; un-memoized version
+(defn sleepy-identity
+  "Returns the given value after 1 second"
+  [x]
+  (Thread/sleep 1000)
+  x)
+
+(sleepy-identity "Mr. Fantastico")
+
+; memoized version
+; only first call takes 1 second
+(def memo-sleepy-identity (memoize sleepy-identity))
+(memo-sleepy-identity "Mr. Fantastico")
+(memo-sleepy-identity "Mr. Fantastico")


Works to level it did before rewrite, it seems.

--- src/angelic/search/incremental/implicit.clj
+++ src/angelic/search/incremental/implicit.clj
@@ -144,6 +144,15 @@
                    (conj rest-things next-thing) (max-summary next-summary rest-summary) even-more-things)))
         [best-thing best-summary rest-things rest-summary])))

+(defn summary-str [s] (str (max-reward s) (:status s) (vec (:opt-sol s))))
+(defmethod print-method SimpleSummary [s o] (print-method (summary-str s) o))
+
+(defn assert-valid-summary-change [old-summary new-summary]
+  (util/assert-is (<= (max-reward new-summary) (max-reward old-summary)) "%s" [old-summary new-summary])
+  (when-not (live? old-summary) (assert (= old-summary new-summary))))
+
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Subproblems ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -170,6 +179,10 @@
    plans-atom     plan-summary-atom       ; Plans directly at node
    child-map-atom descendant-summary-atom ; Plans at descendants
    ])
+
+(defn osn-str [osn]
+  (str "OSN: " (env/action-name (second (:input-pair osn))) " " (clojure.string/join ", " (map #(summary-str (deref (% osn))) [:ancestor-summary-atom :plan-summary-atom :descendant-summary-atom]))))
+(defmethod print-method OutputSetNode [osn o] (print-method (osn-str osn) o))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Creating ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -272,7 +285,7 @@

 ;; misc accessors
 (def osn-output-set :output-set)
-(def osn-action     (comp first :input-pair))
+(def osn-action     (comp second :input-pair))

@@ -355,6 +368,10 @@
 (defrecord PlanNode [sub-osn excluded-child-set output-constraint
                      reward-bound output-set output-summary])

+(defn plan-node-str [pn]
+  (str (env/action-name (osn-action (:sub-osn pn))) " (" (summary-str (:output-summary pn)) ")"))
+(defmethod print-method PlanNode [pn o] (print-method (plan-node-str pn) o))
+

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Creating ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

@@ -400,8 +417,11 @@
 (defn refine-pn [pn input-summary min-reward]
   (let [{:keys [sub-osn excluded-child-set reward-bound]} pn]
     (refine-osn! sub-osn min-reward excluded-child-set)
-    (assoc pn :output-summary
-           (compute-plan-node-output-summary input-summary sub-osn excluded-child-set reward-bound))))
+    (let [new-summary (compute-plan-node-output-summary input-summary sub-osn
+                                                        excluded-child-set reward-bound)]
+      (assert-valid-summary-change (:output-summary pn) new-summary)
+      (assoc pn :output-summary new-summary))))
+

 ;;;;;;;;;;;;;;;;;;;;;;;;;;; Splitting Plan Nodes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -410,15 +430,18 @@
   "Split this plan node into a seq of plan nodes, all but 0-1 of which will have
    refined output sets."
   [pn input-set input-summary min-step-reward]
-  (let [{:keys [sub-osn excluded-child-set]} pn]
-    (let [split-children (split-osn sub-osn min-step-reward excluded-child-set)
-          new-ecs        (into excluded-child-set split-children)
-          new-summary    (broom-summary sub-osn new-ecs)]
-      (concat
-       (when (viable-summary? new-summary)
-         [(assoc pn :excluded-child-set new-ecs :output-summary new-summary)])
-       (for [child split-children]
-         (make-plan-node input-set input-summary child nil {} is/pos-inf))))))
+  (let [{:keys [sub-osn excluded-child-set]} pn
+        split-children (split-osn sub-osn min-step-reward excluded-child-set)
+;        _   (println "split" pn (count excluded-child-set) (count split-children))
+        new-ecs        (into excluded-child-set split-children)
+        new-summary    (add-summaries input-summary (broom-summary sub-osn new-ecs))]
+    (concat
+     (when (viable-summary? new-summary)
+       (assert-valid-summary-change (:output-summary pn) new-summary)
+       [(assoc pn :excluded-child-set new-ecs :output-summary new-summary)])
+     (for [child split-children]
+       (do ;         (println "SC"  sub-osn child )
+           (make-plan-node input-set input-summary child nil {} is/pos-inf))))))

 (defn update-pn-input
@@ -430,12 +453,14 @@
     (if (identical? new-osn sub-osn)
       (let [new-output-summary (compute-plan-node-output-summary
                                 new-input-summary sub-osn excluded-child-set reward-bound)]
+        (assert-valid-summary-change (:output-summary pn) new-output-summary)
         (when (viable-summary? new-output-summary)
           [[false output-set new-output-summary] (assoc pn :output-summary new-output-summary)]))
       (let [new-pn (make-plan-node new-input-set new-input-summary new-osn nil
                                    (osn-output-set sub-osn)
                                    (max-reward (broom-summary sub-osn)))
             new-output-pair (plan-node-output-set-and-summary new-pn)]
+        (assert-valid-summary-change (:output-summary pn) (second new-output-pair))
         (when (viable-output-set-and-summary? new-output-pair)
           [(cons (not (= (:output-set new-pn) output-set)) new-output-pair) new-pn])))))

@@ -448,8 +473,14 @@

 (defrecord Plan     [input-constraint input-set plan-nodes output-set summary])

+(defn plan-str [p]
+  (clojure.string/join ", " (map plan-node-str (:plan-nodes p))))
+(defmethod print-method Plan [p o] (print-method (plan-str p) o))
+
 (def plan-summary :summary)
 (def plan-output-set :output-set)
+
+

 (defn map-state
   "Transform a sequence via a state-machine.  transition-fn takes a state and input item,
@@ -492,16 +523,18 @@
 (defn expand-plan [plan min-reward]
   (if (not (refinable-summary? (:summary plan) min-reward)) [plan]
       (let [{:keys [input-constraint input-set plan-nodes output-set summary]} plan
-            [pre-nodes [ref-node & post-nodes]] (split-at (rand-int (count plan-nodes)) plan-nodes)
-;            _ (println summary (count pre-nodes) (class ref-node) (count post-nodes))
+            ref-index                           (rand-int (count plan-nodes))
+            [pre-nodes [ref-node & post-nodes]] (split-at ref-index plan-nodes)
+;            _ (println plan  (count pre-nodes) (class ref-node) (count post-nodes))
             [pre-set pre-summary]  (if (seq pre-nodes) (plan-node-output-set-and-summary (last pre-nodes)) [input-set zero-summary])
             sub-min-reward (- min-reward
                               (- (max-reward summary)
                                  (- (max-reward (:output-summary ref-node)) (max-reward pre-summary))))]
         (filter identity
                 (for [next-pn (split-pn-output (refine-pn ref-node pre-summary sub-min-reward) pre-set pre-summary sub-min-reward)]
-                  (propagate-plan-changes input-constraint input-set (concat pre-nodes [next-pn]) post-nodes
-                                          (not= (:output-set next-pn) (:output-set ref-node))))))))
+                  (do (assert-valid-summary-change (:output-summary ref-node) (:output-summary next-pn))
+                   (propagate-plan-changes input-constraint input-set (concat pre-nodes [next-pn]) post-nodes
+                                           (not= (:output-set next-pn) (:output-set ref-node)))))))))

@@ -521,6 +554,7 @@
         (let [sum (broom-summary root nil)]
           (println sum)
           (assert (not (refinable-summary? sum is/neg-inf)))
+          (def *root* root)
           (when-let [sol (optimal-solution sum)]
             [sol (max-reward sum)]))))))


[core] fix comment format

[core] fix comment format

--- src/braid/core/server/routes/api/public.clj
+++ src/braid/core/server/routes/api/public.clj
@@ -38,7 +38,7 @@
         (error-response 401 "Group is private"))
       (error-response 404 "No group with that id found")))

-  ; log in
+  ;; log in
   (PUT "/session" [email password :as req]
     (if-let [user-id (when (and email password)
                        (user/authenticate-user email password))]
@@ -65,7 +65,7 @@
              :session (assoc (req :session) :user-id (user :id))})))
       (error-response 500 "Couldn't exchange token with github")))

-  ; register a user
+  ;; register a user
   (PUT "/users" [email password :as req]
     (cond
       (string/blank? email)
@@ -97,7 +97,7 @@
           (edn-response {:ok true}))
       (error-response 400 :no-such-email)))

-  ; accept an email invite to join a group
+  ;; accept an email invite to join a group
   (POST "/register" [token invite_id email now hmac :as req]
     (let [fail {:status 400 :headers {"Content-Type" "text/plain"}}]
       (cond
@@ -125,7 +125,7 @@
                :session (assoc (req :session) :user-id user-id)
                :body ""}))))))

-  ; join by invite link
+  ;; join by invite link
   (POST "/link-register" [group-id email password now form-hmac :as req]
     (let [bad-resp {:status 400 :headers {"Content-Type" "text/plain"}}]
       (if-not group-id
@@ -175,7 +175,7 @@
                    :body ""}))
               (assoc bad-resp :body "Not logged in")))))))

-  ; reset password
+  ;; reset password
   (POST "/reset" [new-password token user-id :<< as-uuid now hmac :as req]
     (let [fail {:status 400 :headers {"Content-Type" "text/plain"}}]
       (cond


better logs

better logs

--- src/clj/algorithms_clj/macro_initiation.clj
+++ src/clj/algorithms_clj/macro_initiation.clj
@@ -402,7 +402,7 @@
   [bindings]
   (->>
     (flatten bindings)
-    (remove #{'&})
+    (remove #{'& '_})
     (remove keyword?)
     (vec)))

@@ -491,10 +491,15 @@
   [a b]
   (+ a b))

+(defn-log-3 get-first
+  [[x & _ :as list]]
+  x)
+
 (defn test-add-with-log-3
   []
   (reset! logger default-logger)
-  (println (add-with-log-3 1 2)))
+  (println (add-with-log-3 1 2))
+  (println (get-first [1 2 3])))

 ;; --------------------------------------------------------


Remove done todo

Remove done todo

--- src/cljs/iframe_app/condition_selector.cljs
+++ src/cljs/iframe_app/condition_selector.cljs
@@ -12,8 +12,6 @@
 (declare init-state)
 (declare will-mount)

-
-; TODO: items inside any currently selected condition should be bold
 (defcomponent value-picker [{:keys [selections conditions]} owner]
   (render-state [_ _]
     (html


Fix problem with compound keys in iterate-world query

--- src/clojure/clojurewerkz/cassaforte/cql.clj
+++ src/clojure/clojurewerkz/cassaforte/cql.clj
@@ -219,19 +219,22 @@
 (defn- get-chunk
   "Returns next chunk for the lazy world iteration"
   [table partition-key chunk-size last-pk]
-  (if (nil? last-pk)
+  (if (nil? (first last-pk))
     (select table
             (query/limit chunk-size))
     (select table
-            (query/where (query/token partition-key) [> (query/token last-pk)])
+            (query/where (apply query/cql-fn "token" partition-key) [> (apply query/cql-fn "token" last-pk)])
             (query/limit chunk-size))))

 (defn iterate-world
   "Lazily iterates through the collection, returning chunks of chunk-size."
   ([table partition-key chunk-size]
-     (iterate-world table partition-key chunk-size []))
+     (iterate-world table (if (sequential? partition-key)
+                            partition-key
+                            [partition-key])
+                    chunk-size []))
   ([table partition-key chunk-size c]
      (lazy-cat c
-               (let [last-pk    (get (last c) partition-key)
+               (let [last-pk    (map #(get (last c) %) partition-key)
                      next-chunk (get-chunk table partition-key chunk-size last-pk)]
                  (iterate-world table partition-key chunk-size next-chunk)))))


OpenCL 2.0 info implemented.

OpenCL 2.0 info implemented.

--- src/clojure/uncomplicate/clojurecl/info.clj
+++ src/clojure/uncomplicate/clojurecl/info.clj
@@ -6,11 +6,46 @@
              [structs :refer [int32 int64 wrap-byte-seq]]])
   (:import [org.jocl CL cl_platform_id  cl_device_id cl_context cl_command_queue
             cl_mem cl_program cl_kernel cl_sampler cl_event
+            cl_device_partition_property
             Sizeof Pointer]
            [java.nio ByteBuffer]))

+;; TODO OpenCL 2.0
+(def CL_QUEUE_ON_DEVICE (bit-shift-left 1 2))
+(def CL_QUEUE_ON_DEVICE_DEFAULT (bit-shift-left 1 3))
+(def CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE 0x1054)
+(def CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT 0x104B)
+
+(def CL_DEVICE_IMAGE_PITCH_ALIGNMENT 0x104A)
+(def CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE 0x104D)
+(def CL_DEVICE_MAX_ON_DEVICE_EVENTS 0x1052)
+(def CL_DEVICE_MAX_ON_DEVICE_QUEUES 0x1051)
+(def CL_DEVICE_MAX_PIPE_ARGS 0x1055)
+(def CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS 0x104C)
+(def CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS 0x1056)
+(def CL_DEVICE_PIPE_MAX_PACKET_SIZE 0x1057)
+(def CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT 0x1059)
+(def CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT 0x105A)
+(def CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT 0x1058)
+(def CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE 0x1050)
+(def CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE 0x104F)
+(def CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES 0x104E)
+(def CL_DEVICE_QUEUE_ON_HOST_PROPERTIES 0x102A)
+(def CL_DEVICE_SPIR_VERSIONS 0x40E0)
+(def CL_DEVICE_SVM_CAPABILITIES 0x1053)
+(def CL_DEVICE_SVM_COARSE_GRAIN_BUFFER (bit-shift-left 1 0) )
+(def CL_DEVICE_SVM_FINE_GRAIN_BUFFER (bit-shift-left 1 1));
+(def CL_DEVICE_SVM_FINE_GRAIN_SYSTEM (bit-shift-left 1 2))
+(def CL_DEVICE_SVM_ATOMICS (bit-shift-left 1 3))
+
 ;; =================== Info* utility macros ===============================

+(defmacro ^:private info-num* [method clobject info sizeof]
+  `(let [res# (long-array 1)
+         err# (~method ~clobject ~info 0 nil res#)]
+     (with-check err# (/ (aget res# 0) ~sizeof))))
+
+;;TODO use info-num*
 (defmacro ^:private info-string* [method clobject info]
   `(let [size# (long-array 1)
          err# (~method ~clobject ~info 0 nil size#)]
@@ -57,6 +92,7 @@
                          (byte-seq res#)))))
     ([method clobject info]
      `(first (info-size* ~method ~clobject ~info 1)))))
+

 (defmacro ^:private info-long*
   ([method clobject info num]
@@ -206,9 +242,9 @@
 (defn global-mem-size ^long [device]
   (info-long* CL/clGetDeviceInfo device CL/CL_DEVICE_GLOBAL_MEM_SIZE))

-;; TODO Opencl 2.0
-(defn global-variable-preferred-total-size [device]
-  nil)
+(defn global-variable-preferred-total-size ^long [device]
+  (info-size* CL/clGetDeviceInfo device
+              CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE))

 (defn image2d-max-height ^long [device]
   (info-size* CL/clGetDeviceInfo device CL/CL_DEVICE_IMAGE2D_MAX_HEIGHT))
@@ -225,9 +261,8 @@
 (defn image3d-max-width ^long [device]
   (info-size* CL/clGetDeviceInfo device CL/CL_DEVICE_IMAGE3D_MAX_WIDTH))

-;; TODO Opencl 2.0
-(defn image-base-address-alignment [device]
-  nil)
+(defn image-base-address-alignment ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT))

 (defn image-max-array-size ^long [device]
   (info-size* CL/clGetDeviceInfo device CL/CL_DEVICE_IMAGE_MAX_ARRAY_SIZE))
@@ -235,9 +270,8 @@
 (defn image-max-buffer-size ^long [device]
   (info-size* CL/clGetDeviceInfo device CL/CL_DEVICE_IMAGE_MAX_BUFFER_SIZE))

-;; TODO Opencl 2.0
-(defn image-pitch-alignment [device]
-  nil)
+(defn image-pitch-alignment ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_IMAGE_PITCH_ALIGNMENT))

 (defn image-support [device]
   (info-bool* CL/clGetDeviceInfo device CL/CL_DEVICE_IMAGE_SUPPORT))
@@ -268,34 +302,29 @@
 (defn max-constant-buffer-size ^long [device]
   (info-long* CL/clGetDeviceInfo device CL/CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE))

-;; TODO Opencl 2.0
-(defn max-global-variable-size [device]
-  nil)
+(defn max-global-variable-size ^long [device]
+  (info-size* CL/clGetDeviceInfo device CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE))

 (defn max-mem-aloc-size ^long [device]
   (info-long* CL/clGetDeviceInfo device CL/CL_DEVICE_MAX_MEM_ALLOC_SIZE))

-;; TODO Opencl 2.0
-(defn max-on-device-events [device]
-  nil)
-
-;; TODO Opencl 2.0
-(defn max-on-device-queues [device]
-  nil)
+(defn max-on-device-events ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_MAX_ON_DEVICE_EVENTS))
+
+(defn max-on-device-queues ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_MAX_ON_DEVICE_QUEUES))

 (defn max-parameter-size ^long [device]
   (info-size* CL/clGetDeviceInfo device CL/CL_DEVICE_MAX_PARAMETER_SIZE))

-;; TODO Opencl 2.0
-(defn max-pipe-args [device]
-  nil)
+(defn max-pipe-args ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_MAX_PIPE_ARGS))

 (defn max-read-image-args ^long [device]
   (info-int* CL/clGetDeviceInfo device CL/CL_DEVICE_MAX_READ_IMAGE_ARGS))

-;; TODO Opencl 2.0
-(defn max-read-write-image-args [device]
-  nil)
+(defn max-read-write-image-args ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS))

 (defn max-samplers ^long [device]
   (info-int* CL/clGetDeviceInfo device CL/CL_DEVICE_MAX_SAMPLERS))
@@ -373,20 +402,36 @@
   (info-int* CL/clGetDeviceInfo device CL/CL_DEVICE_PARTITION_MAX_SUB_DEVICES))

 ;;TODO
+
+(defn ^:private decode-partition-property [^long code]
+  (case code
+    0x1086 :partition-equally
+    0x1087 :partition-by-counts
+    0x1088 :partition-by-affinity-domain
+    :unknown))
+
 (defn partition-properties [device]
-  (info-long* CL/clGetDeviceInfo device CL/CL_DEVICE_PARTITION_PROPERTIES))
+  (set (map decode-partition-property
+            (vec (info-long* CL/clGetDeviceInfo device
+                             CL/CL_DEVICE_PARTITION_PROPERTIES
+                             (info-num* CL/clGetDeviceInfo device
+                                        CL/CL_DEVICE_PARTITION_PROPERTIES
+                                        Sizeof/cl_long)))) ))

 ;;TODO
 (defn partition-type [device]
-  (info-long* CL/clGetDeviceInfo device CL/CL_DEVICE_PARTITION_TYPE))
-
-;; TODO Opencl 2.0
-(defn pipe-max-active-reservations [device]
-  nil)
-
-;; TODO Opencl 2.0
-(defn pipe-max-packet-size [device]
-  nil)
+  (set (map decode-partition-property
+            (vec (info-long* CL/clGetDeviceInfo device
+                             CL/CL_DEVICE_PARTITION_TYPE
+                             (info-num* CL/clGetDeviceInfo device
+                                        CL/CL_DEVICE_PARTITION_TYPE
+                                        Sizeof/cl_long)))) ))
+
+(defn pipe-max-active-reservations ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS))
+
+(defn pipe-max-packet-size ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_PIPE_MAX_PACKET_SIZE))

 (defn platform [device]
   (let [p (cl_platform_id.)
@@ -394,22 +439,19 @@
                                 Sizeof/cl_platform_id
                                 (Pointer/to p)
                                 nil)]
-    (with-check err platform)))
-
-;; TODO Opencl 2.0
-(defn preferred-global-atomic-alignment [device]
-  nil)
+    (with-check err p)))
+
+(defn preferred-global-atomic-alignment ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT))

 (defn preferred-interop-user-sync [device]
   (info-bool* CL/clGetDeviceInfo device CL/CL_DEVICE_PREFERRED_INTEROP_USER_SYNC))

-;; TODO Opencl 2.0
-(defn preferred-local-atomic-alignment [device]
-  nil)
-
-;; TODO Opencl 2.0
-(defn preferred-platform-atomic-alignment [device]
-  nil)
+(defn preferred-local-atomic-alignment ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT))
+
+(defn preferred-platform-atomic-alignment ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT))

 (defn preferred-vector-width-char ^long [device]
   (info-int* CL/clGetDeviceInfo device CL/CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR))
@@ -438,21 +480,27 @@
 (defn profiling-timer-resolution [device]
   (info-size* CL/clGetDeviceInfo device CL/CL_DEVICE_PROFILING_TIMER_RESOLUTION))

-;; TODO Opencl 2.0
-(defn queue-on-device-max-size [device]
-  nil)
-
-;; TODO Opencl 2.0
-(defn queue-on-device-preferred-size [device]
-  nil)
-
-;; TODO Opencl 2.0
+(defn queue-on-device-max-size ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE))
+
+(defn queue-on-device-preferred-size ^long [device]
+  (info-int* CL/clGetDeviceInfo device CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE))
+
 (defn queue-on-device-properties [device]
-  nil)
-
-;; TODO Opencl 2.0
+  (let [mask (info-long* CL/clGetDeviceInfo device
+                         CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES)]
+    (disj (hash-set (mask* mask CL/CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
+                           :out-of-order-exec-mode)
+                    (mask* mask CL/CL_QUEUE_PROFILING_ENABLE :profiling))
+          nil)))
+
 (defn queue-on-host-properties [device]
-  nil)
+  (let [mask (info-long* CL/clGetDeviceInfo device
+                         CL_DEVICE_QUEUE_ON_HOST_PROPERTIES)]
+    (disj (hash-set (mask* mask CL/CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
+                           :out-of-order-exec-mode)
+                    (mask* mask CL/CL_QUEUE_PROFILING_ENABLE :profiling))
+          nil)))

 (defn single-fp-config [device]
   (let [mask (info-long* CL/clGetDeviceInfo device
@@ -468,13 +516,21 @@
                     (mask* mask CL/CL_FP_SOFT_FLOAT :soft-float))
           nil)))

-;; TODO Opencl 2.0
 (defn spir-versions [device]
-  nil)
-
-;; TODO Opencl 2.0
+  (to-set (info-string* CL/clGetDeviceInfo device CL_DEVICE_SPIR_VERSIONS)))
+
 (defn svm-capabilities [device]
-  nil)
+  (let [mask (info-long* CL/clGetDeviceInfo device
+                         CL_DEVICE_SVM_CAPABILITIES)]
+    (disj (hash-set (mask* mask CL_DEVICE_SVM_COARSE_GRAIN_BUFFER
+                           :coarse-grain-buffer)
+                    (mask* mask CL_DEVICE_SVM_FINE_GRAIN_BUFFER
+                           :fine-grain-buffer)
+                    (mask* mask CL_DEVICE_SVM_FINE_GRAIN_SYSTEM
+                           :fine-grain-system)
+                    (mask* mask CL_DEVICE_SVM_ATOMICS
+                           :svm-atomics))
+          nil)))

 ;; TODO Opencl 2.0
 (defn terminate-capability-khr [device]
@@ -518,16 +574,16 @@
      global-mem-cache-type
      ^long global-mem-cacheline-size
      ^long global-mem-size
-     global-variable-preferred-total-size
+     ^long global-variable-preferred-total-size
      ^long image2d-max-height
      ^long image2d-max-width
      ^long image3d-max-depth
      ^long image3d-max-height
      ^long image3d-max-width
-     image-base-address-alignment
+     ^long image-base-address-alignment
      ^long image-max-array-size
      ^long image-max-buffer-size
-     image-pitch-alignment
+     ^long image-pitch-alignment
      image-support
      linker-available
      ^long local-mem-size
@@ -536,14 +592,14 @@
      ^long max-compute-units
      ^long max-constant-args
      ^long max-constant-buffer-size
-      max-global-variable-size
+     ^long max-global-variable-size
      ^long max-mem-aloc-size
-     max-on-device-events
-     max-on-device-queues
+     ^long max-on-device-events
+     ^long max-on-device-queues
      ^long max-parameter-size
-     max-pipe-args
+     ^long max-pipe-args
      ^long max-read-image-args
-     max-read-write-image-args
+     ^long max-read-write-image-args
      ^long max-samplers
      ^long max-work-group-size
      ^long max-work-item-dimensions
@@ -562,15 +618,15 @@
      parent-device
      partition-affinity-domain
      ^long partition-max-sub-devices
-     ;;:partition-properties partition-properties ;;TODO raises exception when called on CPU
+     partition-properties
      partition-type
-     pipe-max-active-reservations
-     pipe-max-packet-size
+     ^long pipe-max-active-reservations
+     ^long pipe-max-packet-size
      platform
-     preferred-global-atomic-alignment
+     ^long preferred-global-atomic-alignment
      preferred-interop-user-sync
-     preferred-local-atomic-alignment
-     preferred-platform-atomic-alignment
+     ^long preferred-local-atomic-alignment
+     ^long preferred-platform-atomic-alignment
      ^long preferred-vector-width-char
      ^long preferred-vector-width-short
      ^long preferred-vector-width-int
@@ -581,8 +637,8 @@
      ^long printf-buffer-size
      profile
      profiling-timer-resolution
-     queue-on-device-max-size
-     queue-on-device-preferred-size
+     ^long queue-on-device-max-size
+     ^long queue-on-device-preferred-size
      queue-on-device-properties
      queue-on-host-properties
      ^long reference-count
@@ -658,7 +714,7 @@
        :parent-device (parent-device d)
        :partition-affinity-domain (partition-affinity-domain d)
        :partition-max-sub-devices (partition-max-sub-devices d)
-       ;;:partition-properties partition-properties ;;TODO raises exception when called on CPU
+       :partition-properties (partition-properties d)
        :partition-type (partition-type d)
        :pipe-max-active-reservations (pipe-max-active-reservations d)
        :pipe-max-packet-size (pipe-max-packet-size d)
@@ -750,7 +806,7 @@
       (parent-device d)
       (partition-affinity-domain d)
       (partition-max-sub-devices d)
-     ;;:partition-properties partition-properties ;;TODO raises exception when called on CPU
+      (partition-properties d)
       (partition-type d)
       (pipe-max-active-reservations d)
       (pipe-max-packet-size d)
@@ -878,8 +934,8 @@
       (disj (hash-set (mask* mask CL/CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
                              :out-of-order-exec-mode)
                       (mask* mask CL/CL_QUEUE_PROFILING_ENABLE :profiling)
-                      ;; TODO OpenCL 2.0 (mask* mask CL/CL_QUEUE_ON_DEVICE :queue-on-device)
-                      #_(mask* mask CL/CL_QUEUE_ON_DEVICE_DEFAULT
+                      (mask* mask CL_QUEUE_ON_DEVICE :queue-on-device)
+                      (mask* mask CL_QUEUE_ON_DEVICE_DEFAULT
                                :queue-on-device-default))
             nil))))


map data in inbound #230

map data in inbound
#230

--- src/clj/swarmpit/docker/engine/mapper/inbound.clj
+++ src/clj/swarmpit/docker/engine/mapper/inbound.clj
@@ -389,7 +389,8 @@
     :version (get-in config [:Version :Index])
     :configName (get-in config [:Spec :Name])
     :createdAt (:CreatedAt config)
-    :updatedAt (:UpdatedAt config)))
+    :updatedAt (:UpdatedAt config)
+    :data (get-in config [:Spec :Data])))

 (defn ->configs
   [configs]


added specialized work-group-Xd functions.

--- src/clojure/uncomplicate/clojurecl/core.clj
+++ src/clojure/uncomplicate/clojurecl/core.clj
@@ -1179,7 +1179,7 @@
   "
   ([kernel x & values]
    (if (integer? x)
-     (loop [i x values values]
+     (loop [i (long x) values values]
        (if-let [val (first values)]
          (do (set-arg! kernel i val)
              (recur (inc i) (next values)))
@@ -1225,8 +1225,87 @@
    (let [global-array (long-array global)]
      (->WorkSize (alength global-array) global-array nil nil)))
   ([]
-   (let [global-array (long-array [1])]
+   (let [global-array (doto (long-array 0) (aset 0 1))]
      (->WorkSize 1 global-array nil nil))))
+
+(defn work-size-1d
+  "Creates a 1-dimensional [[WorkSize]] from the long numbers it receives.
+  See also [[work-size]].
+
+  Examples:
+  (work-size-1d 1024)
+  (work-size-1d 1024 256)
+  (work-size-1d 1024 256 1)"
+  ([^long global ^long local ^long offset]
+   (->WorkSize 1
+               (doto (long-array 1) (aset 0 global))
+               (doto (long-array 1) (aset 0 local))
+               (doto (long-array 1) (aset 0 offset))))
+  ([^long global ^long local]
+   (->WorkSize 1
+               (doto (long-array 1) (aset 0 global))
+               (doto (long-array 1) (aset 0 local))
+               nil))
+  ([^long global]
+   (->WorkSize 1 (doto (long-array 1) (aset 0 global)) nil nil))
+  ([]
+   (->WorkSize 1 (doto (long-array 1) (aset 0 1)) nil nil)))
+
+(defn work-size-2d
+  "Creates a 2-dimensional [[WorkSize]] from the long numbers it receives.
+  See also [[work-size]].
+
+  Examples:
+  (work-size-2d 1024 2048)
+  (work-size-2d 1024 2048 16 16)
+  (work-size-2d 1024 2048 16 16 8 0 2)
+  "
+  ([global0 global1 local0 local1 offset0 offset1]
+   (->WorkSize 2
+               (doto (long-array 2) (aset 0 (long global0)) (aset 1 (long global1)))
+               (doto (long-array 2) (aset 0 (long local0)) (aset 1 (long local1)))
+               (doto (long-array 2) (aset 0 (long offset0)) (aset 1 (long offset1)))))
+  ([^long global0 ^long global1 ^long local0 ^long local1]
+   (->WorkSize 2
+               (doto (long-array 2) (aset 0 global0) (aset 1 global1))
+               (doto (long-array 2) (aset 0 local0) (aset 1 local1))
+               nil))
+  ([^long global0 ^long global1]
+   (->WorkSize 2 (doto (long-array 2) (aset 0 global0) (aset 1 global1)) nil nil))
+  ([]
+   (->WorkSize 2 (doto (long-array 2) (aset 0 1) (aset 1 1)) nil nil)))
+
+(defn work-size-3d
+  "Creates a 3-dimensional [[WorkSize]] from the long numbers it receives.
+  See also [[work-size]].
+
+  Examples:
+  (work-size-3d 1024 2048 512)
+  (work-size-3d 1024 2048 256 16 16)
+  (work-size-3d 1024 2048 128 16 4 4 16 0 2 512)
+  "
+  ([global0 global1 global2 local0 local1 local2 offset0 offset1 offset2]
+   (->WorkSize 3
+               (doto (long-array 3) (aset 0 (long global0))
+                     (aset 1 (long global1)) (aset 2 (long global2)))
+               (doto (long-array 3) (aset 0 (long local0))
+                     (aset 1 (long local1)) (aset 2 (long local2)))
+               (doto (long-array 3) (aset 0 (long offset0))
+                     (aset 1 (long offset1)) (aset 2 (long offset2)))))
+  ([global0 global1 global2 local0 local1 local2]
+   (->WorkSize 3
+               (doto (long-array 3) (aset 0 (long global0))
+                     (aset 1 (long global1)) (aset 2 (long global2)))
+               (doto (long-array 3) (aset 0 (long local0))
+                     (aset 1 (long local1)) (aset 2 (long local2)))
+               nil))
+  ([^long global0 ^long global1 ^long global2]
+   (->WorkSize 3
+               (doto (long-array 3) (aset 0 global0)
+                     (aset 1 global1) (aset 2 global2))
+               nil nil))
+  ([]
+   (->WorkSize 3 (doto (long-array 3) (aset 0 1) (aset 1 1) (aset 2 1)) nil nil)))

 ;; ============== Command Queue ===============================

@@ -1448,7 +1527,7 @@
   ([queue cl host blocking offset ^objects wait-events event]
    (with-check
      (CL/clEnqueueWriteBuffer queue (cl-mem cl) blocking offset
-                              (min (size cl) (size host)) (ptr host)
+                              (min (long (size cl)) (long (size host))) (ptr host)
                               (if wait-events (alength wait-events) 0)
                               wait-events event)
      queue))
@@ -1547,7 +1626,7 @@
   [queue cl blocking offset req-size flags ^objects wait-events event]
   (let [err (int-array 1)
         res (CL/clEnqueueMapBuffer queue (cl-mem cl) blocking flags offset
-                                   (min req-size (- (size cl) offset))
+                                   (min (long req-size) (- (long (size cl)) (long offset)))
                                    (if wait-events (alength wait-events) 0)
                                    wait-events event err)]
     (with-check-arr err (.order res (ByteOrder/nativeOrder)))))


Fixed bug in error function

Fixed bug in error function

--- src/clojush/problems/software/syllables.clj
+++ src/clojush/problems/software/syllables.clj
@@ -13,8 +13,8 @@
   (:use clojush.pushgp.pushgp
         [clojush pushstate interpreter random util globals]
         clojush.instructions.tag
-        clojure.math.numeric-tower
-        ))
+        clojure.math.numeric-tower)
+    (:require [clojure.string :as string]))

 ;; Define test cases
 (defn syllables-input
@@ -106,7 +106,7 @@
   (let [[train-cases test-cases] (map #(sort-by (comp count first) %)
                                       (map syllables-test-cases
                                            (test-and-train-data-from-domains data-domains)))]
-    (when true ;; Change to false to not print test cases
+    (when false ;; Change to false to not print test cases
       (doseq [[i case] (map vector (range) train-cases)]
         (println (format "Train Case: %3d | Input/Output: %s" i (str case))))
       (doseq [[i case] (map vector (range) test-cases)]
@@ -137,11 +137,14 @@
                              ; Error is Levenshtein distance and, if ends in an integer, distance from correct integer
                              (vector
                                (levenshtein-distance correct-output printed-result)
-                               (if-let [num-result (re-find #"-?\d+$" printed-result)]
-                                 (abs (- (Integer/parseInt (re-find #"-?\d+$" correct-output))
-                                         (Integer/parseInt num-result))) ;distance from correct integer
-                                 1000)
-                             )))))]
+                               (let [num-result (try (read-string (last (string/split printed-result #"\s+")))
+                                                  (catch Exception e nil))]
+                                 (if (integer? num-result)
+                                   (abs (- (try (read-string (last (string/split correct-output #"\s+")))
+                                             (catch Exception e nil))
+                                           num-result)) ;distance from correct integer
+                                   1000)
+                                 ))))))]
           (when @global-print-behavioral-diversity
             (swap! population-behaviors conj @behavior))
           errors)))))


Support tag queries on Postgres 8.1

Support tag queries on Postgres 8.1

This version doesn't have the <@ operator for arrays, so we have to fall
back to using ANY.

--- src/com/puppetlabs/puppetdb/scf/storage.clj
+++ src/com/puppetlabs/puppetdb/scf/storage.clj
@@ -87,7 +87,9 @@

 (defmethod sql-array-query-string "PostgreSQL"
   [column]
-  (format "ARRAY[?::text] <@ %s" column))
+  (if (pos? (compare (sql-current-connection-database-version) [8 1]))
+    (format "ARRAY[?::text] <@ %s" column)
+    (format "? = ANY(%s)" column)))

 (defmethod sql-array-type-string "HSQL Database Engine"
   [basetype]


don't update UI so much

don't update UI so much

Until we get to web sockets polling slows everything down!

--- src/webapp/framework/client/coreclient.cljs
+++ src/webapp/framework/client/coreclient.cljs
@@ -1562,7 +1562,7 @@

-       ))) 200)
+       ))) 500)


Current time is returned in status call

Current time is returned in status call

--- src/emender_jenkins/rest_api.clj
+++ src/emender_jenkins/rest_api.clj
@@ -144,11 +144,12 @@
 (defn status-handler
     "REST API handler for the /api/status"
     [request]
-    (let [response {:properties (process-info/read-properties)
-                    :pid        (process-info/get-current-pid)
-                    :started-on (config/get-started-on-str request)
-                    :started-ms (config/get-started-on-ms request)
-                    :uptime-sec (/ (- (System/currentTimeMillis) (config/get-started-on-ms request)) 1000)}]
+    (let [response {:properties     (process-info/read-properties)
+                    :pid            (process-info/get-current-pid)
+                    :started-on     (config/get-started-on-str request)
+                    :started-ms     (config/get-started-on-ms request)
+                    :current-time   (.toString (new java.util.Date))
+                    :uptime-seconds (/ (- (System/currentTimeMillis) (config/get-started-on-ms request)) 1000)}]
          (send-response response request)))

 (defn reload-job-list


Don't print stack trace to the standard output

--- src/emender_jenkins/rest_api.clj
+++ src/emender_jenkins/rest_api.clj
@@ -223,7 +223,7 @@
         (let [response (metadata-reader/get-metadata)]
             (send-response response request))
         (catch Exception e
-                (.printStackTrace e)
+                ;(.printStackTrace e)
                 (-> (create-error-response "(not needed)" "reload-tests-metadata" (.getMessage e))
                     (send-error-response request :internal-server-error)))))

@@ -302,7 +302,7 @@
                         (send-job-invalid-metadata-response request :create-job (job-invalid-input job-name git-repo branch))))
                 (send-wrong-job-name-response request job-name :create-job)))
         (catch Exception e
-            (.printStackTrace e)
+            ;(.printStackTrace e)
             (send-job-invalid-metadata-response request :create-job "invalid or missing input"))))

 (defn update-job


Remove *err* and *out* binding from log-exceptions.

It does nothing.

--- src/incise/watcher.clj
+++ src/incise/watcher.clj
@@ -7,15 +7,11 @@

 (defn log-exceptions [func]
   "Log (i.e. print) exceptions received from the given function."
-  (let [out *out*
-        err *err*]
-    (fn [& args]
-      (binding [*out* out
-                *err* err]
-        (try
-          (apply func args)
-          (catch Exception e
-            (error (with-out-str (print-cause-trace e)))))))))
+  (fn [& args]
+    (try
+      (apply func args)
+      (catch Exception e
+        (error (with-out-str (print-cause-trace e)))))))

 (defn per-change [change-fn]
   (fn [files]


more testing with the same bug

more testing with the same bug

--- src/mafia_votecount/scraper/team_liquid.clj
+++ src/mafia_votecount/scraper/team_liquid.clj
@@ -53,9 +53,9 @@
   (let [page-number-bar (get-page-number-bar content)
         last-page  (->> (reverse page-number-bar)
                         (filter #(Character/isDigit (first %))) ;; Filter is lazy
-                        (first)
-                        (if (integer? (Integer/parseInt)) (Integer/parseInt) 1 ))]
-    (vec (range 1 (inc last-page)))))
+                        (first))
+        last-page-number (if (integer? (Integer/parseInt last-page)) (Integer/parseInt) 1)]
+    (vec (range 1 (inc last-page-number)))))

 (defn- has-quote? [part]
   (and (map? (:attrs part))


api: allow disabling altogether

api: allow disabling altogether

--- src/io/cyanite/api.clj
+++ src/io/cyanite/api.clj
@@ -117,10 +117,12 @@
 (defrecord Api [options pool service store index engine]
   component/Lifecycle
   (start [this]
-    (let [tp      (cp/threadpool 1)
-          handler (make-handler store index engine)]
-      (cp/future tp (run-jetty (assoc options :ring-handler handler)))
-      (assoc this :pool tp)))
+    (if (:disabled options)
+      this
+      (let [tp      (cp/threadpool 1)
+            handler (make-handler store index engine)]
+        (cp/future tp (run-jetty (assoc options :ring-handler handler)))
+        (assoc this :pool tp))))
   (stop [this]
     (when pool
       (cp/shutdown pool))


reinstated :x-liftstack with better protections vs overflow

--- src/push/instructions/extra/stack_combinators.clj
+++ src/push/instructions/extra/stack_combinators.clj
@@ -69,7 +69,7 @@
     (eval (list
       'push.instructions.core/build-instruction
       instruction-name
-      (str "`:" instruction-name "` takes an `:integer` argument, makes that into an index modulo the `" typename "` stack size, 'cuts' the stack after the first [idx] items and copies everything below that point onto the top as a block. If the result has more than `max-collection-size` items, the change is undone.")
+      (str "`:" instruction-name "` takes an `:integer` argument, makes that into an index modulo the `" typename "` stack size, 'cuts' the stack after the first [idx] items and copies everything below that point onto the top as a block. If the result would have more points (at any level) than `max-collection-size`, the change is undone.")
       :tags #{:combinator}
       `(push.instructions.dsl/consume-top-of :integer :as :where)
       `(push.instructions.dsl/consume-stack ~typename :as :old)
@@ -79,7 +79,7 @@
         #(into '() (reverse (concat (drop %2 %1) %1))) :as :new)
       '(push.instructions.dsl/save-max-collection-size :as :limit)
       `(push.instructions.dsl/calculate [:new :limit :old]
-        #(if (> (count %1) %2) %3 %1) :as :new)
+        #(if (> (u/count-collection-points %1) %2) %3 %1) :as :new)
       `(push.instructions.dsl/replace-stack ~typename :new)))))

@@ -93,7 +93,7 @@
       (t/attach-instruction (flipstack-instruction pushtype))
       (t/attach-instruction (cutflip-instruction pushtype))
       (t/attach-instruction (cutstack-instruction pushtype))
-      ; (t/attach-instruction (liftstack-instruction pushtype))
+      (t/attach-instruction (liftstack-instruction pushtype))
       ))


Unit tests for transformations

Unit tests for transformations

--- test/cia/stores/sql/transformation_test.clj
+++ test/cia/stores/sql/transformation_test.clj
@@ -1,9 +1,34 @@
 (ns cia.stores.sql.transformation-test
   (:require [cia.stores.sql.transformation :as t]
             [cia.test-helpers.core]
+            [clj-time.core :as time]
             [clj-time.coerce :as coerce]
             [clojure.test :refer [deftest is]])
   (:import org.joda.time.DateTime))
+
+(deftest drop-nils-test
+  (is (= {:a :foo :c :bar}
+         (t/drop-nils {:a :foo :b nil :c :bar :d nil}))))
+
+(deftest to-db-observable
+  (is (= {:foo :bar :observable_type "type" :observable_value "value"}
+       (t/to-db-observable
+        {:foo :bar :observable {:type "type" :value "value"}}))))
+
+(deftest to-schema-observable
+  (is (= {:foo :bar :observable {:type "type" :value "value"}}
+         (t/to-schema-observable
+          {:foo :bar :observable_type "type" :observable_value "value"}))))
+
+(deftest to-db-valid-time
+  (is (= {:foo :bar :valid_time_start_time "start" :valid_time_end_time "end"}
+         (t/to-db-valid-time
+          {:foo :bar :valid_time {:start_time "start" :end_time "end"}}))))
+
+(deftest to-schema-valid-time
+  (is (= {:foo :bar :valid_time {:start_time "start" :end_time "end"}}
+         (t/to-schema-valid-time
+          {:foo :bar :valid_time_start_time "start" :valid_time_end_time "end"}))))

 (deftest datetimes-to-sqltimes-test
   (let [now (DateTime.)
@@ -16,3 +41,64 @@
           [{:foo :bar}
            {:a :a :b now :c :c}
            {:a now :b {:c now :d {:e now}}}])))))
+
+(deftest sqltimes-to-datetimes-test
+  (let [now (time/date-time 2016 2 29 7 6 0)
+        sql-now (coerce/to-sql-time now)]
+    (is (deep=
+         [{:foo :bar}
+          {:a :a :b now :c :c}
+          {:a now :b {:c now :d {:e now}}}]
+         (t/sqltimes-to-datetimes
+          [{:foo :bar}
+           {:a :a :b sql-now :c :c}
+           {:a sql-now :b {:c sql-now :d {:e sql-now}}}])))))
+
+(def relationship-example
+  {:entity-relationship-key :indicators
+   :relationship-reference-key :indicator
+   :entity-id-key :judgement_id
+   :other-id-key :indicator_id})
+
+(deftest db-relationship->schema-relationship
+  (let [sut (t/db-relationship->schema-relationship relationship-example)]
+    (is (= {:confidence "confidence"
+            :source "source"
+            :relationship "relationship"
+            :indicator "indicator_id"}
+           (sut
+            {:confidence "confidence"
+             :source "source"
+             :relationship "relationship"
+             :judgement_id "judgement_id"
+             :indicator_id "indicator_id"})))
+
+    (is (= {:indicator "indicator_id"}
+           (sut
+            {:judgement_id "judgement_id"
+             :indicator_id "indicator_id"})))))
+
+(deftest entities->db-relationships
+  (let [sut (t/entities->db-relationships relationship-example)]
+    (is (= [{:confidence "confidence"
+             :source "source"
+             :relationship "relationship"
+             :judgement_id "judgement_id"
+             :indicator_id "indicator_id"}
+            {:judgement_id "judgement_id"
+             :indicator_id "indicator_id"}]
+           (sut
+            [{:id "judgement_id"
+              :indicators [{:confidence "confidence"
+                            :source "source"
+                            :relationship "relationship"
+                            :indicator "indicator_id"}]}
+             {:id "judgement_id"
+              :indicators [{:indicator "indicator_id"}]}])))))
+
+(deftest filter-map->where-map
+  (is (= {:observable_type "type"
+          :observable_value "value"}
+         (t/filter-map->where-map
+          {[:observable :type] "type"
+           [:observable :value] "value"}))))


fixed typo (#133)

fixed typo (#133)

abbreviation for October in German is okt (not oct)

--- resources/languages/de/rules/time.clj
+++ resources/languages/de/rules/time.clj
@@ -94,7 +94,7 @@
   (month 9)

   "named-month"
-  #"(?i)oktober|oct\.?"
+  #"(?i)oktober|okt\.?"
   (month 10)

   "named-month"


fix clear for behaviors helper

fix clear for behaviors helper

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- src/lt/objs/langs/behaviors.cljs
+++ src/lt/objs/langs/behaviors.cljs
@@ -159,7 +159,8 @@
                   :triggers #{:clear!}
                   :reaction (fn [this]
                                   (when (:mark @this)
-                                    (editor/-line-class (:ed @this) (:line @this) :text "behavior-helper-line")
+                                    (when (and (:ed @this) @(:ed @this))
+                                      (editor/-line-class (:ed @this) (:line @this) :text "behavior-helper-line"))
                                     (object/raise (:mark @this) :clear!))
                                   (object/merge! this {:content nil})
                                   (object/merge! this {:mark nil


Don't try to deref nil hook atom.

Don't try to deref nil hook atom.

--- src/leiningen/core.clj
+++ src/leiningen/core.clj
@@ -84,14 +84,14 @@
   (fn [g] (f1 (fn [] (f2 g)))))

 (defn- join-hooks [hooks]
-  (reduce compose-hooks #(%) hooks))
+  (reduce compose-hooks #(%) (and hooks @hooks)))

 (defn run-task
   "Run the given task with its hooks activated."
   [task-name args]
   (let [task (resolve-task task-name)]
     (load-hooks task-name)
-    ((join-hooks @(::hooks (meta @task)))
+    ((join-hooks (::hooks (meta @task)))
      #(apply task args))))

 (defn ns->path [n]