Fork me on GitHub
#clojure
<
2015-09-14
>
redbeardymcgee00:09:07

how do i add a ring middleware in addition to other dependencies in my dev profile?

redbeardymcgee00:09:44

I was looking at magnars prone-middleware

redbeardymcgee00:09:17

:profiles {:dev {:ring {:stacktrace-middleware prone.middleware/wrap-exceptions}} {:dependencies [...]}} gives me "Map literal must contain an even number of forms"

redbeardymcgee00:09:31

Confusing to me because it would appear that's a misleading message. Each nested map does have an even number of forms.

gcommer00:09:33

No they don't

gcommer00:09:58

{:ring {...} {:dependencies [...]} has 3 forms

mosho09:09:01

Can I do stuff to namespaces? pass them around, reference their methods etc?

helios09:09:12

mosho: what do you mean? "(the.other.namespace/function arg)" should work

Alex Miller (Clojure team)13:09:55

@mosho: the symbol referring to a namespace can be passed around as data. an actual namespace object (like you'd get from ns) is a stateful Java object (not a value) and has the same caveats

mr-spock14:09:30

Hi. Some help needed simple_smile I have go-loop that is writing to files. go-loop receives on one channel info when it should start writing to new file. Everything works except that when app is closed (CTRL-C) then data in buffers are not flushed to disk and I’m loosing some data. How to nicely close flush all buffers when app is shutting down ?? This is result of testing in lein

mr-spock14:09:08

Here is code I’m running:

mr-spock14:09:09

(defn start-writer [dst msg] (let [dest-file (atom nil) ] (go-loop [] (alt! dst ([val] (if @dest-file (dosync (println "Got file request change " val) (.close @dest-file) (reset! dest-file (writer val))) (dosync (reset! dest-file (writer val))) )) msg ([val] (if dest-file (.write @dest-file val)))) (recur))) )

mr-spock14:09:01

in last if there should be @dest-file

teslanick14:09:58

Tip: you can fence your code in three backticks to format it with a fixed-width font.

ljosa16:09:05

We’ve started to use @stuartsierra’s component framework for a project that needs connections to multiple databases, statsd, etc. It cleaned up the configuration and state handling quite a bit. However, it’s now pain to work in the repl because, for every function that I want to call, I have to dig out the appropriate piece of the system so I can pass it in as an argument. Has anyone tried to combine components and dynamic variables? So, a dynamic variable for each component, plus a mechanism to bind the dynamic variables of all the components of a system. (And maybe call alter-var-root on them all, for use when developing.)

stuartsierra16:09:48

ljosa: I almost always recommend against dynamic vars; see my old blog post "On the Perils of Dynamic Scope."

stuartsierra16:09:19

And you should rarely or never need to pass more than one component to a top-level API function.

stuartsierra16:09:56

If some operation depends on multiple components, then that operation should take as its argument a single component that encapsulates all those dependencies.

ljosa16:09:25

What is your workflow when developing an application that uses the component framework? So far, I have been doing (def system (component/start-system (build-my-system configuration)1)) in my myproject.core ns. (Only in the repl, not for production use.) Then, when working in a different namespace, I have been doing (def c (:my-component-name project.core/system)) so that I have it on hand when I want to call functions that need the component in the repl, such as (frobnicate c 42).

timvisher17:09:17

is there a way using clj-time to get the tz of an iso8601 string?

malcolmsparks17:09:16

@ljosa: I add convenience functions in user.clj that do the digging out of system for me. If I have to change the system structure, I change the convenience functions too.

profil18:09:22

I am using vectors to represent math vectors in my program, now I want to update certain values by index, how should I do this? Should I use some other data structure than a vector?

ghadi18:09:44

profil: vectors are fine. there are some specialized vectors in core.matrix too

ghadi18:09:04

and there are primitive specialized vectors in clojure core vector-of

ghadi18:09:37

(As in they don't box with a full object reference but rather store primitive arrays internally)

profil18:09:41

@ghadi: Okay, thanks. I find it ugly that I have into [] .. on several places in my code, because lots of functions returns lists. Is there some better way?

ghadi18:09:33

profil: maybe learn about transducers to get rid of intermediate lists

nberger18:09:40

Anyone knows what's the roadmap to leiningen 2.5.3? I'd say that https://github.com/technomancy/leiningen/issues/1963 (about gpg signing, fixed 3 weeks ago) alone deserves a new release. That's something that worked fine in 2.5.1 and got broke in 2.5.2. The issues in https://github.com/technomancy/leiningen/milestones/2.5.3 don't look like 2.5.1 regressions I find myself switching between 2.5.1 (for signing a release) and 2.5.2 (so lein test picks up .cljc files, for example) too frequently... I'm also delaying building 2.5.3-SNAPSHOT in my local machine, as my experience doing so was not a walk in the park...

lvh18:09:42

some have vector equivalents (e.g. mapv), also transducers

profil18:09:31

I am using stuff like for, repeatedly, take

nberger20:09:01

@timvisher yes thanks, I got there. I'm saying that all of them exist way before 2.5.2, and 2.5.2 included a critical regression IMHO, so I was wondering if there's any chance that 2.5.3 might be cut before those 4 issues get a fix. @ztellman: good to know. It's also pre 2.5.2 but I see the importance

timvisher20:09:39

@nberger: my understanding from @hypirion is that there will not be a release prior to that

nberger20:09:41

ok, ztellman, sorry for atmention you simple_smile

timvisher20:09:02

but you can always ask simple_smile

timvisher20:09:10

i want one too simple_smile

nberger20:09:39

Do you think is there a better place to ask? lein google group seems inactive

timvisher20:09:59

@nberger: i generally ask either in #C0AB48493@freenode or directly via twitter

timvisher20:09:06

both are reasonably good options

stuartsierra20:09:10

There is a Leiningen mailing list (not google groups)

hypirion20:09:02

@nberger: The only remaining big issue is the pom task, as @timvisher mentioned. And it's good to get feedback, so thanks. simple_smile I didn't know that the regression's impact was so severe, so I'll see if I can get some time this week(end) to look at the remaining blockers.

nberger20:09:09

@hypirion: whoa thanks!!! simple_smile

benedek21:09:23

any ideas how to persuade travis to use leiningen 2.5.2? (it seems to default 2.5.1)