This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-31
Channels
- # beginners (57)
- # boot (25)
- # cider (86)
- # cljs-dev (6)
- # clojure (137)
- # clojure-russia (7)
- # clojure-spec (10)
- # clojure-turkiye (1)
- # clojure-uk (47)
- # clojurescript (37)
- # cursive (10)
- # datascript (2)
- # datomic (2)
- # dirac (59)
- # emacs (1)
- # hoplon (46)
- # instaparse (122)
- # om (32)
- # om-next (1)
- # onyx (3)
- # pedestal (2)
- # perun (4)
- # protorepl (6)
- # re-frame (15)
- # reagent (60)
- # rum (4)
- # specter (7)
- # sql (3)
- # untangled (3)
- # yada (4)
is there an alternative to -> or ->> where it's (----> arg f1 f2 f3 f4) where the fi's are all of the form #( .... % ... ) ?
@bradford You may also be interested in https://github.com/TheClimateCorporation/claypoole this lib.
Besides Red5/Java, are there any other libraries for building live video streaming (like twitch ) in Clojure?
src/bar/foo.clj <-> src/bar/foo_test.clj is becoming really annoying; is there any downsides to using test/bar/foo_test.clj ?
Not sure what you're asking there @qqq -- most people have tests in the test
subtree and source in the src
subtree...
@seancorfield: I guess I was asking "is there anything bad if I stop kicking this rock" ;; I originally had impl/code in the same directory due to a problem with cider/emacs having difficult jumping between the two; but now they're in separate dirs, and I'm much happier
I would ask, why would you have tests in the src
tree?
Pretty much everyone puts their tests in the test
tree...
After all, when you build production artifacts, you don't want test
included.
@seancorfield : because I'm working on hobby projects, and getting C-c p t to work was more important than directory structure at the time (until it started getting overcrowded)
The greatest gain is from "no unit tests" to "unit tests" -- anything else is pre mature optimization. 🙂
Thank you @pesterhazy, that works
I have now these specs :
; specs for validatimg input to find rhe ids(s/def ::artObject (s/keys :req-un [::objectNumber]))(s/def ::artObjects (s/coll-of ::artObject))(s/def ::body (s/keys :req-un [::artObjects]))(s/def ::response (s/keys :req-un [::body]))
Is it right I have to make copies of artObjects if I want to check for objectNumber and for example a description@futuro it's a base class for reference type implementations
@alexmiller I must admit I'm a little confused by what a reference type is
I see in the source that clojure.lang.ARef extends clojure.lang.AReference, and so does clojure.lang.Namespace, and then c.l.Atom, c.l.Agent, c.l.Ref, and c.l.Var extend c.l.ARef; which at first glance makes me think c.l.AReference is a super-type of just about everything
ah, but a little searching helps me; am I correct in understanding that vars, refs, agents, and atoms are all reference types?
a reference type is generally a "pointer" to a single value, and you can use deref
to pull the value out
Cool, thank you @gfredericks and @alexmiller 🙂
When writing middlewares for nrepl, is there a dynamic var bound to the id of the response I'm working on?
I'm registering a handler for writing to java.lang.System/out. Its registered once but the middleware puts the id of the registering request rather than the request it is handling further down
I'm actually a little surprised that I can't leave the Id off and let the middlewares further up merge it in if its nil
@dpsutton there's a dynamic var with the whole req I think
that might be only accessible during eval though
and it looks like if you eval (.println (java.lang.System/out) "hi")
it has that binding but its bound to id 7
nrepl middlewares always give me a headache
I think I tested faster than that
if you run lein repl
out of the project with the middleware you should be able to do it that way
still a pain to test, just didn't have to go through maven
I have a file. It has ~ 20 functions. 4 are public. The rest are private. When unit testing, do I only test these 4 functions (because the rest are implementation details) or do I unit test all of them (helps me check bugs when refactoring) ?
Last night, I went from s/foo/bar.clj and src/foo/bar_test.clj to a separate "test" directory; so I want to follow best practices.
Is there any chance of https://github.com/clojure-emacs/cider/blob/c698df1c905127f190efee3403822b2b09a811c3/doc/indent_spec.md becoming an official clojure thing? I think it’s a good standard, but standards like these are only as good as how much they’re used
I need a way to (1) dump out all function names and (2) for each function, print the number of arguments it takes (or if it's var arg). What libraries / functions should I use to do this?
@mingp: In haskell, because functions have fixed arity, we can do application without using ()
it looks at its arguments, figures out which ones are functions, and their input arity, then puts () at the right palces [this would ignore var arg functions and functions with multiple arity]
https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/refresh.clj
when refreshing a repl, it used to invoke functions that you set up for before and after
is the :arglists field of meta something that (1) you setup yourself or (2) something clojure does for you?
is there a way to force correct method dispatch on a java method in clojure? basically, if i do Paths.get("/tmp")
works in java, but (Paths/get "/tmp") does not work in clojure. Here
Paths` is java.nio.file.Paths
. https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html
sorry, this is the exception: java.lang.ClassCastException: Cannot cast java.lang.String to java.net.URI
using ns-interms, I have gotten a kv map of "symbol" -> "var object for symbol" for namespaces I care about. From this, how do I get the corresponding source of the symbol?
1. source is returhing "source not found" even though the repl can see the var. 2. This doesn't seem to be how spectrum https://github.com/arohner/spectrum/tree/master/src/spectrum is doing it
so a file that the source looks up has to be evaluated via require or whatever it does that adds the :file metadata to the var
can anyone think of a performant way to query ~250 sqlite file databases that will be read from more-or-less equally ?i'm using a third party data source that happens to be structured in individual DBs... i've considered writing a script to merge them into postgress or something but it complicates the process of updating the resource dbs individually.
right now i've got a map of :id => db connection (using conman for a connection pool) and it works, but i think the overhead is probably huge (havent figured out how to measure it yet)
I guess one nice thing about loop
is you can write recursive anonymous functions easily without having to use combinators
one thing I wish I could do with loop is (loop [obj] .... (modify obj) .... (modify obj) .... (recur))
sometimes, it's imperative though, like I have one part which is: increment counter add element ot raw data store update indexes
(with-local-vars [v1 "foo" v2 :bar] ...)
@gfredericks How does using a local var compare with using a volatile or a plain atom? When is each preferable?
I've never seen anybody use a local var in my life, so I have no idea.
I think, but am not certain, that local vars are "cheaper" than atoms, because atoms are concurrency safe, and local vars should only be used in one thread?
I am pprint on a large data structure. Is there a way to tell pprint to only print 20 lines?} I could possibly use (subs (with-out-str (pprint ...))) ... but then it has the problem that I end up printing it as a string
@qqq You can use *print-level*
and *print-length*
to control that
for example (binding [*print-level* 5 *print-length* 5 ] (clojure.pprint/pprint {:a 1 :b {:c 2 :d (range 20) :e 3} :f 4}))
(adjust both values to see the effects)
@seancorfield: print-level is even more better
(binding [*print-level* 3 *print-length* 2 ] (clojure.pprint/pprint {:a 1 :b {:c 2 :d (range 20) :e 3} :f 4}))
user=> {:a 1, :b {#, #, ...}, …}
[xpost] Is there a way in honeysql
or pure clojure.jdbc
to cast a Postgres parameter? I receive :
PSQLException ERROR: column "personal" is of type jsonb but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 66 org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse (QueryExecutorImpl.java:2182)
I am passing a parameter as jsonb