Clojurians
#clojure
<
2015-11-03
>

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

richiardiandrea03:11:04

@bhauman: I tried 0.5.0-SNAPSHOT and I noticed that the sidecar bootstrapping for connect through cider is broken, just wanted to report it but probably you know already :simple_smile:

bhauman03:11:18

cider hasn't been part of figwheel for a while now. Are you saying the nrepl-middleware key isn't working?

bhauman03:11:02

@richiardiandrea: ^^

bhauman03:11:36

Not sure I understand

richiardiandrea04:11:58

oh yes I know, but before the following was working for me on top of nrepl:

(require 'figwheel-sidecar.repl-api)
(figwheel-sidecar.repl-api/cljs-repl)
No problem though, I know that is kind of a hack :wink:

richiardiandrea04:11:57

@bhauman: I will have a look at the changes as well, good job btw

zcaudate05:11:33

hey guys, I need some help tweaking clojure.test

zcaudate05:11:12

in the docs, https://clojuredocs.org/clojure.test/deftest, there is a line "If you compose tests, you should also define a function named test-ns-hook; run-tests will call test-ns-hook instead of testing all vars."

zcaudate05:11:55

We are doing some front end testing with webdriver - what I want to do is to hook in additional functionality to any ^:web deftest forms so that when a test has failed or an exception has occurred, it will take a screenshot of the browser.

zcaudate05:11:54

I’m wondering how it will be possible to hook this in without changing any of the current test code

zcaudate05:11:05

hoping to get some help from the author (@stuartsierra) but any advice would be appreciate.

ul06:11:02

My attempt to automate particular refactor tasks http://ul.mantike.pro/automating-clojure-refactor-with-rewrite-clj/ Any critics/suggestions are very appreciated!

wei06:11:05

using http-kit and compojure.route/resources to serve a media file but the Content-Length is always 0. anyone see this problem before?

wei06:11:36

$ curl -I 
HTTP/1.1 200 OK
Content-Length: 0
Last-Modified: Tue, 03 Nov 2015 06:19:46 GMT
Content-Type: video/mp4
Server: http-kit
Date: Tue, 03 Nov 2015 06:55:52 GMT

darnok09:11:06

@wei how big is that mp4 file?

wei09:11:11

it’s 5 mb

pupeno09:11:43

I want to update-in a value into a collection but if the collection is nil, I want it to be a set, not a list. Is this the best way: (update-in {} [:foo :bar] #(into (or %1 #{}) #{%2}) :value)

taylor.sando09:11:12

You could just do (update-in {} [:foo :bar] #(conj (or %1 #{}) %2) :value) -- I don't know if it's best, but I'm not sure you really need to use into, conj would be more clear if you're adding a single item to a collection.

pupeno09:11:58

taylor.sando: ah, yes.

darnok09:11:52

@wei ok, so it's not big

darnok09:11:45

I thought that it can be some issue with handling large data by httpkit.

wei09:11:38

not in this case. good point though

darnok10:11:48

i think i know why it works like this.

darnok10:11:26

it doesn't support HTTP HEAD command. I've checked and the same is with aleph.

darnok10:11:26

if you use resource from classpath, it sets body to InputStream.

darnok10:11:30

InputStream doesn't have size so HEAD returns 0.

xcthulhu11:11:10

Hi! I'm a Clojure programmer, ClojureScript/frontend n00b

xcthulhu11:11:15

I am making Web/Mobile app and I liked the idea of GraphQL/Falcore so much I decided to start writing my own system like this.

xcthulhu11:11:09

My idea is to have a DSL where you program route-like thingies in a tree structure, and it either compiles Compojure routes or to an object you can query with an EDN, so I can just wrap it with sente instead of doing bijillions of AJAX calls: https://github.com/ptaoussanis/sente

xcthulhu11:11:43

I was discussing my idea with a friend and he declared "Somebody must have already made this" so I am asking around here before I go hog-wild with this thing

niwinz11:11:32

@xcthulhu: I'm working on an "possible" approach for that

niwinz11:11:27

It is still very initial development, but you can read the documentation and everything related in recently merged PR in catacumba: https://github.com/funcool/catacumba/pull/33

niwinz11:11:09

Is something less "frameworky" than relay and friends and it leaves to the user the responsability of build the needed abstraction for communicate with the server, such as sending datomic like pull queries (as om-next does) or just build more traditional rpc communication

niwinz12:11:22

postal (client + server) solves the communication/transport part of relay like architecture, allowing you send messages with better semantics than http and allow use your own messages. It is very similar to something om-next-tutorial does for communicate with backend; using very simple messages such as query and novelty (analogous to read and mutation from om-next...), it not implies any coupling with a concrete framework, so if you don't want use om-next aproach you can build your own.

niwinz12:11:00

Later, we are working in a "query" abstraction for aggregate and join different queries for efficient fetching from the backend (https://github.com/funcool/muse) that will work together with postal out of the box.

niwinz12:11:55

The main objective is not build a big magical framework like graphql/relay, instead build little (easy replaceable) libraries for solve that kind of problems :wink:

stuartsierra13:11:31

@zcaudate: clojure.test doesn't do anything special with metadata on test definitions. If you want to do any custom coding around how your tests are run, the easiest thing to do will be to create your own test runner, maybe using clojure.test/test-vars. The test-ns-hook stuff is rarely used and not well-defined.

pesterhazy13:11:14

clojure.test's test runner is a bit basic. It would be great to have a more configurable alternative that still uses clojure.test's api

jstew14:11:32

@xcthulhu: Without knowing the specifics of what you want to implement, Om.next seems to be pretty close. It solves some of the same problems that relay, falcor, and graphql solve.

jstew14:11:41

@xcthulhu: Also, there's a lot of activity in the #C03S1L9DN channel here, and some of us may be able to help you even further in there.

jonpither14:11:09

Looking at @bozhidar's clojure style guide. The line " Vertically align function (macro) arguments spanning multiple lines", sometimes it makes sense to not do this and stick to an indent of two spaces. I.e. code could made a lot terser if commonly used macros/fns were whitelisted - is there any 'official' standard verbage on this?

bozhidar14:11:55

pretty sure there’s not

jonpither14:11:57

What are your thoughts, i.e. I'm seeing some clojurescript using dom/div a lot, which results in very long cljs lines. Using two spaces would be aesthetically more pleasing

stuartsierra14:11:16

@pesterhazy: clojure.test tests are just functions, it's pretty easy to write your own runner.

pesterhazy14:11:54

@stuartsierra: agree. I appreciate that clojure.test is so simple that you can write your own runner in a day

stuartsierra14:11:51

I'll be the first to admit it has some sub-optimal design decisions that were locked in too early (e.g. tying execution to reporting).

anshbansal15:11:09

Is there anyone who could answer questions on New Clojurians: Ask Anything? https://www.reddit.com/r/Clojure/comments/3rcjus/new_clojurians_ask_anything/

anshbansal15:11:18

Who is maintaining the http://clojurians.net page? They need to add a link to the login page. I had to ask a question on reddit https://www.reddit.com/r/Clojure/comments/3rcjus/new_clojurians_ask_anything/ to find where the login page was as I had deleted the email.

launchpad15:11:48

is it frowned upon to use core async for parallel processing of data?

jstew15:11:39

launchpad: No. Not unless the specifics of your data depend on the order that the results of the processing. In that case, IMO, core.async may not be a great fit. Or if your problem really can't be solved asynchronously.

launchpad15:11:39

Thanks for the quick response. I’ve done an implementation of my logic in core.async, reducers, and regular reducing. Trying to understand the best approach to the problem.

noisesmith15:11:17

pupeno: regarding making something default to a set - (fnil conj #{}) is conj, except if the first arg is nil it is replaced by an empty set

noisesmith15:11:21

eg. ((fnil conj #{}) #{1 2} 3) => #{3 1 2} ((fnil conj #{}) nil 3) => #{3}

pupeno15:11:03

noisesmith: cool :simple_smile:

noisesmith15:11:45

pupeno: I frequently find use for (fnil + 0)

noisesmith15:11:00

or (fnil inc 0)

loganmac17:11:22

I found a resource for browser-testing in clojure using https://github.com/semperos/clj-webdriver. Does anyone have any resources/tutorials/libraries for capturing the browser's console.log(x) and console.error(x) logs in clojure? Specifically using Selenium would be great. Basically I've been tasked for writing some tests that just query a bunch of urls and make sure that the console doesn't have any errors in it (an angular application that I don't have access to the production code of) Thanks!

snoe17:11:11

@loganmac We do something like

(doseq [entry (.. t/*driver*  webdriver manage logs (get "browser"))]
    (log/info entry))

loganmac17:11:58

@snoe thanks! .. is just for chaining interop commands, right?

loganmac18:11:28

also, @snoe is there a way to use that to filter out only errors, and not just all logs?

snoe18:11:08

I think it is, but you're deep in webdriver guts at that point

conan18:11:37

@loganmac: I wrote a fairly hacky library for hooking up clj-webdriver to things like SauceLabs http://conan.is/webdriver/selenium/testing/clojure/2014/12/09/the-green-cross-code.html

conan18:11:54

might be something in there that helps, but it was a while ago, sorry!

robert-stuttaford18:11:15

i’ve found, it doesn’t matter how much Lisp you rub on it, maintainable selenium test suites are near impossible to have

loganmac18:11:51

I'm open to alternatives to selenium. What I really want to do is spin up a headless browser (phantomjs), then just look for console.errors in it

loganmac18:11:49

I don't even need it to click or interact with elements. Just wait for the page to render, then look for errors

zcaudate18:11:25

@stuartsierra: ahh okay… thanks for the clarification. I may have to go with another option.

robert-stuttaford18:11:09

hey @zcaudate! i’m a big fan of cronj - thanks for that :simple_smile:

zcaudate18:11:33

hahaha :smiley: thanks mate

robert-stuttaford18:11:59

i will admit i still struggle with the time spec syntax, though

robert-stuttaford18:11:05

love that you can simulate it

zcaudate18:11:31

I’ve been pretty slack these days so it’s nice to get some love

robert-stuttaford18:11:45

it’s all good :simple_smile:

zcaudate18:11:55

I’m in the process of merging cronj into hara… so there is no dependency on clj-time and it uses the java time api instead

robert-stuttaford18:11:53

ah, that’s good to know

robert-stuttaford18:11:52

ah, section 3.4 is what i need

roosta19:11:07

oops :simple_smile:

ddellacosta19:11:57

is there anything like a “toggle” conj / disj kind of function for sets? if something exists it conj s it on, otherwise disj s it...

ddellacosta19:11:12

easy enough to write but just curious if I’m missing something

bostonaholic19:11:49

@ddellacosta: think you have that backwards

bostonaholic19:11:09

if something exists in a set, conjwon't do anything

ddellacosta19:11:40

oh yeah bostonaholic, sorry had that reversed

ddellacosta19:11:11

so I’m guessing nothing like that exists though huh

taylor.sando19:11:10

Is there a better way to do email polling then what I have going here: https://gist.github.com/taylorSando/979ab571923286b96662 -- I noticed that I had a Maximum number of connections from user+IP exceeded error. I hadn't seen that error before, but it occurred in a program that had been running for about a week.

razum2um19:11:16

I have a library organized as src/clj, src/cljs, src/cljc and I have :source-paths ["src/clj" "src/cljc" "src/cljs”] but when I run lein jar I get jar only with src/cljc files. what am I missing?

bostonaholic20:11:11

@razum2um: are you using lein-cljsbuild?

razum2um20:11:28

@bostonaholic: yep, but nevermind, i just misslooked some files that being collected under projname directory

magnars21:11:12

I read somewhere that using dev/user.clj was a bad idea - something about the name user.clj? Anyone else seen this, or have I been dreaming?

stuartsierra21:11:34

@magnars: Clojure always loads user.clj on startup. If your user.clj tries to load a file with a syntax error, the REPL won't start.

magnars21:11:57

ah, that's it. Thanks!

stuartsierra21:11:10

I typically use dev.clj instead.

magnars21:11:25

makes sense

markmandel22:11:00

Curiosity question: So when doing a lein new compojure it creates a dev-resources directory, that I swear I've never seen before... I can't find reference to it anywhere - does anyone know what it's for?

xeqi22:11:08

@markmandel It is for resource files you don't want in production. Think files that can be loaded in tests, or at repl. I suspect a recent lein change may be creating the directory when it used to just use it when it existed. https://github.com/technomancy/leiningen/issues/2010

markmandel22:11:58

Aaah, that makes sense. Thanks!