This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-05
Channels
- # bangalore-clj (4)
- # boot (196)
- # chestnut (1)
- # cider (4)
- # clara (3)
- # cljs-dev (23)
- # cljsjs (28)
- # cljsrn (1)
- # clojure (79)
- # clojure-art (1)
- # clojure-berlin (1)
- # clojure-hk (17)
- # clojure-italy (5)
- # clojure-korea (1)
- # clojure-russia (21)
- # clojure-spec (5)
- # clojure-uk (26)
- # clojurescript (125)
- # core-async (1)
- # cursive (23)
- # datomic (7)
- # emacs (17)
- # hoplon (51)
- # jobs (2)
- # leiningen (2)
- # om (11)
- # om-next (26)
- # onyx (39)
- # pedestal (9)
- # proton (4)
- # re-frame (43)
- # reagent (1)
- # ring (2)
- # slack-help (12)
- # sydney (4)
- # test-check (9)
- # yada (40)
@didibus Looks like you can just embed the ?U flag as in #"(?U)foo"
: https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#UNICODE_CHARACTER_CLASS
I have a few questions about transit. (There doesn't seem to be a better channel to discuss this)
- What is the difference between rep
and stringRep
methods of a write handler? i.e. when would I expect one to get called vs the other? (that doesn't seem well documented on transit-format
)
- Is it typical / advised to implement a write handler with different rep
and stringRep
methods (where rep
does not return a string)?
- If so, do I need to implement my read handler for a given tag so that it can take either the rep
or stringRep
formats?
basically what I want to do is to: define a var pointing to a map. the value of the key is a function with wrap another function passed as second parameter to the macro
@aengelberg: https://github.com/cognitect/transit-java/blob/master/src/main/java/com/cognitect/transit/WriteHandler.java has some comments on the methods that look like they might explain it
(defn add [a] (+ a 10))
(defmacro def-handler [name f]
`(def ~name
{:enter ~(fn [a] (f 10))}))
(def-handler h add)
((:enter h) 20) ;; => 30
the fn form you have sort of works, because you have fallen in to an edge case in the compiler
but you are emitting a fn object instead of a form that when evaluated returns a fn object
unless you use the auto gensym feature, which is when you syntax quote a symbol with the suffix #
@grzm I just ran into http://seespotcode.net/2016/08/16/figwheel-reloaded/
We came up with a different solution though. For just refresh, simply setting your refresh dirs with: (clojure.tools.namespace.repl/set-refresh-dirs "test" "src")
should work, as an inclusive set of directories you want to bring in.
Looks like the #boot guys ran into this sometime last year. And came up with this solution to the problem: https://github.com/boot-clj/boot/wiki/Repl-reloading#problems-with-setting-refresh-dirs Something similar in Leiningen should work, based on your directory listing functions.
It's particularly potent with https://github.com/juxt/bidi as it includes protocols and such, which with the wrong reload order breaks your entire site on refresh.
On further digging, I'm not sure about the method involving user.dir
, I don't think it solves this particular problem completely. As cljs output files are in user.dir
, so I stand by my original solution ("test" "src")
so I'm implementing a web app in clojure/script and I was wondering if I should use om (in clojurescript) or enlive (in clojure) for creating the pages. The website is similiar to a forum, so mostly static but some buttons and stuff to press.
@donyorm it depends… If you’re doing this to learn “How to write a web-app in clojure”, I’d start out with enlive, and keep clojurscript on hold for a while. If this is a production system which might want to have several clients (mobile, web, what have you), a restish kind of api would be usefull, and implementing the frontend in Om would make sense.
IMNSHO, I find that people way to often reach for spa’s when plain old html generated on the server with a wee bit of jquery would do the job perfectly.
It's kind of a mix of both. I'm definitely learning clojure, but I wouldn't mind this being actually useful. I'll probably go with enlive, since I don't think I'll be doing javacript intensive work
I've heard that jquery doesn't work with clojurescript, is that true? Should I even bother using clojurescript for relatively simple tasks?
(I've done a small web app using luminus, but I used normal JS, so I haven't looked into clojurescript as much)
Enlive hasn't been worked on for a couple of years, and is still using clojure 1.5. Is that something to be concerned about?
Hiccup seemed like a ton of typing for creating a whole html page, though it seemed like it would be useful for shorter snippets
I use hiccup almost exclusively. I like how Clojure-esque it is. I’ve always disliked Selmer/handlebar-style solutions that bury code snippets inside of markup. Hiccup requires a bit more upfront work but you can compose snippets together to form full pages to keep things DRY.
yeah @akiva that's part of what I liked about om and/or enlive. But maybe I look into hiccup more then. Om was very slick, but felt like it was possibly more than I needed
I’m a fan of Om but it is heavy, especially syntax-wise, but worth the work for a massive/complex SPA. Keep an eye on Om-Next, however; it’s going to be severely bad ass. Currently, I’m using re-frame/reagent for smaller projects.
I know I'm tapping into a classic source of Java pain here, but I'm generating some SVG, and I naively started feeding literals like 10
into calculations which included division. Then my tests start failing because even when everything adds up perfectly, (not (= 10 10.0))
.
Is the correct move to just use float literals in every context that is not guaranteed to be ints only? I've spent a bit too long working with languages that were a bit more cheerful about converting between types...
not always safe as well… see http://gettingclojure.wikidot.com/cookbook:numbers#toc10
Interesting, I never knew about ==
. And it doesn't surprise me that it's not perfect either... but I guess I'll use ==
and see what happens in real life. I doubt I'll ever be seeing numbers larger than a few thousand, since I'm just rendering SVGs of relatively small graphs.
Thanks for the tips!
Bah, I'll have to extend that to collections!
(= [1 2 3] '(1 2 3)) ; true
(= [1 2 3] '(1.0 2.0 3.0)) ; false
(== [1 2 3] '(1.0 2.0 3.0)) ; ClassCastException
(defn equal-numbers? [c1 c2]
(every? #(apply == %) (partition 2 (interleave c1 c2))))
This does the job, anyway. Perhaps there's something easier.Any common lisp wizards here? I'm trying to use cl-format
to format money. I want (f 12345) ;=> "12,345.00"
. I get the decimals with "~$"
and I get the comma separators with "~:D"
. How do I combine them?
Yeah, i just went and used java ¯\(ツ)/¯. #(.format (java.text.DecimalFormat. "#,###,###,###.00") %)
when 1.9.0
is no longer alpha will specs defined by clojure.core
e.g. :clojure.core.specs/bindings
be reliable for use? ie. i'm writing a macro and i want to support the bindings form as defined by :clojure.core.specs/bindings
; can i rely on it for parsing, etc.?
thanks @andrepnh, @alexmiller
The idea is that they are public specs for core and you can build on them
I don't expect them to change dramatically
This has probably been asked before but, is there an easy way to generate urls from compojure routes? I am building a rest api and want to have links to other resources.
@jannikko do you want those links for api documentation purposes, or something else?
I know that bidi was created for these kind of things but I really want to stick to compojure
I just found this https://github.com/clojurewerkz/route-one looks promising