Fork me on GitHub
#clojure
<
2017-06-15
>
qqq00:06:32

afaik; all my current uses of clojure involves a single machine

qqq00:06:43

I'\ve yet to run clojure on a cluster, though I won't rule out the possibility

qqq00:06:47

is (async/chan) the same as (async/chan 0) or (async/chan infty) ? I used to think infty; but I'm now starting to think it's 0.

joshjones01:06:30

(chan 0) is not allowed, as there is an assertion that it must be a pos? number? @qqq

joshjones01:06:06

(chan nil) is equal to (chan)

cmal03:06:38

Hi, I am getting this error when tring to use cider-find-var after connected to a remote server compiled using lein uberjar:

user-error: 'cider-find-var' requires the nREPL op "info".  Please, install (or update) cider-nrepl 0.15.0-SNAPSHOT and restart CIDER
I use lein and tools.nrepl to start a nrepl server:
(defn start-nrepl-server [port]
  (log/info "Start nREPL server at port:" port)
  (reset! g-nrepl-server (nreplsrv/start-server :port port)))
and in project.clj ‘s :plugin field,
[cider/cider-nrepl "0.15.0-SNAPSHOT"]
and :dependencies:
[org.clojure/tools.nrepl "0.2.12"]

noisesmith03:06:21

wait, are you using lein on the remote server or an uberjar?

noisesmith03:06:32

because an uberjar won't have your plugins in it

qqq03:06:04

I get that (swap! atom f) can execute f multiple times. Question: suppose we have multiple swap!'s -- is there any guarantee on the order in which the corresponding functions are claled?

noisesmith03:06:48

the retry happens if another change to the atom happens between start and end of call to f

noisesmith03:06:01

so if the first to start, is first to finish, it doesn't retry

noisesmith03:06:15

other than that I don't think we can generalize much?

cmal03:06:34

@noisesmith So I would add cider-nrepl into dependencies and have another try. Thanks!

qqq03:06:34

f1 starts f2 starts f3 starts f1 finishes f2 -- oh fuck, cancelled f3 -- oh fuck , cancedlled -- do we have a guarntee that f2 will start/finish before f3 ?

noisesmith03:06:50

cancelled? they run to completion, then run again

noisesmith03:06:12

and no, it's based on the order they finish the first time

qqq03:06:25

okay, I meant: f1 starts f2 starts f3 starts f1 finishes f2 / f3: completes, colmpare+swap fails do we have a guarantee that f2 will restart+finish before f3 ?

noisesmith03:06:57

if f2 takes longer than f3, it could retry more times

noisesmith03:06:02

and finish last

qqq03:06:19

okay, so if we have n running concurrently, it's: first to finish = finishes, updates atom second to finish = next to run

noisesmith03:06:35

if the starts overlap, yeah

noisesmith03:06:36

@cmal iirc the cider-nrepl github page has an example of adding it to an nrepl you start yourself - it's not automatic, you need to apply it's middleware to nrepl

qqq03:06:13

Can anyone recommend readings on desgining systems with 'back pressure' ? I'm convinced core.async/back-pressure is right, ... but I clearly don't know how to correctly handle the backpressure.

oli04:06:46

trouble past 47933

qqq04:06:22

clojure.core.async/put! has a limit of 1024 go blocks can be parked on one channel right?

qqq04:06:26

why is there that this limit?

qqq04:06:48

@oli : what is the problem? running out of memory? stack overflow? wrong answer? infinite loop ?

oli04:06:42

not really a problem. just looking for improvement. ideally a lazy list of all primes.

qqq04:06:11

sieve is notorious for memory consumption

qqq04:06:23

what is your end goal? educational purposes? primality checking in the wild

oli04:06:19

just playing

oli04:06:33

i like the aesthetics of (cons var (function x)) and i'd like to find a way to preserve them

oli04:06:06

past trivial details like memory 😛

qqq05:06:07

(defn swap-exactly-once! [my-atom my-func]
   (locking my-atom
    (swap! my-atom my-func)))
this ensures the function my-func is NOT called multiple times right?

qqq05:06:39

so I can then add something which implements the Atom interface, and now I have "one at a time swap!" atom

bob_dole_12308:06:28

(disclaimer/apology, pasting from clojure irc) does anyone have any clues as to how i would maybe go about changing the behavior of the lein repl multline promt? it is not so hard to change the normal prompt in the :repl-options, but how to handle the multi-line case? right now if i type i get: (defn foo [] #_=> (println "this is foo")) but i want to edit what shows up where the "#_->" prompt currently is. (i want it just to be whitespace)

xiongtx08:06:28

My macro-fu is weak 🙁. How do I turn this:

(eval `(potemkin/import-vars
        [clojure.spec.alpha
         ~@(clojure.core/keys (clojure.core/ns-publics 'clojure.spec.alpha))]))
into a form that uses a gensym for clojure.spec.alpha? Something like:
(eval (let [ns (gensym)]
        `(let [~ns clojure.spec.alpha]
           (potemkin/import-vars
            [~ns
             ~@(clojure.core/keys (clojure.core/ns-publics ???))]))))

gaverhae09:06:09

It's an unquoted context so you should be able to just use ns directly

gaverhae09:06:28

instead of ???

gaverhae09:06:59

Bit curious about the context though, how do you expect that to return a non-empty set of keys?

metametadata09:06:36

Using ns directly in ~@() fails. But this works:

(eval (let [ns 'clojure.spec.alpha]
        `(potemkin/import-vars
           [~ns
            ~@(clojure.core/keys (clojure.core/ns-publics ns))])))

metametadata09:06:27

it's because at the evaluation time of ~@() variable ns is bound to the value generated by gensym

gaverhae09:06:41

Oh, right, I missed the intent of the let

gaverhae09:06:44

So the problem here is the order of evaluation with regards to the two nested lets; you can't unquote-splice the ns-publics call because you need it to be evaluated in the context of the quoted let

gaverhae09:06:56

something like this should work better:

(let [ns (gensym)]
  `(let [~ns clojure.spec.alpha]
     (potemkin/import-vars
       (apply vector ~ns (clojure.core/keys (clojure.core/ns-publics ~ns))))))

xiongtx00:06:40

gaverhae: evaling this throws:

1. Caused by java.lang.ClassNotFoundException
   clojure.spec.alpha

       URLClassLoader.java:  381  java.net.URLClassLoader/findClass
   DynamicClassLoader.java:   69  clojure.lang.DynamicClassLoader/findClass
          ClassLoader.java:  424  java.lang.ClassLoader/loadClass
   DynamicClassLoader.java:   77  clojure.lang.DynamicClassLoader/loadClass
          ClassLoader.java:  357  java.lang.ClassLoader/loadClass
                Class.java:   -2  java.lang.Class/forName0
                Class.java:  348  java.lang.Class/forName
                   RT.java: 2168  clojure.lang.RT/classForName
                   RT.java: 2177  clojure.lang.RT/classForName
             Compiler.java: 7145  clojure.lang.Compiler/resolveIn
             Compiler.java: 7108  clojure.lang.Compiler/resolve
...
The tricky thing here is that potemkin/import-vars is a macro. We need to pass it [clojure.spec.alpha ..., but can't let-bind clojure.spec.alpha directly.

gaverhae09:06:55

The error message there seems to indicate it got the right symbol?

gaverhae09:06:04

Do you absolutely need that let binding? What's the bigger context here?

gaverhae09:06:34

Depending on your context I guess this could be useful?

(defn import-all-vars
  [ns-symb]
  (eval `(potemkin/import-vars [~ns-symb ~@(clojure.core/keys (clojure.core/ns-publics ns-symb))])))

gaverhae09:06:53

This seems to work and gets you back out of macro land, so let should work as expected

gaverhae09:06:47

(defn import-all-vars
  [ns-symb]
  (eval `(potemkin/import-vars [~ns-symb ~@(clojure.core/keys (clojure.core/ns-publics ns-symb))])))

(eval (let [some-sym (gensym)]
        `(let [~some-sym 'clojure.spec.alpha]
           (import-all-vars ~some-sym))))
seems to do the trick for me, though I'm not sure I see the point of the lets anymore

xiongtx15:06:16

😆 macros--who gets ‘em? Thanks for following up!

gaverhae09:06:32

This way the call to (ns-publics G_00001) is generated by the quasiquote rather than evaluated outside it and spliced in, if that makes sense?

metametadata10:06:54

nice, it's more in spirit with the original idea 🙂

dartov11:06:05

Disclaimer: sorry if it’s not the right channel to ask Looking for something like Lightbend Activator for Clojure: set of skeleton apps engaging popular frameworks and components, showcasing pattern. Maybe just a curated set of links? Thanks!

dartov12:06:03

thanks pesterhazy! there is “Project Templates” category in the clojure toolbox, I’m looking for more like those templates

pesterhazy12:06:45

yeah the ones listed are great

pesterhazy12:06:35

also check tenzing (for boot frontend dev) and https://github.com/bhauman/figwheel-template for lein frontend dev

pesterhazy12:06:46

but of course all depends on what you actually need

Lambda/Sierra12:06:43

@dartov Luke VanderHart gave a talk comparing ReactJS libs for ClojureScript https://www.youtube.com/watch?v=oRmj3IUkRVk with a companion repo showing the same app in 3 frameworks https://github.com/levand/qttt

dartov12:06:18

Thanks Stuart, looks great

luke13:06:14

@dartov @stuartsierra note that that talk predates Rum, which is now my go-to framework (providing both Quiescent-style functional components and local state should the need arise)

lvh15:06:32

hm, I should try rum; normally I’m a big fan of re-frame which seems to take a pretty different approach (re-frame definitely has opinions about where your state lives)

tomaas15:06:17

hi, how can I create a File type object from java.io.ByteArrayInputStream?

donaldball15:06:41

tomaas: See and

tomaas15:06:37

the url is dead

luke15:06:23

Specifically, you’ll need to: 1. Create a file. 2. Open an output stream on the file (using |clojure.java.io/output-stream`>) 3. Copy your input stream to the output stream (using |clojure.java.io/copy`>)

luke15:06:15

Those are not URLs, they’re the name of functions in the namespace. Slack just interprets them as URLs for some reason

gaverhae15:06:39

Something like

(require '[ :as io])
(with-open [in (your-input-stream)
            out (io/output-stream "/path/to/file" )]
  (io/copy in out))

gaverhae15:06:10

(note that this will create a file on disk, which you can then open as a file; I'm not aware of any more direct way to go from a stream to a java.io.File, but I'm definitely not claiming any expertise around java io)

luke16:06:07

The file is not created on disk when you create the File instance… instances of File can represent non-existing files. I believe the file isn’t created on disk until you create the output stream on the file.

tomaas16:06:36

No method in multimethod 'do-copy' for dispatch value: [java.io.ByteArrayOutputStream java.io.BufferedOutputStream]

luke16:06:09

copy copies from an input stream to an output stream. Looks like you have two output streams there.

tomaas16:06:09

this is what I get when I do (io/copy data out)

tomaas16:06:24

where data is of type java.io.ByteArrayInputStream

luke16:06:46

data is actually of the type java.io.ByteArrayOutputStream, per your error message

tomaas16:06:44

its' java.io.ByteArrayOutputStream

tomaas16:06:57

which is allowed as stated in docs you linked me

donaldball16:06:11

You can’t copy from an outputstream to an outputstream.

donaldball16:06:36

You could get the byte array from the source outputstream and write that to the destination outputstream.

weavejester18:06:00

Does anyone know of a good database fixtures library for Clojure?

weavejester18:06:03

Or database seeding library

mattly18:06:23

@weavejester about a year ago, after looking at damn near everything that was out there, I opted to roll my own around test.check generators, since I had built those anyway

mattly18:06:22

I'm not sure how much of it is really extractable to a general-purpose lib, but none of the existing options really fit the need of my project

mattly18:06:33

(sorry to not be of any help)

weavejester18:06:00

No problem 🙂

weavejester18:06:06

I think I’ll write my own.

qqq18:06:48

naming question: is there a single word that means the same as "login Manager" ?

zylox18:06:30

login-manager

mikerod18:06:35

not sure how you’d get one word to mean that

qqq18:06:46

guardian

qqq18:06:47

kerberos

zylox18:06:26

gatekeeper

qqq18:06:03

see, by using the intelligence of all of #clojurians and abusing the def of 'one word', we can make this happen 🙂

qqq18:06:21

I don't mind - in var names, but I dislike them in module names as they become _ in file names

zylox18:06:48

give-me-your-password-and-username-preferably-the-right-ones-the-first-time-because-that-would-be-much-easier

tanzoniteblack19:06:11

of if you really really hate - in names: giveMeYourPasswordAndUsernamePreferablyTheRightOnesTheFirstTimeBecauseThatWouldBeMuchEasier

bfabry19:06:04

login.manager

zylox19:06:09

i prefer to name everything like java enterprise tests

mikerod19:06:40

> I don’t mind - in var names, but I dislike them in module names as they become _ in file names In Java it is pretty shunned to put “_” in package names too

qqq19:06:45

bfabry: as in login/manger.clj ?

mikerod19:06:29

I’m not sure I’d consider “kerberos” to mean that. that’s like a “brand name” right?

qqq19:06:49

it refers to the three headed dog that guards hell in greek mythology

mikerod19:06:55

well that too

mikerod19:06:05

not sure I’d consider that dog a login manager

tanzoniteblack19:06:19

which is far more often spelled cerberus in English, so it seems a bit obfuscated

tanzoniteblack19:06:39

Unless you speak ελληνικά, of course

qqq19:06:06

can we put unicode chars in file names?

mikerod19:06:31

💩-manager

bfabry19:06:45

@qqq ya. I was actually being a bit facetious but it does kind of work depending on how much you expect your system to grow

qqq19:06:19

it's an interesting generic solution

tanzoniteblack19:06:28

κέρβερος ? And god forbid you forget to change ς to σ if you add something to the end of the name?

zylox19:06:51

does the bridge troll in monty python and the holy grail have a name?

mikerod19:06:40

When spelled cerberus in English, I believe I always heard it pronounced with a “s” sound

mikerod19:06:48

seems like keberos is better, if it is supposed to be the “k” sound

mikerod19:06:23

However, enough on that topic from me. just didn’t equate it to a login manager. 😛

mobileink19:06:56

bifrost? (norse mythology)

qqq19:06:23

there's @mobileink , getting #clojure #offtopic again 🙂

mobileink19:06:49

qqq: sorry, i promise not to deviate from greek mythology.

cap10morgan19:06:03

Does anyone know why the RegexReader code in EdnReader.java is commented out? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/EdnReader.java#L53

hiredman19:06:59

regexs aren't part of edn, if I recall

hiredman19:06:57

I imagine that is an oversight

cap10morgan19:06:10

It is incredibly difficult to ensure you don't end up with any regex literals in your EDN. And one #" will choke clojure.edn/read-string. 😞

cap10morgan19:06:52

third party libraries can (and do) inject them via their own print-methods, for example

cap10morgan19:06:56

anyway, I'm just complaining now 🙂

tanzoniteblack19:06:22

In actual seriousness about the unicode in filename questions: https://github.com/echeran/clj-thamil/blob/master/src/clj_thamil/%E0%AE%AE%E0%AF%8A%E0%AE%B4%E0%AE%BF%E0%AE%AF%E0%AE%BF%E0%AE%AF%E0%AE%B2%E0%AF%8D.cljc yes, it’s completely reasonable in some situations

mobileink20:06:13

tanzoniteblack: that is an awesome example, thanks for posting it!

tanzoniteblack20:06:32

Best way to get my attention: combine diverse human languages with programming languages 😄

j-po20:06:05

@U4ZL7F31N , this seems relevant to your interest

mobileink20:06:55

tanzoniteblack: years ago i dabbled in making an arabic programming language by hacking a scheme implementation. didn't get very far, but very gratified to see this example. Clojure rules!

tanzoniteblack20:06:29

(also: https://github.com/nasser/--- github does not like unicode project names apparently? )

mobileink20:06:33

i got a good one for ya: the roots of algebraic thinking are to be found in the philological writings of the scholars who preceeded al-Khwarizmi. his language is very similar to the language of the grammarians, which makes sense because arabic morphology is very algebraic. izzat nutty or what?

tanzoniteblack20:06:24

I should check that stuff out sometime. Really, I just need to get around to learning Arabic, it’s been on my todo list for a while, but hasn’t happened yet. But it might happen before too long, because I’m finally tackling Chinese, which has been on my todo list for only slightly longer

mobileink20:06:24

@U236LQYB0 no, that's not me, but thanks for the link! this is me: http://www.sibawayhi.org. warning: old sucky website, doesn't really work on mobile. hope to update it someday, since i now have clojure tools.

mobileink20:06:29

shockingly, arabic is very easy, IF you have the right pedagogical materials. well, except fot the pronunciation, that took me years of hard work. dm me if you ever need help.

mobileink20:06:25

chinese, i wish. or any tonal language. i can't quite wrap my head around meaningful tones.

mobileink20:06:30

got any favorite language learning apps?

tanzoniteblack20:06:05

Not apps, but I’ve been having a lot of fun/success with https://glossika.com/ as a language learning course lately

tanzoniteblack20:06:36

actually that’s not completely true, I have been using skritter app to help with learning Chinese characters https://skritter.com/

mobileink20:06:14

it's common in many regions.

guy21:06:32

Hey folks sorry for the newbie question, is there a list of open source Clojure projects somewhere in this slack? Or a channel for it?

weavejester21:06:46

@guy There’s https://www.clojure-toolbox.com/ if that’s what you mean.

shaun-mahood22:06:34

@guy: There's also http://open-source.braveclojure.com/ if you're looking for something to contribute to