This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-02
Channels
- # admin-announcements (4)
- # aleph (10)
- # arachne (1)
- # beginners (66)
- # boot (19)
- # cider (6)
- # cljs-edn (2)
- # cljs-site (32)
- # cljsjs (4)
- # cljsrn (32)
- # clojure (116)
- # clojure-austin (6)
- # clojure-belgium (2)
- # clojure-dusseldorf (1)
- # clojure-russia (16)
- # clojure-uk (5)
- # clojurescript (178)
- # community-development (2)
- # cursive (28)
- # datascript (16)
- # datomic (16)
- # dirac (13)
- # editors (2)
- # emacs (1)
- # error-message-catalog (30)
- # events (3)
- # garden (2)
- # hoplon (27)
- # jobs (4)
- # ldnclj (4)
- # liberator (3)
- # off-topic (6)
- # om (49)
- # onyx (24)
- # parinfer (9)
- # re-frame (59)
- # reagent (46)
- # remote-jobs (1)
- # rethinkdb (4)
- # rum (2)
- # slack-help (11)
- # untangled (13)
I notice some difference in sorting with clj-time and cljs-time. I can sort timestamps like this in cljs (sort #(t/before? (t/date-time %1) (t/date-time %2)) '(#inst "2016-03...etc.." ..etc..))
but the same code in clj gives me java.util.Date cannot be cast to java.lang.Number
anyone know how to sort by timestamps in clj-time?
doing (sort #(< (clj-time.coerce/to-long %1) (clj-time.coerce/to-long %2)) timestamps)
does the trick.
@thiagofm Regarding your non-dry tests in midje - could tabular facts be what your’re looking for? https://github.com/marick/Midje/wiki/Tabular-facts
i figure a lot of you have seen rich hickey's language of the system talk
that sounds a lot like it's promoting a sort of message passing model for parts of the system
which in turn, sounds like the actor model fits the bill
but rich specifically said that he didn't want to design the language around actor model (ala erlang)
what am i missing here? possibly a whole lot of nuance
if it's a stupid question, forgive me, I'm still trying to learn
@bojan.matic: which talk are you specifically referring to? mind sharing a link with us?
@bojan.matic: it’s been a while since the last time I watched “simple made easy”, but I do remember Rich mentioning that he chose CSP over actor model for simplicity reasons
and indeed, actors are more complex machinery than queues and threads. if I understand Erlang/OTP correctly, the core concept is the tree of linked processes
@bojan.matic: please have a look at this blogpost from parallel universe giving background for creating pulsar (actor library for JVM): http://blog.paralleluniverse.co/2013/05/02/quasar-pulsar/
>Rich Hickey, Clojure’s designer, has made it very clear why he chose not to have Erlang-style actors in Clojure. His makes some good arguments, and far be it from me to disagree with Hickey on Clojure’s philosophy, but I think that that reasoning, too, serves programming-in-the-small rather than in the-large. Actors, in addition to their contribution to simplifying concurrency, help isolate and handle errors. In fact, that is why they’re used in Erlang in the first place. Actors in Clojure may be a tool for programming-in-the-large.
i saw that post, that is why i'm asking this question
@infosophy: not entirely. I don't really want the table, what I've wanted was a way to specify I want to test a function, and then use the normal => syntax for the args. But thanks a lot!
Hi there. Is there an idiomatic way of swallowing an exception and returning nil if one occurs?
it is common clojure style to name predicate fns, macros, etc with a ? suffix - what about boolean values, like in a let binding? Style guide is silent on this. Is it confusing to name boolean values like 'found-the-thing?'
@patrkris: just catch Throwable and return nil
if you are doing this often, maybe write a macro for it
@cpmcdaniel: that's what I ended up doing, but thought maybe it's such a common use case that Clojure already had a solution
@seancorfield: Actually, the ring server has no problem finding the views, which are the Selmer templates to be rendered. It renders the view fine, but the css and js files referenced in the template are not found, pretty much no matter how I specify the paths. It's kind of odd. Hiccup had no problem rendering the page with the included css and js, but it was too limited for my needs.
it is likely you changed something else when you switched to selmer, like removed the resources middleware
Yeah, I asked @nkraft about resource middleware earlier. Using Selmer vs Hiccup has absolutely no bearing on whether a given URL to a static file will render via Ring.
Look at the source of the generated page in the browser, produced by each template engine. Compare the URLs to the static assets.
requiring middleware doesn't mean you are using it, your handler needs to be wrapped in it
did you change versions of ring-middleware-defaults? (whatever that is?) if you did, they could have changed
I don't do a lot of front end stuff, mostly just back end, compojure for APIs, stuff like that. Haven't tried clojure templates before so this is a learning process.
If the assets load in one case and not the other, then you’ve changed how you generate those URLs and that is the problem — and its independent of whether you’re using Hiccup or Selmer or Mustache or whatever.
(and technically this is back end, not front end, since you’re generating the HTML on the server 😄 )
Ran into this myself just now with a different annotation that expects an integer, getting the same errors. Does anyone know the secret to this or is it just one of the places where interop is limited? http://stackoverflow.com/questions/18280626/clojure-annotations-and-integers
Not my idea of back end. I work mostly with APIs and big data implementations. Anything a user can see is "front end" to me.
I've always used Python for HTML generation, but I'd like to get this going with Clojure.
I understand. I try to avoid HTML / CSS / JS too, but I’ve had to build a bunch of stuff with Hiccup and Selmer where I’m generating some crazy complex stuff on the server.
does anyone have a simple way of making a fork that doesn’t conflict with the original version? i forked tools.reader, but the only way i can use it is by carefully excluding the original tools.reader from any dependency that uses it. it would be nicer if i could just rename the namespaces, but i don’t know how to do that short of changing every file in the fork.
Hey @gjnoonan , how can I turn off meekan notifications for everything in my Google Calendar? It is most annoying!!!
@cloojure: That doesn’t sound like a Clojure question — was it meant for another channel/room?
The bot that is installed by default is named "meekan". I already asked the slack people how to disable it and they said I have to talk to the Clojure room moderators.
Try #C04V84U7G then?
(I’m one of the admins but I’ve never heard of meekan)
how do people feel about global state management in clojurescript compared to a backend clojure application? Over the past months i've fully adopted Component on the server side and thoroughly enjoy the repl experience it allows. It has influenced the way I am now building up a client side app. I'm passing local state down the ladder everywhere, taking state as args instead of referring to a global. While this keeps things a little organized, it's also seeming to put a strain on front end api, having to pass around resources everywhere where it would be easier just to silently depend on something like a singleton async channel, and the gains are less pronounced because on the frontend my workflow is based around page refreshes instead of resetting the repl (and i'm fine with this). Basically, is it common for state management to be less strict on client side applications?
@cloojure: @seancorfield I nevr installed meekan either, but will have a look
@jjttjj: I’m not sure what’s considered best practice these days but there are #C03S1L9DN #C0620C0C8 and #C06DT2YSY channels where I bet you’ll get more opinions… Last time I did any cljs the wisdom seemed to be a single global atom but maybe that’s changed.
@scriptor: it’ll be a lot easier if you can use HoneySQL for that
(j/query db (hsql/format (hsql/build :select :foo :from :bar :where [:in :a some-coll])))
for example
otherwise, probably some way to build up the string yourself, just more work
and HoneySQL will handle making it a prepared statement for you, so it’s safer in that sense
> (hsql/format (hsql/build :select :foo :from :bar :where [:in :a ["a" "b" "c"]]))
["SELECT foo FROM bar WHERE (a in (?, ?, ?))" "a" "b" "c”]
</end HoneySQL sales pitch>
ddellacosta: gotcha, is there a practical limit to how big of a collection I can throw in there?
@scriptor: that I don’t know…if I had to guess I would guess it’s whatever (clojure.)java.jdbc limits you to
but I don’t know
@scriptor The limit is based on your underlying JDBC driver. It differs for each driver based on the max parameter binding limit.
there ya go, thanks @curtis.summers , didn’t know that
Also, you might check out my library for "SQL-first" workflow: http://www.hugsql.org
IN (...) clause is handled by value list parameters: http://www.hugsql.org/#param-value-list
@curtis.summers: any idea what the name of that setting is?
I don't believe it is configurable. See this comment on this issue: https://github.com/layerware/hugsql/issues/22#issuecomment-188353269
@scriptor So, some of the limits we've seen: 8k for SQLite, 32k for Postgresql, and ~2k for SQL Server.
I read somewhere that SQLite used to be 999 and it seems like Oracle has (or had?) a limit of 1000… So it’s probably fair to say that "about 1,000" is a portable limit?
@ag I don't think you can attach metadata to keywords. Trying to find the documentation on this...
hey guys im trying to write a macro that acts just like the threading macro, except decorates all of it’s arguments, does anyone have something similar i might be able to look at?
@flyboarder: why not looking at Clojure’s threading macro? https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L1586
does anyone know why trailing colons (in symbols) are reserved in clojure? I tried but haven’t found a reason for that.
@darwin: I was looking there but i thought that might be overly complicated. What I am trying to do is take (my-> arg1 arg2 arg3 ...)
and turn it into (-> (fn1 arg1) (fn2 arg2) (fn2 arg3) (fn2 arg4) ...)
i thought I could figure this out with some unquote splicing
@flyboarder: only that first arg has fn1 or is it a typo?
@darwin: im trying that now yes fn1 and fn2 are hard coded
@darwin: that almost gets me there, the problem is that fn2
is interop so it gets broken into (. (fn1 arg1) fn2 arg2)
instead of .fn2
@darwin: i moved interop to it’s own function and that seems to work thanks so much!
@darwin: do you have a suggestion for that case?
Anyone ever notice inconsistent behavior with comparison operators and sorting? For instance, (< -1 nil)
returns true
, but (sort [-1 0 1 nil])
returns (nil -1 0 1)
.
@flyboarder: all looks good here, (. (fn1 arg1) fn2 arg2)
is correct output, it is expanded (.fn2 (fn1 arg1) arg2)
, both mean the same thing
@paul4nandez: sort
uses compare
not <
user=> (compare -1 nil)
1
-1 is ‘greater than’ nil
Yes, nil is supposed to be less than everything.
@darwin: it's working for me, much appreciated!!!
But (< -1 nil)
says otherwise.
actually, I’m getting NullPointerException
for (< -1 nil)
1.8.0
That's actually somewhat encouraging (I guess).
I'm seeing this in a Planck repl, so it could be a bug there.
ah, so clojurescript
different animal
> WARNING: cljs.core/<, all arguments must be numbers, got [number clj-nil] instead. at line 1
It seems so. I just checked it in intellij and get a warning in clj and exception in cljs.
I think you mean the other way around
warning in cljs, exception in clj
Right. Yes. So I guess the moral here is to make sure its a number before comparing.
or use compare
read the explanation in (source compare)
in planck
Yep. "...special-cases nil to be less than any other object."
Still seems a bit inconsistent to have <
and >
treat it otherwise though. Thanks for the insight.
I agree it’s probably not what you expected to happen
but if you can’t guarantee both arguments to be Number, then you’re at the mercy of JavaScript object comparison