Fork me on GitHub
#clojure
<
2017-12-23
>
caleb.macdonaldblack02:12:06

Can this be simplified?

(map #(map first %) [[[1 2] [3 4]] [[5 6]]])
 => ((1 3) (5))

noisesmith02:12:41

same items, different shape

+user=> (for [x [[[1 2] [3 4]] [[5 6]]] [y] x] y)
(1 3 5)

caleb.macdonaldblack03:12:44

@noisesmith Thanks, I ended up with this (partial map (partial map first))

jgh03:12:12

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 😛

noisesmith03:12:18

I'm sure it still works if you combine it with the right jdbc version

jgh03:12:16

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

noisesmith03:12:18

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

noisesmith03:12:19

usually the approach is to treat old deploys as immutable

jgh03:12:37

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)

jgh03:12:18

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.

noisesmith03:12:50

I think the main problem is you shouldn't be looking for postgresql on clojars

noisesmith03:12:20

it's a java project, like most mainstream java stuff they deploy to maven - someone mirrored to clojars once and used their name

noisesmith03:12:59

(may even have been the postgres driver devs but I doubt it)

jgh03:12:00

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.

jgh03:12:20

I assumed clojars was official because that’s where lein looks

noisesmith03:12:34

OK - good rule of thumb is that java code is canonical on maven or sonatype, and clojure stuff is canonical on clojars

noisesmith03:12:44

lein looks in maven before clojars iirc

jgh03:12:18

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

noisesmith03:12:19

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

noisesmith03:12:29

but I'm not sure, honestly

noisesmith03:12:45

I agree that it's good for people to understand where the artifacts they use come from, and how they got there

devn07:12:26

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))))

devn07:12:47

Note: It is possible for a dictionary word itself to appear in mixed case: "QQQDeALeRQQQ" for example

devn07:12:40

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] ...}

devn07:12:29

So in that example, [\A \f \o \o] wouldn't be filtered out.

qqq08:12:08

the fact that it contanis a dictikonay word is almost useless

qqq08:12:28

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

qqq08:12:11

(Math/pow 52 14)
(comment
 1.0569314255388205E24)

mpenet08:12:00

Usually in these cases you exclude stopwords and/or short ones

qqq08:12:44

even if you limiktd to 5+ letter words, you'd still have atleast:

(Math/pow 52 10)
(comment
 1.44555105949057024E17)

devn10:12:29

@qqq 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.

devn10:12:06

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.

gonewest81815:12:52

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].

pyr15:12:35

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?

qqq19:12:02

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 ?

qqq19:12:21

(I don't want to use declare as these bindings are not meant to be global)

noisesmith19:12:39

why wouldn't your macro work in letfn?

qqq19:12:31

because letfn wants me to do

(letfn [(foo [args] body)]
whereas for my macro, I do (def foo (fn00 [args] body)))

qqq19:12:40

perhaps tehre's another way to use letfn that I am unaware of

noisesmith19:12:11

you could just change the macro?

qqq19:12:42

change which macro? change letfn or change fn00 ?

noisesmith19:12:59

fn00 - that seems like a trivial difference if the alternative is rewriting let

qqq19:12:01

the problem with letfn is -- it's not going to call my macro fn00

noisesmith19:12:46

that's easy to fix with another macro

lodin19:12:48

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.

lodin23:12:39

@qqq letfn uses letfn* which I think has the shape you request. I guess that would be relying on an implementation detail though.