This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-16
Channels
- # aws-lambda (3)
- # beginners (20)
- # boot (201)
- # cljs-dev (45)
- # cljsrn (9)
- # clojars (19)
- # clojure (141)
- # clojure-china (2)
- # clojure-dev (11)
- # clojure-greece (6)
- # clojure-italy (1)
- # clojure-new-zealand (1)
- # clojure-romania (1)
- # clojure-russia (55)
- # clojure-spec (58)
- # clojure-taiwan (1)
- # clojure-uk (97)
- # clojure-ukraine (40)
- # clojurescript (77)
- # core-async (5)
- # core-typed (1)
- # cursive (35)
- # datomic (9)
- # jobs (2)
- # jobs-rus (25)
- # juxt (8)
- # lein-figwheel (14)
- # luminus (24)
- # mount (16)
- # off-topic (56)
- # om (36)
- # onyx (22)
- # pedestal (3)
- # perun (14)
- # re-frame (111)
- # reagent (5)
- # remote-jobs (6)
- # ring-swagger (3)
- # slack-help (1)
- # specter (17)
- # unrepl (12)
- # untangled (56)
I haven't experienced that, but I could easily see boot having issues with data readers, because it starts its "main" pod or whatever before it knows what the classpath should be, and clojure sets up data readers by looking for stuff on the classpath when clojure.core is loaded
I feel like in exxchange for the "easily be constant stack space", we must be losing something somewhere
@qqq Yes, but be aware that many "lazy" functions aren't truly lazy if you give them a chunked sequence, and compute the output for chunks (which is faster).
@rauh: chunking, right, remember running into that issue earlier;;; so basicaly I need o make functions pure-ish where it doesn't matter when it gets evaled
@qqq Well if you have side effecting functions, you should never use a lazy seq, that's just asking for trouble. And chunking is only unwanted, if your computation is expensive and might not be needed, in that case people unchunk (exists in many libs)
If you don't need laziness, then start with a vector and work with those. 90% of my code uses vectors instead of lazy sequences.
Hi! How to get the content of an incoming POST
httpRequest in :body #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x42c3599b "HttpInputOverHTTP@42c3599b"]
? I know that the body is composed of a part named data
whose MIME-type
is text-plain
and another part named excel
whose MIME-type
is application/excel
.
morning. I am having a rather weird problem. I am getting a java.lang.AbstractMethodError
exception in a function that uses postwalk
, but when I leave a certain key/value pair in my map it works fine.
@cmal have you tried slurping it? (that is what I had to do). No idea though how that would work with the two MIME types though
@thomas Hi! slurp
seems not work with this kind of :body
, but it do works when :body
's content is string.
@cmal shame... have a look at the documentation of org.eclipse.jetty.server.HttpInputOverHTTP
and I suspect there is something of a .read you can do on it for a certain length.
slurp
returns this kind of things. (.read (:body req))
returns 45
. Is this the length of the incomming req?
@thomas or should I write the string slurp from (:body req) to a file to get the excel file?
I don't know how two the different parts are differentiated. Maybe start with one first? Assuming you have control over the client that is
slurp is for things that form text
I don't think it's the right thing for an excel document at all
you can use filename and a java.io.File to create an excel file on disk
or you can put the HttpInputOverHTTP stream into a byte-array, if you like that better and have some plan for it
Is this 75c65ba8-57e4-4b4a-99fa-28a837e4e263
filename some tmp file name of jetty? If so, maybe I can get the file by this name.
@cmal do you use ring with wrap-multipart-params middware, it may handle your data (not quite sure)
@quan I've tried that. but it seems the client did not send the data in a multipart form. So the :params
key's value is {}
.
data are all in :body
of req
. I do not know how to get the files from the :body #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x42c3599b "HttpInputOverHTTP@42c3599b"]
object in java.
oki, so try to explore these object method http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/server/HttpInputOverHTTP.html
@quan How can I use this nextContent
? I am not familiar with java and only know basic java-interops. I do (.nextContent (:body req))
but it failed: No matching field found: nextContent for class org.eclipse.jetty.server.HttpInputOverHTTP
or try this lib https://github.com/ztellman/byte-streams, it handle most java stream data
@cmack The HttpInputOverHTTP implements java.io.InputStream, byte-streams should work with it.
Is it possible to protect a private project from accidental deployment to public repository, for example when not choosing the correct private repository on lein deploy?
Surprisingly, I can't find a function in clojure to insert into a vector at an index without overwriting what was there. Is the zipper library supposed to be used for this?
@cmal it sounds like you are working with a multipart request? ie. 2 different files in one upload?
@thheller You can say that. Actually the first part is only some text, the second part is an excel file
My boss won't let me use byte-streams
in the project. So I must use HttpInputOverHTTP to read the content and get the file. But I still know how.
@cmal https://github.com/ztellman/byte-streams/blob/master/src/byte_streams.clj#L503-L512
Last time I added a package in my project, my boss got fury. He won't let any new package to be introduced in this project. 😄
http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getParts()
IllegalArgumentException No matching field found: getParts for class org.eclipse.jetty.server.HttpInputOverHTTP
clj
(def svc-app
(wrap-routes main-routes
#(-> %
wrap-reload
keyword-params/wrap-keyword-params
cookies/wrap-cookies
params/wrap-params)))
https://github.com/ring-clojure/ring/blob/master/ring-servlet/src/ring/util/servlet.clj#L55-L67
my concern with this problem is an excel file is not a file type that is appropriate for slurp - slurp only makes sense for text
I dunno, I like C. I think it shares a lot of ideas with Clojure. Simple being one of them. Interop too.
Me too – my background is in systems programming actually, still to promote C is a bit anachronistic don’t you agree? I’m not talking learning and experiencing how computers work (where simplicity of C still has its place IMHO).
I suppose it all depends on what you're doing. Close to hardware, and need to squeeze every last bit of performance out of something... C is fine. Writing a large enterprise system, don't use C unless you're crazy.
Although now Rust is a little more stable, the author has hinted that the Wayland version will potentially be in Rust.
I like the idea that my laptop is this beast, but I could run my window manager on a microwave 😆
can you get Lein to simply print the classpath, if you pass it argument of deps? similar to Boot's with-cp?
lein classpath
I guess maybe that’s not actually what you meant
@cmal if you can't add libraries, you can translate one of the answers on this S.O. post with interop http://stackoverflow.com/questions/1264709/convert-inputstream-to-byte-array-in-java - or there might be something else more direct, but that depends on what you really want to do with that data. If you want to put the attachment in a file, you can put that in directly and you don't need slurping or an array
hi! where i can read about alpha15 release notes /changes ?
@mike1452 - https://groups.google.com/forum/#!msg/clojure/7ZqGTjJoQEQ/RkUYCCbeAwAJ
@jeff.terrell thanks!
@noisesmith Thank you
I have a project I created with lein that I am using to do some coding problems, so just have been editing core.clj. Today when I tried to lein repl
to start the repl I am getting a stack trace with the error
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: create in this context, compiling:(/private/var/folders/25/t0k03gfd2hz4y_5nll9zn7080000gn/T/form-init9009948996929075819.cl
j:4223:33)
My core.clj file just has a print call in it at the moment and I haven't changed anything since it was last working. Any ideas what could be causing this?Is it possible in lein-less
to create one target-path
? I have multiple less files, but want to compile them into one. Or should I then use another plugin as well?
greg_arcara try lein run -m clojure.main
then (require 'my.ns.core)
to see an error that is more directly related to your source files
user=> (require 'my.ns.core)
FileNotFoundException Could not locate my/ns/core__init.class or my/ns/core.clj on classpath. clojure.lang.RT.load (RT.java:456)
well - I meant to use your actual core namespace, not literally 'my.ns.core
@noisesmith sorry, I am just getting started with clojure and lein, should that just be clojure.core?
greg_arcara what is the namespace declared in your core.clj file?
I don't even have one, the only line is (println "Hello world")
greg_arcara well that's one of your problems then - what is the path to the file?
noisesmith src/test_app - This was working fine yesterday
not that I question that it's wrong 🙂
greg_arcara if all you want is to write a clj file and do simple forms, you can use clojure.jar instead of lein. lein is a project manager, to use it, your files should declare namespaces that reflect their location on the classpath
so src/test_app/core.clj should start with (ns test-app.core)
@grrt Is it possible in lein-less
to create one target-path
? I have multiple less files, but want to compile them into one. Or should I then use another plugin as well?
@grrt I found a solution. The target file is compiled if I import all others. I misunderstood Less, now I understand. Thanks for the software.
I am just trying to use the repl to run my code in vim for testing what I am doing
let me try adding that in
greg_arcara OK - java -jar clojure.jar
is all you need for that, then (load-file "foo.clj")
but lein is really useful for more organized projects, it's good to learn to do things that way
noisesmith that did work, which is interesting, because it was working fine for a few days now. I have been using the lein repl because it allows me to run the code easily from within vim itself. I'll keep investigating the best way to do this, thank you
$ ed deleteme.clj
deleteme.clj: No such file or directory
a
(println "Hello WOrld")
.
w
24
q
$ java -jar ~/bin/clojure.jar deleteme.clj
Hello WOrld
$ lein new abc
$ cd abc
$ lein repl
user=> (load-file "src/abc/core.clj")
user=> (in-ns 'abc.core)
abc.core=> (foo 42)
@joshjones but if you have a lein project, you can just use require - I was trying to show the minimal setup, since clearly some details of what lein is for were being missed
and if you can't use require (eg. you removed your ns form) that means you have a broken lein project, which involves a bunch of other things about how clojure needs to be able to use the classpath and how resources map to namespaces
Thanks guys, I appreciate the help
i recall there being a leiningen plugin or something for counting clojure sloc. any ideas?
Hi niroshan, I like to contribute clojurian in GSOC 2017. Can you help me for start contribution now?
I think I have asked this before, but I can't find the function. Given f, x is there a function for generating x, f(x), f(f(x))), f(f(f(x))), f(f(f(f(x)))) , .... ?
iterate
Hi, I'm trying to use clojure.tools.namespace.repl/refresh
but I'd like to exclude my test files. Is there something I can add to my lein profile so those files aren't on the classpath?
You can also use clojure.tools.namespace.repl/set-refresh-dirs
to set only the directories you'd like to refresh.
Hi! I’m looking for libraries to do integration tests on a restful API. things like “get this url with this headers, expect a json response with this and that property, etc.”. clj-http + clojure.test seems to be the basic choice, any other suggestions?
@greg_arcara maybe you've fixed your problem by now, but did you change something in .lein? That's usually how I confuse myself with inexplicable errors.
@mars0i no, I just am using the namespace
@facundo Yeah, clj-http
+ either clojure.test
or Expectations would be fine (we use the latter).
We found it worthwhile to write some convenience functions to wrap post/get clj-http operations to make our tests easier to write — a mini-DSL if you like.
I’ll take a look at Expectations, thanks @seancorfield
@facundo i've used juxt/iota (https://github.com/juxt/iota) occasionally for partial assertions on a response map