Fork me on GitHub
#clojure
<
2018-02-21
>
macrobartfast02:02:51

I just watched the video on vase and the concise amount of code used to generate the consumer report UI... I haven't found much more information on the UI part, as opposed the pedestal endpoints... can someone fill me in on what that is all about or where I can find out more?

macrobartfast03:02:08

he talks about reducing the front end code to 26 lines, but obviously there's a lot more, somewhere (as styles, largely, I'd guess), but I'm unclear of how it all works.

hawari04:02:10

HI, does anybody use toucan here? How do I make a query with multiple condition on a single field, I've tried

(db/select Model :start-time [:> start :< end])
but it resulted in a query with only start_time > start condition

hawari04:02:53

Could anybody explain how toucan options destructuring works? I understand it tries to simplify a HoneySQL form, I'm able to construct simple := queries, but it became more of a guessing game for me on complex queries with condition like :between, :in, and :order-by

attentive04:02:34

Hey gang, trying to choose a sound reactive atom (ratom with cursors) library for JVM Clojure, what’s the best option do people think?

attentive04:02:01

Many prototype FRP libs for Clojure seem to be obsolete or unmaintained

qqq06:02:55

is it possible to borrow from om-next or reagent?

attentive06:02:41

Possibly, I mean that’s more or less what I want (Rum might be even simpler), like something from https://github.com/tonsky/rum/blob/gh-pages/src/rum/cursor.clj

attentive06:02:46

But I’ve got a non-UI use for it, wanting to do declarative music generation stuff, so a generic library which is used by other stuff might be preferable

attentive06:02:44

Maybe Clara would be an option

Serge07:02:05

How to reduce starting time of lein run / lein ring server?

noisesmith17:02:51

you can use lein trampoline run or lein trapoline ring server - for that it helps to also have the LEIN_FAST_TRAMPOLINE flag set in your environment https://github.com/technomancy/leiningen/wiki/Faster

noisesmith17:02:22

but even better you can design your application so that it won’t need as many restarts during development https://github.com/stuartsierra/reloaded

triss09:02:22

hey all. what’s a simple profiler I can use with Clojure?

schmee10:02:29

I use jvisualvm for basic profiling

jumar12:02:09

Yeah, I think jvisualvm is a decent one - especially if you have some experience with Java/JVM development.

triss23:02:16

many thanks guys. I’ll take a look tomorrow.

triss09:02:12

@attentive I was thinking about this for a while. never used a library for it. I think my approach was to build declarative trees describing my audiograph, have one function for constructing it for real, another for updating the real model. Every time the user changed the tree I did a clojure.data/diff to check what they had changed and use the update function to update the real model.

triss09:02:43

I don’t know if thats how the other FRP guys did it but it seemed to work

Zsuark10:02:16

@faxa Ring and compojure are fantastic!

Zsuark10:02:42

@serge I think a lot of the time has to do with the JVM and the way Clojure works. Lein uses multiple JVMs and has to load a number of classes. Also see: https://dev.clojure.org/display/design/Improving+Clojure+Start+Time http://clojure-goes-fast.com/blog/clojures-slow-start/ https://github.com/technomancy/leiningen/wiki/Faster

Zsuark10:02:47

Does anyone here have experience using clarango ?

Zsuark10:02:37

You are welcome @serge 😄

Zsuark10:02:54

@edlich @mikeholmesuk How do you specify the username/password to use with Clarango?

mikeholmesuk10:02:31

Eesh, that takes me back. Haven’t looked at that for a while.

mikeholmesuk10:02:49

It takes a connection string so you can pass username and password in the url.

Zsuark10:02:56

Thanks... the docs are strangely quiet on this topic.

Zsuark10:02:48

Hmm.... maybe I am using illegal characters in my password... let me try something simpler and see.

mikeholmesuk10:02:01

Indeed. Let me know how you get on and I can pu together a PR to update the docs

Zsuark11:02:47

Thanks - even the Arango docs are quiet on this...

mikeholmesuk11:02:45

Yeah, they are a bit quiet in places. I noticed that when I was last working with it. Are you just starting out with it?

Zsuark11:02:08

So, double whammy - new to Clarango and Arango

chrisblom11:02:15

how can it pass an expression to lein repl so that it evaluated when the repl is started?

chrisblom11:02:29

preferably from the shell, not by editing the project.clj

chrisblom11:02:24

this kill the repl after the command runs, it there a way to keep it running?

Zsuark11:02:40

... I was just about to say that... hmm... this is more a bash/shell question than a Clojure one.

Zsuark11:02:26

the bash command alias may also be your friend.

chrisblom11:02:48

thanks, i was hoping there would be something like lein repl -e "(println "hello world)" but this will do

schmee15:02:39

you can do exactly this with tools.deps, I haven’t tried it out myself yet but it should just be clj -e '(println "hello world")'

Zsuark12:02:46

lein does not provide such a facility, so you will have to pipe it in from the shell.

Empperi13:02:37

hmm, I have a problem with sente. Getting Bad ev-msg logs when client tries to connect to the server

Empperi13:02:31

started a new project where I took some earlier sente configs in which had worked before

Empperi13:02:39

but apparently something has changed

Empperi13:02:18

with aleph adapter I got NPEs, when I switched to http-kit I get a bit more reasonable errors, which is what I'm seeing above

Empperi13:02:05

most disturbing piece of information I can see is within connected-uids atom:

Empperi13:02:29

{:status :ready,
 :val {:ws #{:taoensso.sente/nil-uid},
       :ajax #{},
       :any #{:taoensso.sente/nil-uid}}}

Empperi13:02:36

nil-uid doesn't sound right at all

Empperi13:02:18

decided to dump sente for now, this project doesn't need it that much. Will dig into that later when I have more time

Empperi13:02:33

still happy to hear ideas on the problem

gklijs13:02:17

I tried to use sente twice, but both times I reverted to something use, I just needed websockets.

rutledgepaulv14:02:13

I had a similar experience and opted for https://github.com/jarohen/chord

joelsanchez14:02:39

+1 for chord, also dropped sente 🙂

Empperi14:02:33

need to check out chord, cheers!

dominicm16:02:08

Is there a default for compiler-options? It's nil when I run a REPL.

dominicm16:02:47

@alexmiller The docstring for *compiler-options* are out of date. It's missing direct linking.

dominicm16:02:45

It also mentions something about merging, which is what threw me off. I figured it was a caution against overriding the defaults.

Alex Miller (Clojure team)16:02:31

Agreed, docstring is out of date, feel free to jira

bronsa16:02:34

@alexmiller fyi the image on http://clojure.org for your new book (congrats!) is not working

Alex Miller (Clojure team)16:02:01

I noticed that. worked for me locally though

dominicm16:02:31

@alexmiller I'm a bit confused by "priority" on JIRA. > Ignore these names and assume only relative priority Relative to what?

Alex Miller (Clojure team)16:02:47

don’t set the priority

bronsa16:02:12

@alexmiller the width is being set as 3rd edition in css which is probably why it’s not showing

Alex Miller (Clojure team)16:02:43

@dominicm what that means is - the words here are unimportant (“Critical”, “Major”, etc), they are just used for relative ordering

bronsa16:02:50

I don’t think adoc likes commas there

dominicm16:02:39

> don’t set the priority Is it possible for the JIRA to have that written somewhere? "Contributors should not set the priority"

dominicm16:02:56

> An issue has a priority level which indicates its importance. The currently defined priorities are listed below. In addition, you can add more priority levels in the administration section. ^ I guess adding to this text.

dominicm16:02:12

(or maybe it's just me who gets confused by this!)

Alex Miller (Clojure team)16:02:51

I dont think I can change that text

Alex Miller (Clojure team)16:02:25

I just reprioritize it as needed

dominicm16:02:24

That's fair enough then. It's caused me confusion until now about what to do.

dominicm17:02:45

Contradicting advice is given by that page: > Priority: categorize based on impact and whether this is a theoretical issue or one actually encountered in real code

Alex Miller (Clojure team)16:02:15

hard to get all that context into jira though

Alex Miller (Clojure team)16:02:25

I just fix stuff during triage

pfeodrippe17:02:16

I'm creating pdf reports with charts using https://github.com/clj-pdf/clj-pdf and the library from https://www.gicentre.net/utils/chart, my workflow is working right now using quil to output svg and adding it to the pdf.

pfeodrippe17:02:34

Is it a good way to make this kind of pdf reports with clojure or am I missing something?

misha18:02:04

is there already a name for monad, which is like either, but instead of left/right it has error/value with the same meaning?

fmnoise18:02:58

it's still either

sundarj18:02:13

i've seen people call it Result

misha18:02:34

I don't want to call it either, since user might think it expects :left :right. On the other hand, we have :error :value all over the code base already

misha18:02:08

and I don't want to go with actual monads, since it'll spread like cancer all over the place in no time

misha18:02:18

since I am not actually naming a monad, but a set of custom threading macros, I don't want to use either, so nobody would confuse it with actual left/right either from cats or whatever lib might appear in project.

fmnoise18:02:37

I've faced with the same problem, but as for today everything except either is still a compromise and has just a bit wider meaning

manutter5118:02:39

@misha Not sure how useful it might be to you, but you might be interested in looking at a beanbag lib I wrote several years ago as a kind of design experiment. https://github.com/manutter51/beanbag

misha18:02:52

slack threads are the worst

fmnoise18:02:33

cognitect calls their error handling concept anomaly

fmnoise18:02:48

not sure I like this naming

misha18:02:45

@manutter51 > Wrap your function call inside a when-result block to read the status keys used by ok, fail and skip. this requires altering a bunch of code, instead of providing convenience of threading macro, such as some->

fmnoise18:02:22

I had some ideas which contained chain and flow

fmnoise18:02:51

and there's also railway from Mr. Scott Wlaschin

misha18:02:29

the idea is to: - shortcircuit on the first value containing :error, - unwrap values wrapped in :value before threading further - wrap last value in :value, if not wrapped already

fmnoise18:02:52

I'd stick with chain or flow

fmnoise18:02:58

operation-chain

misha18:02:00

chain/flow/railway - all sound like synonyms for "threading", so "meh"

misha18:02:37

still same as "threading" kappa

fmnoise18:02:56

but it's actually threading 😄

misha18:02:14

went with ve->, ve->> ve-as->

fmnoise18:02:18

(chain-> op1 op2 op3)

greglook18:02:40

manifold has a lot of this as concepts in its async deferred implementation

greglook18:02:02

so you can d/chain, d/catch, d/finally etc

misha18:02:15

calling it chain-> is a tautology

hiredman18:02:34

what I would recommend doing, instead of writing lots of custom -> operators, is to write lift

misha18:02:23

@hiredman at this point I am explicitly trying to avoid it opieop

misha18:02:01

I might replace it with lift someday, when bigger picture is more clear, and tech debt time budget is fatter.

fmnoise18:02:19

@misha chainable 🙂

fmnoise18:02:36

xv - for and

misha18:02:59

~ the same as ve, but at least ve hints on key names

fmnoise18:02:05

I give up 😄

misha18:02:47

good talk!

fmnoise18:02:30

btw we moved from key names to protocol

fmnoise18:02:15

cause handling cases like {:error "oh me" :value 2} is kinda tricky

fmnoise18:02:42

but if you use [:error "oh me"] then it may work

Alex Miller (Clojure team)19:02:44

that is the plan - use it if you like :)

misha18:02:43

handling {:error "oh me" :value 2} is simple: it is error

fmnoise18:02:26

it's more close to anomaly then

fmnoise18:02:45

cause we strongly split cases

fmnoise18:02:16

in your case if something has a key :error, then it's error

fmnoise18:02:28

otherwise whole thing can be used as value

fmnoise18:02:00

I'd say you don't even need wrapping to map

fmnoise18:02:25

1 - value, {:error "Oo" ...} - error

fmnoise18:02:28

thanks to clojure approach to keywords as a functions, it's easy

misha18:02:01

I already have desired implementation, just needed a name ; )

arrdem19:02:12

(gensym) 😛

hlolli19:02:19

Is there any alternative to Cemerick's Friend for authenticating out there?

dominicm19:02:32

Yada has a very nice authentication and authorization api imo.

hlolli19:02:47

It would require one to go all in, into the yada framework?

dominicm20:02:26

@hlolli you can create a ring handler by calling yada/handler on a resource :)

dominicm20:02:08

But pretty much, yes. I wouldn't expect it to be difficult for most apps though. I've not found it to be difficult though

hlolli20:02:29

ok nice, I tried yada like 2 years ago when it was new, me and yada have matured probably since then. But at the time I was useing it for websockets and server sent events.

hlolli20:02:01

but got the feeling, that one had to be sold on the whole yada thing. probably wrong impression

dominicm20:02:01

We're all happy to help on any bumps down the road in #yada

noisesmith19:02:41

there’s also buddy

noisesmith19:02:58

I’ve heard some complaints but wasn’t able to use either productively

hlolli19:02:40

ok, I'll give it a try, I think Friend is not being a friend to me, tough s/he may be a friend to others.

greglook19:02:42

We use Yada and Auth0 JWTs pretty effectively

hlolli19:02:29

thanks for pointing out Auth0 https://github.com/cjohansen/auth0-ring looks good!

dpsutton19:02:31

we use buddy for jwt validation. put in a PR and they updated it for what we needed. simple changes and easy to use lib

greglook19:02:38

yeah, we use buddy-sign for handling the JWTs

manutter5119:02:27

@hlolli I switched to Buddy from Friend, found it a lot easier to work with

hlolli19:02:25

nice to hear, I've used friend now and then for last 2 years, of course when it works it works. But recently it's been getting on my nerves, especially with complicated and nested compjure routes, its behaviour is unpredictable, of course I'm doing something wrong, but the documentation and demos aren't helping.

hlolli19:02:18

yeh, I guess you can use ring-session and sign the passwords without useing jwt, but I'm not a security expert.

dpsutton19:02:02

the only point in there that seems big to me is > You cannot invalidate individual JWT tokens

dpsutton19:02:20

the rest he concedes they are just as nice as cookies or the deficiencies are in rare or obscure cases

dpsutton19:02:13

> Now you are not vulnerable to CSRF attacks, but your application or site now requires JavaScript to work, and you've just made yourself vulnerable to an entirely different, potentially worse class of vulnerabilities. More about this below.

noisesmith19:02:14

@dpsutton it’s true you can’t invalidate on a token level, but it’s easy to keep a whitelist of good tokens in your db

dpsutton19:02:46

yeah true. but it is a valid point. they point out if you do that you might as well just do cookie sessions server side anyways. i don't think that follows and i like the jwt so far

dpsutton19:02:56

but i just wanted to credit the only valid argument i thought they made

greglook19:02:06

the spec does specify a way of tracking individual tokens with the jti claim

greglook19:02:18

so you can definitely build a blacklist that lasts until the token expires

greglook19:02:22

if you have that security need

greglook19:02:52

JWTs are not a good fit for mutable session state, but they are great for authentication

greglook19:02:18

and authorization if you construct them with whatever claims you need signed into the payload

noisesmith20:02:13

@dpsutton now I see that article addresses that somewhat - but keeping a blacklist of expired tokens (or whitelist of good ones) is much simpler than a generalized distributed session

hlolli20:02:02

fwiw, I gave friend a few more minutes before I changed, the problem was, the auth endpoint (post version of login endpoint), was always redirecting to asbolute localhost address with port, and I didn't want a port forwarded server on port 80 with domain to be redirected to localhost:8080, so I attempted to use full path for the :login-url parameter, and there it got lost.

noisesmith20:02:19

yeah, definitely don’t use jwt for arbitrary data - but for storing data that is permanently tied to an account on auth - hell yeah, reduce the number of lookups you do for user data

ccann20:02:54

is it possible to use with-redefs with a multimethod?

noisesmith20:02:16

Interesting question. There’s a lot of good reasons not to use with-redefs btw

ccann20:02:32

it’s only for tests

noisesmith20:02:50

even for tests - for example using with-redefs means your tests can’t be run in parallel

ccann20:02:05

I don’t mind that it’s a small project

dpsutton21:02:50

is there a good way to sort things based on an array that dictates that order? ie when retrieving things from db with keys in this array, sort them according to the order of the array?

dpsutton21:02:09

would make a key to index hashmap and just sort by those indices?

hiredman22:02:22

turn the array in to a function, sort-by that function

hiredman22:02:53

(sort-by (zipmap arr (range)) ...)

dpsutton22:02:30

ok. that's the turn it into an val to index hashmap and sort by that. thanks @hiredman

dpsutton22:02:38

just making sure i wasn't overlooking something

dominicm22:02:00

> (zipmap arr (range)) I need to use this more. I always end up with (into {} (map-indexed vector …))

ag23:02:13

how do I get value by using unqualified key from a map? e.g. (get {:foo/bar "3" :foo/zap "4"} :bar) want to return "3"

hiredman23:02:00

:bar is not :foo/bar

hiredman23:02:27

that is like wanting (get {:a 1} :b) to return 1

ag23:02:36

ah, sorry... I'm just being silly... ignore me please

ag23:02:59

I meant to ask something else, blurted out this... nevermind

triss23:02:49

how does one set options for CIDER repl?

triss23:02:51

I’d like to set it to use pprint and maybe have it time every command I run…

dpsutton23:02:29

Ask in #cider I think it's let easy to configure the pretty printer