Fork me on GitHub
#clojure
<
2020-03-15
>
Eddie06:03:50

I am looking for an implementation of a reversable hash function that allows for the seed to be set. Any suggestions? It would be ideal if it could hash any Clojure collection, but if not I can work with byte arrays.

Eddie16:03:26

Thanks everyone, and sorry for the ignorance on my end. I am an ML practitioner so I used all the wrong terms. Here are some corrections • I am looking for a cryptographic hash function. • By seed, I now know I meant secret key, which all crypto libraries should let you provide. :) After you all pointed me towards encryption, I think I found what I needed via interop to javax.crypto.

👍 4
hiredman07:03:56

Unless reversable means something else here, hash functions are never reversable

hiredman07:03:26

For cryptographic hash functions that is an important property they designed for, for non-cryptographic hash functions they throw away information, so you can't go backwards

jsn10:03:33

"Hash functions" is not the same as "cryptographic hash function", @hiredman . It's unclear though what "hash seed" and "reversible" mean in the original question, though.

hindol11:03:04

If we want a reversible hash, the length of hash will grow proportional to the amount of data we are hashing. Maybe an encoding like base64 is useful?

vlaaad11:03:34

if it’s reversible, it’s not a hash, it’s encryption

flefik13:03:04

What is the canonical way to run Clojure on AWS Lambda in 2020? All the resources I've found online are a couple of years old.

p-himik13:03:51

Did something relevant change in those 2 years?

pinkfrog14:03:23

nothing changed. Use the inputstream approach is the safest way to go.

jsyrjala15:03:24

Nothing has changed that much in last couple of years. There is nowdays GraalVM which may be usable in some cases to decrease startup time.

nickbauman16:03:39

If you’re using Lambda with Clojure you should probably be writing it in ClojureScript not Clojure. The Firecracker VM’s (what lambda runs on) entire value proposition is to not have anything warmed up so startup time for short work (typical for Lambda) is a big waste.

flefik17:03:45

yeah, i'll be using cljs for this use-case

kwladyka14:03:56

(utils/submap? {:shops [#:shop{:uuid #uuid"00000000-0000-0000-0000-000000000000"
                                 :name "redshop"
                                 :engine "atomstore"
                                 :config {:foo "bar"}}]}
                 {:shops [#:shop{:uuid #uuid"00000000-0000-0000-0000-000000000000"
                                 :name "redshop"
                                 :engine "atomstore"
                                 :config {:foo "bar"}
                                 :updated_at #inst"2020-03-15T10:05:07.926-00:00"
                                 :created_at #inst"2020-03-15T10:05:07.926-00:00"}]})
Has someone fn like this? I use this one:
(defn submap?
  "Is subset of m?"
  [subset m]
  (if (and (map? subset) (map? m))
    (every? (fn [[k v]] (and (contains? m k)
                             (submap? v (get m k))))
            subset)
    (= subset m)))
But this doesn’t work with [] correctly.

Darin Douglass14:03:14

When I've needed something like this I found https://clojure.github.io/clojure/clojure.data-api.html#clojure.data/diff to work well

👍 4
kwladyka14:03:03

thank you, I will try this

kwladyka14:03:34

diff and diff-similar return the same. Do I miss something?

kwladyka14:03:50

works great

kwladyka14:03:05

but still diff and diff-similar are confuse

jumpnbrownweasel15:03:00

diff-similar doc says "Implementation detail. Subject to change." so it is not meant to be used directly.

jjttjj15:03:06

I'm trying to get an absolute minimal prompt thing working. If I have

(defn -main []
  (loop []
    (print "user> ")
    (println (read-line))
    (recur)))
Why does "user>" not print until I enter input when I call clojure -m myns ? There will be a blank prompt until I type "x" and then user> x will print

hindol15:03:45

I am not 100% sure but I think sending a \n in the string auto-flushes the buffer, hence printing immediately. So you can try println. If you don't want a newline, try flushing manually.

jjttjj15:03:30

that did it, thanks!

hindol15:03:06

NP. As I was not 100% sure, thanks for confirming!

hindol04:03:40

Yeah. Just (flush) will do it for whatever is bound to *out*.

hindol04:03:36

If you want to flush something other than stdout, see binding.

Eddie16:03:26

Thanks everyone, and sorry for the ignorance on my end. I am an ML practitioner so I used all the wrong terms. Here are some corrections • I am looking for a cryptographic hash function. • By seed, I now know I meant secret key, which all crypto libraries should let you provide. :) After you all pointed me towards encryption, I think I found what I needed via interop to javax.crypto.

👍 4
marrs17:03:41

I've installed io.aviso/pretty in leiningen (following the instructions) but my shell doesn't seem to be interpretting the output correctly. As an example, I get something like:

Caused by:
clojure.lang.ExceptionInfo: ?[38:5;32m-- ?[0m?[38;5;45mRouter creation failed
This is not quite the improvement I was hoping for. I'm pretty sure the garbage prefixed with ?[ is shell formatting markup, so I think the plugin is at least running. Has anyone else had this issue? I'm running Bash within XFCE Terminal 0.8.7.4

marrs17:03:51

Oh, the output is formatted further down the screen. I guess it was working after all!

Lennart Buit19:03:33

yeah those outputs are ANSI escape codes, which are used to produce the colors in your terminal

jeff tang17:03:48

Does anyone know of any startups that use Clojure? I know there is http://roamresearch.com and https://whimsical.com/blog/how-we-built-whimsical

jeff tang17:03:38

this is cool! it's a bit more corporate tho 😛

Eddie17:03:22

I believe Reify Health is a Clojure shop. They are at least 3 years old, so they may be further along than what you are looking for. https://www.reifyhealth.com/

👍 4
Alex Turok17:03:03

There is http://amperity.com. They started in 2015, so well beyond the first stages, but with clojure from the beginning, afaik

🔥 4
orestis18:03:32

We (Nosco) are migrating to Clojure.

😯 4
hindol18:03:55

@U7PBP4UVA Is the reasoning for the move documented somewhere? Maybe a talk? I am always interested to hear such stories.

orestis18:03:11

Not yet - I’m pondering submitting a talk to ClojuTRE later this year - but perhaps the move has failed so the title has to be “Schrodinger”-like.

orestis18:03:09

Other people have also expressed interest (we are also migrating our frontend from jQuery/handlebars to ClojureScript) so perhaps I should just submit a proposal.

hindol18:03:36

I am curious about the "move has failed" bit. But perhaps I should wait for your talk. I do hope you get time to submit a proposal.

mccraigmccraig11:03:23

we've use clojure/script since we started in 2015 - http://yapster.info

🙂 4
yiorgos19:03:41

I was checking the string doc of defonce and I am not 100% sure there is a typo in it “defs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated” shouldn’t the iff be if ?

vlaaad20:03:14

iff means “if and only if”

eq 12
yiorgos20:03:33

ah, good to know. Thank you very much!

hindol04:03:50

iff is not so common outside academics so it might make sense to update the doc string.

p-himik08:03:19

I would argue that it's pretty common - I see it all the time in documentation, and not only in the Clojure's one.