Fork me on GitHub
#clojurescript
<
2016-02-18
>
richiardiandrea00:02:12

Is there an equivalent to java.util.Properties in JavaScript?

ag01:02:14

Object.keys() ? What are you trying to do?

richiardiandrea01:02:12

@ag just read "KEY=VALUE" (multiple)

richiardiandrea01:02:01

yes I can use ClojureScript split, etc, etc, but just for curiosity

noonian01:02:09

Are you trying to read from a config file at compile time?

richiardiandrea01:02:14

no no just asking if there was an equivalent, but it is actually clunky to use and will use split on lines, it's easier 😄

noonian01:02:45

yeah, I don’t think there are any helpers for that kind of thing

cfleming01:02:36

I’m trying to run the devcards demos, but I can’t get them working.

cfleming01:02:53

Am I right in thinking that lein figwheel in the root of the project should do it?

cfleming01:02:00

Or do I need a cljsbuild first?

cfleming01:02:56

According to the doc that should work.

noonian01:02:07

You need to make sure its building your devcards build, so if you have two builds “dev” and “devcards” should be lein figwheel devcards

noonian01:02:16

I think it defaults to just the first one

cfleming01:02:58

@noonian: Thanks - neither of those work. I’m getting:

clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could not locate cljs/analyzer__init.class or cljs/analyzer.clj on classpath: , compiling:(figwheel_sidecar/utils.clj:1:1)
 at clojure.lang.Compiler.load (Compiler.java:7142)
    clojure.lang.RT.loadResourceScript (RT.java:370)
    clojure.lang.RT.loadResourceScript (RT.java:361)
    … etc etc…

cfleming01:02:28

According to the readme, just going into the directory and running lein figwheel should work.

noonian01:02:36

@cfleming: my bad, I didn’t read you original question closely enough and didn’t realize you meant the demos in the devcards repo. I just cloned the repo and lein figwheel worked fine to build the demos so it must be something wonky with your environemt. Maybe you have Clojurescript pinned at an older version in .lein/profiles.clj or something like that?

cfleming01:02:21

@noonian: No, I have nothing cljs related in profiles.

cfleming01:02:00

And removing profiles altogether doesn’t help either.

cfleming01:02:38

Is there anything else that might affect this I should check?

noonian01:02:56

Nothing springs to mind. It seems like a dependency version conflict thing though, but very strange that it works for me and not you. I assume you are running Java 8?

cfleming01:02:15

lein classpath shows clojurescript 1.7.170 in the classpath, so I have no idea why it wouldn’t find that file.

cfleming01:02:34

I get the same problem with a new project created with lein new devcards hello-world

cfleming01:02:31

@noonian: Yeah, I just saw that now, thanks

cfleming01:02:35

Upgrading as we speak

noonian01:02:35

might be some info there that can help, seems there could be a couple things causing it

cfleming01:02:13

That looks much better, thanks!

cfleming02:02:50

Is there a setting I can change to make the autobuilding refresh happen faster with figwheel?

cfleming02:02:04

Currently when I save, it takes up to about 5 seconds - I assume that’s the polling frequency of the autobuilder.

anmonteiro02:02:28

@cfleming: do you have .cljc files in that project?

anmonteiro02:02:37

not aware of any option, then. I've had problems where rebuilding projects with .cljc files pulled in more dependencies than it should

anmonteiro02:02:43

hence my question

cfleming02:02:08

I guess these days there are probably cljc files in dependencies, but they shouldn’t be changing.

anmonteiro02:02:39

yes, it would matter if they were on your project

cfleming02:02:21

I’m just running the devcards demos, looks like they’re all just cljs

anmonteiro02:02:39

no idea then, sorry

noonian02:02:07

@cfleming: It looks like you can control watching behavior a bit in your figwheel config (I haven’t tried it myself): https://github.com/bhauman/lein-figwheel/blob/30c78fdfc017a0996886cf785b4fc665bd85f2bf/example/project.clj#L139

cfleming02:02:41

@noonian: I was just checking that - that implies that by default it uses FS events.

cfleming02:02:51

I’d expect it to be faster

noonian02:02:09

yeah, it uses the hawk library under the hood: see https://github.com/wkf/hawk#polling-watches

cfleming02:02:41

I’m on OSX, it says it should use the barbary lib by default but I wonder if it’s actually polling instead.

cfleming02:02:47

It certainly looks like it.

cfleming02:02:34

I’m not sure how to check that.

cfleming02:02:51

Ok, I can explicitly set the watcher to :barbary, but it doesn’t seem to improve things much.

cfleming02:02:46

Looking at the server log, it looks like the compilation of the file is taking anywhere from 1.8-2.5 seconds

jotaro07:02:04

hello folks:simple_smile:

jotaro07:02:18

I'have problem at connecting cljs repl in project created with command "lein new duct +example +cljs"

lein repl 
(go)
; open localhost:3000/example
(cljs-repl)
this gives me error : java.net.UnknownHostException: E "E" is the drive letter which my project resides Anybody knows about this ? or What am I doing wrong?

thheller09:02:04

@cfleming depending on your project try :recompile-dependents false, that usually speeds up the build but makes it less reliable

jannis14:02:24

Is there simpler, more idiomatic way to translate something like [user [name email] foo bar [baz]] into [[user [name email]] [foo nil] [bar [baz]]] than with this massive transducer I just wrote? https://gist.github.com/Jannis/e30374115f1065edea11

meow14:02:39

@cfleming: There is also a #C09GR9UJC channel if that helps.

jannis14:02:51

It seems to me that using reduce and building pairs on the fly in the reducing function via a result map would be simpler. But here I am, thinking 'hey, transducers are better!' 😉

meow14:02:56

@jannis: You might look at something like flatten and then constuct what you need with the results.

jannis14:02:49

flatten would drop the hierarchy from the input, which is essential grouping information in this case. I'm not sure how that helps.

slipset14:02:16

@jannis: is there no way you can do something with the input?

jannis14:02:36

(partition-all 2 1 input) -> ((user [name email]) ([name email] foo) (foo bar) (bar [baz]) ([baz])). That's an interesting starting point. Drop a few from that, transform a few and that might be it.

slipset14:02:41

if you could get the input to be [user [name email] foo nil bar [baz]]

meow14:02:47

Okay, then, can't you just destruct things in a function's arguments?

jannis14:02:34

@meow: The input is just an example, it's an arbitrary combination of standalone symbols and symbol-vector pairs.

slipset14:02:42

I guess you’d be a partition away from solving your problem

jannis14:02:06

@slipset: That's a good idea. Insert nil in between any two consecutive standalone symbols.

meow14:02:12

Gotcha. Didn't know it was arbitrary.

slipset14:02:41

or some other thing that shouldn’t be there like :missing

jannis14:02:44

@meow: Sorry, I should have been more explicit about it. Perhaps I thought "something like ..." was enough. 😉

rauh14:02:53

@jannis: I'd take the source of dedupe and edit it and insert a nil upon seeing two consecutive symbols. Then all that's needed is a partition.

meow14:02:19

@rauh: Hello, my friend.

meow14:02:49

Andre Rauh is one sharp guy.

meow14:02:37

Helped me tremendously when I was a newbie.

rauh14:02:23

Looks great, I'd probably generalize it and give it a param instead of hard coding nil

jannis14:02:36

@rauh: Really nice. Checking for type equality rather than value equaility also ensures that nil in inserted between [foo] [bar].

rauh14:02:36

and possibly even a pred? function argument, but that's just flavor.

jannis14:02:46

Yep, good idea.

rauh14:02:15

I always like to generalize and in case this comes up again at some point. Then I can re-use it

jannis14:02:03

With that, my reducing function will now receive either [foo nil] or [nil [bar]] (invalid case but trivial to catch now) or [foo [bar]]. That's awesome.

jannis14:02:58

That's assuming the input data is roughly well formatted of course.

slipset14:02:53

you need to change dedupe to pad-pairs i guess

jannis14:02:08

Yup, just spotted that as well

jannis14:02:19

I guess I want nil instead of ::none for comparing types. Other than that - I like it! Thanks @rauh simple_smile

slipset15:02:44

@jannis: I do believe this works, but it’s not tail recursive

slipset15:02:04

wow, that took me an hour simple_smile

peeja16:02:39

I'm getting ANALYSIS ERROR: Invalid token: : from one of my files, with no obvious cause (I don't have any :s with whitespace on either side). Any chance that's something that's come up before? I feel like I must be doing something dumb, but I can't figure out what.

peeja16:02:21

Oh. Is that : part of the error message and not the invalid token? I'm not sure where to look to figure that out.

darwin16:02:01

hard to give any advice, try to bisect your file to isolate the problem

peeja16:02:23

Yeah, that's what I'm doing. I just thought there was a chance this was something others had hit with a known solution.

dnolen16:02:41

@peeja: it’s a JavaScript code gen error - likley a parsing thing

peeja16:02:48

Any idea what could cause it other than actually having a lone : in the source?

dnolen16:02:29

@peeja: no, but that error should tell you where to look

darwin16:02:48

I can imagine corrupted UTF-8 encoding or something like that (a wild speculation) or any chance that some macro emitted “:<space>”?

peeja16:02:52

Oh, yeah, I cut off the error: file null, line null, column null simple_smile

dnolen16:02:26

@peeja: sound unlikely

dnolen16:02:33

unless you’re using Figwheel or some other tool

peeja16:02:48

although, this is when figwheel loads

peeja16:02:52

I'll run it with cljsbuild

peeja16:02:21

What sounds unlikely?

dnolen16:02:33

the lack of error location

peeja16:02:46

I mean, I copied and pasted it from my terminal…

peeja16:02:53

I didn't make it up simple_smile

dnolen16:02:57

you’re misunderstand what I’m saying

dnolen16:02:05

unlikely unless you are using some other tool

peeja16:02:29

Oh, I see.

peeja16:02:40

With cljsbuild I get a full stacktrace, but no information about the location in my file

dnolen16:02:04

@peeja: the full stacktrace should be more informative

peeja16:02:11

Caused by: java.lang.RuntimeException: Invalid token: :
        at clojure.lang.Util.runtimeException(Util.java:221)
        at clojure.lang.EdnReader.interpretToken(EdnReader.java:282)
        at clojure.lang.EdnReader.read(EdnReader.java:168)
        at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:694)
        at clojure.lang.EdnReader$SetReader.invoke(EdnReader.java:639)
...

dnolen16:02:16

this just sounds like a typo in your code

dnolen16:02:23

by itself somewhere

peeja16:02:36

That's what I'm saying; that was the first thing I looked for and I don't see one

dnolen16:02:59

truncated stack traces are also not helpful

dnolen16:02:14

there was never a full Clojure stacktrace that wasn’t useful

peeja16:02:16

Sorry, having trouble getting it out of tmux. Here we go…

peeja16:02:53

Bisecting may be getting me somewhere…

dnolen16:02:34

Caused by: clojure.lang.ExceptionInfo: Invalid token: : in file src-cljs/frontend/components/insights/project.cljs {:tag :cljs/analysis-error}

dnolen16:02:40

are you sure this file is OK?

peeja16:02:07

I'm sure it's not, I just don't know how

peeja16:02:23

It doesn't contain any : tokens, as far as my searching can find

dnolen16:02:53

ah you probably have a corrupted analysis file

dnolen16:02:59

just clean your build

dnolen16:02:22

you may have killed a process while it was writing this out

dnolen16:02:34

file a ClojureScript JIRA issue to check for this

peeja16:02:39

Aha! It works! Thanks

peeja16:02:25

Is it okay to file a JIRA issue that just has the error and says that cleaning fixed it? Having cleaned, I don't think I have a great way to reproduce it now, unfortunately.

dnolen16:02:08

the problem is simple

dnolen16:02:19

“Corrupted Analysis Files Break Compilation"

dnolen16:02:31

file that as the title, done

dnolen16:02:35

there’s really nothing else more needed

peeja16:02:47

Awesome. I'll do that. Thank you so much!

dnolen16:02:57

yes the stacktrace made it obvious 😉

peeja16:02:09

Noted. I'll skip to that sooner in the future. simple_smile

peeja16:02:26

(And not report problems straight out of Figwheel) 😉

benjyz18:02:37

is there much work being done on full stack Clojure/Clojurescript? i.e. integrated framework

benjyz18:02:06

MeteorJS has some interesting patterns

jannis18:02:40

@slipset: Heh, cool. Must have been a fun problem if you took all that time 😉

slipset18:02:17

@jannis: recursion is not my strong side, but these kinds of problems make for nice puzzles

jrheard18:02:59

dumb question: what's the right way to say that i'm interested in both clojure and clojurescript? do i say i'm into clojure/script? clojure(script)? "clojure and clojurescript"?

echristopherson18:02:23

@jrheard: just say "I'm awesome"

jrheard18:02:42

sound advice

dottedmag19:02:22

(clojure :optional script)

anmonteiro20:02:55

@peeja: FWIW, I've also had that happen when having a println in a macro

peeja20:02:19

Huh, good to know.

peeja20:02:21

Do you know why?

jrheard20:02:07

https://github.com/plumatic/schema says Clojure(Script), i'll do that i guess

anmonteiro20:02:07

no idea, I don't have any knowledge of the macro-expansion process

cfleming21:02:57

@thheller: Thanks - in the end I just commented things out until the delay was acceptable for a demo

cfleming21:02:22

@meow: Thanks, I should have thought to check that

Alex Miller (Clojure team)21:02:25

The Google Summer of Code 2016 organization application is due tomorrow and David Nolen and I worked on completing it today. However, this requires community help to get anywhere. Right now we need: 1) project ideas http://dev.clojure.org/display/community/Project+Ideas+2016 2) mentors for those ideas Presuming Clojure is accepted as an org, students will then be able to propose those projects in March.

Alex Miller (Clojure team)21:02:41

there is also now a #C0N1QHE3W channel

josh.freckleton22:02:02

How do I deploy a clojurescript app on Heroku? Should I compile down to js and deliver static assets? But what if I want to have a clojure backend? help? 😬

dnolen22:02:42

@josh.freckleton: production ClojureScript means advanced compilation to JavaScript and delivering that asset in the usual way

josh.freckleton22:02:08

@dnolen Do people commonly use ring/`composure`, or something like node/`express`? is there a community preference?

josh.freckleton22:02:24

(in retrospect, that's maybe a bad question. I'm overwhelmed with decisions as I'm learning this ecosystem, just don't want to be layering bad decisions on top of each other)

shaun-mahood22:02:29

@josh.freckleton: Are you wondering about the clojurescript side or the clojure side? Since you're learning, what part are you focused on right now? We can discuss further in #C053AK3F9 if you want to go into specifics

dnolen22:02:47

@josh.freckleton: not a bad question, people use pair ClojureScript with Clojure

dnolen22:02:00

other language pairings exist but they are less common

josh.freckleton23:02:56

@dnolen: thanks! that helps me eliminate another decision simple_smile @codefinger: Hrm, I read through that but it's not clear why I'd need node.js mixed in with clj/cljs... Is this article the most "idiomatic" way of doing things? And to the second article, I breezed through it previously, but was confused at how there are a few different high-ranking search results for this problem with all different solutions...I'll read these through more closely and hopefully figure it out! @shaun-mahood: Thanks for the recommendation Shaun, just posted in #C053AK3F9 with a couple more details simple_smile It totally rocks how this community jumps in on helping eachother, I'll make sure I pay it back to other learners! I'm on the #C053AK3F9 channel if you have any more advice on this!

jstokes23:02:05

any suggestions for a charting library that works well with clojurescript? im fairly new to clojurescript (have some clj experience) and want to try to put together a ui that is mostly just a metrics dashboard

jstokes23:02:42

ive got something simple up with highcharts, but i feel like im not “correctly” using reagent rerenders when i want to update charts

jstokes23:02:03

i.e. add new data points

jstokes23:02:40

great, this is exactly the kind of thing i was looking for