This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-07
Channels
- # aleph (11)
- # aws (8)
- # bangalore-clj (4)
- # beginners (32)
- # boot (48)
- # cider (2)
- # cljs-dev (57)
- # cljsrn (4)
- # clojars (22)
- # clojure (67)
- # clojure-argentina (2)
- # clojure-austin (9)
- # clojure-berlin (1)
- # clojure-brasil (15)
- # clojure-france (1)
- # clojure-italy (10)
- # clojure-russia (23)
- # clojure-spec (6)
- # clojure-uk (48)
- # clojurescript (143)
- # cursive (15)
- # datomic (30)
- # emacs (18)
- # hoplon (26)
- # instaparse (1)
- # leiningen (1)
- # om (21)
- # om-next (9)
- # parinfer (3)
- # pedestal (3)
- # planck (2)
- # re-frame (53)
- # reagent (4)
- # ring (5)
- # spacemacs (1)
- # specter (10)
- # sql (16)
- # untangled (19)
- # vim (11)
- # yada (2)
I know cljs doesn't inherently support ratios like clj does -- is there a standard approach when you need to represent and work with them? Custom type? Some 3rd-party lib? Or just storing them as a tuple?
@eggsyntax for option 2 I made a portable lib: https://github.com/gfredericks/exact
Lovely! I threw together a defrecord & have been using that so far, but I’ll definitely check exact
out & very possibly switch. Thanks 🙂
Wi3/ork
that's what I get for typing after I turn off the monitor
Despite appearances, that's not actually a Super Secure Password, I was just very poorly trying to invoke dmenu from i3 and type "i3lock"
@atdixon It IS the future.
You beast.
I think #om is where most everybody is at.
DN is in #om and not #om-next
You got it champ.
how do I pre-compile fragments of cljs for execution at run time, i.e. why does this: (js/eval #(+ 3 5)) return [Function "function () {return ((3) + (5));}"] instead of 8 and Uncaught Syntax Error: Unexpected token ( if its converted to a string before being given to js/eval?
IOW, does JS have a reader as separated from its eval and if so, what is its eval called (because as above, its apparent that the js/eval is both reader AND eval)? I've tried using "." all around that and get nothing but errors
hey, if i have (def x 1)
, how do i get 1
from 'x
?
@vigilancetech You don't have a JS runtime during compilation, you do however have all of Clojure available (in macros). So you can use that to do arbitrary complex pre-computation during compilation. Otherwise you can hope on Google Closure to optimize your code if it's not too difficult.
@rauh so you are saying just include bootstrap eval and hope for the best?
it seems to me that a #(function) gives me js and I don't see why I can't execute that with something like a js eval at run time.
I have some variant JSON fields I need to extract and I want to de-complect that from the layout, because it may very well be changing fairly often
when I convert them into cljs maps some have maps within maps and some have maps within vectors within maps
For instance, some people have (my-macros/config :foo :bar)
for reading config from you config file.
I just want to have a list of lists with the field name and then a fragment of code to extract its value right next to it
then I can just walk the list displaying the field name and evaling the code to give me the value
seems the most elegant way. I'm kind of surprised this isn't something commonly done with cljs
the [Function "function () {return ((3) + (5));}"] looks like something I should be able to pass off to js at runtime
I thought them being first class meant you COULD do stuff like that with them. Store them, pass them around, etc...
But yes, you can assign them to anything and then use them just like you'd use a number of any other object
right, so it escapes me why I can't have the cljs compiler convert them to js and then call them later at runtime.
without having to bring a whole cljs compiler with me into the end product
I've also tried that, to just add a set of parens around the extraction code
right. Unfortunately js/eval wants a string, so its both reader and eval
that's what I would have thought.
it doesn't evaluate it for some reason. I get this: MOTHERBOARD, ((fn* [] (cell= (:name (:mb jm))))), 35 when I call it this way: (#(-> info-mb first rest))
(def info-mb "info page motherboard descriptions map" '(("MOTHERBOARD" #(cell= (:name (:mb jm))))
jm is the map created from the JSON
it works with an eval in clojure
its the field name. The descriptive text. Those are the arguments that get passed down to a padding function. The field's VALUE should be the 2nd argument, not the function code
but the map keys are :mb and :name
nested maps
ok, I think I can reduce it down to pretty simple. Like what I did in the original post above
k, thx for trying 🙂
can anyone explane me, how to use reCaptcha in clojurescript for registration from?
Does anyone know if the goog.crypt module supports cryptographic signing/verification?
If node doesn't work out, libsodium(my preferred crytpo lib) has several js wrappers. https://download.libsodium.org/doc/bindings_for_other_languages/
Quick question: my current CI pipeline is Codeship -> S3. Looking at Netlify as it seems… simpler than S3, but doesn’t seem to gel as well with boot/cljs? Any recommendations, or should I work my way through netlify-cli?
@gfredericks re: our conversation the other day about extend-type
, I just remembered that you can (extend-type default)
so you don't need to repeat yourself for number
, object
, string
, function
, etc.
@anmonteiro oh awesome, I will definitely do that. Do you think it works for nil as well?
@gfredericks yeah it does
help! https://gist.github.com/vigilancetech-com/97e8726f2be8e18c575334c414d44fd3
@vigilancetech you want
(def b `("some text" ~#(println "another function")))
@vigilancetech It's because it is a syntax quoted list. Do this
(def b (list "some text" #(println "another function")))
or this ^
jinx 🙂
Are there any benchmarking libraries in cljs? Or do you guys just do a simple loop over the fn calls and create the avg time?
ah, I think I see what you guys are saying. Thanks!
@dnolen Hmm.. I've never used it for benchmarking, only debugging slow code. Is there a way to tell Chrome to run a piece of code 1000 times and report the results?
@cfleming It thought that https://github.com/jedisct1/libsodium.js is pure js so no native extensions.
any ideas how to investigate why the cljs portion of my project will compile for :dev profile in <30s but when I deploy with dokku, the cljs portion takes 400s to compile?
@chrishacker advanced compilation is extremely resource intensive
if the build box doesn’t have enough memory then advanced compiles can take much longer
ok. so I should test it out on a larger memory footprint and in theory it should compile faster
@chrishacker yes by larger I mean at least 1gb
pretty sure we're using 1gb
but we'll bump it.
ha. 🙂
k. thx
@chrishacker check if you've provided memory settings in your project.clj as well, as the JVM will automatically pick values based on the environment which may not be optimal
@danielcompton yep, thx. it was set to -Xmx1g
. going to bump it to -Xmx2g
and see what happens later this afternoon.
I'm drawing a blank here .. is there a way to run a single deftest
in cljs.test
? don't want to test the entire ns?
@anmonteiro just ported Rich Hickey’s perf enhancements to clojure.spec
, if you’re using it - now would be a good time to test with master
@kenny i’m gonna write a blog post on profiling cljs in a few weeks, but i’m sure you’ll figure it out between now and then 🙂 like david said, console.profile totally rules
one thing i didn’t notice for a very long time that i find useful - the profile viewer has this little eye icon, which comes in handy for drilling down past any outer layers of stuff you don’t care about (figwheel, etc)
Following up on earlier :optimizations question/issue. Here is my cljsbuild output from a dokku deployment:
Applying optimizations :advanced to 229 sources
Nov 07, 2016 10:10:05 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /tmp/build/target/cljsbuild/public/js/out/cljs/compiler.js:559: WARNING - References to the global RegExp object prevents optimization of regular expressions.
cljs.compiler.emit_constant.cljs$core$IMultiFn$_add_method$arity$3(null,RegExp,(function (x){
^
Nov 07, 2016 10:10:05 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 1 warning(s)
Optimizing with Google Closure Compiler, elapsed time: 183312.998139 msecs
Optimizing 233 sources, elapsed time: 206736.604839 msecs
Successfully compiled "target/cljsbuild/public/js/app.js" in 286.498 seconds.
Two questions: 1) has anyone see the RegExp warning before? It seemed to appear around the same time as the substantial increase in compile time. 2) any other suggestions on how/where to look into the cause of the compile time?
@dnolen Thanks for the suggestion earlier - I increased from 1gb to 2gb and it sped up from 400s+ to ~300s. Have any further advice based on the above?
@chrishacker make sure that the JVM is running with -server
@dnolen yep, it is
:jvm-opts ["-Xmx2g" "-server" "-Dconf=.lein-env"]
http://stackoverflow.com/questions/19549919/what-does-replace-mean-in-a-leiningen-project-clj-file
ah... k. crap. smh
thx. I'll give that a go
I'm going to repost a question I foolishly posted before getting on a plane from Chicago to Qatar.
Hi all, I'm a clojure noob, and I'm using http://clojure.java.io in a clojure library, but only reading files into data structures at compile time. I'd like to read the same files (at compile time) in a clojurescript program. I've read that it's possible to use clojure IO at compile time, but am unsure how to do it. Can anyone point me to a simple example?
It may get a little messy. I suggest writing it in a .clj
file. I typically use .cljc
for utility functions shared between clj and cljs
hi, with :optimizations :advanced enabled, do we still benefit from goog's module system? i.e., it seems like everything gets compiled into one file so there's no delayed loading of the various modules as they are actually encountered (as there would be in :optimizations :simple or :none modes).
@johanatan Google Closure supports code splitting and deferred loading even with :advanced
optimizations