This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-23
Channels
- # admin-announcements (2)
- # arachne (2)
- # beginners (76)
- # boot (241)
- # cider (14)
- # cljsrn (2)
- # clojars (3)
- # clojure (94)
- # clojure-android (12)
- # clojure-dev (33)
- # clojure-gamedev (1)
- # clojure-greece (3)
- # clojure-india (1)
- # clojure-nl (2)
- # clojure-quebec (3)
- # clojure-russia (21)
- # clojure-spec (38)
- # clojure-uk (72)
- # clojurescript (62)
- # cursive (20)
- # datascript (3)
- # datomic (14)
- # devcards (1)
- # dirac (14)
- # emacs (11)
- # hoplon (7)
- # jobs (2)
- # keechma (1)
- # lein-figwheel (9)
- # leiningen (9)
- # luminus (1)
- # off-topic (6)
- # om (13)
- # onyx (30)
- # planck (181)
- # proton (3)
- # re-frame (6)
- # reagent (6)
- # specter (108)
- # spirituality-ethics (7)
- # untangled (3)
Hello everyone, I’m looking for feedback on a thing I did today, trying to get a basis for a real project: (Requires Clojure-clr dll in ‘clojure’ subfolder) Poshjure - Clojure in Powershell https://gist.github.com/flyboarder/40a7e25c89f6e5dcfb25da37be782037
Hi, not sure if this was discussed before, but I can’t find the answer: I’m using spec to validate the input data to a http json API, and I don’t want to ask the clients to use qualified keys. That’s easy enough with req-un at the top level, but I’d like to have the internal logic use the namespaced map. To be able to validate the external input, I need to use req-un throughout (which is not a nice solution, I would say), or somehow copy the spec (which is even worse). What I need is some kind of s/conform-un that takes a qualified spec and an unqualified map, tries to conform, and returns the qualified map if that worked. Does something like that exist?
@mathias_dw: can you convert the unqualified map to a qualified one for use internally in your api?
yeah, I can do that “manually”, but I was looking for something that already does that generally
I haven’t used spec, but when I get a JSON object like {“some_key”: “foo”}
, I use https://github.com/qerub/camel-snake-kebab to convert it into {:some-key “foo”}
but you’re right, I didn’t mention that in the options above, and this is what I would do as well
thanks, that’s a nice library I didn’t know about
yeah, it makes sense to create something like that for what I’m looking for, thanks! I’ll see what it would take and give it a stab if nothing similar exists
Is it possible to have actual carriage returns while pretty printing, instead of the ”\n”
literal showing up? I’d like to print a map which has some string values containing newlines within them.
I’ve seen the pprint-newline function, but it’s not really clear to me how to actually use it based on the documentation.
I’m sure I’m missing the nice way to express this, but… Suppose I have xs [:a :b :c]
and ys [0 1]
, how do I get [[:a 0 :b 0 :c 0] [:a 0 :b 0 :c 1] [:a 0 :b 1 :c 0], …]
? i.e. I want every possible combination, so (count ys)
raised to the power (count xs)
things. I don’t necessarily know the values of xs and ys statically ahead of time, so the obvious for
doesn’t work, and a macro doesn’t seem very appropriate here
thanks, @weavejester
Your welcome 🙂
*You're
Ugh 🙂
anyone know if there’s a way to get a handle on the variable name while processing a template?
weavejester: so, that still doesn’t quite get me what I wanted, because it gets me every (x, y) tuple, but what I wanted was a set of all of the possible tuples of length (count xs) where the associated y value takes every possible value; more like a counter up to (count ys) (count xs)
if it helps to reason about it, the xs are argument names, the ys are byte types (byte array, ByteBuffer)
(it’s possible that the right answer here is “don’t do that” but I’m still running the necessary experiments to figure that out)
Hm, I see...
(and yes I’ve already made sure I don’t end up with 64k methods that way since that would break the JVM ;))
But… hm, isn’t that a case of applying the combinations twice over?
caesium.binding> (c/selections bound-byte-types (count [:arg1 :arg2 :arg3]))
((#function[clojure.core/bytes] #function[clojure.core/bytes] #function[clojure.core/bytes])
(#function[clojure.core/bytes] #function[clojure.core/bytes] java.nio.ByteBuffer)
(#function[clojure.core/bytes] java.nio.ByteBuffer #function[clojure.core/bytes])
(#function[clojure.core/bytes] java.nio.ByteBuffer java.nio.ByteBuffer)
(java.nio.ByteBuffer #function[clojure.core/bytes] #function[clojure.core/bytes])
(java.nio.ByteBuffer #function[clojure.core/bytes] java.nio.ByteBuffer)
(java.nio.ByteBuffer java.nio.ByteBuffer #function[clojure.core/bytes])
(java.nio.ByteBuffer java.nio.ByteBuffer java.nio.ByteBuffer))
thanks, @weavejester 🙂
Yeah, something like:
(map (partial interleave [:a :b :c]) (combo/selections [0 1] (count [:a :b :c])))
I think you just need interleave
and combo/selections
, @lvh
Yeah. Technically I need to vary-meta (don’t ask) so I can just map with 2 seqs anyway since that fn is going to be something weird
however being able to do stuff like this makes me pretty happy that I did that from Clojure instead 🙂
I have a function that sends a bunch of emails out, mapping over a list of recipients to do this. Wondering if this is an ok place to use pmap
... I'm asking because I think I remember hearing it's a good function to avoid using.
It’s the easier form of concurrency, but the number of threads isn’t under your control
You might want to use a j.u.c Threadpool, perhaps as wrapped by the claypoole
library
@dhruv1 there's a #C0617A8PQ channel btw, you may get help faster there
@ddellacosta: thanks! Didn’t realize there was a #C0617A8PQ channel
also an #C099W16KZ one which I see folks asking cider questions on, and I'm honestly not sure which is better—but could try both!
you are being confused by the way tagged literals have a space between the tag and the value
user=> (Exception.)
#error {
:cause nil
:via
[{:type java.lang.Exception
:message nil
:at [user$eval1 invokeStatic "NO_SOURCE_FILE" 1]}]
:trace
[[user$eval1 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval1 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 6942]
[clojure.lang.Compiler eval "Compiler.java" 6905]
[clojure.core$eval invokeStatic "core.clj" 3177]
[clojure.core$eval invoke "core.clj" 3173]
[clojure.main$repl$read_eval_print__9412$fn__9415 invoke "main.clj" 240]
[clojure.main$repl$read_eval_print__9412 invoke "main.clj" 240]
[clojure.main$repl$fn__9421 invoke "main.clj" 258]
[clojure.main$repl invokeStatic "main.clj" 258]
[clojure.main$repl_opt invokeStatic "main.clj" 322]
[clojure.main$main invokeStatic "main.clj" 421]
[clojure.main$main doInvoke "main.clj" 384]
[clojure.lang.RestFn invoke "RestFn.java" 397]
[clojure.lang.Var invoke "Var.java" 375]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.Var applyTo "Var.java" 700]
[clojure.main main "main.java" 37]]}
user=>
Anyone using clj-webdriver on Linux unable to connect to Firefox? Had this problem a while...
Are you running it interactively, or in background? For the latter, you’ll need a virtual frame buffer set up for X11, as I recall.
It's not a $DISPLAY issue or anything like that; here's a snip of stacktrace: `NotConnectedException Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: me: Recursive scan of <mailto:[email protected]|[email protected]> 1466704056032 addons.xpi DEBUG Updating XPIState for {"id":"{972ce4c6-7e08-4474-a285-3208198ce6fd}","syncGUID":"f9DxnyTWFqZ2","location":"app-global","version":"47.0","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null, ...`
am I being dum here trying to push an artifact to clojars? the error given is clojure.lang.ExceptionInfo: Could not find artifact org.clojure:clojure:jar:1.8.0 in clojars (
…. and if I look through the clojars via the web interface, it doesn’t seem obvious that 1.8.0 is actually present. (clojure 1.8 is listed as a :provided depenency for my lib)
@lwhorton: did you maybe set-state!
the :repositories
key? (overriding the old value)
(set-env!
…
:repositories [["clojars" {:url " "
:username (System/getenv "CLOJARS_USER")
:password (System/getenv "CLOJARS_PASS")}]]
…)
i’m digging around bootlaces (seems to be used all over boot-adzerk) and it seems to be doing what I’m trying to do
@lwhorton: try (set-env! :repositories #(conj % ["clojars" ...]))
so … boot has some of its own env :repositories already set somewhere (which presumably includes things like maven)?
it (and lein) have default repo sets, which consist of clojars and maven central, yes
thanks guys, I appreciate it…. one of these days I’ll actually be able to give back and not just take take take
Hey guys, I've created a dead simple online tool to pretty print EDN: http://edneditor.com
There's just a lot of times that I'll have a chunk of EDN that I want to pretty print, to get a better view of my data.
Very rudimentary at this point - so a lot of TODOs. But have a look, let me know your thoughts. Hopefully it can help you out.
@twashing: thanks, I find I use simple tools like this a lot! 🙂
oo, it would be nice too if it indented a little deeper 🙂
In a similar vain as @twashing, I put made a simple tool for for JSON to EDN conversion (and back). Handy for taking examples (REST API post bodies, Javascript libraries,etc) and easily turning them into a Clojure data structure. http://pschwarz.bicycle.io/json-to-edn/
@josh.freckleton Hmm, fair enough. I’ll make that a TODO 🙂
@peterschwarz Niiice. Looks pretty slick.
Hi! Is there a version of equality that also includes metadata? I am creating an interface that requires types and annotations, so using metadata is not optional (I understand why equality does not normally include metadata)
no, but you could write one
okiedokie, just checking. Thanks @alexmiller 🙂