This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-25
Channels
- # aleph (6)
- # beginners (6)
- # boot (94)
- # cider (34)
- # cljs-dev (36)
- # cljsrn (12)
- # clojure (124)
- # clojure-dev (41)
- # clojure-dusseldorf (6)
- # clojure-italy (3)
- # clojure-norway (1)
- # clojure-russia (161)
- # clojure-sg (7)
- # clojure-spec (71)
- # clojure-uk (95)
- # clojurescript (38)
- # core-async (16)
- # cursive (14)
- # data-science (1)
- # datascript (12)
- # datomic (15)
- # emacs (22)
- # funcool (2)
- # hoplon (15)
- # jobs-rus (2)
- # juxt (9)
- # liberator (7)
- # lumo (1)
- # off-topic (136)
- # onyx (24)
- # pedestal (39)
- # perun (2)
- # planck (20)
- # re-frame (23)
- # spacemacs (31)
- # unrepl (5)
- # untangled (1)
- # vim (1)
- # yada (29)
@qqq Clojure is more like Super FoxPro, not FP for me. Main advantages of clojure: data manipulation is simple and smooth. is Foxpro (or other db) needs to do type checking? 🙂
UNIX TextFlow using the pipe to combine command, Clojure DataFlow using -> and higher-order func to combine func.
Foxpro and clojure have in common, is the data collection operation priorities, As with all DB's, separate data and code, Like separation of machines and raw materials in the industrial pipeline.
data is raw materials, code is machines. dataflow is river, codeflow(logicalflow) is the river bank
Does anyone have cider working with Orgmode/babel ?
Clojure is a DB-mode-based FP language. It is much simpler and more practical than haskell.
Guys, is there a core function to do this:
(do-something [1 2 3] [4 5 6])
=> ([1 4] [2 5] [3 6])
(map vector [1 2 3] [4 5 6])
oh, cool @clojureman!
anybody know if clojure.spec has a way to compose specs for strings? i.e. if I have some formatting string with repeating patterns, say [1]foo[14]bar
, it would be nice to use the normal spec composition instead of regex parsing to build up the spec for the full thing
@mbjarland (clojure.core.strint/<< "(repeat 1 "foo") (repeat 14 "bar")") http://clojure.github.io/core.incubator/clojure.core.strint-api.html#clojure.core.strint/<<
@lincpa much appreciated and I will add (<<
to my list of tricks...though now that I see the answer I suspect I was less than crystal clear in my question : )
So I have a formatting string which verbatim says things like [L]sometext[R]someothertext
etc, i.e. with brackets and all. I would like some way of defining a spec that says:
(s/def ::bracket-expr <some string operation here>)
(s/def ::between-bracket-expr <some string operation here>)
(s/def ::entire-expr (s/cat :expr (s/* (s/alt :bracket ::bracket-expr :between ::between-bracket-expr))))
without using nasty regex group repetition to express the fact that I have repeating groups within the string.i.e. define specs for parts of the string and then handle the repetition part in the spec realm
seems somehow like missing the point if you have to write a 100 char regex in the middle of all this beautiful spec code
I suspect this kind of string destructuring via spec is not possible but I was hoping someone would tell me otherwise
: ) well I'm just starting out, but it seems to me (like clojure itself) that the velocity at which it goes from unreadable to natural is quite surprising
hello all. I'm using Lein 2.61 w/ Java 1.8.0. I have a mixed clj/java project and everything works great in development when I do lein:run. however, lein uberjar doesn't find my java classes as if they are not compiled or not in the classpath. I've specified a default :java-source-paths. any idea what could be the problem?
@kaosko how does your :java-source-paths
line look...strange though, since lein:run works...
@mbjarland :java-source-paths ["src/java"]
@kaosko I'm sitting in a project with a similar setup and it is picking up the java class
@mbjarland yeah, the issue is that it works fine when I do lein run for example, so I'm baffled
the following illustrates a working scenario:
✔ mbjarland@mackmyra:~/projects/clojure/clojure-license-plates [master|✚ 2 …3]$ tree src/
src/
├── clojure_license_plates
│ ├── core.clj
│ └── typing.clj
└── java
└── mxy
└── IntTools.java
3 directories, 3 files
✔ mbjarland@mackmyra:~/projects/clojure/clojure-license-plates [master|✚ 2 …3]$ lein uberjar
...
Created /home/mbjarland/projects/clojure/clojure-license-plates/target/clojure-license-plates-0.1.0-SNAPSHOT.jar
Created /home/mbjarland/projects/clojure/clojure-license-plates/target/clojure-license-plates-0.1.0-SNAPSHOT-standalone.jar
✔ mbjarland@mackmyra:~/projects/clojure/clojure-license-plates [master|✚ 2 …3]$ unzip -l target/clojure-license-plates-0.1.0-SNAPSHOT-standalone.jar | grep mxy 0 2017-04-25 09:42 mxy/
1102 2017-04-25 09:42 mxy/IntTools.class
1775 2017-04-18 08:42 mxy/IntTools.java
0 2017-04-18 08:42 java/mxy/
1775 2017-04-18 08:42 java/mxy/IntTools.java
@kaosko example mini-project where this works for whatever it's worth: https://bitbucket.org/mbjarland/clojure-license-plates
Hi. Does anyone here have experience with clj-http-fake? Maybe pointers to real life examples?
@mbjarland thanks. my build is somewhat complex. must be some specific version, setting or plugin throwing a wrench, perhaps lein-virgil? I guess I just need to start excluding things
@kaosko well share the findings once you figure it out, sounds like a tar pit preferably avoided : )
I wonder if clj-http-fake works, when the calls to the fake HTTP server are in a completely different namespace and way down the stack. The way, fake is writting (using robert.hooke), I would expect it to work, but somehow it doesn't for me.
@mbjarland will do. changing/excluding virgil had no difference though
@jumar, after loading clj-http-fake the metadata of clj-http.core/request
seems to be unchanged. But it should have the ::hooks
of robert.hook, shouldn't it?
I don't know the internals, but I used it once for "integration" tests - let me check if I can find the example
Here is, where fake adds the hook: https://github.com/myfreeweb/clj-http-fake/blob/master/src/clj_http/fake.clj#L187
And this is basically how robert.hook works: https://github.com/technomancy/robert-hooke/blob/master/src/robert/hooke.clj#L48
@jumar, I managed to get something like your code to work, too. But now I try to apply it to real world code where my HTTP calls (using clj-http) are behind a core.async channel, on a different thread and everything. But, as I said, if the instrumenting of clj-http.core/request
worked, I'd expect the more complicated setup to be no problem.
ah, okay - the async stuff can be a problem I guess, but I don't really have experience with this scenario, so sorry O:-)
answering my own clojure.spec question above, it seems if you view strings as sequences of chars things work out fine
Any Clojurians from Singapore? Please do join #clojure-sg channel.😀
@tbaldridge : re 'boot clean' vs 'rm -rf ' // I just realized one advantage of 'boot clean' -- nothing bad happens if the machine you think you're SSH-ed into is DIFFERENT from the machine you are actually SSH-ed into
from time to time i get into a problem that lein works (with plugin for ring ie). but lein uberjar fails. right now my uberjar compilation fails because ‘java.lang.ClassNotFoundException: ring.util.time, ’. That disparity is annoying a bit. what strategy do you use to not make that blunder, and how do i find out what package to import in project.clj ? with version that is current?
the docs do not seem to be helpful. there is a chasm between packages with version and namespaces. most docs focus on namespaces… so what do you do??
actually it gets worse, i assumed that i need to pull in a lib “ring.util” in project.clj, but looking into compojure project.clj i see it has ring.core in it and that ring core has utils.time in it. ??
@karol.adamiec Do you have any dev dependencies? They might be what is bringing in ring.util, and those aren't available during uberjar
solved it
it was not what i thought
basically (ring.util.time/formatDate …) worked in repl, and with lein server ring. but failed compilation with uberjar
for compilation to work in uberjar ‘mode’ i had to declare (:require [ring.util.time :as time])
i pull in my project clj compojure and jetty adapter etc
so that is a bit of a surprise… i clearly misunderstood some tidbit so any explanation or redirect to one of that behaviour would be appreciated
@karol.adamiec You hadn't required the namespace. Sometimes namespaces get loaded by other things, but there's no guarantee of ordering. That is why it worked in the repl.
:thumbsup:
ok, good rule of thumb 🙂. got deceived by it working 🙂
hi all !
i am trying clj-http/request, but i look error when request post “Premature end of Content-Length delimited message body (expected: 5047; received: 3943”
how any solution ?
thanks
Answering myself here after a detour to the core.async channel: Do not use with-global-fake-routes
when your HTTP call is somewhere behind async channels. But the normal with-fake-routes
seems to work (so far). Reason is with-redefs
in the end.
@isankhairul That's a problem with the server/connection, not client.
You can maybe do a raw request, read its stream until you cannot, and then retry with an offset equal to how much you managed to read. Repeat that until everything is read.
This will only work if the server understands requests with offsets.
Ofc. you can also keep retrying the full requests until it succeeds.
is there a way to use read-string
so it reads multiple forms in the same string?
=> (read-string "(+ 2 2) (+ 5 5)")
(+ 2 2)
Oh I guess I have to parse the string first somehow? there should be an easy way to do this
Does anyone here use https://github.com/AvisoNovate/pretty with https://github.com/jakemcc/lein-test-refresh and https://github.com/pjstadig/humane-test-output ?
There seem to be some form of collision when running all three of them. humane-test-output is supposed to print the diff when a test fails, but doesn't after I've called io.aviso.repl/install-pretty-exceptions
. The diff is displayed as expected when I run regular lein test
.
Maybe the (RT/loadResourceScript "clojure/test.clj")
in https://github.com/AvisoNovate/pretty/blob/master/src/io/aviso/repl.clj#L55 is a suspect?
@tmtwd I think the proper way to do this is use a StringReader
, and repeatedly call (read)
on it until you get an EOF
It's easy enough to make sure that the string is a single form instead of 2 forms. IMO.
https://github.com/SevereOverfl0w/lein-bikeshed/blob/master/src/bikeshed/core.clj#L205-L213 <-- this is how I do it
Depends on what tmtwd wants to do with the input, I suppose. If it's from an untrusted source, they will be validating that it's nothing nasty first.
@tmtwd If you want my advice, do it the way I linked, and maybe with tools.reader too, it has additional metadata on read forms.
I’m building a ring svc that needs to take a multipart-form binary upload (like a jpg), and then send that to another REST service which ultimately renders it as a file. Is all I need to do take the (:upload (:multipart-params request))
and make that the content of the next request, + copy over the content-type
?
That sounds reasonable to me. I'd give it a shot and see if it blows up. :-)
How to use Clojure 1.9.0?
@stardiviner in your project.clj
file change the clojure version to "1.9.0-alpha14"
alpha15 is available
I tried, but it still use 1.8.0
, Here is my project.clj
clojure
(defproject clojure-examples "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "Eclipse Public License"
:url ""}
:dependencies [[org.clojure/clojure "1.9.0-alpha12"]])
Is there some reason in ~/.lein/profile.clj
?
How can I use Clojure 1.9.0 in ~/.lein/profile.clj
? After a clean profile.clj
, I start lein repl
in a project project.clj
, Now CLojure uses 1.9.0-alpha12.
A couple things. 1) make sure you’re using profiles.clj
, (you’re missing the ‘s’) 2) for overriding clojure, you need to use ^:displace
e.g. {:repl {:dependencies [^:displace [org.clojure/clojure "1.9.0-alpha12"]]}}
see the docs for more info https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.md
Thanks, ^:displace
metadata works for me. This is really great.
trying it out the first time on my server.. having problem with something simple: Removing intermediate container 7923c371099b Step 3/5 : ADD target/uberjar/xxx.jar /xxx/app.jar remote: lstat target/uberjar/xxx.jar: no such file or directory
(so I'm trying to push to Dokku. a sample app works, my custom one doesn't) sounds like it should be a simple fix but don't know what I need to change
@kaosko check out what is in your target/ directory - many project.clj configs don’t create a separate uberjar directory
@noisesmith figured it out - I had created my project from a Luminus template and it container a Dockerfile that screwed up dokku deploypment. it was enough to remove it
what is the -U
flag in lein -U uberjar
?
@csm (oh, duh, thanks. we need a "Let Me CLI That For You")