This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-05
Channels
- # announcements (17)
- # architecture (5)
- # babashka (12)
- # beginners (155)
- # calva (18)
- # chlorine-clover (2)
- # cider (57)
- # circleci (2)
- # clojure (151)
- # clojure-europe (4)
- # clojure-gamedev (20)
- # clojure-italy (18)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-spec (8)
- # clojure-uk (95)
- # clojurescript (70)
- # core-async (68)
- # css (3)
- # data-science (13)
- # datascript (1)
- # datomic (16)
- # docker (2)
- # figwheel-main (41)
- # fulcro (34)
- # graalvm (6)
- # graphql (7)
- # jobs (14)
- # joker (2)
- # kaocha (1)
- # leiningen (2)
- # malli (3)
- # midje (2)
- # overtone (1)
- # reagent (8)
- # reitit (6)
- # ring-swagger (1)
- # schema (2)
- # shadow-cljs (6)
- # spacemacs (3)
- # specter (5)
- # timbre (3)
- # uncomplicate (1)
is there an idiomatic way to limit precision when generating doubles from a spec? I have the following but I really just want to generate dollar amounts
(spec/def ::amount (spec/double-in :Nan? false :infinite? false))
You could generate integers, then use a function to divide them by 100.
Where by 'use a function' I think I mean using gen/fmap as described here: https://clojure.org/guides/spec
Hello: apologies if this has been asked before, but is there a goto template for react-native development?
• Re-natal : Figwheel + RN https://github.com/drapanjanas/re-natal • If you want run http://Expo.io with Shadow-CLJS : https://github.com/PEZ/rn-rf-shadow Note that you have the channel #cljsrn for all the CLJS and React Native stuff
• Re-natal : Figwheel + RN https://github.com/drapanjanas/re-natal • If you want run http://Expo.io with Shadow-CLJS : https://github.com/PEZ/rn-rf-shadow Note that you have the channel #cljsrn for all the CLJS and React Native stuff
Did anyone try to decode binary transit data in js / cljs?
E.g. via goog.crypt.base64/decodeStringToByteArray (https://google.github.io/closure-library/api/goog.crypt.base64.html)
You probably mean "encode"? If so, Transit already supports binary data. And it uses base64 for it.
@U2FRKM4TW transit-js and transit-cljs only support the :json format, right? And I only need decoding
There is something with msgpack it seems https://www.reddit.com/r/Clojure/comments/8nb199/msgpackcljs_a_clojurescript_implementation_of/
I am still not sure what you mean. You pass the data to a Transit writer on one end, you get it out of a Transit reader on the other end. Why do you need to explicitly do something with base64?
(require '[cognitect.transit :as t])
(let [out (ByteArrayOutputStream.)
writer (t/writer out :json)]
(t/write writer (.getBytes "Clojure" "UTF-8"))
(let [in (ByteArrayInputStream. (.toByteArray out))
reader (t/reader in :json)]
(String. (t/read reader))))
=> "Clojure"
And something similar should work in CLJS just as well - you'd get a Uint8Array
instead of bytes[]
.Here, if you scroll a bit, is a table with all data types supported by Transit: https://github.com/cognitect/transit-format#how-it-works
bytes
is in there.
Thank you. However I want the binary format because it is more compact than json. Not for a regular web app case. It will have to be like this: encoding clj data -> transit msgpack bytes -> base64 string. On the cljs side: decode base64 to binary integer array -> cljs data
I see. Just make sure you do actual measurements, because base64 eats away more than 30% of space. Just out of curiosity - why do you even need base64, why not just transfer binary data?
I need to put the dat in a cloudformation template
maybe it could be higher order base, but then I would also have to write that decoding code
My point is that it's very likely that JSON will end up being smaller than base64-encoded binary. :) I just tested it on a few samples, and that's indeed the case.
I've tested in on a few samples where it wasn't the case 🙂 But it depends on other things as well. I heavily use integers for instance
But i'm happy to have received your feedback and given the current state of transit libraries I'll try to get the maximum out of transit-cljs
It's not open source yet, but it will be when it's done. The basic idea is to replace repeated and known entities by integers. For my use case it is much more compact than Gzip for instance
Hi, I am trying to find my way around inside of a CLJS REPL.
cljs.user> (require 'cljs.analyzer.api)
nil
cljs.user> (cljs.analyzer.api/all-ns)
#object[Error Error: No protocol method IDeref.-deref defined for type null: ]
cljs.core/missing-protocol (target/public/cljs-out/admin/cljs/core.cljs:316:4)
cljs.core/-deref (target/public/cljs-out/admin/cljs/core.cljs:671:1)
cljs$core$deref (target/public/cljs-out/admin/cljs/core.cljs:1452:4)
(target/public/cljs-out/admin/cljs/analyzer/api.js?zx=huuvsoaczikn:197:73)
(target/public/cljs-out/admin/cljs/analyzer/api.js?zx=huuvsoaczikn:183:33)
(target/public/cljs-out/admin/cljs/analyzer/api.js?zx=huuvsoaczikn:193:33)
(target/public/cljs-out/admin/cljs/analyzer/api.js?zx=huuvsoaczikn:179:33)
This is a bit confusing
Is there a way to dig deeper and understand what this "null" is about?
The CIDER message is as follows:
1. Unhandled clojure.lang.ExceptionInfo
#object[Error Error: No protocol method IDeref.-deref defined for
type null: ]
{:type :js-eval-exception,
:error
{:status :exception,
:value
"#object[Error Error: No protocol method IDeref.-deref defined for type null: ]",
:ua-product :firefox,
:stacktrace
"cljs$core$missing_protocol@http://exchange-cljs.test/cljs-out/admin/cljs/core.js:309:9\ncljs$core$_deref@http://exchange-cljs.test/cljs-out/admin/cljs/core.js:2162:17\ncljs$core$deref@http://exchange-cljs.test/cljs-out/admin/cljs/core.js:4927:18\ncljs.analyzer.api.all_ns.cljs$core$IFn$_invoke$arity$1@http://exchange-cljs.test/cljs-out/admin/cljs/analyzer/api.js?zx=huuvsoaczikn:197:73\ncljs$analyzer$api$all_ns@http://exchange-cljs.test/cljs-out/admin/cljs/analyzer/api.js?zx=huuvsoaczikn:183:33\ncljs.analyzer.api.all_ns.cljs$core$IFn$_invoke$arity$0@http://exchange-cljs.test/cljs-out/admin/cljs/analyzer/api.js?zx=huuvsoaczikn:193:33\ncljs$analyzer$api$all_ns@http://exchange-cljs.test/cljs-out/admin/cljs/analyzer/api.js?zx=huuvsoaczikn:179:33\n@http://exchange-cljs.test/cljs-out/admin/figwheel/repl.js line 751 > eval:1:94\n@http://exchange-cljs.test/cljs-out/admin/figwheel/repl.js line 751 > eval:9:3\nfigwheel$repl$eval_javascript_STAR__STAR_@http://exchange-cljs.test/cljs-out/admin/figwheel/repl.js:751:24\n@http://exchange-cljs.test/cljs-out/admin/figwheel/repl.js:799:56\nG__12816__2@http://exchange-cljs.test/cljs-out/admin/cljs/core.js:35676:106\nG__12816@http://exchange-cljs.test/cljs-out/admin/cljs/core.js:35943:20\nfigwheel.repl.ws_connect.cljs$core$IFn$_invoke$arity$variadic/</<@http://exchange-cljs.test/cljs-out/admin/figwheel/repl.js:1053:30\ngoog.events.EventTarget.prototype.fireListeners@http://exchange-cljs.test/cljs-out/admin/goog/events/eventtarget.js:284:23\ngoog.events.EventTarget.dispatchEventInternal_@http://exchange-cljs.test/cljs-out/admin/goog/events/eventtarget.js:381:26\ngoog.events.EventTarget.prototype.dispatchEvent@http://exchange-cljs.test/cljs-out/admin/goog/events/eventtarget.js:196:34\<http://ngoog.net|ngoog.net>.WebSocket.prototype.onMessage_@http://exchange-cljs.test/cljs-out/admin/goog/net/websocket.js:426:8\n"},
:form (cljs.analyzer.api/all-ns),
:js
"try{cljs.core.pr_str.call(null,(function (){var ret__6754__auto__ = cljs.analyzer.api.all_ns.call(null);\n(cljs.core._STAR_3 = cljs.core._STAR_2);\n\n(cljs.core._STAR_2 = cljs.core._STAR_1);\n\n(cljs.core._STAR_1 = ret__6754__auto__);\n\nreturn ret__6754__auto__;\n})());\n}catch (e184785){var e__6755__auto___184786 = e184785;\n(cljs.core._STAR_e = e__6755__auto___184786);\n\nthrow e__6755__auto___184786;\n}"}
repl.cljc: 578 cljs.repl$evaluate_form/invokeStatic
repl.cljc: 499 cljs.repl$evaluate_form/invoke
piggieback_impl.clj: 207 cider.piggieback/eval-cljs
piggieback_impl.clj: 206 cider.piggieback/eval-cljs
piggieback_impl.clj: 243 cider.piggieback/do-eval/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 665 clojure.core/apply
core.clj: 1973 clojure.core/with-bindings*
core.clj: 1973 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
piggieback_impl.clj: 220 cider.piggieback/do-eval
piggieback_impl.clj: 219 cider.piggieback/do-eval
piggieback_impl.clj: 266 cider.piggieback/evaluate
piggieback_impl.clj: 264 cider.piggieback/evaluate
Var.java: 384 clojure.lang.Var/invoke
piggieback_impl.clj: 297 cider.piggieback/wrap-cljs-repl/fn/fn/fn
piggieback_impl.clj: 190 cider.piggieback/enqueue/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 171 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 170 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 834 java.lang.Thread/run
@holtzermann17 you are not in a self-hosted REPL so you can only access the analyzer from a clojure REPL
the null is about the compiler env not being initialized, since that is initialized on the clojure side of things
OK, that's interesting.
I do have Clojure listed as a dependency in the project, but that's not enough?
no you misunderstand how things work. you are in CLJS REPL so things you eval'd run in the JS engine after being compiled by the CLJ side
but what exactly are you after? you might need to go self-hosted depending on what you are doing
Yeah, just hoping to use all-ns
at the moment. Ah. I could try for the [self-hosted](https://practicalli.github.io/clojurescript/quickstart/self-hosted-clojurescript.html) compilation...
Sounds like a bit of heavy lifting for this limited purpose but it might be interesting.
all-ns is intended to be used from CLJ (or from macros), so its not directly accessible in the REPL unless you are using self-hosted
Maybe compiling a self-hosted version will be a good "learning project" for me for this weekend
Thanks for the helpful guidance!
Guys, i'm just getting into frontend, how do you approach css\layout side of things is there something specific for that?
there's something to be said for just sticking with vanilla css, especially if it's newish to you. it'll be by far the easiest to google etc
i have no problems with java or clojure, but it's a bit confusing how it all works together, atm the hardest part is css\layouts\rendering side of react components and how static\client rendering fits into a whole
and in my experience it's pretty rare to need to generate css. if you do, then https://github.com/noprompt/garden might make sense
but probably best to just define explicit css classes and assign the classes to your react components
how do professionals approach css and layouts in their apps? Just to see if there is a direction to go to.
That's a big question - I would look for general CSS and design resources specific to the kind of work you want to do. In general, I think the biggest changes in the past 10 years have been the rise of preprocessors and the way that React has brought styles into React components with JSX.
There are also things like https://tailwindcss.com/ and https://bulma.io/
Yes, though flexbox is a browser standard (so much nicer to use than what we had 10 years ago), where bootstrap is another framework
The CSS resources I've used the most have been https://alistapart.com/ https://abookapart.com/products/ https://css-tricks.com/ (in particular https://css-tricks.com/snippets/css/a-guide-to-flexbox/ and https://css-tricks.com/snippets/css/complete-guide-grid/ may help you get up to speed on some nice things)
A couple of component libraries specific to Reagent (if that's what you're using) https://re-com.day8.com.au/ https://github.com/gadfly361/soda-ash
Personally, I tend to throw all my CSS directly into my reagent components as I'm figuring things out (https://github.com/bhauman/devcards is amazing for this) and move it into classes later (using garden to generate my stylesheets)
Good luck - there's a lot to learn, and I found it particularly challenging to translate from general resources to CLJS when I was getting started.
No problem, hope things go well!