Fork me on GitHub
#clojure
<
2015-06-12
>
fhanreich00:06:04

(let [y 2] (for [x [0 1 2] :let [z (* x 3)] (+ x y z))) would return (2 6 10), y is constant while z in this case isn't

bjarnagin00:06:24

i was thinking more like `(for [x (range 1 6)] (let [y ( x x) z ( x x x)] [x y z]))` vs `(for [x (range 1 6) y (* x x) z (* x x x)] [x y z])`

bjarnagin00:06:41

that didn’t come through very well

bjarnagin00:06:58

i think i got a better understanding looking at clojuredocs a bit more closely, though

nside04:06:52

curious as to why people use boot. isn't lein perfect?

domkm06:06:27

nside: Neither Leiningen nor Boot are perfect. Boot is less imperfect.

arrdem06:06:35

nside: Lein has real issues in terms of composing tasks, and in terms of scripting custom tasks. It also doesn't help that the primary maintainer has largely withdrawn from the community of late. Boot has active maintainers/promoters and solves the task authorship issues which plagued leiningen.

arrdem06:06:54

or at leas that's my view of this

borkdude06:06:21

@arrdem: he has withdrawn? I got an answer from him in #leiningen on IRC recently

arrdem07:06:44

@borkdude: maybe it's been a while since I've been IRC active as well

arrdem07:06:40

@borkdude: I just remember that when Phil did his big move he scaled back his channel involvements and the leiningen stuff went quiet (which is a totally reasonable reflection of his real world priorities, just opens the door wider to boot)

borkdude07:06:29

@arrdem: I am reading his latest blog. I was vaguely aware of it, but that explains it. http://technomancy.us/

smnplk07:06:43

Howdy folks! Does someone know how can I setup lein repl, so I have syntax highliting and/or (at least) have indentation support ?

arrdem07:06:14

smnplk: sadly lein's repl does none of those things.

arrdem07:06:31

smnplk: your best bet is probably to reach for cursive, cider or fireplace

arrdem07:06:41

leiningen is just the dependency tool

arrdem07:06:58

what's your background?

arrdem07:06:07

tooling[/editor] wise that is

smnplk07:06:51

Actually I am using fireplace in vim, but usually that means i have to run lein repl in another console tab, then connect to it manually from vim, specifying port ... or create a new clojure project via leiningen and open it with vim, but sometimes i just need to quickly try something..

borkdude07:06:47

@smnplk: for quick snippets spinning up a REPL and connecting to it from your favorite editor is still the best option

smnplk07:06:48

Also I am trying to migrate to spacemacs..but I have no emacs knowledge, I would really like to try cider, b

arrdem07:06:51

lein-ultra pins a lot of transitive dependencies :c

smnplk07:06:58

@ayato_p: wow, ultra looks awesome, thanks

arrdem07:06:37

but it's been a long time since I used it last, will give it a shot

mitchelkuijpers07:06:40

I am looking for a scheduler in Clojure any personal preferences or tips here?

wei07:06:20

http://clojurequartz.info perhaps? never used it but you can’t go wrong with ClojureWerkz

mitchelkuijpers07:06:57

Yeah that's true that is also the one I found first

mitchelkuijpers07:06:16

Let's just try this

mitchelkuijpers08:06:31

And the clojurewerkz guys always have top notch documentation ^^

pastafari08:06:50

mitchelkuijpers: I’ve used quartzite for a long time in production, works well. I vaguely remember that the DSL for recurring jobs wasn’t working exactly as I expected, we used Cron strings instead.

danielcompton08:06:29

@mitchelkuijpers: you can always go with Java ScheduledThreadExecutors if its simple

mitchelkuijpers08:06:39

@danielcompton: I will need more scheduling in the app so I don't mind the extra options for later simple_smile

mitchelkuijpers08:06:19

@pastafari: Hmm let's see if i get bitten by that

arrdem08:06:20

Hey folks I'm thinking about a UI redesign for Grimoire (http://conj.io) and would appreciate any criticism of the live site you care to offer.

arrdem08:06:36

And with that sleep.

tcrayford09:06:15

@seancorfield: using the bare x inside the implementation is likely a bit faster (until the JIT wakes up anyway). That and field access style are definitely faster than keyword access, even with the JIT fully warmed up.

pastafari09:06:14

@arrdem: bigger fonts please. And thank you simple_smile

txus09:06:18

@mitchelkuijpers: I’ve used quartzite, no problem at all

txus09:06:21

pretty nice

mitchelkuijpers09:06:52

@txus: Yeah using it right now, really like it! First time quarts does not make me cry

txus09:06:21

I didn’t even know about Quartz before, only used sidekiq in Ruby before 😛

sveri10:06:05

The last time I tried to use quartzite, the docs were not up to date with the library, which was a pity, as the api seem to have changed, is that fixed?

mitchelkuijpers10:06:00

@sveri: Seems fixed to me 😄

sveri10:06:09

@mitchelkuijpers great, I will give it another try then

txus10:06:06

I need to start a greenfield om SPA with a bit of dumb backend code (it’s basically an admin section interacting with postgres, needs authentication as well) I’ve considered Pedestal, haven’t used it, but what are your thoughts?

txus10:06:34

what are people using for semi-dumb backends to Om apps?

tcrayford10:06:30

@txus: gonna guess the bog standard compojure/ring stuff

minimal10:06:25

I’ve been trying buddy for auth recently. Seems good but haven’t used it in production

txus10:06:21

so I guess compojure/ring and something like buddy or friend? I don’t mind too much but i was wondering if there is something a bit less hand-crafted these days, Luminus is a bit old but Pedestal looked nice

mitchelkuijpers10:06:34

@txus I use Pedestal it is pretty nice, but the docs are very outdated

mitchelkuijpers10:06:04

@txus: But he interceptor API is pretty powerfull

sveri10:06:24

@txus disclaimer i am the author. This is what I built closp for. Having authentication and some user admin on the backend side, with server side template generation + the ability to have semi SPA. I built that on top of luminus and reagent, but switching to on is pretty easy.

slipset10:06:21

is it me, or is it a bug in http://tryclj.com at the moment

txus10:06:30

ooh jeesus system integration, chestnut @sveri

txus10:06:37

looks exactly like what I’m looking for

slipset10:06:46

> (defn foo [x] (* x x))
#'sandbox7490/foo
> (foo 10)
java.lang.IllegalStateException: Attempting to call unbound fn: #'sandbox7490/foo
>  

acron10:06:30

@slipset: works for me :s

txus10:06:49

@sveri: gonna go with closp, I’ll let you know if I get in trouble 😄

slipset10:06:57

acron: works for me in another browser

sveri10:06:01

@txus great to hear that, I am always eager for any kind of feedback, also pull requests and things, good luck

acron10:06:01

@slipset: must be a glitch in the matrix 😮 what browser does it fail in?

slipset10:06:29

acron: chrome, but it works in a private tab in same browser. Glitch in matrix

ghadi13:06:55

FYI channel notifications can be disable on a per-channel basis, if hearing the ping in clojurians rooms is bothersome

michaeldrogalis14:06:34

Is it possible to create a defmethod in Java of a multimethod defined in Clojure?

tcrayford14:06:20

@michaeldrogalis: by definition, yes, right? Clojure is just a java program

tcrayford14:06:27

don't think there's any public api for it or anything though…

tcrayford14:06:31

prolly real gnarly

michaeldrogalis14:06:35

@tcrayford: Yeah, I figured 😞

tcrayford14:06:40

@michaeldrogalis: making a java api for onix?

michaeldrogalis14:06:07

Yee-up. Actually someone else is, happy that I don't have to. 😛

tcrayford14:06:16

oh dope 😄

michaeldrogalis14:06:51

0.6 seems to have pushed a lot of people over the edge from "interested" to "dabbling". Nice to have more hands

tcrayford14:06:21

awesome 😄

tcrayford14:06:19

I read through the kafka adapter somewhat recently. Does onyx have anything like storm's transactional spouts?

tcrayford14:06:31

(not to say it should, just curious)

michaeldrogalis14:06:05

@tcrayford: Like Trident? Not yet, but now I want one haha

tcrayford14:06:02

@michaeldrogalis: yeah. It's a pain in the butt to do properly 😞

tcrayford14:06:24

(Yeller has handrolled stuff that does that on top of kafka's simpleconsumer. So much painful)

michaeldrogalis14:06:59

@tcrayford: I want to see Yeller's source so bad

michaeldrogalis15:06:10

Are you doing Yeller full time now, btw?

tcrayford15:06:24

nope, still part time with a rails day job

michaeldrogalis15:06:02

You're really cranking along for those circumstances

tcrayford15:06:22

thanks simple_smile. It's a difficult balance

malabarba15:06:09

Hey everyone. I've got to turn a bunch of java objects into maps based on their getters. I can just write a macro for that, but I'm wondering if there's already a library?

arohner15:06:20

malabarba: clojure.core/bean

arohner15:06:30

is there a clojurebot in here?

arohner15:06:34

,(doc bean)

arohner15:06:37

@malabarba: I also wrote unbean, if you need the inverse: https://github.com/arohner/unbean

malabarba15:06:38

arohner: thanks! but that requires the java side to be beaned, right?

malabarba15:06:25

Or something like that

arohner15:06:39

@malabarba: if they have getters and setters that follow the convention, I think it just works

malabarba15:06:05

I'll check it out then! (On the phone now)

seancorfield16:06:36

Thanks @tcrayford — I suspected that might be the case (and in fact had a noticeable slowdown when I used :x access inside a record that was accessed a lot in our app).

tcrayford16:06:34

@seancorfield: as always with the JVM though, the JIT makes benchmarking hella awful 😕

seancorfield16:06:13

Yeah, I gave up on micro-benchmarking a long time ago simple_smile

tcrayford16:06:40

seems wise 😄

seancorfield16:06:59

In general, if something affects the time our full test suite runs, we know to dig more (normal time is ~11 minutes right now).

tcrayford16:06:21

ahh, that makes sense. Easy approach to implement as well

seancorfield16:06:05

Our full test suite exercises our two main apps at pretty much every level: from the lowest unit test up to full end-to-end WebDriver and Selenium suites.

seancorfield16:06:10

We have about 25K lines of production Clojure and nearly 7K lines of test code (although that includes a fairly extensive suite of HTTP API tests) and nearly 2K lines of WebDriver test code. Plus we have unit tests and integration tests at our CFML layer (which also exercises a lot of Clojure code) and we have Selenium HTML tests too (from the "good ol’ days").

tcrayford16:06:43

yeaaah, selenium'll do that 😕 Seems fairly normal simple_smile

seancorfield16:06:43

I always wonder, when I hear people say "Oh, those Clojure folks don’t really do any (unit) testing…"

gjnoonan16:06:05

I hear that a lot, It’s nonsense @seancorfield I think we just do it at a different time.

gjnoonan16:06:15

Exploring in the REPL vs full TDD

tcrayford16:06:10

@seancorfield: for the record, Yeller has ~1k or so automated tests, with maybe 50 of those being end to end ones (no selenium here though). 10k lines of production code, 3k lines of test. Bugs that made it to prod since launch last year: 8

seancorfield16:06:25

We still have too many bugs getting through to production but it’s a vast dating platform and we expose similar functionality in a lot of different places in the UI so getting full test coverage of a feature at the end user level is a huge amount of work.

akiva16:06:56

I think a lot of it has to do with the idea that coverage is everything.

tcrayford16:06:44

@seancorfield: yeah. Comparing apples and oranges here I think, Yeller is greenfield as of last year, and has one dev. Super different environment 😄

seancorfield16:06:17

For example, we let members add someone as a favorite in maybe a dozen places — and one of those broke due to an unrelated change (a data type changed in an unrelated table and that caused a small piece of JavaScript to break in one file used to construct ajax links for favoriting a member on one particular page).

voxdolo16:06:43

@tcrayford: what sort of end-to-end testing are you doing?

seancorfield16:06:45

So now we’re going to write a WebDriver test that makes sure you can favorite / unfavorite a member from every single possible location in the app. Sigh.

voxdolo16:06:33

Right now the closest I'm getting to end-to-end are some ring-mock tests and I have far too few 😕

voxdolo16:06:40

@seancorfield: you work at World Singles, I take it?

seancorfield16:06:58

Yup. That’s me.

seancorfield16:06:11

We’re the crazy "Clojure embedded in CFML" folks simple_smile

voxdolo16:06:16

you said CFML and clojure, so 😄

masonbrowne16:06:33

Holy what? CFML like ColdFusion?

masonbrowne16:06:06

That’s kind of awesome.

tcrayford16:06:31

@voxdolo: think it's "the number of bugs that make it to prod" that is the important number, and the feeling of confidence programmers have whilst changing existing code. Both of those can be improved with better testing, but don't think coverage or a feeling of "I should write more tests" are good reasons for writing tests

voxdolo16:06:32

have you guys talked about how you use clojure from CF?

seancorfield16:06:52

We recently passed the point where we have more lines of Clojure in our Model than CFML, but we still have a lot of CFML in our Controllers (and don’t get me started on the Views!).

seancorfield16:06:20

Yeah, I did a short talk at Clojure/West a few years back about it, and a longer one at a few user groups around the world.

voxdolo16:06:27

@tcrayford: yeah, agreed. I was mostly just curious how you were going about your end-to-end. Still looking for something I feel like is a better way… I've been struggling against ring-mock pretty hard.

voxdolo16:06:30

seancorfield: ah, sweet simple_smile Morbid curiosity and all...

seancorfield16:06:12

CFML is not like it used to be. And we use a modern FOSS engine for it.

tcrayford16:06:53

@voxdolo: I use https://github.com/xeqi/kerodon for now. I don't have much javascript, or even very many end to end tests that hit the web ui at all

tcrayford16:06:04

(most of the end to end tests are of "the backend")

seancorfield16:06:22

@voxdolo: here’s one of our CFML functions calling into Clojure https://www.refheap.com/102130

voxdolo16:06:34

@tcrayford: nice! thank you.

voxdolo16:06:40

@seancorfield: I actually had no idea CF ran on the JVM, so it's just standard interop then, eh?

voxdolo16:06:04

not too bad at all

tcrayford16:06:02

@voxdolo: happy too help simple_smile

seancorfield17:06:09

@voxdolo: Yeah, most folks who’ve even heard of CFML still think it’s a proprietary interpreter written in C++ simple_smile It’s been running on the JVM as a compile-on-demand to bytecode system for nearly 15 years now.

voxdolo17:06:45

When I last encountered it, it was a Macromedia product 😉

seancorfield17:06:05

It’s had closures for years now, and arrays and structs have map/filter/reduce member functions etc simple_smile

seancorfield17:06:01

I worked at Macromedia when they bought Allaire — CF5 was the last C++ interpreter version and the first released under the Macromedia brand. The next release was compile-to-Java, followed by a compile-to-bytecode release.

seancorfield17:06:44

That’s how I came to be doing CFML in the first place — management made my team (of C++ and Java developers) use CF for a big new web project on http://macromedia.com!

voxdolo17:06:12

hah simple_smile nice. I was working at http://homes.com in the early 2000s and significant bits of the front end were written in CFML. Backend in Pro-C 😢 and a little Java (struts/tiles).

seancorfield17:06:20

And, to bring this back on topic, that’s why I’ve always been so interested in the ability to "host" Clojure code inside other JVM languages and why I was particularly concerned about a stable API to do so (which we got in Clojure 1.6).

voxdolo17:06:23

back when AJAX was still XMLHTTPRequest

seancorfield17:06:39

Ah, the good ol’ dot-com boom days… simple_smile

voxdolo17:06:53

dot-com 💥

akiva17:06:12

asp remote scripting. oy.

borkdude19:06:21

I haven't been doing it, but is there any drawback to running 'lein run' in production from a source project, instead of packaging as uberjar + java -jar ...?

noisesmith19:06:50

longer startup time, more ram usage, less runtime optimization (by default hotspot is turned off)

noisesmith19:06:20

also more to install on each server instance, and more elaborate setup for each server

borkdude19:06:37

I was thinking about this, because it seemed to be suggested as ok from the Pedestal docs: (defn -main "The entry-point for 'lein run'" https://github.com/pedestal/pedestal/blob/master/guides/documentation/hello-world-service.md

borkdude19:06:56

@noisesmith: I see those drawbacks, but what about installation? can you explain why uberjar is better in those terms? git push deployment is pretty easy too

noisesmith19:06:29

@borkdude: lein, git, all your maven artifacts

noisesmith19:06:46

it's not a big difference, but it's a lot more that ends up being installed

noisesmith19:06:02

(and statefully ends up needing to be on disk before you can run)

noisesmith19:06:18

as opposed to java, plus a single jar

borkdude19:06:52

I don't understand: what needs to be on disk?

noisesmith19:06:42

lein, git, your repo, your deps

noisesmith19:06:49

(plus java of course)

noisesmith19:06:18

just in terms of what needs to be downloaded before the thing can run on a fresh server

markstang19:06:12

lein cljsbuild once...

borkdude19:06:30

so basically 'lein run' is just to test -main behavior before you package it?

aaronm19:06:47

think of it as lein run being like hitting ‘run’ in an IDE, and the uberjar as your nice, packaged, optimized release build

borkdude19:06:50

right. I usually start my project with a REPL, so never used that

charlespwd19:06:08

Did someone ever try clicking on an element inside an iframe with clj-webdriver? (is (exists? “#foo”)) passes but (click “#foo”) complains

charlespwd19:06:39

I’ve tried switching to frame with no success...

arohner19:06:27

@borkdude: IMO, prefer lein uberjar etc. because you get stable “releases"

arohner19:06:53

lein run resolves deps at startup time, so depending on your deps, you could get different versions at runtime

arohner19:06:24

@borkdude: lein run is also slower to startup, because of second JVM process + more compile time

arohner19:06:58

I used to run lein run in production, and now I’m firmly in the ‘single release artifact’ camp

borkdude19:06:08

@arohner: all good reasons for uberjar then, I've been using uberjar as long as I can remember. Just wondered about this simple_smile

fhanreich19:06:27

@charlespwd: i never had to deal with iframe, but clj-webdriver in general, yes

charlespwd19:06:46

@fhanreich: I’m playing inside shopify’s iframe so I’m kind of forced to. But while I’m saying this I’m probably not forced to.

charlespwd19:06:08

I’ll test the login/iframe business once and everything else outside the context

charlespwd19:06:16

Alright thanks!

fhanreich19:06:05

@charlespwd: what does it return when you do (first (filter visible? (elements "#foo"))) ?

fhanreich19:06:21

@charlespwd: oh? (first is not really necessary because #foo is an id)

fhanreich19:06:20

@charlespwd: what does it show when you inspect element?

charlespwd19:06:42

AH! It’s because it’s an overlay button/link I’m guessing.

charlespwd19:06:38

Much thanks!

fhanreich19:06:08

@charlespwd: I learned something new simple_smile Thanks!

charlespwd19:06:26

clojure
(ƒ click-hidden [q]
  (execute-script
    (str "document.querySelector('" q "').click();")))

charlespwd19:06:47

Had nothing to do about the iframe

fhanreich19:06:02

Thanks for sharing this!

fhanreich19:06:21

I'm going to need it 😉

fhanreich20:06:02

@charlespwd: second thought, maybe that should be added to clj-webdriver?

charlespwd20:06:34

That’s a good question. Should it?

fhanreich20:06:42

yes, please simple_smile

charlespwd20:06:08

I’ll open an issue

fhanreich20:06:38

Thank you!! simple_smile (maybe PR?)

charlespwd20:06:45

@fhanreich: Same username on GH?

borkdude20:06:45

what would be the cheapest option if I would host a small simple clojure app + small postgres db. I guess Heroku with 1 dyno and free Postgres? or maybe DigitalOcean.

borkdude20:06:03

it has to be up and not asleep for 5 minutes like you have with free Heroku

borkdude20:06:14

DigitalOcean seems cheaper than Heroku.

gjnoonan20:06:11

@borkdude: yup, I would recommend DO I have many servers hosted there

markstang20:06:50

@borkdude: webline @ $10.00 per month 2 cpu’s, 1.5G RAM and 50 G diskspace

borkdude20:06:38

it's for some people I know, they want to host a simple webapp. DigitalOcean starts at 5 and that seems nice for them

markstang20:06:05

Seems Webline has dropped their prices to $5.00 per month.

borkdude20:06:39

@markstang: what domain? .be?

shriphani20:06:24

anyone doing any clj-webdriver stuff ?

shriphani20:06:53

I am using chromedriver and want to tinker with the driver. Does anyone have a code sample or anything ?

akiva20:06:23

I’m a Heroku refugee and DO has been fantastic so far.

akiva20:06:13

But Webline’s prices look more attractive. I’d like to drop Dreamhost entirely. These days, I just use them for domain registration but I’m still paying for the full boat.

seancorfield21:06:00

@shriphani: what are you looking to do?

shriphani21:06:21

@seancorfield: i want to load a plugin (a .crx file)

shriphani21:06:42

I’m using the chromedriver (in case that is relevant)

seancorfield21:06:05

Hmm, that I can’t help with.

seancorfield21:06:20

The most we’ve done is set the window size and stuff.