This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-15
Channels
- # beginners (16)
- # cljs-dev (12)
- # clojure (9)
- # clojure-berlin (5)
- # clojure-russia (16)
- # clojure-uk (26)
- # clojurescript (48)
- # community-development (2)
- # cursive (1)
- # data-science (10)
- # datomic (7)
- # emacs (27)
- # figwheel-main (31)
- # fulcro (6)
- # hoplon (47)
- # immutant (1)
- # jobs (1)
- # jobs-discuss (33)
- # off-topic (3)
- # onyx (34)
- # protorepl (5)
- # re-frame (26)
- # reagent (1)
- # reitit (1)
- # shadow-cljs (80)
- # spacemacs (44)
- # specter (4)
- # testing (1)
- # tools-deps (4)
i'm using hikari-cp to handle my database connection. i was only running it from lein locally for development so far, but now i tried to build an uberjar to test online. however, it seems to try to connect to (the "production") database host while building the jar which obviously fails. why is it doing that and how do i stop it?
it's possible (and often a good idea) to build a jar without compiling, but even so you should not have side effecting code at the top level of a namespace
there's a few alternate patterns, a common robust one is a library for managing stateful things, like stuartsierra/component or integrant
but even putting your connection in a delay or promise, and not forcing / realizing until later will suffice
for reference though, how would i build a jar without compiling (the problematic namespace)?
by not specifying aot, and changing your app startup to java -jar my-uber.jar clojure.main -m my.ns
(plus any other args you need, of course)
So I have to de-dupe a list of browsers visited and come up with this:
;; pick out most recent of visits to same URL
(->> (vals browsers)
(group-by :url)
(map (fn [[_ values]]
(first (sort-by :timestamp > values))))
;; now restore original structure
(into {} (map (fn [m] [(:browser-id m) m]))
but the idea of parameterized de-duping seems reusable. Question: do good Clojurians cook up a new group-distict-by-yada-yada
and wonder if it will ever get re-used, or do we just knock off these three-step transformations ad hoc and keep on trucking?