reformat using (with-out-str (pprint ...))

--- src/otp_api_proxy/test_data.clj
+++ src/otp_api_proxy/test_data.clj
@@ -1,490 +1,644 @@
-(ns otp-api-proxy.test-data)
-
-
-(def cached-otp-response-1
-  {:orig-content-encoding nil, :trace-redirects
-   ["http://anaheim-otp.ed-groth.com/otp/routers/default/plan?fromPlace=33.8046480634388,-117.915358543396&toPlace=33.77272636987434,-117.8671646118164&time=1:29pm&date=03-31-2015&mode=TRANSIT,WALK&maxWalkDistance=750&walkReluctance=40&walkSpeed=0.3&arriveBy=false&showIntermediateStops=false"],
-   :request-time 1125, :status 200, :headers {"Transfer-Encoding" "chunked",
-                                              "Connection" "close", "Via" "1.1
-                                                                          anaheim-otp.ed-groth.com",
-                                              "Content-Type"
-                                              "application/json", "Date" "Fri,
-                                                                         10 Apr
-                                                                         2015
-                                                                         20:52:39
-                                                                         GMT"},
-   :body {:requestParameters {:arriveBy "false", :date "03-31-2015",
-                              :walkReluctance "40", :time "1:29pm",
-                              :showIntermediateStops "false", :mode
-                              "TRANSIT,WALK", :walkSpeed "0.3",
-                              :maxWalkDistance "750", :toPlace
-                              "33.77272636987434,-117.8671646118164",
-                              :fromPlace "33.8046480634388,-117.915358543396"},
-          :plan {:date 1427833740000, :from {:departure nil, :arrival nil,
-                                             :zoneId nil, :stopCode nil, :name
-                                             "South Harbor Boulevard",
-                                             :platformCode nil, :orig nil,
-                                             :stopId nil, :lon
-                                             -117.91541338573779, :lat
-                                             33.80464805427682, :stopIndex
-                                             nil}, :to {:departure nil,
-                                                        :arrival nil, :zoneId
-                                                        nil, :stopCode nil,
-                                                        :name "Memory Lane",
-                                                        :platformCode nil,
-                                                        :orig nil, :stopId nil,
-                                                        :lon
-                                                        -117.86715235633582,
-                                                        :lat 33.77275256538152,
-                                                        :stopIndex nil},
-                 :itineraries [{:waitingTime 10802, :startTime 1427833740000,
-                                :endTime 1427848350000, :fare {:fare {:regular
-                                                                      {:currency
-                                                                       {:currency
-                                                                        "USD",
-                                                                        :currencyCode
-                                                                        "USD",
-                                                                        :defaultFractionDigits
-                                                                        2,
-                                                                        :symbol
-                                                                        "$"},
-                                                                       :cents
-                                                                       500}}},
-                                :elevationGained 0.0, :duration 14610.0,
-                                :walkLimitExceeded false, :tooSloped false,
-                                :walkTime 2428, :walkDistance
-                                710.7051355362557, :legs [{:rentedBike false,
-                                                           :departureDelay 0,
-                                                           :agencyTimeZoneOffset
-                                                           -25200000,
-                                                           :tripShortName nil,
-                                                           :startTime
-                                                           1427833740000,
-                                                           :routeLongName nil,
-                                                           :alightRule nil,
-                                                           :endTime
-                                                           1427834414000,
-                                                           :steps [{:streetName "South Harbor Boulevard",
-                                                                    :elevation
-                                                                    [],
-                                                                    :relativeDirection
-                                                                    "DEPART",
-                                                                    :exit nil,
-                                                                    :absoluteDirection
-                                                                    "SOUTH",
-                                                                    :bogusName
-                                                                    false,
-                                                                    :alerts
-                                                                    nil, :lon
-                                                                    -117.91541338573779,
-                                                                    :lat
-                                                                    33.80464805427682,
-                                                                    :stayOn
-                                                                    false,
-                                                                    :area
-                                                                    false,
-                                                                    :distance
-                                                                    200.81470288460554}],
-                                                           :mode "WALK",
-                                                           :tripBlockId nil,
-                                                           :duration 674.0,
-                                                           :route "",
-                                                           :interlineWithPreviousLeg
-                                                           false, :legGeometry
-                                                           {:points
-                                                            "_nimEjjunUdA?|@?l@Aj@?ZA^?\\An@?",
-                                                            :levels nil,
-                                                            :length 9},
-                                                           :agencyName nil,
-                                                           :realTime false,
-                                                           :routeColor nil,
-                                                           :serviceDate nil,
-                                                           :agencyUrl nil,
-                                                           :headsign nil, :from
-                                                           {:departure
-                                                            1427833740000,
-                                                            :arrival nil,
-                                                            :zoneId nil,
-                                                            :stopCode nil,
-                                                            :name "South Harbor
-                                                                  Boulevard",
-                                                            :platformCode nil,
-                                                            :orig "", :stopId
-                                                            nil, :lon
-                                                            -117.91541338573779,
-                                                            :lat
-                                                            33.80464805427682,
-                                                            :stopIndex nil},
-                                                           :alerts nil, :notes
-                                                           nil,
-                                                           :intermediateStops
-                                                           nil, :tripId nil,
-                                                           :agencyId nil,
-                                                           :routeId nil,
-                                                           :distance
-                                                           200.81470288460554,
-                                                           :transitLeg false,
-                                                           :headway nil,
-                                                           :arrivalDelay 0,
-                                                           :boardRule nil,
-                                                           :routeTextColor nil,
-                                                           :isNonExactFrequency
-                                                           nil, :routeType nil,
-                                                           :routeShortName nil,
-                                                           :to {:departure
-                                                                1427845215000,
-                                                                :arrival
-                                                                1427834414000,
-                                                                :zoneId nil,
-                                                                :stopCode nil,
-                                                                :name
-                                                                "Portofino
-                                                                Stop",
-                                                                :platformCode
-                                                                nil, :orig nil,
-                                                                :stopId
-                                                                {:agencyId
-                                                                 "248", :id
-                                                                 "778154"},
-                                                                :lon
-                                                                -117.91538037734423,
-                                                                :lat
-                                                                33.80284241778634,
-                                                                :stopIndex
-                                                                nil}}
-{:rentedBike false, :departureDelay 0, :agencyTimeZoneOffset -25200000,
- :tripShortName nil, :startTime 1427845215000, :routeLongName "Mainplace Line",
- :alightRule nil, :endTime 1427846595000, :steps [], :mode "BUS", :tripBlockId
- nil, :duration 1380.0, :route "19", :interlineWithPreviousLeg false,
- :legGeometry {:points
-               "wbimEbjunU??dRM?lJQJAZNPTCNV@v@?nCHJR@F_AKoCGYYSEsKfUS?kV?u^uJHmOBqO@@gM`C@n@Od@a@\\sAJ{G^oArDuDl@|@PQFu@\\a@??FKYi@~FmGHUdR_SAkL?mUBwMCcL?}OHaAn@{EFoB?qK?mP@kOb@cEb@eB|@uBZiCBsNMoAYqBEy@Fi@vP?~OB|@Ph@h@b@d@f@^nAPtBB|MEhIDtLD|N@pG@pKBrOAIvGAtEAnAIn@Qh@q@l@}DtBcAuAd@u@EC[@OBW\\",
-               :levels nil, :length 90}, :agencyName nil, :realTime false,
- :routeColor "390FA3", :serviceDate "20150331", :agencyUrl nil, :headsign
- "Disneyland Resort", :from {:departure 1427845215000, :arrival 1427834414000,
-                             :zoneId nil, :stopCode nil, :name "Portofino
-                                                               Stop",
-                             :platformCode nil, :orig nil, :stopId {:agencyId
-                                                                    "248", :id
-                                                                    "778154"},
-                             :lon -117.91547, :lat 33.80284, :stopIndex 1},
- :alerts nil, :notes nil, :intermediateStops nil, :tripId "73448A1314B2783",
- :agencyId "248", :routeId "1713", :distance 5950.749039460567, :transitLeg
- true, :headway 10800, :arrivalDelay 0, :boardRule nil, :routeTextColor
- "ffffff", :isNonExactFrequency true, :routeType 3, :routeShortName "19", :to
- {:departure 1427846596000, :arrival 1427846595000, :zoneId nil, :stopCode nil,
-  :name "Main St. & Mainplace Mall", :platformCode nil, :orig nil, :stopId
-  {:agencyId "248", :id "780771"}, :lon -117.87105, :lat 33.77476, :stopIndex
-  4}} {:rentedBike false, :departureDelay 0, :agencyTimeZoneOffset -25200000,
-       :tripShortName nil, :startTime 1427846596000, :routeLongName nil,
-       :alightRule nil, :endTime 1427848350000, :steps [{:streetName "service road",
-                                                         :elevation [],
-                                                         :relativeDirection
-                                                         "DEPART", :exit nil,
-                                                         :absoluteDirection
-                                                         "SOUTHEAST",
-                                                         :bogusName false,
-                                                         :alerts nil, :lon
-                                                         -117.87119620948738,
-                                                         :lat
-                                                         33.774644889724115,
-                                                         :stayOn false, :area
-                                                         false, :distance
-                                                         385.0275794476968}
-                                                        {:streetName "North Main Street",
-                                                         :elevation [],
-                                                         :relativeDirection
-                                                         "RIGHT", :exit nil,
-                                                         :absoluteDirection
-                                                         "SOUTH", :bogusName
-                                                         false, :alerts nil,
-                                                         :lon
-                                                         -117.86741230000001,
-                                                         :lat 33.7737568,
-                                                         :stayOn false, :area
-                                                         false, :distance
-                                                         105.54126024616954}
-                                                        {:streetName "Memory Lane",
-                                                         :elevation [],
-                                                         :relativeDirection
-                                                         "LEFT", :exit nil,
-                                                         :absoluteDirection
-                                                         "EAST", :bogusName
-                                                         false, :alerts nil,
-                                                         :lon
-                                                         -117.86734580000001,
-                                                         :lat 33.7728151,
-                                                         :stayOn false, :area
-                                                         false, :distance
-                                                         18.891592974870505}],
-       :mode "WALK", :tripBlockId nil, :duration 1754.0, :route "",
-       :interlineWithPreviousLeg false, :legGeometry {:points
-                                                      "orcmE~ulnUFERWT[N_@He@DUFOT[RWRYRYBk@@g@?iC?k@?{EvCAb@KJe@",
-                                                      :levels nil, :length 20},
-       :agencyName nil, :realTime false, :routeColor nil, :serviceDate nil,
-       :agencyUrl nil, :headsign nil, :from {:departure 1427846596000, :arrival
-                                             1427846595000, :zoneId nil,
-                                             :stopCode nil, :name "Main St. &
-                                                                  Mainplace
-                                                                  Mall",
-                                             :platformCode nil, :orig nil,
-                                             :stopId {:agencyId "248", :id
-                                                      "780771"}, :lon
-                                             -117.87119620948738, :lat
-                                             33.774644889724115, :stopIndex
-                                             nil}, :alerts nil, :notes nil,
-       :intermediateStops nil, :tripId nil, :agencyId nil, :routeId nil,
-       :distance 509.4604326687368, :transitLeg false, :headway nil,
-       :arrivalDelay 0, :boardRule nil, :routeTextColor nil,
-       :isNonExactFrequency nil, :routeType nil, :routeShortName nil, :to
-       {:departure nil, :arrival 1427848350000, :zoneId nil, :stopCode nil,
-        :name "Memory Lane", :platformCode nil, :orig "", :stopId nil, :lon
-        -117.86715235633582, :lat 33.77275256538152, :stopIndex nil}}],
-:transfers 0, :transitTime 1380, :elevationLost 0.0} {:waitingTime 0,
-                                                      :startTime 1427833740000,
-                                                      :endTime 1427857800000,
-                                                      :fare nil,
-                                                      :elevationGained 0.0,
-                                                      :duration 24060.0,
-                                                      :walkLimitExceeded true,
-                                                      :tooSloped false,
-                                                      :walkTime 24060,
-                                                      :walkDistance
-                                                      7128.643068525066, :legs
-                                                      [{:rentedBike false,
-                                                        :departureDelay 0,
-                                                        :agencyTimeZoneOffset
-                                                        -25200000,
-                                                        :tripShortName nil,
-                                                        :startTime
-                                                        1427833740000,
-                                                        :routeLongName nil,
-                                                        :alightRule nil,
-                                                        :endTime 1427857800000,
-                                                        :steps [{:streetName "South Harbor Boulevard",
-                                                                 :elevation [],
-                                                                 :relativeDirection
-                                                                 "DEPART",
-                                                                 :exit nil,
-                                                                 :absoluteDirection
-                                                                 "SOUTH",
-                                                                 :bogusName
-                                                                 false, :alerts
-                                                                 nil, :lon
-                                                                 -117.91541338573779,
-                                                                 :lat
-                                                                 33.80464805427682,
-                                                                 :stayOn false,
-                                                                 :area false,
-                                                                 :distance
-                                                                 124.15090711937937}
-                                                                {:streetName "path",
-                                                                 :elevation [],
-                                                                 :relativeDirection
-                                                                 "LEFT", :exit
-                                                                 nil,
-                                                                 :absoluteDirection
-                                                                 "EAST",
-                                                                 :bogusName
-                                                                 true, :alerts
-                                                                 nil, :lon
-                                                                 -117.9154034,
-                                                                 :lat
-                                                                 33.8035316,
-                                                                 :stayOn false,
-                                                                 :area false,
-                                                                 :distance
-                                                                 47.49975374313189}
-                                                                {:streetName
-                                                                 "West Katella Avenue",
-                                                                 :elevation [],
-                                                                 :relativeDirection
-                                                                 "LEFT", :exit
-                                                                 nil,
-                                                                 :absoluteDirection
-                                                                 "EAST",
-                                                                 :bogusName
-                                                                 false, :alerts
-                                                                 nil, :lon
-                                                                 -117.91503220000001,
-                                                                 :lat
-                                                                 33.8033986,
-                                                                 :stayOn false,
-                                                                 :area false,
-                                                                 :distance
-                                                                 767.5336616318095}
-                                                                {:streetName
-                                                                 "Katella Avenue",
-                                                                 :elevation [],
-                                                                 :relativeDirection
-                                                                 "CONTINUE",
-                                                                 :exit nil,
-                                                                 :absoluteDirection
-                                                                 "EAST",
-                                                                 :bogusName
-                                                                 false, :alerts
-                                                                 nil, :lon
-                                                                 -117.90672540000001,
-                                                                 :lat
-                                                                 33.8034132,
-                                                                 :stayOn false,
-                                                                 :area false,
-                                                                 :distance
-                                                                 18.890335608480278}
-                                                                {:streetName
-                                                                 "East Katella Avenue",
-                                                                 :elevation [],
-                                                                 :relativeDirection
-                                                                 "CONTINUE",
-                                                                 :exit nil,
-                                                                 :absoluteDirection
-                                                                 "EAST",
-                                                                 :bogusName
-                                                                 false, :alerts
-                                                                 nil, :lon
-                                                                 -117.90652100000001,
-                                                                 :lat
-                                                                 33.8034096,
-                                                                 :stayOn false,
-                                                                 :area false,
-                                                                 :distance
-                                                                 518.4026602557909}
-                                                                {:streetName
-                                                                 "Anaheim Way",
-                                                                 :elevation [],
-                                                                 :relativeDirection
-                                                                 "RIGHT", :exit
-                                                                 nil,
-                                                                 :absoluteDirection
-                                                                 "SOUTHEAST",
-                                                                 :bogusName
-                                                                 false, :alerts
-                                                                 nil, :lon
-                                                                 -117.9009106,
-                                                                 :lat
-                                                                 33.803440900000005,
-                                                                 :stayOn false,
-                                                                 :area false,
-                                                                 :distance
-                                                                 1028.8025851593518}
-{:streetName "North Anaheim Boulevard", :elevation [], :relativeDirection
- "CONTINUE", :exit nil, :absoluteDirection "SOUTHEAST", :bogusName false,
- :alerts nil, :lon -117.89399200000001, :lat 33.796221800000005, :stayOn false,
- :area false, :distance 575.6594026197595} {:streetName "The City Drive North",
-                                            :elevation [], :relativeDirection
-                                            "RIGHT", :exit nil,
-                                            :absoluteDirection "SOUTH",
-                                            :bogusName false, :alerts nil, :lon
-                                            -117.88963550000001, :lat
-                                            33.792652000000004, :stayOn false,
-                                            :area false, :distance
-                                            78.548006566911} {:streetName "The City Drive South",
-                                                              :elevation [],
-                                                              :relativeDirection
-                                                              "CONTINUE", :exit
-                                                              nil,
-                                                              :absoluteDirection
-                                                              "SOUTH",
-                                                              :bogusName false,
-                                                              :alerts nil, :lon
-                                                              -117.88985290000001,
-                                                              :lat 33.7919691,
-                                                              :stayOn false,
-                                                              :area false,
-                                                              :distance
-                                                              130.43133025794972}
-{:streetName "road", :elevation [], :relativeDirection "LEFT", :exit nil,
- :absoluteDirection "EAST", :bogusName true, :alerts nil, :lon -117.8902333,
- :lat 33.790839600000005, :stayOn false, :area false, :distance
- 217.60662799990848} {:streetName "Chapman Avenue", :elevation [],
-                      :relativeDirection "LEFT", :exit nil, :absoluteDirection
-                      "EAST", :bogusName false, :alerts nil, :lon
-                      -117.88856480000001, :lat 33.7895035, :stayOn false,
-                      :area false, :distance 956.945401568818} {:streetName "West Chapman Avenue",
-                                                                :elevation [],
-                                                                :relativeDirection
-                                                                "CONTINUE",
-                                                                :exit nil,
-                                                                :absoluteDirection
-                                                                "EAST",
-                                                                :bogusName
-                                                                false, :alerts
-                                                                nil, :lon
-                                                                -117.87872920000001,
-                                                                :lat
-                                                                33.7878903,
-                                                                :stayOn false,
-                                                                :area false,
-                                                                :distance
-                                                                496.0815877922827}
-{:streetName "South Marks Way", :elevation [], :relativeDirection "RIGHT",
- :exit nil, :absoluteDirection "SOUTH", :bogusName false, :alerts nil, :lon
- -117.8733612, :lat 33.7878835, :stayOn false, :area false, :distance
- 201.64813440100178} {:streetName "West Almond Avenue", :elevation [],
-                      :relativeDirection "LEFT", :exit nil, :absoluteDirection
-                      "EAST", :bogusName false, :alerts nil, :lon
-                      -117.87334310000001, :lat 33.7860701, :stayOn false,
-                      :area false, :distance 261.0397193260992} {:streetName
-                                                                 "South Feldner
-                                                                 Road",
-                                                                 :elevation [],
-                                                                 :relativeDirection
-                                                                 "RIGHT", :exit
-                                                                 nil,
-                                                                 :absoluteDirection
-                                                                 "SOUTH",
-                                                                 :bogusName
-                                                                 false, :alerts
-                                                                 nil, :lon
-                                                                 -117.8705185,
-                                                                 :lat
-                                                                 33.7860669,
-                                                                 :stayOn false,
-                                                                 :area false,
-                                                                 :distance
-                                                                 228.2731144019491}
-{:streetName "West Palmyra Avenue", :elevation [], :relativeDirection "LEFT",
- :exit nil, :absoluteDirection "EAST", :bogusName false, :alerts nil, :lon
- -117.87052360000001, :lat 33.784014, :stayOn false, :area false, :distance
- 97.70236420150239} {:streetName "S Bedford Rd", :elevation [],
-                     :relativeDirection "RIGHT", :exit nil, :absoluteDirection
-                     "SOUTH", :bogusName false, :alerts nil, :lon
-                     -117.86946680000001, :lat 33.7840095, :stayOn false, :area
-                     false, :distance 688.6542061385021} {:streetName "Mainplace Drive",
-                                                          :elevation [],
-                                                          :relativeDirection
-                                                          "LEFT", :exit nil,
-                                                          :absoluteDirection
-                                                          "SOUTHEAST",
-                                                          :bogusName false,
-                                                          :alerts nil, :lon
-                                                          -117.86953510000001,
-                                                          :lat 33.7778219,
-                                                          :stayOn false, :area
-                                                          false, :distance
-                                                          246.9085879874431}
-{:streetName "North Main Street", :elevation [], :relativeDirection "RIGHT",
- :exit nil, :absoluteDirection "SOUTH", :bogusName false, :alerts nil, :lon
- -117.86741380000001, :lat 33.7766078, :stayOn false, :area false, :distance
- 422.5597555326885} {:streetName "Memory Lane", :elevation [],
-                     :relativeDirection "LEFT", :exit nil, :absoluteDirection
-                     "EAST", :bogusName false, :alerts nil, :lon
-                     -117.86734580000001, :lat 33.7728151, :stayOn false, :area
-                     false, :distance 18.891592974870505}], :mode "WALK",
-:tripBlockId nil, :duration 24060.0, :route "", :interlineWithPreviousLeg
-false, :legGeometry {:points
-                     "_nimEjjunUdA?|@?l@Aj@??g@?]DATA?_B?yA?_@Ai@?cA?s@?c@?aA?a@?]?g@?oGAaC?S?qF?}B?}G@g@AsG?qB?sACePAaB`@a@dEsEn@q@nBoBfA_ArAiAJG|E_DXOh@e@`GwFhBoBpAaBrC}C\\]xQsRPUP[JWHYFYH]Dy@RDXFzA\\x@RtA\\pAXJm@Ri@X[nEyECi@Fs@C]AeBBs@RgARgAb@wAz@_BtBeEh@uBBYPcBBeA?_G@u@@o@AgDAyCAiD?O?S@mA?Y?aA?yB?sE?gE?kIhJC@gA?cD?aD?gDrC?^?dF@@_@?sDlJAnJDpA@fG?NAhB?`@H`@mAZ}@FMN_@LWVYj@a@d@]P[J[Dc@@_@zD?jE?pD?vCAb@KJe@",
-                     :levels nil, :length 129}, :agencyName nil, :realTime
-false, :routeColor nil, :serviceDate nil, :agencyUrl nil, :headsign nil, :from
-{:departure 1427833740000, :arrival nil, :zoneId nil, :stopCode nil, :name
- "South Harbor Boulevard", :platformCode nil, :orig "", :stopId nil, :lon
- -117.91541338573779, :lat 33.80464805427682, :stopIndex nil}, :alerts nil,
-:notes nil, :intermediateStops nil, :tripId nil, :agencyId nil, :routeId nil,
-:distance 7126.22973528763, :transitLeg false, :headway nil, :arrivalDelay 0,
-:boardRule nil, :routeTextColor nil, :isNonExactFrequency nil, :routeType nil,
-:routeShortName nil, :to {:departure nil, :arrival 1427857800000, :zoneId nil,
-                          :stopCode nil, :name "Memory Lane", :platformCode
-                          nil, :orig "", :stopId nil, :lon -117.86715235633582,
-                          :lat 33.77275256538152, :stopIndex nil}}], :transfers
-0, :transitTime 0, :elevationLost 0.0}]}, :error nil, :debug
-{:precalculationTime 0, :pathCalculationTime 868, :pathTimes [10 166],
- :renderingTime 4, :totalTime 872, :timedOut false}}})
+{:orig-content-encoding nil,
+ :trace-redirects
+ ["http://anaheim-otp.ed-groth.com/otp/routers/default/plan?fromPlace=33.8046480634388,-117.915358543396&toPlace=33.77272636987434,-117.8671646118164&time=1:29pm&date=03-31-2015&mode=TRANSIT,WALK&maxWalkDistance=750&walkReluctance=40&walkSpeed=0.3&arriveBy=false&showIntermediateStops=false"],
+ :request-time 1125,
+ :status 200,
+ :headers
+ {"Transfer-Encoding" "chunked",
+  "Via"
+  "1.1\n                                                                          anaheim-otp.ed-groth.com",
+  "Date"
+  "Fri,\n                                                                         10 Apr\n                                                                         2015\n                                                                         20:52:39\n                                                                         GMT",
+  "Content-Type" "application/json",
+  "Connection" "close"},
+ :body
+ {:requestParameters
+  {:arriveBy "false",
+   :date "03-31-2015",
+   :walkReluctance "40",
+   :time "1:29pm",
+   :showIntermediateStops "false",
+   :mode "TRANSIT,WALK",
+   :walkSpeed "0.3",
+   :maxWalkDistance "750",
+   :toPlace "33.77272636987434,-117.8671646118164",
+   :fromPlace "33.8046480634388,-117.915358543396"},
+  :plan
+  {:date 1427833740000,
+   :from
+   {:departure nil,
+    :arrival nil,
+    :zoneId nil,
+    :stopCode nil,
+    :name "South Harbor Boulevard",
+    :platformCode nil,
+    :orig nil,
+    :stopId nil,
+    :lon -117.91541338573779,
+    :lat 33.80464805427682,
+    :stopIndex nil},
+   :to
+   {:departure nil,
+    :arrival nil,
+    :zoneId nil,
+    :stopCode nil,
+    :name "Memory Lane",
+    :platformCode nil,
+    :orig nil,
+    :stopId nil,
+    :lon -117.86715235633582,
+    :lat 33.77275256538152,
+    :stopIndex nil},
+   :itineraries
+   [{:waitingTime 10802,
+     :startTime 1427833740000,
+     :endTime 1427848350000,
+     :fare
+     {:fare
+      {:regular
+       {:cents 500,
+        :currency
+        {:symbol "$",
+         :currency "USD",
+         :defaultFractionDigits 2,
+         :currencyCode "USD"}}}},
+     :elevationGained 0.0,
+     :duration 14610.0,
+     :walkLimitExceeded false,
+     :tooSloped false,
+     :walkTime 2428,
+     :walkDistance 710.7051355362557,
+     :legs
+     [{:rentedBike false,
+       :departureDelay 0,
+       :agencyTimeZoneOffset -25200000,
+       :tripShortName nil,
+       :startTime 1427833740000,
+       :routeLongName nil,
+       :alightRule nil,
+       :endTime 1427834414000,
+       :steps
+       [{:streetName "South Harbor Boulevard",
+         :elevation [],
+         :relativeDirection "DEPART",
+         :exit nil,
+         :absoluteDirection "SOUTH",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.91541338573779,
+         :lat 33.80464805427682,
+         :stayOn false,
+         :area false,
+         :distance 200.81470288460554}],
+       :mode "WALK",
+       :tripBlockId nil,
+       :duration 674.0,
+       :route "",
+       :interlineWithPreviousLeg false,
+       :legGeometry
+       {:points "_nimEjjunUdA?|@?l@Aj@?ZA^?\\An@?",
+        :levels nil,
+        :length 9},
+       :agencyName nil,
+       :realTime false,
+       :routeColor nil,
+       :serviceDate nil,
+       :agencyUrl nil,
+       :headsign nil,
+       :from
+       {:departure 1427833740000,
+        :arrival nil,
+        :zoneId nil,
+        :stopCode nil,
+        :name
+        "South Harbor\n                                                                  Boulevard",
+        :platformCode nil,
+        :orig "",
+        :stopId nil,
+        :lon -117.91541338573779,
+        :lat 33.80464805427682,
+        :stopIndex nil},
+       :alerts nil,
+       :notes nil,
+       :intermediateStops nil,
+       :tripId nil,
+       :agencyId nil,
+       :routeId nil,
+       :distance 200.81470288460554,
+       :transitLeg false,
+       :headway nil,
+       :arrivalDelay 0,
+       :boardRule nil,
+       :routeTextColor nil,
+       :isNonExactFrequency nil,
+       :routeType nil,
+       :routeShortName nil,
+       :to
+       {:departure 1427845215000,
+        :arrival 1427834414000,
+        :zoneId nil,
+        :stopCode nil,
+        :name
+        "Portofino\n                                                                Stop",
+        :platformCode nil,
+        :orig nil,
+        :stopId {:id "778154", :agencyId "248"},
+        :lon -117.91538037734423,
+        :lat 33.80284241778634,
+        :stopIndex nil}}
+      {:rentedBike false,
+       :departureDelay 0,
+       :agencyTimeZoneOffset -25200000,
+       :tripShortName nil,
+       :startTime 1427845215000,
+       :routeLongName "Mainplace Line",
+       :alightRule nil,
+       :endTime 1427846595000,
+       :steps [],
+       :mode "BUS",
+       :tripBlockId nil,
+       :duration 1380.0,
+       :route "19",
+       :interlineWithPreviousLeg false,
+       :legGeometry
+       {:points
+        "wbimEbjunU??dRM?lJQJAZNPTCNV@v@?nCHJR@F_AKoCGYYSEsKfUS?kV?u^uJHmOBqO@@gM`C@n@Od@a@\\sAJ{G^oArDuDl@|@PQFu@\\a@??FKYi@~FmGHUdR_SAkL?mUBwMCcL?}OHaAn@{EFoB?qK?mP@kOb@cEb@eB|@uBZiCBsNMoAYqBEy@Fi@vP?~OB|@Ph@h@b@d@f@^nAPtBB|MEhIDtLD|N@pG@pKBrOAIvGAtEAnAIn@Qh@q@l@}DtBcAuAd@u@EC[@OBW\\",
+        :levels nil,
+        :length 90},
+       :agencyName nil,
+       :realTime false,
+       :routeColor "390FA3",
+       :serviceDate "20150331",
+       :agencyUrl nil,
+       :headsign "Disneyland Resort",
+       :from
+       {:departure 1427845215000,
+        :arrival 1427834414000,
+        :zoneId nil,
+        :stopCode nil,
+        :name
+        "Portofino\n                                                               Stop",
+        :platformCode nil,
+        :orig nil,
+        :stopId {:id "778154", :agencyId "248"},
+        :lon -117.91547,
+        :lat 33.80284,
+        :stopIndex 1},
+       :alerts nil,
+       :notes nil,
+       :intermediateStops nil,
+       :tripId "73448A1314B2783",
+       :agencyId "248",
+       :routeId "1713",
+       :distance 5950.749039460567,
+       :transitLeg true,
+       :headway 10800,
+       :arrivalDelay 0,
+       :boardRule nil,
+       :routeTextColor "ffffff",
+       :isNonExactFrequency true,
+       :routeType 3,
+       :routeShortName "19",
+       :to
+       {:departure 1427846596000,
+        :arrival 1427846595000,
+        :zoneId nil,
+        :stopCode nil,
+        :name "Main St. & Mainplace Mall",
+        :platformCode nil,
+        :orig nil,
+        :stopId {:id "780771", :agencyId "248"},
+        :lon -117.87105,
+        :lat 33.77476,
+        :stopIndex 4}}
+      {:rentedBike false,
+       :departureDelay 0,
+       :agencyTimeZoneOffset -25200000,
+       :tripShortName nil,
+       :startTime 1427846596000,
+       :routeLongName nil,
+       :alightRule nil,
+       :endTime 1427848350000,
+       :steps
+       [{:streetName "service road",
+         :elevation [],
+         :relativeDirection "DEPART",
+         :exit nil,
+         :absoluteDirection "SOUTHEAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.87119620948738,
+         :lat 33.774644889724115,
+         :stayOn false,
+         :area false,
+         :distance 385.0275794476968}
+        {:streetName "North Main Street",
+         :elevation [],
+         :relativeDirection "RIGHT",
+         :exit nil,
+         :absoluteDirection "SOUTH",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.86741230000001,
+         :lat 33.7737568,
+         :stayOn false,
+         :area false,
+         :distance 105.54126024616954}
+        {:streetName "Memory Lane",
+         :elevation [],
+         :relativeDirection "LEFT",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.86734580000001,
+         :lat 33.7728151,
+         :stayOn false,
+         :area false,
+         :distance 18.891592974870505}],
+       :mode "WALK",
+       :tripBlockId nil,
+       :duration 1754.0,
+       :route "",
+       :interlineWithPreviousLeg false,
+       :legGeometry
+       {:points
+        "orcmE~ulnUFERWT[N_@He@DUFOT[RWRYRYBk@@g@?iC?k@?{EvCAb@KJe@",
+        :levels nil,
+        :length 20},
+       :agencyName nil,
+       :realTime false,
+       :routeColor nil,
+       :serviceDate nil,
+       :agencyUrl nil,
+       :headsign nil,
+       :from
+       {:departure 1427846596000,
+        :arrival 1427846595000,
+        :zoneId nil,
+        :stopCode nil,
+        :name
+        "Main St. &\n                                                                  Mainplace\n                                                                  Mall",
+        :platformCode nil,
+        :orig nil,
+        :stopId {:id "780771", :agencyId "248"},
+        :lon -117.87119620948738,
+        :lat 33.774644889724115,
+        :stopIndex nil},
+       :alerts nil,
+       :notes nil,
+       :intermediateStops nil,
+       :tripId nil,
+       :agencyId nil,
+       :routeId nil,
+       :distance 509.4604326687368,
+       :transitLeg false,
+       :headway nil,
+       :arrivalDelay 0,
+       :boardRule nil,
+       :routeTextColor nil,
+       :isNonExactFrequency nil,
+       :routeType nil,
+       :routeShortName nil,
+       :to
+       {:departure nil,
+        :arrival 1427848350000,
+        :zoneId nil,
+        :stopCode nil,
+        :name "Memory Lane",
+        :platformCode nil,
+        :orig "",
+        :stopId nil,
+        :lon -117.86715235633582,
+        :lat 33.77275256538152,
+        :stopIndex nil}}],
+     :transfers 0,
+     :transitTime 1380,
+     :elevationLost 0.0}
+    {:waitingTime 0,
+     :startTime 1427833740000,
+     :endTime 1427857800000,
+     :fare nil,
+     :elevationGained 0.0,
+     :duration 24060.0,
+     :walkLimitExceeded true,
+     :tooSloped false,
+     :walkTime 24060,
+     :walkDistance 7128.643068525066,
+     :legs
+     [{:rentedBike false,
+       :departureDelay 0,
+       :agencyTimeZoneOffset -25200000,
+       :tripShortName nil,
+       :startTime 1427833740000,
+       :routeLongName nil,
+       :alightRule nil,
+       :endTime 1427857800000,
+       :steps
+       [{:streetName "South Harbor Boulevard",
+         :elevation [],
+         :relativeDirection "DEPART",
+         :exit nil,
+         :absoluteDirection "SOUTH",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.91541338573779,
+         :lat 33.80464805427682,
+         :stayOn false,
+         :area false,
+         :distance 124.15090711937937}
+        {:streetName "path",
+         :elevation [],
+         :relativeDirection "LEFT",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName true,
+         :alerts nil,
+         :lon -117.9154034,
+         :lat 33.8035316,
+         :stayOn false,
+         :area false,
+         :distance 47.49975374313189}
+        {:streetName "West Katella Avenue",
+         :elevation [],
+         :relativeDirection "LEFT",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.91503220000001,
+         :lat 33.8033986,
+         :stayOn false,
+         :area false,
+         :distance 767.5336616318095}
+        {:streetName "Katella Avenue",
+         :elevation [],
+         :relativeDirection "CONTINUE",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.90672540000001,
+         :lat 33.8034132,
+         :stayOn false,
+         :area false,
+         :distance 18.890335608480278}
+        {:streetName "East Katella Avenue",
+         :elevation [],
+         :relativeDirection "CONTINUE",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.90652100000001,
+         :lat 33.8034096,
+         :stayOn false,
+         :area false,
+         :distance 518.4026602557909}
+        {:streetName "Anaheim Way",
+         :elevation [],
+         :relativeDirection "RIGHT",
+         :exit nil,
+         :absoluteDirection "SOUTHEAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.9009106,
+         :lat 33.803440900000005,
+         :stayOn false,
+         :area false,
+         :distance 1028.8025851593518}
+        {:streetName "North Anaheim Boulevard",
+         :elevation [],
+         :relativeDirection "CONTINUE",
+         :exit nil,
+         :absoluteDirection "SOUTHEAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.89399200000001,
+         :lat 33.796221800000005,
+         :stayOn false,
+         :area false,
+         :distance 575.6594026197595}
+        {:streetName "The City Drive North",
+         :elevation [],
+         :relativeDirection "RIGHT",
+         :exit nil,
+         :absoluteDirection "SOUTH",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.88963550000001,
+         :lat 33.792652000000004,
+         :stayOn false,
+         :area false,
+         :distance 78.548006566911}
+        {:streetName "The City Drive South",
+         :elevation [],
+         :relativeDirection "CONTINUE",
+         :exit nil,
+         :absoluteDirection "SOUTH",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.88985290000001,
+         :lat 33.7919691,
+         :stayOn false,
+         :area false,
+         :distance 130.43133025794972}
+        {:streetName "road",
+         :elevation [],
+         :relativeDirection "LEFT",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName true,
+         :alerts nil,
+         :lon -117.8902333,
+         :lat 33.790839600000005,
+         :stayOn false,
+         :area false,
+         :distance 217.60662799990848}
+        {:streetName "Chapman Avenue",
+         :elevation [],
+         :relativeDirection "LEFT",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.88856480000001,
+         :lat 33.7895035,
+         :stayOn false,
+         :area false,
+         :distance 956.945401568818}
+        {:streetName "West Chapman Avenue",
+         :elevation [],
+         :relativeDirection "CONTINUE",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.87872920000001,
+         :lat 33.7878903,
+         :stayOn false,
+         :area false,
+         :distance 496.0815877922827}
+        {:streetName "South Marks Way",
+         :elevation [],
+         :relativeDirection "RIGHT",
+         :exit nil,
+         :absoluteDirection "SOUTH",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.8733612,
+         :lat 33.7878835,
+         :stayOn false,
+         :area false,
+         :distance 201.64813440100178}
+        {:streetName "West Almond Avenue",
+         :elevation [],
+         :relativeDirection "LEFT",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.87334310000001,
+         :lat 33.7860701,
+         :stayOn false,
+         :area false,
+         :distance 261.0397193260992}
+        {:streetName
+         "South Feldner\n                                                                 Road",
+         :elevation [],
+         :relativeDirection "RIGHT",
+         :exit nil,
+         :absoluteDirection "SOUTH",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.8705185,
+         :lat 33.7860669,
+         :stayOn false,
+         :area false,
+         :distance 228.2731144019491}
+        {:streetName "West Palmyra Avenue",
+         :elevation [],
+         :relativeDirection "LEFT",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.87052360000001,
+         :lat 33.784014,
+         :stayOn false,
+         :area false,
+         :distance 97.70236420150239}
+        {:streetName "S Bedford Rd",
+         :elevation [],
+         :relativeDirection "RIGHT",
+         :exit nil,
+         :absoluteDirection "SOUTH",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.86946680000001,
+         :lat 33.7840095,
+         :stayOn false,
+         :area false,
+         :distance 688.6542061385021}
+        {:streetName "Mainplace Drive",
+         :elevation [],
+         :relativeDirection "LEFT",
+         :exit nil,
+         :absoluteDirection "SOUTHEAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.86953510000001,
+         :lat 33.7778219,
+         :stayOn false,
+         :area false,
+         :distance 246.9085879874431}
+        {:streetName "North Main Street",
+         :elevation [],
+         :relativeDirection "RIGHT",
+         :exit nil,
+         :absoluteDirection "SOUTH",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.86741380000001,
+         :lat 33.7766078,
+         :stayOn false,
+         :area false,
+         :distance 422.5597555326885}
+        {:streetName "Memory Lane",
+         :elevation [],
+         :relativeDirection "LEFT",
+         :exit nil,
+         :absoluteDirection "EAST",
+         :bogusName false,
+         :alerts nil,
+         :lon -117.86734580000001,
+         :lat 33.7728151,
+         :stayOn false,
+         :area false,
+         :distance 18.891592974870505}],
+       :mode "WALK",
+       :tripBlockId nil,
+       :duration 24060.0,
+       :route "",
+       :interlineWithPreviousLeg false,
+       :legGeometry
+       {:points
+        "_nimEjjunUdA?|@?l@Aj@??g@?]DATA?_B?yA?_@Ai@?cA?s@?c@?aA?a@?]?g@?oGAaC?S?qF?}B?}G@g@AsG?qB?sACePAaB`@a@dEsEn@q@nBoBfA_ArAiAJG|E_DXOh@e@`GwFhBoBpAaBrC}C\\]xQsRPUP[JWHYFYH]Dy@RDXFzA\\x@RtA\\pAXJm@Ri@X[nEyECi@Fs@C]AeBBs@RgARgAb@wAz@_BtBeEh@uBBYPcBBeA?_G@u@@o@AgDAyCAiD?O?S@mA?Y?aA?yB?sE?gE?kIhJC@gA?cD?aD?gDrC?^?dF@@_@?sDlJAnJDpA@fG?NAhB?`@H`@mAZ}@FMN_@LWVYj@a@d@]P[J[Dc@@_@zD?jE?pD?vCAb@KJe@",
+        :levels nil,
+        :length 129},
+       :agencyName nil,
+       :realTime false,
+       :routeColor nil,
+       :serviceDate nil,
+       :agencyUrl nil,
+       :headsign nil,
+       :from
+       {:departure 1427833740000,
+        :arrival nil,
+        :zoneId nil,
+        :stopCode nil,
+        :name "South Harbor Boulevard",
+        :platformCode nil,
+        :orig "",
+        :stopId nil,
+        :lon -117.91541338573779,
+        :lat 33.80464805427682,
+        :stopIndex nil},
+       :alerts nil,
+       :notes nil,
+       :intermediateStops nil,
+       :tripId nil,
+       :agencyId nil,
+       :routeId nil,
+       :distance 7126.22973528763,
+       :transitLeg false,
+       :headway nil,
+       :arrivalDelay 0,
+       :boardRule nil,
+       :routeTextColor nil,
+       :isNonExactFrequency nil,
+       :routeType nil,
+       :routeShortName nil,
+       :to
+       {:departure nil,
+        :arrival 1427857800000,
+        :zoneId nil,
+        :stopCode nil,
+        :name "Memory Lane",
+        :platformCode nil,
+        :orig "",
+        :stopId nil,
+        :lon -117.86715235633582,
+        :lat 33.77275256538152,
+        :stopIndex nil}}],
+     :transfers 0,
+     :transitTime 0,
+     :elevationLost 0.0}]},
+  :error nil,
+  :debug
+  {:pathTimes [10 166],
+   :precalculationTime 0,
+   :totalTime 872,
+   :pathCalculationTime 868,
+   :renderingTime 4,
+   :timedOut false}}}


fix test

fix test

--- test/shuppet/unit/elb.clj
+++ test/shuppet/unit/elb.clj
@@ -78,7 +78,7 @@
                   (check-string-value xml :missing "value") =>  (throws clojure.lang.ExceptionInfo))

             (fact "error when fixed value changed"
-                  (ensure-config config) => (throws clojure.lang.ExceptionInfo)
+                  (ensure-elb config) => (throws clojure.lang.ExceptionInfo)
                   (provided
                    (find-elb anything) => xml))


really fixed looping

really fixed looping

--- src/server/core.cljs
+++ src/server/core.cljs
@@ -223,14 +223,15 @@
                       (fn [started?]
                         (rooms/is-looping? room
                           (fn [looping?]
-                            (if-not (and started? looping?)
-                              (rooms/get-current-track room
-                                (fn [current-track]
-                                  (println current-track)
-                                  (rooms/change-track room current-track
-                                    (fn [track-id]
-                                      (println "Track changed to " track-id)
-                                      (.emit (.to io room) "track-change" track-id))))))))))))))
+                            (if-not started?
+                              (if-not looping?
+                                (rooms/get-current-track room
+                                  (fn [current-track]
+                                    (println current-track)
+                                    (rooms/change-track room current-track
+                                      (fn [track-id]
+                                        (println "Track changed to " track-id)
+                                        (.emit (.to io room) "track-change" track-id)))))))))))))))

             (println (str "Successfully uploaded " absolute-file-path)))))))


Rework let macro to ensure bindings are in order

--- test/tracks/core_test.clj
+++ test/tracks/core_test.clj
@@ -27,6 +27,11 @@
   (prop/for-all [m shallow-map-gen]
                 (let [map-two (zipmap (keys m) (shuffle (vals m)))]
                   (= map-two ((t/track m map-two) m)))))
+(deftest track-let
+  (testing "multiple bindings"
+    (is (= 2 (t/let [{:a a} {:a 1}
+                     b      (+ a a)]
+                b)))))

 (deftest track-let
   (testing "multiple bindings"


Tidy up whitespacing

Tidy up whitespacing

--- src/shokunin/cmr.clj
+++ src/shokunin/cmr.clj
@@ -31,17 +31,16 @@
   ([url params]
      (let [opts {:last-page (page-count url params)}]
        (http-seq url params opts)))
-  ([url {{:keys [page-num page-size]} :query-params :as params}
+  ([url {{:keys [page-num page-size]
+          :or   {page-num 1 page-size 10}} :query-params :as params}
         {:keys [last-page] :as opts}]
-       (let [results     (get-in (query url params) ["feed" "entry"])
-             next-params (update-in params [:query-params :page-num] inc)
-             more-pages  (< page-num last-page)]
+       (let [results       (get-in (query url params) ["feed" "entry"])
+             next-params   (update-in params [:query-params :page-num] inc)
+             more-pages    (< page-num last-page)]
          (lazy-cat results (if more-pages (http-seq url next-params opts))))))

 (comment "usage example"
   (let [params  { :query-params {:short-name "MOD09A1" :page-num 1 :page-size 25}}
         url     "https://cmr.earthdata.nasa.gov/search/granules"
         results (http-seq url params)]
-    (map #(get % "title") (take 5 results)))
-  results)
-
+    (map #(get % "title") (take 2 results))))


read period from config

read period from config

--- src/trackif/core.clj
+++ src/trackif/core.clj
@@ -113,9 +113,9 @@
    :handle-not-found (fn [_] "Ops. May the lambda be with you!")
    :authorized? authenticated?})

-(defresource hello-resource auth-res
+(defresource hello-resource
   :allowed-methods [:get]
-  :handle-ok (fn [_] {:may "the lambda be with you"}))
+  :handle-ok (fn [_] "May the lambda be with you!"))

 (defresource subscribe-res auth-res
   :allowed-methods [:get]
@@ -148,7 +148,7 @@
   (go-loop []
     (doseq [url (all-urls)]
       (>! c url))
-    (<! (timeout 3600000))
+    (<! (timeout (or (env :period) 10000)))
     (recur))
   (let [port (Integer. (or (env :port) 5000))]
     (jetty/run-jetty (-> app api) {:port port :join? false})))


Improvement: Increasing update time, a week should be more than enough

--- src/tropefest/db.clj
+++ src/tropefest/db.clj
@@ -20,7 +20,7 @@
 ; Timestamp functions
 ;

-(def update-period (j/days 5))
+(def update-period (j/days 7))

 (defn timestamp-next-update
   "Updates a data hashmap with the current time and the next time for update,


Read writer type from arguments

Read writer type from arguments

--- src/whitman/core.clj
+++ src/whitman/core.clj
@@ -15,7 +15,10 @@
         docs (map #(crawler/sample-docs cfg %) users)]
     (doseq [d docs] (writer/write writer cfg (:query d) (:insert d)))))

+(defn writer [args]
+  :db)
+
 (defn -main [& args]
   (if (< (count args) 1)
     (exit 1 "No configuration file specified")
-    (do-crawl (config/read-config (last args)) :db)))
+    (do-crawl (config/read-config (last args)) (writer args))))


Remove draft warning

Remove draft warning

--- src/uk/co/tombooth/pollock.cljs
+++ src/uk/co/tombooth/pollock.cljs
@@ -4,8 +4,6 @@
 ;; ---
 ;; title: Painting in Clojure
 ;; ...
-
-;;
DRAFT ARTICLE

 ;; Learning Clojure by building a digital Jackson Pollock. This
 ;; article and the source code backing it can be [found on


Fix spelling mistakes in article

Fix spelling mistakes in article

--- src/uk/co/tombooth/pollock.cljs
+++ src/uk/co/tombooth/pollock.cljs
@@ -9,7 +9,7 @@

 ;; Learning Clojure by building a digital Jackson Pollock. This
 ;; article and the source code backing it can be [found on
-;; github](https://www.github.com/tombooth/painting-in-clojure).
+;; GitHub](https://www.github.com/tombooth/painting-in-clojure).
 ;; Below is an example of what we will be building, running the code
 ;; found in this page.

@@ -49,7 +49,7 @@
 ;;    - A string, represented as a sequence of characters, for example
 ;;      `"Hello world!"`;
 ;;    - A keyword, which are very similar to strings in appearance
-;;      except they are preceeded by a colon e.g. `:an-identifier`. As
+;;      except they are preceded by a colon e.g. `:an-identifier`. As
 ;;      alluded to in the example they are usually used for identifiers or
 ;;      labels and do not allow spaces.
 ;;    - A list `(...)`, this is a way of grouping values into a
@@ -164,7 +164,7 @@
 ;;
 ;; We can solve this using the Quadratic Equation, but this will yield
 ;; us two results. In general we can say that we are interested in the
-;; result with the maxium value.
+;; result with the maximum value.
 ;;
 ;; In the next block of code you can see an example of call out to Java(Script).
 ;; Clojure doesn't have an in-built square root function, so we are calling out
@@ -282,7 +282,7 @@

 ;; For simplicity of code we are just going to consider the y axis as
 ;; this is the most important when it comes to working out the impact
-;; force of the paint into the canvase. The above equation can
+;; force of the paint into the canvas. The above equation can
 ;; therefore be expressed as:

 (defn impact-force [mass velocity]
@@ -323,7 +323,7 @@
 ;; equation so we should define some more functions before trying to
 ;; implement it. The first is the vector dot product, this is defined
 ;; as the sum of the multiples of each dimension. Otherwise we need
-;; substraction of two vectors and a function to multiply a vector by
+;; subtraction of two vectors and a function to multiply a vector by
 ;; a constant.

 (defn dot-product [vector1 vector2]
@@ -419,7 +419,7 @@

 ;; Firstly, we can define a function that will generate a random
 ;; vector inside of lower and upper bounds that can be combined with
-;; the unrandomised position to provide a randomised path.
+;; the non-randomised position to provide a randomised path.

 (defn random-vector-between [lower upper]
   [(random-between lower upper)
@@ -428,13 +428,13 @@

 ;; In order to provide an unbounded path we can use a lazy sequence.
 ;; This function returns a value that is somewhat akin to list that
-;; never ends. Everytime you try to look at the next value in the list
+;; never ends. Every time you try to look at the next value in the list
 ;; it will generate one just in time for you to see no end.

 ;; In this function the first value returned should always be the
 ;; initial starting position, each following value should be a step
 ;; along the path. You can see this below, it returns the position
-;; argument cons'd with another interation of random-path with the
+;; argument cons'd with another iteration of random-path with the
 ;; position randomised.

 (defn random-path [position step-vector bounds]
@@ -587,7 +587,7 @@

 ;; I've pulled a bunch of colours that Pollock used in his seminal
 ;; work "Number 8" so that each flick of paint can be rendered in a
-;; random colour out of this pallete
+;; random colour out of this palette

 (def canvas-colour [142 141 93])

@@ -638,7 +638,7 @@
 ;; We need to know the available size for the outputted image to fit
 ;; in. To work this out we are going to have to interface with
 ;; JavaScript directly. Luckily ClojureScript makes this very easy
-;; using the js namespace.
+;; using the `js` namespace.

 (def image-width (.-clientWidth (.querySelector js/document "#pollock")))


bug (num-files)

bug (num-files)

--- test/feedparser_test.clj
+++ test/feedparser_test.clj
@@ -26,6 +26,6 @@
             num-ok (count (filter passes? files))
             prec (* (/ num-ok num-files) 100)]
         (println (format "[wellformed] Passing %d of %d (%.2f%%)"
-                         num-ok num-ok (float prec)))))))
+                         num-ok num-files (float prec)))))))

 (check)


test for symmetry in vclock-comparator & documentation

--- test/meo/vclock_test.clj
+++ test/meo/vclock_test.clj
@@ -123,36 +123,48 @@
                     3    "a"})))))

-;;; QuickCheck tests for comparing vclocks
-
+;;; QuickCheck tests for comparing vector clocks.
+;;; First, a generator for valid node-ids, which are non-empty strings.
 (def gen-not-empty-alphanumeric
   (gen/such-that not-empty gen/string-alphanumeric))

+;;; Generator for valid vclocks that creates maps with node-ids as key and
+;;; positive integers as values.
 (def gen-vclock
   (gen/such-that
     not-empty
     (gen/map gen-not-empty-alphanumeric gen/pos-int)))

+;;; Another generator gives us expected comparison results.
 (def gen-type (gen/elements [:a>b :b>a :concurrent :equal]))

+;;; Generator for tuples of vclocks and one of the gen-types.
 (def gen-vclock-type-pair (gen/tuple gen-vclock gen-type))

-(defn change-vclock [op pos]
+(defn change-vclock
+  "Changes value at index determined by pos-fn (e.g. first, last) by applying
+   op to the value at the key found by pos-fn."
+  [op pos-fn]
   (fn [vclock]
     (if (empty? vclock)
       {}
-      (let [first-node (pos (keys vclock))]
+      (let [first-node (pos-fn (keys vclock))]
         (update-in vclock [first-node] op)))))

+;;; Functions for modifying vclock for use in create-expectation below.
 (def make-lower (change-vclock dec first))
 (def make-greater (change-vclock inc first))

-(defn create-conflict [vclock]
+(defn create-conflict
+  "Takes vclock map and modifies one entry plus inserts 1 at another key."
+  [vclock]
   (let [first-node (first (keys vclock))
         updated (update-in vclock [first-node] dec)]
     (assoc-in updated ["______concurrent"] 1)))

-(defn create-expectation [[vclock mutation]]
+(defn create-expectation
+  "Takes a tuple of vclock and mutation to perform, then performs that mutation."
+  [[vclock mutation]]
   (cond
     (= mutation :equal) [vclock vclock :equal]
     (= mutation :a>b) [vclock (make-lower vclock) :a>b]
@@ -161,13 +173,43 @@
                               (create-conflict vclock)
                               :concurrent]))

+;;; Generator that generates vclock/expectation pairs, where the vclocks
+;;; are modified so that they should meet the expectation.
 (def gen-l-r-expected (gen/fmap create-expectation gen-vclock-type-pair))

+;;; Property for asserting that vc/vclock-comparator gives the expected result
+;;; for all tuples generated by gen-l-r-expected.
 (def property
   (prop/for-all [v gen-l-r-expected]
                 (let [[a b exp] v]
                   (= (vc/vclock-comparator a b) exp))))

 (deftest vclock-quick-check
+  (testing "property checks for successful vector clock comparison"
+    (is (:result (tc/quick-check 500 property)))))
+
+;;; Property for asserting symmetry, such taht when passing the same values
+;;; into vc/vclock-comparator in opposite order, we get the opposite results
+;;; in the cases of :a>b and :b>a, and :equal and :concurrent regardless of
+;;; order.
+(def symmetry-property
+  (prop/for-all [v gen-l-r-expected]
+                (let [[a b exp] v]
+                  (cond
+                    (= exp :equal)
+                    (= (vc/vclock-comparator a b) (vc/vclock-comparator b a))
+
+                    (= exp :concurrent)
+                    (= (vc/vclock-comparator a b) (vc/vclock-comparator b a))
+
+                    (= exp :a>b)
+                    (and (= (vc/vclock-comparator a b) :a>b)
+                         (= (vc/vclock-comparator b a) :b>a))
+
+                    (= exp :b>a)
+                    (and (= (vc/vclock-comparator a b) :b>a)
+                         (= (vc/vclock-comparator b a) :a>b))))))
+
+(deftest vclock-symmetry-test
   (testing "property checks for vector clock comparison succeed"
-    (is (:result (tc/quick-check 500 property)))))
+    (is (:result (tc/quick-check 500 symmetry-property)))))


Missed a test rename and character set -> vector change somehow

--- test/cljs/fatlip/core_test.cljs
+++ test/cljs/fatlip/core_test.cljs
@@ -98,9 +98,9 @@
         "Positions are set correctly")))

-(deftest set-qs-non-qs
-  (let [q (f/Node. :0-0 0 #{})
-        not-q (f/Node. :0-1 0 #{})
+(deftest test-set-qs-non-qs
+  (let [q (f/Node. :0-0 0 [])
+        not-q (f/Node. :0-1 0 [])
         graph {:q #{q}}
         layer (f/Layer. 0 0 [q not-q])]
     (is (= (f/set-qs-non-qs graph layer) (assoc layer :qs #{q} :non-qs #{not-q}))


unravel let block and apply+concat to all

--- ohack/src/ohack/core.clj
+++ ohack/src/ohack/core.clj
@@ -272,27 +272,27 @@

       ]

-  ;; map over each 6-line-set...
-  ;; using the first value as example let's get the playable notes
-  (let [play-map (first (for [line-set sorted-grouped-line-set-list]
-                          ;; map over each line in the line-set, with string index
-                          (apply
-                           merge-with concat
-                           ;; note the reverse
-                           (for [[string-index tab-line] (map-indexed vector (reverse line-set))]
-                             ;; now we need to parse the tab-line...
-                             ;; collect each string's results into into {}
-                             (into {}
-                                   ;; create index -> []
-                                   ;; when no string is played, for rest
-                                   (map (fn [[k v]] [k (if v
-                                                        [string-index v]
-                                                        [])])
-                                        (parse-guitar-tab-line tab-line)))
-                             )))
-                        )
-        max-beat (apply max (keys play-map))
-        ]
-    (playguitar320 (map play-map (range max-beat))))
-
-  )
+  ;; now we apply to everything
+  (apply
+   concat
+   (map (fn [play-map]
+          (let [max-beat (apply max (keys play-map))]
+            (map play-map (range max-beat))))
+        (for [line-set sorted-grouped-line-set-list]
+          ;; map over each line in the line-set, with string index
+          (apply
+           merge-with concat
+           ;; note the reverse
+           (for [[string-index tab-line] (map-indexed vector (reverse line-set))]
+             ;; now we need to parse the tab-line...
+             ;; collect each string's results into into {}
+             (into {}
+                   ;; create index -> []
+                   ;; when no string is played, for rest
+                   (map (fn [[k v]] [k (if v
+                                        [string-index v]
+                                        [])])
+                        (parse-guitar-tab-line tab-line))))))))
+
+
+)


fix a crash in the sse test woooooo

fix a crash in the sse test woooooo

--- test/riemann/transport_test.clj
+++ test/riemann/transport_test.clj
@@ -93,7 +93,10 @@
            ; Shut down server and close client stream
            (client/close! client)
            (stop! core)
-           (dorun stream)))))))
+           ; lol actually not safe to close the reader; apache httpclient
+           ; explodes because .close calls .read and it's closed so fml
+           ;(dorun stream)
+           ))))))

 (deftest udp-test
   (logging/suppress ["riemann.transport"


test it

test it

--- src/async_macros/core.clj
+++ src/async_macros/core.clj
@@ -12,7 +12,7 @@
   [then else]
   (if (cljs-env? &env) then else))

-(if-cljs
+#_(if-cljs
  (do
    (require '[cljs.core.async :refer [<! >!]])
    (require-macros '[cljs.core.async.macros :refer [go]]))


Reset namespace after tests finish

Reset namespace after tests finish


PLATFORM-2818: fixed tests

PLATFORM-2818: fixed tests


Properly check const fn bindings

Properly check const fn bindings

--- test/caesium/binding_test.clj
+++ test/caesium/binding_test.clj
@@ -94,4 +94,7 @@
   "Check a method binding a const fn."
   [^Method method]
   (let [rtype (.getGenericReturnType method)]
-    ))
+    (condp = rtype
+        Integer/TYPE (is (= "sodium_init" (.getName method)))
+        Long/TYPE (is (= #{size_t} (annotation-set method)))
+        (is (= String rtype)))))


make miner interruptable

make miner interruptable

--- src/block_chain/miner.clj
+++ src/block_chain/miner.clj
@@ -1,4 +1,5 @@
 (ns block-chain.miner
+  (:import [java.util UUID])
   (:require [clojure.math.numeric-tower :as math]
             [block-chain.utils :refer :all]
             [block-chain.db :as db]
@@ -10,18 +11,24 @@
             [block-chain.block-validations :as block-v]
             [block-chain.peer-notifications :as peers]))

-(defn mine
-  ([block] (mine block (atom true)))
-  ([block switch]
-   (let [attempt (blocks/hashed block)]
-     (when (= 0 (mod (get-in attempt [:header :nonce]) 1000000))
-       (log/info "got to nonce: " (get-in attempt [:header :nonce]) "against parent" (q/phash attempt)))
-     (if (blocks/meets-target? attempt)
-       attempt
-       (if (not @switch)
-         (do (println "exiting") nil)
-         (recur (update-in block [:header :nonce] inc)
-              switch))))))
+(defonce miner-interrupts (atom {}))
+(defn interrupt-miner! []
+  (doseq [i (vals @miner-interrupts)]
+    (reset! i true)))
+
+(defn mine [block]
+  (let [miner-id (UUID/randomUUID)
+        interrupt (atom false)]
+    (swap! miner-interrupts assoc miner-id interrupt)
+    (try
+      (loop [attempt (blocks/hashed block)]
+        (when (= 0 (mod (get-in attempt [:header :nonce]) 1000000))
+          (log/info "got to nonce: " (get-in attempt [:header :nonce]) "against parent" (q/phash attempt)))
+        (cond
+          (blocks/meets-target? attempt) attempt
+          @interrupt (do (println "Miner interrupted.") nil)
+          :else (recur (blocks/hashed (update-in attempt [:header :nonce] inc)))))
+      (finally (swap! miner-interrupts dissoc miner-id)))))

 (defonce mine? (atom true))
 (defn stop-miner! [] (reset! mine? false))


use get

use get

--- src/bzzz/index_search.clj
+++ src/bzzz/index_search.clj
@@ -321,7 +321,7 @@

 (defn search [input]
   (let [ms-start (time-ms)
-        facets (:facets input)
+        facets (get input :facets)
         index (need :index input "need <index>")
         shards (index-name-matching (resolve-alias index))
         n-shards (count shards)
@@ -334,15 +334,15 @@
                                             (shard-search :searcher searcher
                                                           :shard shard
                                                           :taxo-reader taxo-reader
-                                                          :analyzer (:analyzer input)
-                                                          :query (:query input)
+                                                          :analyzer (get input :analyzer)
+                                                          :query (get input :query)
                                                           :facet-config (get-facet-config facets)
                                                           :facets facets
-                                                          :highlight (:highlight input)
+                                                          :highlight (get input :highlight)
                                                           :page (get input :page 0)
                                                           :size (get input :size default-size)
-                                                          :sort (:sort input)
+                                                          :sort (get input :sort)
                                                           :spatial-filter (get input :spatial-filter nil)
                                                           :explain (get input :explain false)
-                                                          :fields (:fields input)))))))]
+                                                          :fields (get input :fields)))))))]
     (reduce-collection futures input ms-start)))


wrap compile-file in try/catch

wrap compile-file in try/catch

when compiling a directory via compile-dir and one
file fails to compile, it can be kinda hard to track
down which file actually failed to compile.

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -839,10 +839,13 @@
      (let [src-file (io/file src)
            dest-file (io/file dest)]
        (if (.exists src-file)
-         (if (requires-compilation? src-file dest-file)
-           (do (mkdirs dest-file)
-               (compile-file* src-file dest-file))
-           (parse-ns src-file dest-file))
+         (try
+           (if (requires-compilation? src-file dest-file)
+             (do (mkdirs dest-file)
+                 (compile-file* src-file dest-file))
+             (parse-ns src-file dest-file))
+           (catch Exception e
+             (throw (ex-info (str "failed compiling file:" src) {:file src} e))))
          (throw (java.io.FileNotFoundException. (str "The file " src " does not exist.")))))))

 (comment


Use cljs prn for repl

Use cljs prn for repl

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -769,8 +769,9 @@
            (do (load-file jse (second form)) (newline) (recur))

            :else
-           (let [ret (eval1 jse (assoc env :ns (@namespaces *cljs-ns*)) form)]
-             (prn ret)
+           (let [ret (eval1 jse
+                            (assoc env :ns (@namespaces *cljs-ns*))
+                            (list 'cljs.core.prn form))]
              (recur))))))))

 (comment


better outout

better outout

--- src/clj/football/main.clj
+++ src/clj/football/main.clj
@@ -26,8 +26,7 @@

 (defn selection-repr [sel]
   (str "- team1:  " (clojure.string/join ", " (team-names (first (:selection sel))))
-       "\n-team2: " (clojure.string/join ", " (team-names (second (:selection sel))))
-       "\n-difference = " (:ranking sel)))
+       "\n- team2: " (clojure.string/join ", " (team-names (second (:selection sel))))))

 (defn -main [& args]
   (let [options (parse-opts args cli-options)


Made string reader more general, simplified precondition

--- src/clj/forma/gfw/cdm.clj
+++ src/clj/forma/gfw/cdm.clj
@@ -99,11 +99,11 @@
 ;; Map of lat/lon min and max values.
 (def latlon-range {:lat-min -90 :lat-max 90 :lon-min -180 :lon-max 180})

-(defn read-latlon
-  "Converts lat and lon values from string to number."
-  [lat lon]
-  {:pre [(= (type lat) java.lang.String), (= (type lon) java.lang.String)]}
-  [ (read-string lat) (read-string lon)])
+(defn read-string->num
+  "Convert strings to number."
+  [& s]
+  {:pre [(every? string? s)]}
+  (vec (map read-string s)))

 (defn latlon-valid?
   [lat lon]


Wrap method name strings in label objects in IR generation

--- src/clj/minijava/tree.clj
+++ src/clj/minijava/tree.clj
@@ -86,7 +86,7 @@

 (deftree minijava.ast.Call
   [x frame]
-  (Call (Name (.name x))
+  (Call (Name (tm/label (.name x)))
         (map (comp unEx #(tree % frame))
              (cons (.receiver x) ($ (.rands x))))))

@@ -147,11 +147,11 @@

 (deftree minijava.ast.NewArray
   [x frame]
-  (Call (Name "newArray") [(-> x .size (tree frame) unEx)]))
+  (Call (Name (tm/label "newArray")) [(-> x .size (tree frame) unEx)]))

 (deftree minijava.ast.NewObject
   [x frame]
-  (Call (Name "newObject") [(.typeName x)]))
+  (Call (Name (tm/label "newObject")) [(.typeName x)]))

 (deftree minijava.ast.Not
   [x frame]
@@ -171,7 +171,7 @@

 (deftree minijava.ast.Print
   [x frame]
-  (Call (Name "print") [(-> x .exp (tree frame) unEx)]))
+  (Call (Name (tm/label "print")) [(-> x .exp (tree frame) unEx)]))

 (deftree minijava.ast.Program
   [x frame]


Fix dict writer

Fix dict writer

--- src/cljam/dict/writer.clj
+++ src/cljam/dict/writer.clj
@@ -77,7 +77,7 @@

 (defn- write-sequence!
   [^BufferedWriter wtr name blen ur m5]
-  (.write wtr (str "@SQ\tSN:" name "\tLN:" blen "\tUR:" ur "\tM5:" m5))
+  (.write wtr (str "@SQ\tSN:" name "\tLN:" blen "\tM5:" m5 "\tUR:" ur))
   (.newLine wtr))

 (defn- write-dict*!


fix match-int for IE

fix match-int for IE

--- src/cljs/cljs/reader.cljs
+++ src/cljs/cljs/reader.cljs
@@ -99,15 +99,17 @@

 (defn- match-int
   [s]
-  (let [groups (re-find int-pattern s)]
-    (if (nth groups 2)
+  (let [groups (re-find int-pattern s)
+        group3 (nth groups 2)]
+    (if (not (or (undefined? group3)
+                 (< (.length group3) 1)))
       0
-      (let [negate (if (= "-" (nth groups 1)) -1 1)
+      (let [negate (if (= "-" (nth groups 1)) -1 1)
             [n radix] (cond
                        (nth groups 3) [(nth groups 3) 10]
                        (nth groups 4) [(nth groups 4) 16]
                        (nth groups 5) [(nth groups 5) 8]
-                       (nth groups 7) [(nth groups 7) (js/parseInt (nth groups 7))]
+                       (nth groups 7) [(nth groups 7) (js/parseInt (nth groups 7))]
                        :default [nil nil])]
         (if (nil? n)
           nil


loop bullets

loop bullets

--- src/cljs/mpd/bullets.cljs
+++ src/cljs/mpd/bullets.cljs
@@ -1,5 +1,5 @@
 (ns mpd.bullets
-  (:require [mpd.shared :refer [log]]
+  (:require [mpd.shared :refer [log entity_looper]]
             [mpd.assets :as assets]))

 (def fire_queue (atom []))
@@ -22,8 +22,8 @@
                   angle (:angle bullet)
                   dx (* (Math/cos angle) speed)
                   dy (* (Math/sin angle) speed)]
-              (merge bullet {:x (if (not= dx 0) (+ x dx) x)
-                             :y (if (not= dy 0) (+ y dy) y)
+              (merge bullet {:x (if (not= dx 0) (entity_looper (+ x dx)) x)
+                             :y (if (not= dy 0) (entity_looper (+ y dy)) y)
                              :distance (- distance 1)})))))
                          (:bullets @state))))
     ; test for hits?


minor

minor

--- src/cljs/server/core.cljs
+++ src/cljs/server/core.cljs
@@ -22,7 +22,7 @@
 ;; github route
 (. app (get "/api/github"
             (fn [req res]
-              (take! (gh/get-activity) #(.send res (str %1))))))
+              (take! (gh/get-activity) #(.send res (str %))))))

 ;; bitbucket route
 (. app (get "/api/bitbucket" (fn [req res] (.send res "Hello, World!"))))


Fix some of the early evaluation functions

--- src/clojure_ruby/core.clj
+++ src/clojure_ruby/core.clj
@@ -22,12 +22,10 @@

 (defmulti evaluate first)

-(defmethod evaluate :method_call_infix [stmt]
-  (let [[_ obj method arg] stmt
-        arg (evaluate arg)]
-    (assert (= :var_ref (first obj)))
-    (case method
-      "=" (swap! variables assoc (second obj) arg))))
+(defmethod evaluate :assignment [stmt]
+  (let [[_ name val] stmt
+        val (evaluate val)]
+    (swap! variables assoc name val)))

 (defn rb-send [obj method-name args]
   (if-let [meth (get-in obj [:methods method-name])]
@@ -40,14 +38,13 @@
       var
       (throw (RuntimeException. (str "Cannot find variable [" name "]"))))))

-(defmethod evaluate :method_call_args [stmt]
+(defmethod evaluate :method_call [stmt]
   (let [[_ obj method & args] stmt
         obj (evaluate obj)
         args (map evaluate args)]
     (rb-send obj method args)))

-(defmethod evaluate :method_call_naked [stmt]
-  ;; Duplication!
+(defmethod evaluate :method_call_infix [stmt]
   (let [[_ obj method & args] stmt
         obj (evaluate obj)
         args (map evaluate args)]


clean up sc book examples (I committed before I saved my cleanup changes - doh)

--- docs/sc-book/sc-one.clj
+++ docs/sc-book/sc-one.clj
@@ -475,7 +475,6 @@

 (stop)

-
 ;; Page 28

 ;;~kbus3 = Bus.control;
@@ -487,49 +486,23 @@
 ;;x.map(\freq, ~kbus3)
 ;;x.map(\freq, ~kbus4)

-(def kbus3 (control-bus))
-(def kbus4 (control-bus))
-
-(defsynth wave-ctl [] (out:kr kbus3 (lin-lin (sin-osc:kr 1) -1 1 140 740)))
-(defsynth pulse-ctl [] (out:kr kbus4 (lin-lin (sin-osc:kr 1) -1 1 240 640)))
-
-(defsynth switch [freq 440]
-  (out 0 (sin-osc freq 0 0.3)))
-
-(definst foo [] (sin-osc 440))
-
-(keys foo)
-(type kbus4)
-
-(:type foo)
-(keys switch)
-
-(:type switch)
-
-(:ugens :group :args :player :name :sdef :out-bus :fx-chain :type :doc)
-
-(defn node-id [node]
-  (let [id (if (inst? node) (:group node) node)]
-    (if-not (integer? id)
-      (throw (Exception. (str "The following node id is not an integer:" id))))))
-
-(defn make-foo [s]
-  (reify clojure.lang.IFn
-    (invoke [this] (str "Hello, " s))))
-
-(def s (switch))
-(def w (wave-ctl))
-(def p (pulse-ctl))
-
-(defn map-ctl [node control control-bus]
-  (let [n-id ]))
-
-(snd "/n_map" s "freq" (:id kbus4))
-(parents {})
-
-(def foo [a]
-  (if-let [b ()]))
-
-
+(do
+
+  (def kbus3 (control-bus))
+  (def kbus4 (control-bus))
+
+  (defsynth wave-ctl [] (out:kr kbus3 (lin-lin (sin-osc:kr 1) -1 1 140 740)))
+  (defsynth pulse-ctl [] (out:kr kbus4 (lin-lin (sin-osc:kr 1) -1 1 240 640)))
+
+  (defsynth switch [freq 440]
+    (out 0 (sin-osc freq 0 0.3)))
+
+  (def s (switch))
+  (def w (wave-ctl))
+  (def p (pulse-ctl)))
+
+;;try evaling these
+(map-ctl s :freq kbus3)
+(map-ctl s :freq kbus4)

 (stop)


use resource datasets instead of global

use resource datasets instead of global

--- src/conj_2016/parsers.clj
+++ src/conj_2016/parsers.clj
@@ -91,9 +91,9 @@

 (defn collobert-weston-embeddings*
   []
-  (let [labels (with-open [rdr (clojure.java.io/reader "/Users/alexandermann/Downloads/senna/hash/words.lst")]
+  (let [labels (with-open [rdr (clojure.java.io/reader (io/resource "senna-embeddings/words.lst"))]
                  (doall (line-seq rdr)))
-        data-lines (-> "/Users/alexandermann/Downloads/senna/embeddings/embeddings.txt"
+        data-lines (-> (io/resource "senna-embeddings/embeddings.txt")
                        slurp
                        (csv/read-csv :separator \ ))
         data-parser (fn [nums]


eager evaluation and inverted the set difference order

--- src/crawler/extractor.clj
+++ src/crawler/extractor.clj
@@ -39,14 +39,6 @@
     (swap!
      *url-documents* utils/atom-merge-with set/union {a-link (set [body])})
     body))
-
-(defn update-xpaths-productivities
-  "Expected data structure:
-a vector of xpath and the associated anchor-tags
-in the records"
-  [records-anchors]
-  (map
-   (fn [[xpath anchor]])))

 (defn update-tf
   [xpaths-tfs]
@@ -117,63 +109,64 @@
                                          (/
                                           (count hrefs)
                                           4)))]
-    (map
-     (fn [sampled]
+    (doall
+     (map
+      (fn [sampled]

-;       (println :sampling-url sampled)
-
-       (let [body             (utils/get-and-log sampled {:xpath xpath})
-
-             xpaths-hrefs'    (if body
-                                (try
-                                  (dom/minimum-maximal-xpath-set body sampled)
-                                  (catch Exception e
-                                    (do (error "Failed to parse: " sampled)
-                                        (error "Error caused by: " xpath))))
-                                nil)
-
-             in-host-map      (into
-                               {}
-                               (filter
-                                (fn [[xpath hrefs]]
-                                  (some (fn [a-href]
-                                          (= (uri/host sampled)
-                                             (uri/host a-href)))
-                                        hrefs))
-                                xpaths-hrefs'))
+        (let [body             (utils/get-and-log sampled {:xpath xpath})
+
+              xpaths-hrefs'    (if body
+                                 (try
+                                   (dom/minimum-maximal-xpath-set body sampled)
+                                   (catch Exception e
+                                     (do (error "Failed to parse: " sampled)
+                                         (error "Error caused by: " xpath))))
+                                 nil)
+
+              _                (update-df xpaths-hrefs')
+
+              _                (update-hrefs xpaths-hrefs')
+
+              in-host-map      (into
+                                {}
+                                (filter
+                                 (fn [[xpath hrefs]]
+                                   (some (fn [a-href]
+                                           (= (uri/host sampled)
+                                              (uri/host a-href)))
+                                         hrefs))
+                                 xpaths-hrefs'))

-             in-host-xpath-hs (map first in-host-map)
-
-             ;; similarity of page w/ source page
-             page-sim         (page/signature-similarity signature in-host-xpath-hs)
-
-             ;; xpaths of the source
-             src-xpaths       (map first in-host-xpath-hrefs)
-
-             diff             (map vector
-                                   src-xpaths
-                                   (map
-                                    (fn [xpath]
-                                      (count
-                                       (set/difference
-                                        (set (in-host-map xpath))
-                                        (set (in-host-xpath-hrefs xpath)))))
-                                    src-xpaths))]
+              in-host-xpath-hs (map first in-host-map)
+
+              ;; similarity of page w/ source page
+              page-sim         (page/signature-similarity signature in-host-xpath-hs)
+
+              ;; xpaths of the source
+              src-xpaths       (map first in-host-xpath-hrefs)
+
+              diff             (map vector
+                                    src-xpaths
+                                    (map
+                                     (fn [xpath]
+                                       (count
+                                        (set/difference
+                                         (set (in-host-xpath-hrefs xpath))
+                                         (set (in-host-map xpath)))))
+                                     src-xpaths))]

-         (when xpaths-hrefs'
-           (do
-             (update-df xpaths-hrefs')
-             (update-hrefs xpaths-hrefs')
-             (swap! *visited* conj sampled)
-             (if (> page-sim *page-sim-thresh*)
-               {:enum-candidate true
-                :page-sim       page-sim
-                :url            sampled
-                :novelty        (novelty diff)}
-               {:enum-candidate false
-                :url            sampled
-                :novelty        (novelty diff)})))))
-     sampled-uris)))
+          (when xpaths-hrefs'
+            (do
+              (swap! *visited* conj sampled)
+              (if (> page-sim *page-sim-thresh*)
+                {:enum-candidate true
+                 :page-sim       page-sim
+                 :url            sampled
+                 :novelty        (novelty diff)}
+                {:enum-candidate false
+                 :url            sampled
+                 :novelty        (novelty diff)})))))
+      sampled-uris))))

 (defn is-enum-candidate?
   [{xpath :xpath explorations :explorations}]


SQUASHME

SQUASHME

--- src/detritus/variants.clj
+++ src/detritus/variants.clj
@@ -119,7 +119,7 @@
            ~?pre-map
            (->ATaggedVal ~kw-tag (hash-map ~@(interleave kw-members members))))
          (defn ~(symbol (str (name vname) "?"))
-           ~(str "Generated predicate for the " ~vname " type.")
+           ~(str "Generated predicate for the " vname " type.")
            ([x#]
             (and (tagged? x#)
                  (= ~kw-tag (tag x#))


Fix search-stations trading API call and ws handler

--- src/elite_mfd/trading.clj
+++ src/elite_mfd/trading.clj
@@ -13,7 +13,9 @@
   "http://www.elitetradingtool.co.uk/api/EliteTradingTool/Calculator")
 (def search-url
   "http://www.elitetradingtool.co.uk/api/EliteTradingTool/Search")
-
+;; mapping for search-stations :search-type arg value to API value
+(def search-types {:buying "Station Buying"
+                   :selling "Station Selling"})
 ;;
 ;; Util methods
 ;;
@@ -30,6 +32,19 @@
             (.contains station-name input)
             (.contains system-name input))))
       (get-stations))))
+
+(defn- exists?
+  "Conveniently get a true/false value if an arg exists"
+  [arg]
+  (or (= true arg)
+      (not (nil? arg))))
+
+(defn- arg-value
+  "Provide a safe default value if none is provided"
+  [arg]
+  (if (nil? arg)
+    "1"
+    arg))

 ;;
 ;; API calls
@@ -73,25 +88,36 @@
 (defn search-stations
   "Call the station searcher with various filters"
   [system-name &
-   {:keys [callback commodity-id pad-size search-type search-range]
+   {:keys [callback
+           allegiance-id commodity-id economy-id government-id
+           has-blackmarket has-outfitting has-repairs has-shipyard
+           pad-size search-type search-range]
     :or {callback identity
-         commodity-id nil
-         pad-size "Small"
-         search-type "Station Selling" ; or "Station Buying"; req for commodity-id
+         pad-size :Small
+         search-type :selling ; req for commodity-id
          search-range "15"}}]
-  (let [request-body {:CurrentLocation system-name
-                      :Commodity (if commodity-id true false)
-                      :CommodityId commodity-id
+  (let [request-body {:Allegiance (exists? allegiance-id)
+                      :AllegianceId (arg-value allegiance-id)
+                      :Blackmarket (exists? has-blackmarket)
+                      :Commodity (exists? commodity-id)
+                      :CommodityId (arg-value commodity-id)
+                      :CurrentLocation system-name
+                      :Economy (exists? economy-id)
+                      :EconomyId (arg-value economy-id)
+                      :Government (exists? government-id)
+                      :GovernmentId (arg-value government-id)
+                      :Outfitting (exists? has-outfitting)
                       :PadSize pad-size
-                      :SearchType search-type
-                      :SearchRange search-range}]
+                      :Repairs (exists? has-repairs)
+                      :SearchRange search-range
+                      :SearchType (get search-types search-type)
+                      :Shipyard (exists? has-shipyard)}]
     (println request-body)
     (http/post
       search-url
       {:headers {"Content-Type" "application/json"}
-       :body request-body}
+       :body (generate-string request-body)}
       (fn [{:keys [error body]}]
-        (println body)
         (if error
           (do
             (log "! Error searching" error "Request:" request-body)
@@ -123,13 +149,13 @@
 (defn on-search
   "Packet handler for :search"
   [ch packet]
-  ; TODO implement
   (if-let [system (:system packet)]
-    ; NB this seems overly complicated
+    ; NB this also seems overly complicated
     (apply search-stations
            (flatten (conj [system]
                           (calculate-packet-to-seq packet)
-                          :callback #(to-client ch %))))
+                          :callback #(to-client ch {:type :search-result
+                                                    :result %}))))
     (client-error ch "Must specify system")))

 ;;