Fork me on GitHub
#clojure
<
2017-09-26
>
seancorfield04:09:38

Because the vector of common-redefs# in the let isn't quoted, it will all be evaluated -- put a ' before the vector and see if that helps.

seancorfield04:09:24

^ @ido Not sure if you'll need more changes than that. You might...

ido04:09:01

@seancorfield thanks! I probably do. looks like this was a help in the right direction but now I get Unable to resolve var: consul/get-record in this context in the calling code (but this is requireed in the declaring code),

ido04:09:17

do I need to mangle the symbols inside the vector? damn, I need to learn writing macros the right way.

seancorfield05:09:16

@ido Why not use with-redefs? I think you could do this with less code that way...

ido05:09:00

@seancorfield I might save some code in the defmacro. btw I used ' instead of ` which led to the former error

seancorfield05:09:41

(defmacro with-common-redefs [bindings & body]
  (let [common# '[...]]
    `(with-redefs ~(into bindings common#) [email protected])))
this seems to work for me locally

seancorfield05:09:57

^ @ido Would this work for you?

curlyfry06:09:31

@seancorfield @ido Wouldn't a fixture in combination with with-redefs be suitable for this problem?

kardan07:09:56

I have a jdbc prepared statement and I want to get the “filled in” sql string. The reason is to send sql to non jvm service. Is there a better way than https://github.com/akvo/akvo-lumen/blob/f2725e715945b96854768b705ffc5acf2fd67621/backend/src/akvo/lumen/lib/visualisation/maps.clj#L40 to #L44 ?

danielstockton08:09:01

Getting [object Object] is not ISeqable when calling js->clj on some json in advanced optimizations, works fine without optimizations.

danielstockton08:09:13

Can't see anything in the object that cljs wouldn't like.

danp09:09:52

Hi folks. I'm looking to run a moderately intensive function on a remote machine, but there's a chance my connection may drop out, so I've setup a headless nREPL on the remote. I have to SSH onto the remote to connect to REPL (due to firewall), but I need a way to detach the REPL once I've kicked the function off. Is this possible, or am I just going to have to kick it off and hope it doesn't drop out?

hlolli09:09:18

(defn start-local-server []
  (jetty/run-jetty server/handler {:port 8441}))

(deftest test-google-chrome
  (api/set-driver! (driver/create-chrome))
  (api/implicit-wait 1000)
  (api/to "")
  (is (api/contains-text? "title" "blabla")))

(use-fixtures :once (fn [f]
                      (start-local-server)
                      (f)))
I haven't done this kind of test for long time, but when I start jetty, the whole test just stalls. Any way to run-jetty and make the test continue (if I remove the start-server, the tests run). (using lein test)

stijn09:09:58

@danp if it's on unix you can use screen or tmux for that

danp09:09:56

Ah @stjn - that sounds like a good shout, thanks!

qqq09:09:05

what's the most efficient way to convert a java double [] to a java int [] } (I'd prefer to not call a clojur map/for)

hlolli09:09:34

to answer my question :join? false was needed in options

bcbradley10:09:32

is it possible to get the name of an anonymous function? like (fn foo [x] (x + 42))

pesterhazy11:09:46

cljs.user=> (.-name (fn foo [x] (+ x 42)))
"cljs$user$foo"

pesterhazy11:09:07

@bcbradley oh I thought you were talking about cljs

bcbradley11:09:15

hrm yeah i was talking about clojure

bcbradley11:09:26

was trying to figure out if i was doing something wrong and was about to say something about it

bcbradley11:09:33

is there a way to get the name in clojure?

pesterhazy11:09:13

(.getName (type (fn foo [x] (+ x 42)))) ? 🙂

pesterhazy11:09:29

don't know if that's the proper way

bcbradley11:09:51

its a shame the name is mungled

pesterhazy11:09:06

(clojure.repl/demunge (.getName (type (fn foo [x] (+ x 42)))))

bcbradley11:09:06

jesus they thought of everything xd

bcbradley11:09:12

thankyou so much for your help!

ttx16:09:01

Is there any way to park a go block while waiting for a promise to be fullfilled?

dominicm16:09:35

Maybe you could use (<! (async/thread @the-promise))?

michaelblume18:09:07

Is there any simple way to call reify such that if I leave a method out I’ll get an error at compile time?

michaelblume18:09:28

Obviously I could write a wrapper but maybe somebody’s already done that or there’s a switch I’m missing?

yogidevbear18:09:31

Does anyone know if Mark McDonnell is on this slack group?

benny18:09:15

not sure if this is the right channel to ask, but how do I go about setting my maven repository location with lein? needing to change it so I can cache it for CI builds

noisesmith18:09:35

@benny quoting the output of lein help sample

;; Override location of the local maven repository. Relative to project root.
  :local-repo "local-m2"

benny18:09:14

i've been seeing that in my searches, but i would prefer to do it via command line or environment variable if possible

noisesmith18:09:53

lein update-in :local-repo '(constantly "local-m2")' -- should do it

noisesmith18:09:07

the rest of your command would come after that

benny18:09:55

tried

❯ lein update-in :local-repo '(constantly "/lein")' -- cljsbuild once min
java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Named

michaelblume18:09:21

apparently f must be a resolvable var

michaelblume18:09:38

so (constantly “/lein”) doesn’t work

michaelblume18:09:28

trying to think of a way to do it with a named var

noisesmith18:09:50

maybe something like

lein update-in :local-repo get :not_found "local-m2"
- hacky, but should put the right string in the right place

noisesmith18:09:42

if we had lein assoc-in it would be nicer

benny18:09:31

sorry guys

benny18:09:33

❯ lein update-in :local-repo get :not_found "lein" -- cljsbuild once min
java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #' found for class: clojure.lang.Symbol

benny18:09:45

(tried even removing the leading /)

dpsutton18:09:11

is there a way to assert that a key is not present on a map in a test or should i just assert that it's the :not-found key from a (get (fn ....) :permissions :not-found)?

noisesmith18:09:33

@dpsutton (not (find m :k))

noisesmith18:09:39

it returns nil, or a vector of k/v

noisesmith18:09:50

or (not (contains? m :k))

tbaldridge18:09:52

(not (contains? m :k))

dpsutton18:09:06

thanks. that's legible and "conversant" in a test

michaelblume18:09:51

@benny surround “lein” in single quotes

michaelblume18:09:58

‘“lein”’

noisesmith18:09:22

oh! of course

michaelblume18:09:26

shell sees and strips the single quotes, clojure reader sees a string

benny18:09:23

❯ lein update-in :local-repo get :not_found 'lein' -- cljsbuild once min
java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #' found for class: clojure.lang.Symbol

michaelblume18:09:41

you need the single quotes and the double quotes

michaelblume18:09:51

single quotes on the outside, double quotes on the inside

benny18:09:27

thank you guys

noisesmith18:09:55

it’s an ugly and hard to decipher command line, but it does what you want, a shell function with an apropriate name might help

noisesmith18:09:02

(in terms of ops maintainability)

benny18:09:44

definitely, thanks again

sashton19:09:55

@benny it’s also possible to do the same with assoc: lein update-in : assoc :local-repo \"/lein\" -- cljsbuild once min

noisesmith19:09:42

@sashton oh, I wouldn’t have expected : to work, cool

dadair21:09:55

in a gen-class method signature, is it possible to specify the types on the k,v of a java.util.Map return value?

noisesmith22:09:55

that’s a fiction of javac - it doesn’t actually exist in the runtime in any way that matters

noisesmith22:09:26

if you want it for introspection / javadoc etc. it’s much easier to just make a minimal java class and use clojure from inside that

noisesmith22:09:43

(sadly there is actually code that breaks if it can’t use reflection to figure out what kind of generic was originally created, and that will break with clojure code, luckily that isn’t recommended and there’s very few libraries that do such a thing)

bfabry22:09:08

^ a huge amount of the fancy new Apache Beam framework uses that ridiculousness, god knows what google were thinking

bfabry22:09:06

they also decided to switch from interface implementation for integration to java annotations 2 releases ago :face_with_rolling_eyes:

noisesmith22:09:18

theoretically we could make a macro that applies the right annotations so that the right generic would be inferred via reflection, right?

bfabry22:09:50

it depends on exactly how they captured the generic I think. I honestly don't know I just gave up on it

bfabry22:09:13

everything is an Object and is serialized using nippy. fixed 😆

noisesmith22:09:27

I was under the impression a generic became an annotation of some sort that you could reflect on, but I should double check that

noisesmith22:09:44

@bfabry haha, that’s one way to fix it

bfabry22:09:12

it's honestly a better way to fix it than doing weird generic capture so you can determine a serializer at compile time. I'm sure someone had some idea that that was going to be a huge performance boost but it turns out a case statement is actually pretty cheap

josh.freckleton23:09:31

isn't there a select-keys alternative that works with functions instead of keys?

noisesmith23:09:51

what would select-keys but for functions do?

noisesmith23:09:08

hazarding a guess - juxt?

josh.freckleton23:09:30

yes! i was thinking of juxt, but your comment was right, this isn't what i need 🙂