This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-10
Channels
- # aws (3)
- # beginners (186)
- # boot (25)
- # cider (2)
- # cljsrn (57)
- # clojure (161)
- # clojure-boston (1)
- # clojure-dusseldorf (11)
- # clojure-italy (5)
- # clojure-russia (20)
- # clojure-serbia (1)
- # clojure-spec (10)
- # clojure-uk (16)
- # clojurescript (207)
- # community-development (86)
- # core-async (2)
- # cursive (40)
- # datascript (1)
- # datomic (2)
- # editors (5)
- # emacs (8)
- # funcool (1)
- # gsoc (2)
- # hoplon (2)
- # jobs (5)
- # leiningen (3)
- # liberator (18)
- # luminus (18)
- # off-topic (106)
- # om (2)
- # onyx (5)
- # pedestal (7)
- # powderkeg (7)
- # re-frame (7)
- # remote-jobs (1)
- # ring-swagger (4)
- # rum (5)
- # slack-help (1)
- # untangled (11)
- # yada (48)
It did the trick !
I also used :print-input-delimiter true
and used this perl script to split the output file on the // Input
delimiter. Then sorted the files by descending size.
#!/usr/bin/perl
undef $/;
$_ = <>;
$n = 0;
for $match (split(/(?=\/\/\sInput)/)) {
open(O, '>temp' . ++$n);
print O $match;
close(O);
}
Anyone seen a situation where a map is in atom a
and (swap! a assoc-in [:L1 :L2] val)
fails silently if :L2
already exists. But succeeds if :L2
does not exist in the map?
nevermind. I was doing another assoc-in
elsewhere, after the fact, clobbering this particular swap!
.
Has anyone tried using goog.net.Jsonp recently? I can require/import XhrIo but no luck with the Jsonp
@iku000888 what is Jsonb
? I only know of JsonP
?
Probably meant jsonp. Or perhaps it's the Postgres thing : http://stackoverflow.com/questions/22654170/explanation-of-jsonb-introduced-by-postgresql
Hi! I'm trying to use Pedestal ( clj + cljs SPA). All browser show me a message that thet can't load my SPA: Refused to load the script 'http://localhost:8080/js/compiled/app.js' because it violates the following Content Security Policy directive: "script-src 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http:". 'strict-dynamic' is present, so host-based whitelisting is disabled.
@thheller sorry, it is jsonp. I can't stop making that typo for some weird reason. 😞
and for my specific problem cljs-ajax did the job at the end of the day, so everything is good except it was a weird experience.
@iku000888 goog.net.Jsonp
is a class so use it via (:import [
and then just Jsonp
. a blank goog.net.Jsonp
is not correct
(js/goog.net.Jsonp. ...)
also works but :import
is better. ensures that you don't forget the require/import
Hi. Does someone know why cljc namespaces are analysed every time a namespace is compiled which depends on the cljc namespace? This results in multiple analyses of the same cljc namespaces during one compilation. I have verbose compiler output on and see many “Reading analysis cache for” messages.
@thheller a blog post or piece of documentation explaining requires/imports in cljs, especially wrt GCL, would be great
pesterhazy: I’ve been thinking about writing that post. Can you scan your code for some places where you found it non-trivial to nail down the syntax?
Things I can think of :
- Constructors
- regular functions
- constants
- things like goog.Timer
where the namespace has functions but also is a constructor
What else?
that's a pretty good list
goog.async.Delay is also a candidate
- how do you call things? (goog.async.nextTick)
works, as does (goog.async/nextTick)
and (without adv comp) (js/goog.async.nextTick)
- goog.object as special case?
- constants defined from outside
(in project.clj or whereever)
closure-defines
goog/DEBUG (see discussion here: https://clojurians-log.clojureverse.org/cljs-dev/2017-05-08.html)
goog.async.Delay is just a constructor no?
goog.object - what’s special about it?
constants defined from outside - referring to closure-defines here or something else?
clojure-defines, yes
goog.object is loaded by default, for one thing (so you can in principle skip requiring it)
correct about Delay
Will try to put something together tomorrow
cool!
@martinklepsch the goog.string.format
also deserves to be included IMO
@U0CK4CKAP it’s special because it’s a namespace with a single function?
is the function goog.string.format/format
or goog.string/format
?
@martinklepsch yeah, it’s a quirk that a lot of people fall into:
(require '[goog.string :as string]
'[goog.string.format])
(string/format ....)
Ah interesting. Did not know that one. thanks
I’ll ping you some time tomorrow with a draft, maybe you can just briefly check if there are no obvious mistakes
@U0CK4CKAP do you know why it is done that way? DCE I presume?
sounds good 👍 I don’t know why it’s done that way, I simply accepted it as a quirk of GCL without thinking
I'm usually using trial and error, but it would be great to have a few paragraphs by someone who speaks from (more) authority
in cljs, how do I convert a char (which is represented as a string) to itsw unicode value ?
@pesterhazy :import
classes and :require
namespaces is about it.
so I have some weird code where (.charCodeAt (str some-char-object) 0) works but (.charCodeAt some-char-object 0) fails
@darwin : is ocall supposed to work on string types? i.e. (ocall s "charCodeAt" 0) when s is a string
any problem in that? s
is a String object in JS, so it has normal methods like your charCodeAt
ah, ok, that the debug-time validation: https://github.com/binaryage/cljs-oops/blob/master/src/lib/oops/codegen.clj#L43
I forgot about it, maybe we should relax it or you should do it different way just in this case
string methods have proper externs, so you can fall back to normal cljs js interop in this case it is safe
Wondering if anyone can comment on the idiomatic-ness / correctness of the following variants:
cljs.user=> (import '[goog Timer])
cljs.user=> (require '[goog.Timer :as timer])
cljs.user=> Timer.TICK ;; => "tick"
cljs.user=> timer/TICK ;; => "tick"
cljs.user=> (Timer. 1) ;; => #object[Object [object Object]]
cljs.user=> (goog.Timer. 1) ;; => #object[Object [object Object]]
@martinklepsch import
is specifically for namespaces that are also constructors, I would not use require
in this case
I have a picture or a list of pictures in a DB. I retrieve them in my server (with bytearray format). I use cljs-ajax to GET but I don't know how to handle the display
> this only applies to Google Closure Library stuff
reason for that being goog
being automatically defined?
I can see the object in my console #object[java.io.ByteArrayInputStream 0x51aae898 "java.io.ByteArrayInputStream@51aae898"]
`
@romain I guess you’ll need to convert the ByteArrayInputStream to something that can be handled as response by your web server
when you see something containing
or similar in your JS console that usually means some object could not be coerced into a response in any better way than the string representation you’re seeing
@romain not sure how you’d send it but I guess it’s worth asking in #clojure how to send a ByteArrayInputStream as image file using ring (assuming you use ring)
@romain try debugging your endpoint using curl
, once it does what you expect you may run into clojurescript problems/questions 🙂
@martinklepsch the reason being who would do that except Google Closure Library
Doen anybody know how is cljs ajax supposed to deal with binary data? It returns a value of type #object[String "function String() { [native code] }"] and I'd like to get a nodejs buffer or a byte array or something like that.
When we do a release of our cljs app, built with lein cljsbuild
is there a way to incorporate a build number or release number into the compiled app ?
Hello all, Why this
curl "https://*******.com/**********/servicedesk/odata/login?$format=JSON" --data "username=*********&password=********"
the response is ok and
(ajax/ajax-request
{:uri "https://*******.com/**********/servicedesk/odata/login?$format=JSON"
:method :post
:params {:username "********"
:password "********"}
:format (ajax/url-request-format)
:response-format (ajax/json-response-format {:keywords? true})
:error-handler #(js/console.log "ERRO !!!")
:handler #(js/console.log %)
:headers {"Origin" ""
"viaUI" "1"}
})
Gives this error?
XMLHttpRequest cannot load https://*******.com/**********/servicedesk/odata/login?$format=JSON. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access.
@fabrao you most likely need to check your CORS configuration on the host you’re trying to call.
curl is different from browser since browser will have additional restrictions to call cross site resources
if you write a server side function that calls the URL, it will work and is equivalent to what curl is doing
so, I have to write server side function to call this ajax-request and use cljs -> server to verify?
When I cannot reach a host directly from my browser, I usually route them through my own backend, yes.
do i need to do something to response i get with ajax-cljs ? i wanted to iterate through json i got ( [ {map1} {map2} ] but i get [object Object] is not ISeqable in browser what do i need to do to iterate over that list of maps?
@martinklepsch thanks for pointing me curl. I wasn't understanding why the response type was text/html and it was because of double wrapping the response lol
@lepistane try (js->clj json-object)
I have a piece of code which works fine in optimizations none, but breaks under optimizations advanced. I'm 99.9% sure it has nothing to do with name mangling of js functions being called. I have a data file (531 lines) -- all lines parse + display fine in optimizations none Only some of the lines display fine under optimizations :advanced -- in particular, lines where the charAtCode is < 128. For some weird reason, for lines with unicode vhars, somethin breaks. To repeat: I have 531 lines, some of which use char < 128, some use unicode. optimizations none/advanced agree on the < 128; but diverse on unicode. I'm not even sure what to Google for. Anyone run into a similar problem before?
@thheller couldnt make it work this is my intention 1. have spring backend online with endpoints that i shoot at with cljs-ajax 2. use response and write on page using reagent closest i got is write response on console but even that i cant iterate through (js->clj json) didnt help
@rauh: I should clarify. My functions return [:ok data] or [:error msg] so I'm not getting exceptions advanced/none, for char < 128, both return the same [:ok data] then, for unikcode chars, none returns [:ok data] while advanced returns [:error msg]
yeah, sorry about this, the code is a giant mess and I don't havea minimail failure case yet
in short, each of the 531 lines contains a single char; some chars have asci value < 128, other are full unicode; and the ful unicode ones behave differently under optimizations advnejd/none; but I should make a minimal failure example
@qqq try this https://github.com/binaryage/dirac/blob/a9f5d1c842ff43934b4fc5ed665d3fcd903a655c/project.clj#L191
background info: https://github.com/google/closure-compiler/issues/1704
Hi all, I posted this to #clojure, then realised this may be a better forum. Hoping someone can help 🙂
I set up lein on a cloud9 container a few days ago and was trying to run lein figwheel
. I've set :verbose true
in the project.clj compiler details, but I'm getting nothing more verbose than Subprocess failed
after Compiling resources/public/js/compiled/out/cljs/core/async.cljs
. Nothing seems to be output to figwheel_server.log, so was wondering if anybody knows of anywhere else it might be logged?
1) My cljs code requires 100kb of data to run. 2) Apparently hardcoding this data by (1) reading it in via a clj macro, parsing it, and storing it as cljs data structures is not a good idea -- as it causes the cljs compiler to run for very long time and ver long compile cycles (who'd thought!?) 3) So now, my question is: what is the best way to rxload this data at runtime?
so it's a bad idea to encode it into a base 16 string, hard code it as a var in index.html and have cljs parse it? 🙂
if I load thsi via xhr, now, suddenly, these functions need to take an additional argument, or depend implicitly on the vaue of some atom
well you'll probably have start
fn, just make sure everything is setup properly before the app does anything and you should be fine
its a good idea to never have any global state, so I usually don't mind the additional argument
if you'Re dealing with fonts / glyphs, you need to store the buonding boxes of each (font-family, unicode-id) pair
I guess the problem is,I'm not genunely asking for an opinuion: I think I've already subsconsiouly deicded I want to hard code the data, and is now just looking for a way to do so
sorry for the confusing quesdtino; your arguments are valid; I need to figure out why I'm so attached to hard coding this data
I understand the resistance to passing around extra arguments ... I never wanted to do that. nowadays I'm doing it everywhere and hate the places I didn't. usually I have something like context
I pass around as the first argument to any function that needs any kind of state
(def data [hard coded])
(def c1 (func of data))
(def c2 (func of data))
(def c3 (func of c1 c2))
where c1, c2, c3 are caches of expensitve computationscontext contains the data but also a cache, so the fns can either look up the data from cache or calculate it and put it in the cache
so now, in teh hard code approach, IK'm guaranteed that data, c1, c2, c3 stay the same .... but with te context approach, I lose that guarantee
I just code that way, it is working well for me. no idea what everybody else is doing.
I appreciate you sharing this approach, and one day I may switch to it; but I don't think it's going to work for me right now.
optimizations none compile time went from 1s to 5s, and I have to constantly clear the cache
I suspect the problem may be I'm parsing the 100kb data into lots of tiny cljs data objects