Clojurians
#clojure
<
2017-10-22
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

qqq02:10:00

1. I'm looking for a Clojure database/persistent/storage solution. 2. I know about Datomic. I don't think Datomic is the correct answer. 3. It needs to support the following ops [:assoc-in path value] ==> returns nil [:delete-in path] ==> returns nil [:get-in path] ==> returns part of submap [:get-in-keys path] ==> returns just the keys instead of entire submap 4. so my storage is a giant clojure atom/map, and those 4 ops are available via rest is there any clojure storage solution that is structured like this?

smnirven04:10:10

hey folks. I've been away from the clojure universe for a few years and am working on getting back into it. I'm looking for guidance from the masses on what the current state of the art is vis-a-vis packages for microservices authentication. Previously I've used Chas Emerick's friend - but I'm seeing in the project readme on github that he's been looking for a new maintainer, and I'm not seeing alot of activity in the repo at all. Which, all adds up to a general unease I have with using it on a new project. Any tips, guidance, etc is much appreciated!

the2bears04:10:42

@smnirven did you have issues with it before? If not, and if it worked for you, then that should count for something. I'm just playing devil's advocate here :wink:

smnirven04:10:45

just trying to avoid the trap of using it if the rest of the community has moved onto something that's better supported

qqq07:10:58

I'm looking at amazon cognito, but I've largely accepted aws cloud

danielcompton09:10:57

@smnirven not sure what the breakdown is but Buddy is another relatively well-known security library

ajs11:10:52

at a repl, why would functions like get, get-in be available to me, but not int? where I get CompilerException java.lang.RuntimeException: Unable to resolve symbol: int? in this context -- very strange? I'm using Clojure 1.9

dominicm11:10:00

@ajs do you mean integer?

ajs11:10:41

@dominicm no, the clojure.core function int?

ajs11:10:12

i have odd? inc int but weird that int? is unavailable

ajs11:10:47

i think i found the issue. clojure repls are just too reliable and this one was running for weeks without a restart, even after changing the clojure version to 1.9, and this fn was the only one from 1.9 that is now in the code, so the lack of a restart was not discovered yet.

schmee13:10:30

I just typed this in the REPL and got a very unexpected result :smile:

`(vector 123) `

schmee14:10:03

can someone explain what goes on when you nest syntax quotes like this?

bronsa14:10:01

syntax-quote sets up a context so that unquote will work, to do so it must wrap all its sequential elements in lists and series of concats

bronsa14:10:33

so every time you nest syntax quote it will wrap the transformed body and flatten everything into wrapped lists etc

schmee14:10:50

where in the clojure compiler can I find the implementation of syntax quote? :slightly_smiling_face:

bronsa14:10:10

yes it''s read time not compile time

schmee14:10:29

what is the difference, if any, between these two macros?

(defmacro a [& body]
  (eval (cons 'do body)))

(defmacro b [& body]
  `(do [email protected]))

qqq16:10:15

I'm using http-kit for web-server + web-socket-server. I have created a self signed SSL certificate. What is the easiest way to "wrap" my http/ws as https/wss ?

pesterhazy16:10:04

@qqq for production or development?

qqq16:10:29

It's self signed, so for dev.

qqq16:10:34

@pesterhazy ^

pesterhazy16:10:49

I use the simple way out

qqq16:10:59

prod = aws, and they handle ssl for me

qqq16:10:04

@pesterhazy: what's the simple way out ?

pesterhazy16:10:06

simply provide the certs as command line args, run the proxy server in a separate terminal, done

qqq16:10:24

lol, the instructions I was reading on setting up self signed certificates suggested that very package

qqq16:10:31

but then I saw npm, and decided to ask around instead

pesterhazy16:10:40

http-server is solid

qqq16:10:51

alright, I'll give it a try

pesterhazy16:10:12

I think I followed the same

qqq16:10:13

http-server --ssl --cert /path/to/cert.pem --key /path/to/key.pem is the cmd

pesterhazy16:10:28

there was a problem with Chrome I remember

pesterhazy16:10:47

you need to set the alt-name or something like that when creating the cert

pesterhazy16:10:03

but it was reasonably simple

qqq16:10:07

may I direct message you when I run into that issue ?

qqq16:10:53

http-server -ssl --cert ~/.localhost-ssl/cert.pem --key ~/.localhost-ssl/key.pem 
/usr/bin/env: ‘node’: No such file or directory
do I now install node via "npm" or via "sudo apt-get install nodejs-legacy" ?

pesterhazy16:10:39

install node on ubuntu the normal way, whichever that is

pesterhazy16:10:02

preferably not legacy :slightly_smiling_face:

qqq16:10:25

e: To avoid conflicts, the executable from the Ubuntu repositories is titled nodejs instead of node. Keep this in mind as you are executing applications.

qqq16:10:35

It appears that team Ubuntu renadce 'node' to 'nodejs' just for kicks.

qqq16:10:00

so I think I will install via "sudo ln -s nodejs node" :slightly_smiling_face:

pesterhazy16:10:07

ln -s /usr/bin/nodejs /usr/bin/node

pesterhazy16:10:14

right :slightly_smiling_face:

qqq16:10:56

the really poor design there is that tyoing "node" in bash leads apt-get recommending "nodejs-legacy" (sinde that's the apckage that provides the binary 'node')

qqq16:10:08

so I'm running:

http-server -ssl --cert ~/.localhost-ssl/cert.pem --key ~/.localhost-ssl/key.pem
and then I can access http://localhost:8080 , but I can't access https://localhost:8080 then I do a "netstat -ln" ... and besides 8080, I don't see any other ports opened

qqq16:10:15

where is the -ssl port running on?

qqq17:10:05

For anyone curious, the resolution is (credit for all this goes to @pesterhazy , resolved in #off-topic ) 1. the command is

http-server --ssl --cert ~/.localhost-ssl/cert.pem --key ~/.localhost-ssl/key.pem -p 8443
2. osx / chrome has some weird ssl issue // there are complicated instructions at https://alexanderzeitler.com/articles/Fixing-Chrome-missing_subjectAltName-selfsigned-cert-openssl/ 3. first comment suggest alternative solution of
defaults write com.google.Chrome EnableCommonNameFallbackForLocalAnchors -bool true
I'm not sure the security implications of that -- but it made things work on my machine.

mnewhook17:10:54

for java interop if I import a java inner class I need seem to need to use the full name since Foo$Bar/xyz doesn't work? Any way around that? (nvm, I was importing incorrectly)

qqq17:10:16

@mnewhook: one of the most useful things I found is (clojure.reflect/reflect JAVA-CLASS-NAME) and looking over that, it shows all the members / inner classes / etc ...

qqq17:10:29

basically, seeing "how things are named" makes it easier to figure out how to call it

mnewhook17:10:16

yeah, I was trying to import com.abc.Foo$Bar, or com.abc.Foo$ Bar, etc. When I should have been using com.abc Foo$Bar :weary:

denis66518:10:09

Hi! I read quite a bit about spec and am really fascinated by the concept, but I am still wondering how Clojurians are actually integrating it into their development workflow. Do you just (instrument) your REPL? Or integrate it with your test suite somehow? I would be super interested in experience reports!

keymone18:10:58

is anybody using lein ultra plugin?

keymone18:10:44

can’t seem to make it work - lein repl is just default stuff in every project

slipset19:10:36

Sorry if this is a total n00b question, but why does

slipset19:10:39

Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_144-b01
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (java.util.HashMap.)
{}
user=>

slipset19:10:54

work without doing an (import java.util.HashMap)

bronsa19:10:05

importing just adds an alias

slipset19:10:31

ok, so they're all there, but only by the long name?

slipset19:10:58

and all java.lang is then imported by default.

bronsa19:10:03

"loading" of a java class happens on first use/reference, import is not necessary if you refer by the fully qualified name

bronsa19:10:13

not all of java.lang. i believe there are some new addition missing

bronsa19:10:19

here's the list of the classes interned by default

bronsa19:10:42

one weird one is clojure.lang.Compiler :)

beoliver20:10:55

is there a pattern used for sending functions onto a channel for completion? something like this

(defn expensive-call [number]
  (let [sleep-count (rand-int 5000)]
    (Thread/sleep sleep-count)
    [number sleep-count]))

(defn executor [buff-size]
  (let [in-ch  (async/chan buff-size)
        out-ch (async/chan buff-size)]
    (async/thread
      (loop []
        (let [pending (async/<!! in-ch)]
          (when (instance? clojure.lang.Delay pending)
            (async/thread
              (async/>!! out-ch (force pending)))
            (recur)))))
    {:input-ch in-ch :output-ch out-ch}))

(defn test [buff-size send-count]
  (let [{:keys [input-ch output-ch]} (executor buff-size)]
    (doseq [n (range send-count)]
      (async/>!! input-ch (delay (expensive-call n))))
    (dotimes [n send-count]
      (let [result (async/<!! output-ch)]
        (println "got result:" result)))))

beoliver20:10:36

> (time (test 1 10))
got result: [5 766]
got result: [0 795]
got result: [9 991]
got result: [1 1034]
got result: [4 1524]
got result: [3 1708]
got result: [7 2148]
got result: [2 2486]
got result: [8 3531]
got result: [6 3682]
"Elapsed time: 3690.147902 msecs"
nil

keymone20:10:07

(def executor [] (let [in … out …] (pipeline 4 out deref in))) or something

beoliver20:10:51

@keymone yeah, I think the pipeline-async might be even closer https://clojuredocs.org/clojure.core.async/pipeline-async

h.elmougy22:10:31

how to configure ring adapter for async usage?