This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-08
Channels
- # announcements (6)
- # aws (1)
- # beginners (64)
- # boot (22)
- # calva (9)
- # cider (109)
- # clara (4)
- # cljs-dev (29)
- # clojure (112)
- # clojure-europe (2)
- # clojure-italy (6)
- # clojure-nl (3)
- # clojure-russia (215)
- # clojure-spec (80)
- # clojure-uk (13)
- # clojurescript (150)
- # code-reviews (3)
- # core-async (7)
- # cursive (37)
- # data-science (11)
- # datomic (76)
- # figwheel-main (6)
- # fulcro (56)
- # jobs (3)
- # jobs-discuss (22)
- # juxt (4)
- # off-topic (11)
- # pathom (16)
- # planck (5)
- # portkey (63)
- # re-frame (22)
- # reagent (3)
- # remote-jobs (1)
- # ring-swagger (5)
- # shadow-cljs (3)
- # testing (2)
- # tools-deps (6)
Hi, i have a question about growing vectors as refs. I can't seem to update a vector in a ref:
(def agent-pool (ref []))
(dosync (alter @agent-pool concat (filter odd? [1 2 3])))
(concat [] (filter odd? [1 2 3]))
CompilerException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Ref, compiling:(nubank_task/core.clj:25:1
and another:
(def data (ref [{:a "1"} {:a "2"} {:b "1"}]))
(defn remove-by-a
[value data-ref]
(dosync (alter data-ref remove #(= value (:a %)) )))
(remove-by-a "1" data)
gives IllegalArgumentException Don't know how to create ISeq from: nubank_task.core$remove_by_a$fn__4390$fn__4391 clojure.lang.RT.seqFrom (RT.java:542)
alter will call your function with the ref's value and then the arguments so you'll end up with (remove ref-value #(= value (:a %))
rather than (remove pred coll)
and the error there is saying it doesn't know how to turn that predicate into a collection
#object[com.google.cloud.datastore.GqlQuery 0x3a0c97b7 "GqlQuery{type={queryType=null, resultClass=class java.lang.Object}, namespace=null, queryString=SELECT * FROM User WHERE phone = @phone LIMIT @num, allowLiteral=false, namedBindings={allowliterals=Binding{cursor=null, value=StringValue{valueType=STRING, excludeFromIndexes=false, meaning=0, value=True}}, num=Binding{cursor=null, value=StringValue{valueType=STRING, excludeFromIndexes=false, meaning=0, value=1}}, phone=Binding{cursor=null, value=StringValue{valueType=STRING, excludeFromIndexes=false, meaning=0, value=+5512981491039}}}, positionalBindings=[]}"]
hey guys
how can I change this object property,
allowLiteral=false
to true?reflect gives me that allowLiteral is
{:name allowLiteral,
:type boolean,
:declaring-class com.google.cloud.datastore.GqlQuery$Builder,
:flags #{:private}}
example code in java:
GqlQuery gquery2 = Query.gqlQueryBuilder("SELECT * FROM SomeUnit WHERE key HAS ANCESTOR key(organization,'somename')")
.allowLiteral(true).build();
(.setAllowLiteral (Query/newGqlQueryBuilder "...") true)
There is no cheshire channel so i am asking here.
I added dep [cheshire "5.8.1"]
to my projects (uses clojure 9) and i can't cider jack in anymore
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.async.ByteArrayFeeder
does anyone know what this is about?
I've used cheshire before without problems
@lepistane check the output of lein deps :tree
or lein deps :plugin-tree
- the cause of an error like that will show up explicitly as a dep conflict there
for example, a dep of cheshire could pull in a library version of jackson that lacks a class that cider needs, usually the fix is explicitly asking for the version of the lib that you need
maybe it's too much to suggest CIDER not use deps that so notoriously break between versions
(or maybe I'm misled and the source of the error has nothing to do with CIDER - the deps tree will expose the source of the issue)
@noisesmith that was some quick help! i appreciate it very much! luckily this time around i saw that ajax lib is using cheshire but lower version so i am just using that and it works now. There was no conflict with deps but i will checkout how i can request that jackson feeder and use latest cheshire
btw this is first time i am seeing 'consider adding these excusions' and there are bunch of deps with that. How bad is this since i am first time looking at this? Should i add all exclusions?
that is what conflicts look like in deps tree, it's saying that these libs ask for different versions and suggesting how to explicitly decide which wins
I usually don't bother until I see a ClassNotFound or similar, those are signs of breakages between versions that mean I need to use the exclusions to manually fix deps
(fyi, a surprisingly high number of dependency problems relate to jackson :)
yeah, that's my experience also, using clojure.data.json just for avoiding jackson starts to seem like a good idea
Any more idiomatic way to do a nested map, e.g. (map (partial map inc) [[1 2] [3 4]])
as (nested-map inc [[1 2] [3 4]])
? Not arbitrarily deep, just one deep. Kind of a companion to mapcat
@jstaab (defn assoc-if-not-set [m k v] (update m k (fnil identity v)))
I've got these log files coming out of a service, and I was going to examine them for some stuff, but they come out with a bunch of gnarly characters. E.g.,
[2m2019-01-08 22:01:17.375[0;39m [32mDEBUG[0;39m [35m624[0;39m [2m---[0;39m [2m[nio-8081-exec-5][0;39m [36mo.n.o.drivers.bolt.request.BoltRequest [0;39m [2m:[0;39m Request: match (n) return count(n) as nodes with params {}
(wow that looks even worse pasted than it comes out in the repl)what's the right way to ignore those characters so I'm just getting the text? I tried feeding in :encode
options of "UTF-8" and "us-ascii" to my reader but, same difference
These are ansi escape codes
they tell consoles to print in colour indeed
I bet you could find a regex for deleting them
ansi uses escape codes to control a terminal, it's not something I would want in stored log data
its not an encoding, they are plain ascii, many terminals just assume that they are ansi escape codes and replace them with whatever is specified
in the clojure ecosystem, you can usually figure out which middleware / extension / utility lib is adding ansi escapes into your log messages and turn it off
right, do you know which library is logging those, @mathpunk?
no clue, this is a service I don't run. I'm checking with the service owner to see if he knows these are getting logged. It's also entirely possible I'm consuming the wrong thing
I find it more believable that it's just a poorly designed logger that assumes that the only way you look at the messages is by piping them directly to a terminal (where the color codes will actually work)
if your goal is to just read them, using cat should result in color coded text in term
@mathpunk worst case you can use eg. sed to remove the escapes and read normally https://superuser.com/a/380778
I actually want to turn this into data, not just read it.... and that link has a regex for "remove all control sequences" so I'm well on my way. thanks again!
I actually started building a regex to remove them, and then thought, "Wait this might be solved by the right usage of encodings"
this isn't an encoding thing, the escapes are meant to mess directly with a terminal
but I guess that was already said :D
(I feel inclined to reference https://xkcd.com/1171/)
especially the title text had me rolling on the floor first time I read it