This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-26
Channels
- # aleph (3)
- # beginners (98)
- # boot (24)
- # cljs-dev (13)
- # cljsrn (16)
- # clojure (97)
- # clojure-dusseldorf (2)
- # clojure-italy (2)
- # clojure-losangeles (2)
- # clojure-russia (48)
- # clojure-spec (28)
- # clojure-uk (79)
- # clojurescript (79)
- # community-development (2)
- # cursive (4)
- # datomic (35)
- # duct (1)
- # events (1)
- # fulcro (43)
- # heroku (1)
- # jobs (1)
- # lein-figwheel (2)
- # luminus (1)
- # lumo (12)
- # nyc (1)
- # off-topic (6)
- # om (1)
- # pedestal (7)
- # portkey (9)
- # proton (1)
- # re-frame (45)
- # reagent (27)
- # rum (2)
- # shadow-cljs (78)
- # spacemacs (3)
- # specter (2)
- # testing (2)
- # vim (41)
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.
^ @ido Not sure if you'll need more changes than that. You might...
@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 require
ed in the declaring code),
do I need to mangle the symbols inside the vector? damn, I need to learn writing macros the right way.
@ido Why not use with-redefs
? I think you could do this with less code that way...
@seancorfield I might save some code in the defmacro
. btw I used '
instead of ` which led to the former error
(defmacro with-common-redefs [bindings & body]
(let [common# '[...]]
`(with-redefs ~(into bindings common#) ~@body)))
this seems to work for me locally^ @ido Would this work for you?
yes! thanks @seancorfield
@seancorfield @ido Wouldn't a fixture in combination with with-redefs
be suitable for this problem?
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 ?
Getting [object Object] is not ISeqable
when calling js->clj
on some json in advanced optimizations, works fine without optimizations.
Can't see anything in the object that cljs wouldn't like.
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?
(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)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)
is it possible to get the name of an anonymous function? like (fn foo [x] (x + 42))
cljs.user=> (.-name (fn foo [x] (+ x 42)))
"cljs$user$foo"
thanks a ton @pesterhazy!
@bcbradley oh I thought you were talking about cljs
was trying to figure out if i was doing something wrong and was about to say something about it
(.getName (type (fn foo [x] (+ x 42))))
? 🙂
don't know if that's the proper way
(clojure.repl/demunge (.getName (type (fn foo [x] (+ x 42)))))
Is there any simple way to call reify such that if I leave a method out I’ll get an error at compile time?
Obviously I could write a wrapper but maybe somebody’s already done that or there’s a switch I’m missing?
Does anyone know if Mark McDonnell is on this slack group?
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
@benny quoting the output of lein help sample
;; Override location of the local maven repository. Relative to project root.
:local-repo "local-m2"
i've been seeing that in my searches, but i would prefer to do it via command line or environment variable if possible
lein update-in :local-repo '(constantly "local-m2")' --
should do it
the rest of your command would come after that
tried
❯ lein update-in :local-repo '(constantly "/lein")' -- cljsbuild once min
java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Named
oh, weird
apparently f must be a resolvable var
so (constantly “/lein”) doesn’t work
trying to think of a way to do it with a named var
maybe something like
lein update-in :local-repo get :not_found "local-m2"
- hacky, but should put the right string in the right placeha, clever
if we had lein assoc-in it would be nicer
nodnod
❯ 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
weird
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)
?
@dpsutton (not (find m :k))
it returns nil, or a vector of k/v
or (not (contains? m :k))
(not (contains? m :k))
@benny surround “lein” in single quotes
‘“lein”’
oh! of course
shell sees and strips the single quotes, clojure reader sees a string
❯ 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
you need the single quotes and the double quotes
single quotes on the outside, double quotes on the inside
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
(in terms of ops maintainability)
@benny it’s also possible to do the same with assoc
: lein update-in : assoc :local-repo \"/lein\" -- cljsbuild once min
@sashton oh, I wouldn’t have expected : to work, cool
in a gen-class
method signature, is it possible to specify the types on the k,v
of a java.util.Map
return value?
that’s a fiction of javac - it doesn’t actually exist in the runtime in any way that matters
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
(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)
^ a huge amount of the fancy new Apache Beam framework uses that ridiculousness, god knows what google were thinking
they also decided to switch from interface implementation for integration to java annotations 2 releases ago :face_with_rolling_eyes:
theoretically we could make a macro that applies the right annotations so that the right generic would be inferred via reflection, right?
it depends on exactly how they captured the generic I think. I honestly don't know I just gave up on it
I was under the impression a generic became an annotation of some sort that you could reflect on, but I should double check that
@bfabry haha, that’s one way to fix it
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
isn't there a select-keys
alternative that works with functions instead of keys?
what would select-keys but for functions do?
hazarding a guess - juxt?
yes! i was thinking of juxt, but your comment was right, this isn't what i need 🙂