This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-30
Channels
- # admin-announcements (3)
- # aws-lambda (12)
- # beginners (88)
- # boot (73)
- # capetown (6)
- # carry (16)
- # cider (8)
- # cljsjs (7)
- # clojure (90)
- # clojure-belgium (4)
- # clojure-dev (19)
- # clojure-greece (41)
- # clojure-portugal (1)
- # clojure-quebec (4)
- # clojure-russia (25)
- # clojure-spec (172)
- # clojure-taiwan (1)
- # clojure-uk (76)
- # clojurescript (82)
- # cursive (37)
- # datavis (2)
- # datomic (46)
- # devcards (1)
- # emacs (4)
- # euroclojure (6)
- # events (1)
- # hoplon (31)
- # jobs (1)
- # keechma (9)
- # off-topic (4)
- # om (7)
- # onyx (65)
- # other-languages (15)
- # pedestal (1)
- # planck (50)
- # proton (1)
- # re-frame (40)
- # reagent (7)
- # spacemacs (14)
- # spirituality-ethics (37)
- # testing (1)
- # untangled (2)
- # yada (44)
Hi, clojurists! Has anyone ever used immutant? Trying to import it spits mad stacktraces in Messages emacs buffer, starting with:
Caused by: java.io.FileNotFoundException: Could not locate immmutant/web/middleware__init.class or immmutant/web/middleware.clj on classpath., compiling:(reversi/server.clj:1:1)
Does anyone know what the command in selenium is to press the enter key when on a browser?
I am using this lib: https://github.com/semperos/clj-webdriver/wiki/Taxi-API-Documentation
nvm found it: (submit "input#password")
I’m trying to do a GET request against a site that uses SNI. Is it correct that neither clj-http nor http-kit will work for me?
weird thing is that I seem to be able to talk to other SNI sites with both libraries, but not this one
@vandr0iy: what other dependencies do you have? What other errors are emitted? What namespace are you trying to require?
and I was trying to require: [immutant.web :as web] [immutant.web.async :as async] [immutant.web.middleware :as web-middleware]
@vandr0iy: hmm, that looks fine. Would you be willing to provide a sample project that recreates the issue?
yes, in a moment... anyways, as long as I do not require immutant.web.middleware everything works smoothly
I think the lambda functions are just syntactic sugar for specific concrete classes
eg. classes in this package: https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html
(of course the lambda stuff should work with any class/interface that has a single method, not just the ones in that package)
hey, when using compojure, how can I define a rule that will apply to all routes in a context? Because a let block doesn’t work.
In this case I want something like
(let [foo (lowercase pre-foo)]
(<route>)
(<route>)
)
I was attempting to use Compojure instead of bidi a bit. But Im not getting my transit params, could be chance someone here see quickly why lein-transit middleware is not making :transit-params in the incoming request?
(defroutes app-routes
(GET "/"
[]
{:body {:hello "world"}})
(POST "/"
{:keys [headers params body transit-params] :as request}
{:status 200 :headers {"Content-Type" "application/transit+json"}
:body (write transit-params)}))
(defonce server
(jetty/run-jetty
(-> #'app-routes
wrap-transit-response
wrap-transit-params
(wrap-cors :access-control-allow-origin [#""]
:access-control-allow-methods [:get :put :post :delete]))
{:port 8080 :join? false}))
I just realized that defining regex inline in a function using the #””
reader macro somehow caches the regex so it’s only created once. When I first thought about it, I mistakenly assumed a new regex would be created every time the function was called. Is there some compiler magic which puts the regex Patterns in a static variable somewhere? I was looking through the LispReader
source, but nothing jumped out at me.
Example, where each unique object gets a different hashCode:
(defn foo []
(.hashCode #"123”)) ;; this seems to create a Pattern object which is shared across invocations. How?
=> #'user/foo
(do
(println (foo))
(println (foo)))
664791687 ;; I previously assumed these two would be unique objects, but they are actually the same!
664791687
=> nil
(do
(println (.hashCode #"123"))
(println (.hashCode #"123")))
438713871 ;; different objects, as expected
1176080321
=> nil
It's in the Compiler
The reader reads the pattern and the compiler stashes it as a constant in the compiled class
thanks @alexmiller , is that done through registerConstant()
?
well, on second thought, maybe registerConstant
is for numbers and such, maybe the regex gets put in VARS
?
is there any disadvantage to generating large numbers of keywords at runtime ?
I’ve heard they use up permgen space in the JVM
anyone here using vinyasa? I'm having trouble getting it to bend to my will…in particular, the "pull" command doesn't seem to be doing what I'm expecting
in a fresh project, in a cider repl:
43│ user> (./pull '[org.clojure/data.csv "0.1.3"])
44│ nil
45│ user> (require '[clojure.data.csv :as csv])
46│ FileNotFoundException Could not locate clojure/data/csv__init.class or clojure/data/csv.clj on classpath. clojure.lang.RT.load (RT.java:456)
47│ user>
am I doing something obviously wrong? The .lein/profiles.clj
set up is more or less vanilla taken from the vinyasa README: https://github.com/zcaudate/vinyasa#installation
@ddellacosta: what version are you using?
ah okay, let me try that
@zcaudate: other than that, should it work as described in the README?
@ddellacosta: yeah give it a go
@zcaudate: cool, that seems to be what I needed. Thanks!
@ddellacosta: thanks for picking that up. readme fixed.
sure thing. Glad I could help by being the guinea pig 😄
seriously though, excited to integrate this into my repl flow
lots of useful stuff.
gotcha, will do!
my personal favorites are the reflection macros https://github.com/zcaudate/vinyasa#reflection
@sashton: I’d have to dig through code to tell you the mechanics, don’t know offhand
that could be very useful…not infrequently do I find myself poking at stuff by running it through some variation on (-> thing clojure.reflect/reflect …do stuff…)
thanks zcaudate, will check those out further
@ddellacosta: i think you’ll like it 😃
@octo221: @manutter51 keywords will be on the heap (not permgen). the downside of generating many is that they use memory, but they will get gc’ed if no longer in use. permgen doesn’t exist anymore in Java 1.8+ either.
Did they used to use permgen? I seem to remember something about that from a while ago. Then again I might just be imagining things again
@alexmiller: presumably they use about the same memory as strings ?
@manutter51: in the past (not for the last couple releases) they interned strings
@octo221: a Keyword has a Symbol, which has either one (for unqualified) or two (for qualified) strings + a pre-cached hashcode, so heavier than a string
Hello all, why when I run in lein run the program is ok but when I run in java -jar from uberjar is getting "org.apache.cxf.service.factory.ServiceConstructionException: Could not resolve a binding for http://schemas.xmlsoap.org/wsdl/soap12/" error? Is there something I missing? I´m using apache cfx serivce to access soap stuff
there might be something set up in one of the jar manifests that’s not getting transferred into the uberjar manifest properly
usually stuff like that is in resources
lein probably has some way to do what you want, but I don’t know it off the top of my head
lein sample
will show you a sample project.clj with all the options and that may lead you in useful directions
@alexmiller: Ok, that makes sense, thanks for the clarification.
I just read about clojure.spec and it seems like a great tool for testing with test.check. To utilize it for unit testing, should I specify a spec for every functions using fdef
in my application so that I just call clojure.spec.test/test
to do unit testing?
I've never used schema before so I'm not sure which function I should specify those and which not to
I'm assuming it's maybe a syntax error in a namespace that isn't loaded in test
or run
but I can't seem to find one in the code
Anyone have any hints on what I should look for? My own namespaces aren't anywhere in the tracebacks above
Sometimes I have to do a lein clean
before I can get a REPL spun up. It coughs up some stacktrace although I’m pretty sure it’s not that. Just a thought, though.
Thanks @akiva, I did try that but it didn't make a difference
The other weird thing is that the app is a web server which fires up an nrepl, and I can connect to the nrepl without any problems. It's just lein repl
that won't work
@timgilbert: Have you checked the contents of /private/var/folders/c1/fczp131x18z0s29w7bhwkqgc0000gn/T/form-init2259462831070490027.clj
? Perhaps that can give you some clues.
I’m getting an exception:
actual: java.lang.IllegalArgumentException: No matching method found: crypto_secretbox_easy for class caesium.binding.Sodium$jnr$ffi$0
at clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28)
… which goes away when I annotate with the respective types. Is that necessarily a bug, or just maybe?The annotation is ^ByteBuffer, but the problem appears to only occur with java.nio.DirectByteBuffers, not with java.nio.ByteBuffer or java.nio.MappedByteBuffer
Hmm, thanks @henriklundahl, it somehow didn't occur to me that the file would actually exist on my filesystem
I’m trying to dry up some queries that all use the same query shape with different attributes.
(defn simple-search-query [attrs]
[:find '?e
:in '$ '?term
:where
(apply list 'or-join '[?e ?term]
(map (fn [attr]
(let [sym (gensym)]
(list 'and ['?e attr sym]
[(list 'some.fn/match? '?term sym)])))
attrs))])
(simple-search-query [:some/name :some/code])
This returns the correct data structure, but I need to quote the result of the simple-search-query fn. My macro/quoting fu is weak. Any suggestions?I'm trying to use clojure and the clojure.java.jdbc library to talk to an Oracle database server. Both clojure and the database server are Windows machines. Anyone have any idea where/how would I install/reference the oracle ODBC driver JAR to allow this to work?
what’s a good way to format a date as a human-friendly interval, e.g. “5 hours from now”?
@fadrian: assuming you are using maven or lein, you will need to download the Oracle jar from the Oracle site and install it in your local maven repo
@wei maybe http://joda-time.sourceforge.net/apidocs/org/joda/time/format/PeriodFormatterBuilder.html?
@wei never tried it, but http://www.ocpsoft.org/prettytime/ seems like what you are looking for