workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
va = vector apply, (va [f g h] [v1 v2 v3]) -> [(f v1) (g v2) (h v3)]
2017-12-22T17:58:42.000092
Berry
clojurians
clojure
smap = "stateful map", standard map is: f :: a -> b stateful map is f:: [s, a] -> [s', b] so there is a "state variable" being threaded through
2017-12-22T17:59:19.000007
Berry
clojurians
clojure
What exactly is the question, though? Do the tests cover all/enough of the cases? If yes, then they're enough. 3 lines of test per line of code is such an arbitrary value. How long is a piece of string?
2017-12-22T18:23:12.000067
Bibi
clojurians
clojure
Can this be simplified? ```(map #(map first %) [[[1 2] [3 4]] [[5 6]]]) => ((1 3) (5))```
2017-12-22T21:25:06.000099
Keesha
clojurians
clojure
same items, different shape ```+user=> (for [x [[[1 2] [3 4]] [[5 6]]] [y] x] y) (1 3 5) ```
2017-12-22T21:50:41.000059
Margaret
clojurians
clojure
<@Margaret> Thanks, I ended up with this `(partial map (partial map first))`
2017-12-22T22:23:44.000008
Keesha
clojurians
clojure
is there some way to report to clojars that a project doesn’t work anymore? The postgresql project there is *way* out of date and no longer works for inserts…I just spent a good 3 or 4 hours trying to figure out what I was doing wrong :stuck_out_tongue:
2017-12-22T22:33:12.000014
Williemae
clojurians
clojure
I'm sure it still works if you combine it with the right jdbc version
2017-12-22T22:34:18.000036
Margaret
clojurians
clojure
heh
2017-12-22T22:34:26.000006
Williemae
clojurians
clojure
in that case they could at least put something in there saying that it’s no longer compatible with new versions of the jdbc and go to the right repo for compatibility
2017-12-22T22:36:16.000043
Williemae
clojurians
clojure
all these deps are explicit (clojure.java.jdbc, java.jdbc, db drivers) and many combos won't work, but the older ones still work in the right combination, if they ever worked
2017-12-22T22:36:18.000068
Margaret
clojurians
clojure
usually the approach is to treat old deploys as immutable
2017-12-22T22:37:19.000017
Margaret
clojurians
clojure
i assumed it was an official repo because it’s called `postgresql/postgresql`, if it was `someguy/postgresql` i would have looked for an alternative (and maybe found the official central repo earlier)
2017-12-22T22:37:37.000054
Williemae
clojurians
clojure
i get it but what im saying is this isn’t very user friendly, especially since the error doesnt actually make it clear what’s wrong.
2017-12-22T22:38:18.000057
Williemae
clojurians
clojure
I think the main problem is you shouldn't be looking for postgresql on clojars
2017-12-22T22:38:50.000040
Margaret
clojurians
clojure
it's a java project, like most mainstream java stuff they deploy to maven - someone mirrored to clojars once and used their name
2017-12-22T22:39:20.000010
Margaret
clojurians
clojure
(may even have been the postgres driver devs but I doubt it)
2017-12-22T22:39:59.000055
Margaret
clojurians
clojure
Fair enough, but being that I’m pretty new to the clojure/java ecosystem I honestly have no idea what’s official and what isn’t.
2017-12-22T22:40:00.000036
Williemae
clojurians
clojure
I assumed clojars was official because that’s where lein looks
2017-12-22T22:40:20.000042
Williemae
clojurians
clojure
OK - good rule of thumb is that java code is canonical on maven or sonatype, and clojure stuff is canonical on clojars
2017-12-22T22:40:34.000033
Margaret
clojurians
clojure
lein looks in maven before clojars iirc
2017-12-22T22:40:44.000001
Margaret
clojurians
clojure
in any case it would be good to have clojars or someone make a note on that repo for future noobs like me making that mistake heh
2017-12-22T22:42:18.000034
Williemae
clojurians
clojure
that's fair - I don't know if they have that power with the current site design - my mental model is that it's like github where each project controls what ends up on their clojars page
2017-12-22T22:43:19.000070
Margaret
clojurians
clojure
but I'm not sure, honestly
2017-12-22T22:43:29.000072
Margaret
clojurians
clojure
i see
2017-12-22T22:43:38.000003
Williemae
clojurians
clojure
I agree that it's good for people to understand where the artifacts they use come from, and how they got there
2017-12-22T22:45:45.000015
Margaret
clojurians
clojure
Suggestions on making something like the following fast? - You're given information that a password is 14 characters in length, that it is composed of [a-Z] exclusively, and that it contains a single dictionary word. - You want to limit the cartesian product of all possible selections over [[a-Z] [a-Z] [a-Z] ...] given you know that a dictionary word must exist within the passphrase. Right now I'm doing something like ``` (c/cartesian-product (repeat 15 (map char (concat (range 65 91) (range 97 123)))) ```
2017-12-23T02:00:26.000063
Shavonda
clojurians
clojure
_Note:_ It is possible for a dictionary word itself to appear in mixed case: `"QQQDeALeRQQQ"` for example
2017-12-23T02:04:47.000001
Shavonda
clojurians
clojure
Basically I am generating a massive set of sequences `#{[\A \A \A \B] [\A \A \A \C] [\A \A \A \D] [\A \f \o \o] ...}`, and I want to keep only the ones that contain somewhere in the sequence `#{[\t \h \e] [\f \o \o] ...}`
2017-12-23T02:10:40.000038
Shavonda
clojurians
clojure
So in that example, `[\A \f \o \o]` wouldn't be filtered out.
2017-12-23T02:13:29.000026
Shavonda
clojurians
clojure
the fact that it contanis a dictikonay word is almost useless
2017-12-23T03:33:08.000026
Berry
clojurians
clojure
the word 'a' is a dictionar word, so just words of the form a + 14 other letters is going to give you 52^14 possibilities
2017-12-23T03:33:28.000063
Berry
clojurians
clojure
``` (Math/pow 52 14) (comment 1.0569314255388205E24) ```
2017-12-23T03:34:11.000014
Berry
clojurians
clojure
Usually in these cases you exclude stopwords and/or short ones
2017-12-23T03:35:00.000033
Weston
clojurians
clojure
even if you limiktd to 5+ letter words, you'd still have atleast: ``` (Math/pow 52 10) (comment 1.44555105949057024E17) ```
2017-12-23T03:35:44.000031
Berry
clojurians
clojure
<@Berry> yeah I thought I was going to cut the search space in half, but ignoring words less than 3,4,5,6,7 characters does almost nothing in terms of time complexity.
2017-12-23T05:29:29.000031
Shavonda
clojurians
clojure
The easy answer is to just compute every single sequence and try them all, but it still seems like enough information (14 char, a-Z) to cut the total brute force work significantly. Maybe partitioning and hashing segments of every sequence could be useful. Then you could search whether a word’s hash exists as a segment.
2017-12-23T05:38:06.000058
Shavonda
clojurians
clojure
Seems like it should be faster to iterate over the dictionary and then build passwords around each of those words. Ie. if it’s “apple” then you’re adding X characters of padding before, and Y characters of padding after, where X+Y+length(“apple”)=14. The padding are sequences of integers (1,2,3,4 ...) converted to base 52 where the digits are [a-Z].
2017-12-23T10:18:52.000081
Kyung
clojurians
clojure
Hi, I wasn't aware of CLJ-1814 before (satisfies? being too slow). What approach would be recommended while CLJ-1814 is being worked on to dispatch only if a protocol is satisfied?
2017-12-23T10:44:35.000005
Gilda
clojurians
clojure
This does look like a bug, the Base ClassLoader is no longer derived from the URLClassLoader
2017-12-23T11:33:08.000072
Elanor
clojurians
clojure
so this code in `clojure.java.classpath` fails: ``` (defn get-urls "Returns a sequence of java.net.URL objects used by this classloader, or nil if the classloader does not sastify the URLClasspath protocol." [loader] (when (satisfies? URLClasspath loader) (urls loader))) ```
2017-12-23T11:33:44.000084
Elanor
clojurians
clojure
and looks like there is a JIRA task for this <https://dev.clojure.org/jira/browse/CLASSPATH-8>
2017-12-23T11:46:28.000049
Elanor
clojurians
clojure
Seems like a bug. Patch welcome...
2017-12-23T13:11:37.000116
Sonny
clojurians
clojure
I know about `letfn`. It doesn't work well for me, as I'm trying to write: ``` (let [f1 (fn00 ....) f2 (fn00 ...) f3 (fn00 ...)] ``` where `fn00` is a macro that helps me define functions, and f1/f2/f3/ are mutually recursive does clojure have a mutually recursive let ?
2017-12-23T14:53:02.000059
Berry
clojurians
clojure
(I don't want to use `declare` as these bindings are not meant to be global)
2017-12-23T14:53:21.000018
Berry
clojurians
clojure
why wouldn't your macro work in letfn?
2017-12-23T14:54:39.000119
Margaret
clojurians
clojure
because letfn wants me to do ```(letfn [(foo [args] body)]``` whereas for my macro, I do (def foo (fn00 [args] body)))
2017-12-23T14:55:31.000045
Berry
clojurians
clojure
perhaps tehre's another way to use letfn that I am unaware of
2017-12-23T14:55:40.000088
Berry
clojurians
clojure
you could just change the macro?
2017-12-23T14:56:11.000097
Margaret
clojurians
clojure
change which macro? change letfn or change fn00 ?
2017-12-23T14:56:42.000078
Berry
clojurians
clojure
fn00 - that seems like a trivial difference if the alternative is rewriting let
2017-12-23T14:56:59.000032
Margaret
clojurians
clojure
the problem with letfn is -- it's not going to call my macro fn00
2017-12-23T14:57:01.000056
Berry
clojurians
clojure
that's easy to fix with another macro
2017-12-23T14:57:46.000065
Margaret
clojurians
clojure
Hi. Is there anything like <https://mechanize.readthedocs.io/en/latest/> (or the Perl lib WWW:Mechanize from which it was derived)? I.e., a stateful http lib where you can fill in and submit forms etc.
2017-12-23T14:57:48.000025
Anastacia
clojurians
clojure
I'll let you know if I come up with anything
2017-12-23T15:44:35.000018
Elanor
clojurians
clojure
I'm going with `ClassLoader/getSystemResource` for my current use case
2017-12-23T15:46:51.000063
Elanor
clojurians
clojure
in the mean time it might be better to throw an unsupported exception in `clojure.java.classpath/classpath` when running under java 9
2017-12-23T15:48:44.000057
Elanor
clojurians
clojure
the current behavior of returning `nil` masks the problem and makes it difficult to figure out what happened
2017-12-23T15:49:14.000011
Elanor
clojurians
clojure
this affects any library maintainers who rely on this functionality
2017-12-23T15:50:05.000053
Elanor
clojurians
clojure
it would also be good to have a unit test for this :slightly_smiling_face:
2017-12-23T15:50:20.000084
Elanor
clojurians
clojure
<@Berry> `letfn` uses `letfn*` which I think has the shape you request. I guess that would be relying on an implementation detail though.
2017-12-23T18:12:39.000004
Anastacia
clojurians
clojure
I can't find `letfn*` on clojuredocs; besides the source code, is there any documentation ?
2017-12-23T19:16:54.000020
Berry
clojurians
clojure
no, clojure internals aren't really documented
2017-12-23T19:25:42.000034
Kareen
clojurians
clojure
is there any good talk / blog post on various philosophies of unit testing? I feel like (after a few years of on/off) I'm finally starting to develop a philosophy. It goes something like this: 1. unit test every function 2. go for 100% coverage, make sure all exprs of all functions are executed by some test 3. the basic philosophy is: yeah, sure, this isn't as comprehensive as type checking, but if you have 100% coverage, it's hard to have obvious/simple errors, because there's atleast one non-trivial example on which it worked
2017-12-23T21:46:31.000011
Berry
clojurians
clojure
as a result of this, I'm now moving towards really short functions + unit tests about 2-3 times as long as function, to get 100'% coverage there isn't really a question here, just hoping to get insights / philosophies of unit testing from others / suggestions
2017-12-23T21:47:43.000046
Berry
clojurians
clojure
There’s an article somewhere that suggests going for 100% coverage can have unintended consequences. Namely, that your dev team will be tempted to skew their implementations solely for the purpose of making the code testable at the expense of clarity.
2017-12-23T22:25:03.000012
Kyung
clojurians
clojure
Yeah, 100% coverage is not a good goal, IMO.
2017-12-23T22:29:22.000003
Daniell
clojurians
clojure
perhaps I have not written any complex code yet, but 100% coverage seems simply a matter of: within each function, do as little branching as possible
2017-12-23T22:32:45.000030
Berry
clojurians
clojure
There's a lot of stuff that's pointless to test. There is some stuff where you can describe expected invariants or properties of the code and exercise it in that context (generatively).
2017-12-23T22:37:27.000006
Daniell
clojurians
clojure
There's also a very big difference between "unit testing" and "test-driven development". I think the latter is much more valuable than the former.
2017-12-23T22:39:07.000038
Daniell
clojurians
clojure
<@Berry> I mostly only test the public contract of a module (the published API). And as much as possible I try to write those tests in a data-driven way.
2017-12-23T22:43:23.000013
Sandy
clojurians
clojure
So test.check or any random source of data are helpful there.
2017-12-23T22:43:49.000047
Sandy
clojurians
clojure
And I almost always write my tests after my code unless I'm adding a new feature that won't break any existing tests.
2017-12-23T22:44:55.000013
Sandy
clojurians
clojure
<https://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.pdf>
2017-12-23T22:55:07.000070
Kyung
clojurians
clojure
As we were building out our new REST API, we wrote tests first to reflect the requirements doc, specifically to provide a framework for writing the validation and error reporting. That was back before `clojure.spec` -- now we write specs for a lot of things that we wrote tests for before :slightly_smiling_face:
2017-12-23T23:05:12.000076
Daniell
clojurians
clojure
<@Sandy>: I'm not doing TDD. I wrote a small Joy/Forth interpreter in CLJ. Then I started defining Joy/Forth words, and reailzed: hmm, I should test each word. (So I'm testing after defining the word.) Then, because words are so simple, genrally 1-2 (sometimes 3-4) tests will hit 100% coverage.
2017-12-24T01:33:17.000033
Berry
clojurians
clojure
Fantastic reading. Thanks for the link!
2017-12-24T03:22:20.000043
Terra
clojurians
clojure
Languages are quite unique in that respect.
2017-12-24T09:35:24.000026
Sandy
clojurians
clojure
Here's what I wrote for the core.async go macro <https://github.com/clojure/core.async/blob/master/src/test/clojure/clojure/core/async/ioc_macros_test.clj>
2017-12-24T09:36:34.000034
Sandy
clojurians
clojure
My plan there is to use the same transforms as `go` but remove the nondeterminism. Then unit test "normal" clojure code that's gone through the transform. Probably not 100% coverage, but it's close
2017-12-24T09:37:50.000085
Sandy
clojurians
clojure
But I only ever write code like that when I'm working on a DSL/language
2017-12-24T09:38:13.000056
Sandy
clojurians
clojure
what would be a more idiomatic way to spec an heterogeneous/nested collection value? Current approach: ``` (spec/def ::pending-request-entry (spec/and vector? (fn [[id _]] (number? id)) (fn [[_ x]] (vector? x)) (fn [[_ [url _]]] (url? url)) (fn [[_ [_ all-params]]] (all-params? all-params)))) ```
2017-12-24T13:56:28.000038
Kristy
clojurians
clojure
(I use one `(fn ...` per predicate, so `spec/and` can report the exact culprit)
2017-12-24T13:57:17.000059
Kristy
clojurians
clojure
hi guys
2017-12-24T14:06:57.000077
Silvana
clojurians
clojure
any suggestions on how to have a cache in compojure?
2017-12-24T14:07:12.000032
Silvana
clojurians
clojure
possibly I could just refactor the heterogeneous vector into a map (for which having heterogeneous values is much more usual)
2017-12-24T14:14:56.000009
Kristy
clojurians
clojure
There are many ways I think, you can use redis to memoize some functions, and maybe use flushdb to clean when you know the data is changed?
2017-12-24T14:33:05.000070
Daine
clojurians
clojure
<@Daine> I have no clue at the moment, I'm still trying to figure this out
2017-12-24T14:35:04.000048
Silvana
clojurians
clojure
an in-memory solution would suffice though
2017-12-24T14:35:48.000012
Silvana
clojurians
clojure
<@Silvana> assuming you want an arbitrary object cache for e.g. rendered html or DB records: I'd add a middleware (<http://rjevans.net/post/2655430930/adding-custom-middleware-to-ringcompojure> ) that saves/fetches objects to a plain `atom`. Or a fancier in-memory cache like <https://github.com/clojure/core.cache> Bonus points if you wrap atoms/caches with <https://github.com/stuartsierra/component> so you have a cleanly reloadable dev experience. Non-battle-tested suggestion (middleware/atom) from my side, but seems reasonable
2017-12-24T14:50:39.000024
Kristy
clojurians
clojure
many thanks <@Kristy>, it really seems to be a neat solution to the problem
2017-12-24T14:52:09.000066
Silvana
clojurians
clojure
my suggestion was based on what I remembered from <http://docs.arachne-framework.org/tutorials/dependency-injection/|docs.arachne-framework.org/tutorials/dependency-injection/> You can't map 1-1 that tutorial to a plain compojure app, a more practical reading would be: <https://gist.github.com/Deraen/9d65f447593859dd07ae>
2017-12-24T16:16:30.000027
Kristy
clojurians
clojure
and! <https://github.com/metosin/compojure-api/wiki/Component-integration>
2017-12-24T16:20:24.000087
Kristy
clojurians
clojure
Anyone have strong preferences about graph libraries? Looking between loom, ubergraph, and jungerer. I know clojure libs tend not to break but it looks like loom looks like it hasn't been touched substantively this year so I'm curious if anyone has any endorsement/warning for this.
2017-12-24T17:02:20.000014
Vilma
clojurians
clojure
<@Vilma> <http://crossclj.info|crossclj.info> can be useful for questions like these - at least you can see how many other open source projects use each one <https://crossclj.info/ns/jungerer/0.1.1/project.clj.html>
2017-12-24T17:29:23.000017
Margaret
clojurians
clojure
<@Margaret> thanks for the lead.
2017-12-24T17:41:00.000026
Vilma
clojurians
clojure
I'd expect loom to have the most users, but it can be helpful to use real data and compare
2017-12-24T17:41:51.000020
Margaret
clojurians
clojure
Much appreciated.
2017-12-24T18:38:52.000003
Vilma
clojurians
clojure
<https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool(int)> [service (java.util.concurrent.Executors/newFixedThreadPool 24)] that is something that should, in theory, be a queue with 24 worker threads right? "ps aux | grep java" is only showing a single thread, "top" is only showing &lt; 100% utilization, iknstead of 2400% utilization
2017-12-24T19:50:20.000046
Berry
clojurians
clojure
Are you sending it 'jobs' that take significantly longer to execute than the overhead of starting and finishing the jobs? Sending it really tiny jobs might not get you any actual parallelism
2017-12-24T21:11:59.000008
Micha