Fork me on GitHub
#clojure
<
2017-05-17
>
bherrmann02:05:55

FYI: I started a consultants directory…. its pretty sparse at the moment…. http://clojureconsultants.org

qqq04:05:03

I really wish there was a wiki of some sort so things like this could be pinned rather than vanish into the 10k limit archive

stardiviner05:05:49

I got an weird issue, that Leiningen REPL evaluation very slow in large data structure. Here is the link in #cider https://clojurians.slack.com/files/stardiviner/F5DSLRF0R/CIDER_evaluation_spend_too_long_time.clj

bherrmann11:05:24

Someone DM’d me about my plans for http://clojureconsultants.org … I dont have any big plans really. I’m just trying to find work. I thought it would be neat if work could just find us. I think it the site would be helpful when googling for clojure engineers. It might be a fools errand.

bherrmann11:05:29

@qqq I’m expecting that google will find and rank the page… but yea, this 10k limit is kinda ghetto… slack is pricy for “standard” aka unlimited $8/per user per month

qqq11:05:02

a few years down the line, slack is going to have to buy out a competitor for hundereds of millions of dollars

qqq11:05:23

becuase someone on some open source channel said 'fuck it; this 10k likmit sucks for open soue projects; I'm writing an alternative"

mbjarland12:05:37

clojure map question. There are a couple of clojure 'lazy map' implementations out there which allow you to lazy evaluate or calculate the values in a map when the values are requested. I'm looking for a way to manage missing keys in a similar way, i.e. if a key is not found I would like to call a function to determine what should be returned and or if that key / value should be added to the map on the fly

mpenet12:05:41

potemkin has something like this

tatut12:05:42

what would (keys map-with-lazy-keys) return?

tatut12:05:38

wouldn’t a (memoize some-function) work similarly enough?

mbjarland12:05:46

@tatut the keys added so far I think is what groovy does

mbjarland12:05:52

@tatut I need to return a map from a function, not sure if memoize is applicable in that scenario?

tatut12:05:09

it depends

tatut12:05:33

if it is used as a function of keys to values, then a memoized function would do

tatut12:05:47

if it is asserted to be a map, iterated etc… then no

mbjarland12:05:54

@tatut ah, worldview mutated...thanks for the alternate perspective. It is probably not asserted to be a map so this might be viable

fabrao13:05:20

Hello all, can I post here a question about enlive?

cgrand13:05:53

@fabrao please do. Or contact me in direct message

mbjarland13:05:24

@mpenet found the potemkin option https://gist.github.com/bmabey/5779423 thanks for the reference

fabrao13:05:53

How can I using enlive select a :td tag with class starting with some string?

fabrao13:05:32

(html/select (buscar-tags-nfe) #{[:tr[:class "linha*"]]})
?

fabrao13:05:33

I used (html/select (buscar-tags-nfe) [(html/attr-starts :class "linha")]), but I want to select only the :td that class starts with "linha", not all tags

cgrand15:05:37

@fabrao [[:td (html/attr-starts :class "linha")]], outermost vector denotes descendance, nested vectors means “and”.

lambder16:05:29

is there more idiomatic way for (if (pred? foo) foo nil)

ghadi16:05:53

"one-armed" if == when

ghadi16:05:00

(when (pred? foo) foo)

lambder16:05:14

closer 😉

lambder16:05:37

do we have some equvalent for singletons?

lambder16:05:14

actually not an equivalent of some as it returns the result of a predicate

ghadi16:05:00

not sure I follow. You playing code golf? simple_smile

lambder16:05:07

I should rephrase. Is there a build-in function of the following form (x pred? item) which is equivalent of (when (pred? item) item) ?

noisesmith16:05:39

no, but it’s very easy to write

noisesmith16:05:10

the hardest part is naming the function

ghadi16:05:34

it's better not to write that function, imho. readability is usually the tradeoff for concision

john16:05:52

(or item)?

ghadi16:05:56

👏 beautiful, but i would totally :thumbsdown: that on a PR

lambder16:05:19

@john where is pred?

john16:05:34

just saw that

lambder16:05:02

monadic equivalent of filter

lambder16:05:27

with nil as a None 😉

lambder16:05:21

(or (and (pred? item) item)) 😄

john16:05:09

Why not (or (pred? item)) does that not do it?

john16:05:19

no that doesn't

john16:05:27

right, I see what you're saying

john16:05:51

yeah, what's the word for that?

ghadi16:05:00

yak shaving

john16:05:47

I'm trying to clear my mind off a bug 🙂

noisesmith16:05:48

(defn when-pred [pred? x] (when (pred? x) x))
(when-pred even? 10)
is how I do it

john16:05:41

Yeah, that's the best I could think of too

noisesmith16:05:43

it mostly exists for usage in eg. ->> where it’s nice not to have to use the arg twice

john16:05:48

when-pred

noisesmith16:05:52

even more specifically, inside some->> - the two together make things much more elegant

noisesmith16:05:38

(some->> request-data (when-pred well-formed?) (api-call) (usable-result?) (frob))

lambder16:05:50

some->> macro threads, which mean after passing it through the predicate we no longer have access to the original value

noisesmith17:05:18

@lambder that’s the point of when-pred - it returns the item if the pred was truthy

noisesmith17:05:39

and usable-result? (or really it’s equivalent in my real code) returns item if usable, otherwise nil

noisesmith17:05:17

I shouldn’t have given my fake-example-function a name ending in ?, my bad

lambder17:05:40

I missed part of the conversation, sorry

dealy17:05:13

Whenever I run lein test-refresh a file .lein-env is created that has the config options for my test DB. Later if I do lein run it picks up the db config from .lein-env which is wrong. What generates this .lein-env file and how can I stop it from being created?

jakemcc17:05:35

@dealy That isn’t a test-refresh thing. Quick search for .lein-env pulls up environ library and config. https://github.com/weavejester/environ https://github.com/yogthos/config

dealy17:05:59

I don't think I'm using environ, but am using luminus

yogthos17:05:56

if you remove the plugin from project.clj the file will not be generated

dealy17:05:04

why is the file only created in test-refresh and not when I run the app normally?

jakemcc17:05:35

@dealy not sure, does it happen with a lein test?

dealy17:05:43

yes it is also created in lein test

devn18:05:22

@jakemcc no mention of outpace/config? 😉

devn18:05:16

err nevermind, missed the thread

qqq19:05:25

I used to believe that HTTP GET requests contained a map of "key-vaule" pairs. However, I'm looking at : http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getParameterMap() It appears that GET requests contains a map of "string, LIST-OF-STRING" instead of "string, string" pairs.

fbielejec19:05:57

anyone played a bit with Enlive? I want to select all links ona page that look like {:tag :a, :attrs {:href "2E3JV4L"}, :content nil}, so any a elements with a href attribute and no content

wiseman19:05:43

@qqq /foo?x=1&x=2&x=3 is perfectly valid.

qqq19:05:12

@wiseman: understood; thanks!