This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-23
Channels
- # bangalore-clj (5)
- # beginners (136)
- # boot (1)
- # bristol-clojurians (6)
- # cider (46)
- # cljs-dev (172)
- # cljsrn (35)
- # clojure (82)
- # clojure-china (2)
- # clojure-dev (9)
- # clojure-dusseldorf (1)
- # clojure-finland (15)
- # clojure-italy (54)
- # clojure-norway (4)
- # clojure-russia (6)
- # clojure-spec (19)
- # clojure-uk (61)
- # clojurebridge (1)
- # clojurescript (55)
- # community-development (23)
- # cursive (7)
- # datomic (19)
- # emacs (10)
- # events (4)
- # fulcro (108)
- # graphql (7)
- # hoplon (1)
- # leiningen (7)
- # lumo (14)
- # off-topic (68)
- # onyx (23)
- # parinfer (8)
- # portkey (40)
- # precept (11)
- # re-frame (5)
- # reagent (40)
- # ring-swagger (5)
- # shadow-cljs (58)
- # specter (5)
- # tools-deps (37)
- # unrepl (13)
- # vim (9)
- # yada (12)
@hiredman thanks š
I have the following setup: 1. there is a LAN 2. on this LAN, there is: server: running http-kit (w/ websocket), port 8000 boot reload node https forwarding forwards 8443 to 8000 using https://github.com/nodejitsu/node-http-proxy laptop: can reach server:8000 and server:8443 chromebook, ipad: can reach server:8000 , but NOT server 8443 3. what tests should I be running to debug this?
laptop, chromebook, ipad are all on WLAN solved issue: as it turns out: 1. I have a self signed SSL certificate. 2. laptop has the *.cer installed, chromebook/ipad do not 3. chromebook/ipad: instead of asking me if I want to trust the self signed certificate, just decides to say: network reset error
Say I have a side-effecting thing which I need to serialize access to..
I manage serializing access to it through an atom holding a state ā :idle
or :in-use
.
Does that make sense to you too? Would you rather use an old-school java lock idiom or something else more clojuresque?
the problem with this strategy is you need to make producers actively poll the atom when the consumer is busy
I assume agents will only help as part of a queue solution, unless I'm missing something
Yeah, I believe agents were included in the language in order to tackle this issue, if you're interested in resources, the o'reilly clojure programming book has a chapter which goes over how the data is accessed concurrently in each scenario, and when to use each concurrency type (atom, ref, agent, var)
I guess a java locking idiom would actually do the same as the atom approach, I mean hog the CPU while waiting, or would it be more like the agent approach in its implementation and impact?
I guess it depends on if whether or not you want to use the Java way of dealing with the issue, the tools suggested are just safer to use. I'm sure you could use a lock between two threads
agents take a function similarly to a thread, i've never attempted to use them, I tend to stick to core.async with channels
Quite frankly, using clojure's locking
, was 3 lines of code to touch and serves well as a stop-gap solution until I have time to fiddle with core.async
. This makes sense, as clojure's basic idioms aren't geared toward side effects, side effects are a second-class citizen.
Why isn't delay
an instance of IBlockingDeref
?
The blocking aspect of calling deref
on an unrealized delay is not mentioned in deref
's documentation and the variant of deref
with timeout (3-arity function) cannot be used with delay
.
I don't see any conceptual difference between e.g. promise
and delay
in this case, so I think that 3-arity deref
should work.
Maybe because the deref-ing does not happen in another thread, which is necessary for timeout to be possible?
Realizing a (delayed) calculation is usually not considered a blocking operation
Congrats with your post on http://clojure.org @val_waeselynck! Amazing job: https://clojure.org/guides/repl/introduction
Has anyone used spyscope? https://github.com/dgrnbrg/spyscope
@borkdude @val_waeselynk that's great - I'd suggest one more trick for the "troubleshooting" entry - if you accidentally end up in a namespace created by in-ns (typo or forgot to require), you can get back to a semi-sane state by calling (clojure.core/refer-clojure) - after that you can do what you need to get into the ns you needed (require it, fix a typo, whatever)
@U051SS2EU already explained in Ā«navigating namespacesĀ»
oh, I missed that, thanks
@schmee I am trying it out with the latest version, and keep getting the following error #spy/p (+ 1 2 3) ;;=> 6 ;;=> 6 #spy/d (+ 1 2 3) ;;=>ClassCastException java.io.StringWriter cannot be cast to clojure.lang.Associative clojure.lang.RT.assoc (RT.java:778)
but there is a workaround here: https://github.com/dgrnbrg/spyscope/issues/26#issuecomment-320614139
@schmee Thanks! Will try your fix. I forgot to mention that it works fine with clojure 1.7.0 and spyscope 0.1.5, but would like to use clojure 1.9.0 if possible..Thanks again.
I was trying to understand how to make a reducible collection for a reader following this gist: https://gist.github.com/borkdude/ddc9433c396b1ff43a091cf2901b9dc7#file-text_xform-clj-L15-L26
however, I don't understand the line (recur (f state line))
. Where does f
come from? Where does state
come from?
@spei f is the argument fn passed to the top call to reduce (line 17). āstate is the loop local which becomes (f state line), and is initialized to the value of āinit, itself another top level argument to reduce. So essentially, invoking ālines-reducible with the requested BufferedReader will yield an object which is reducible: each element is taken from reading a line in the closed-over reader.
@kingcode But the function is called as #(lines-reducible (io/reader %))
, no where is f and state ever given
@spei correct. f is provided by the client code (you?) and state is built up at each step, starting with āinit
@spei just like you would with (reduce + 20 {1 2 3]) replace [1 2 3] with your buffered reader, + with f and init with 20.
maybe i'm misunderstanding how reify
works. I just don't see any code that calls the reduce
([xform f init coll]
(let [f (xform f)
ret (if (instance? clojure.lang.IReduceInit coll)
(.reduce ^clojure.lang.IReduceInit coll f init)
(clojure.core.protocols/coll-reduce coll f init))]
(f ret))))
@spei example: (def my-reducible (lines-reduce (BufferedReader. (FileReader. (File. <somepath>))))) (reduce my-reducible my-own-func āā)
@spei donāt worry about āreify. It simple means āIām giving you something that can reduce itselfā. Try the example I typed in a repl with a real file, and youāll see it works. Use conj and [] for f and init
is there a way to turn the line-seq
into a IReduceInit
? is that even a valid question? does the lines-reduce
function return an IReduceInit
?
@spei āI donāt see any code that calls the reduceā That is not the point of reify. Reify prepares something for you to make your call(s) on it, using your own function (f) and initialized value (init)..Hope this helps..
@kingcode I think it can be confusing when you look at the example in the gist - there's nothing that call reduce
; because there's just transduce
which calls .reduce
internally
@spei Here is a 2-line code example you can try with the gist code (def br (BufferedReader. (StringReader. āLine 1\nLine 2\nLine 3\nLine4ā))) (.reduce (lines-reducible br) conj []) ;;=>[āLine 1" āLine 2ā āLine 3" āLine4ā]
@spei Here is the same example using a transducer instead: (def br (BufferedReader. (StringReader. āLine 1\nLine 2\nLine 3\nLine4ā))) (transduce (mapcat #(lines-reducible %)) conj [] [br])
@spei you could add more sources (make br1 ,br2 and shove them as last input arg to (transduce ā¦[br br1 br2])ā¦
Is there any documentation around regarding writing custom test.check generators? Iām trying to write a generator to sample a collection with a non-level distribution.
Is there a Clojure equivalent to Scalaās Slick DB?
Nothing I know of thatās released and really tries to take Clojureās native datastructures and make them transparently durable besides hitchiker-tree. Iām trying to build something like that but itās very much experimental.
ztellmanās new bifurcan libraries are working towards offering durable models of data which can be round-tripped efficiently but I donāt know how much of that works yet.
clojureās own datastructures are all Java serializable, so you could go put something like this together yourself using say datascript or one of the other in-memory datalogs as a frontend.
Datomic is probably the closest thing to a database for Clojure out of the box, but it isnāt part of Clojure itās a separate product.
@arrdem re: generators, did you see my conj talk?
@gfredericks I donāt think so, but after some digging I concluded that test.check just isnāt appropriate for the generator semantics I want since I just want to kick out random examples with a known distribution and no shrinking so really I just want to hand-roll my own sampling machinery for this one special case.
@arrdem Ugh, that stinks. I have a colleague whoās insisting on NOT using HoneySQL/YeSQL style, which I think works fine for scoped micro-services.
is there a builtin function which does truthy -> true falsey -> false ? input: arbitrary object, output: boolean
user> (boolean nil)
false
user> (boolean false)
false
user> (boolean 1)
true
user> (boolean (Object.))
true
user>
@jmckitrick š thatās definitely the common path AFAIK
@arrdem Maybe Korma??