[ClojureScript] Re: HTML DOM to Edn

2015-08-15 Thread Matthew Molloy
Well that's a Clojure solution, not Clojurescript.  Fortunately it's such a 
powerful language that I can usually get most of what I want with a couple of 
functions.

(def attributes (js/Function.
 "element"
 "out = []
 for (var i = 0; i < element.attributes.length; i++) {
 var x = element.attributes[i]
 out.push([x.nodeName, x.nodeValue])
 }
 return out"))

(defn dom2edn [element]
  (if (.-tagName element)
(let [
  a (-> element .-tagName .toLowerCase keyword)
  b (into {} (map (fn [[a b]] [(keyword a) b]) (js->clj (attributes 
element
  children (filter identity (map dom2edn (array-seq (.-childNodes 
element
  ]
  (if (not-empty children)
[a b children]
[a b]))
(if (.-textContent element)
  (let [
trimmed (-> element .-textContent .trim)
]
(if (not-empty trimmed) trimmed)

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Re: HTML DOM to Edn

2015-08-15 Thread Matthew Molloy
(def attributes (js/Function.
 "element"
 "out = []
 for (var i = 0; i < element.attributes.length; i++) {
 var x = element.attributes[i]
 out.push([x.nodeName, x.nodeValue])
 }
 return out"))

(defn dom2edn [element]
  (if (.-tagName element)
(let [
  a (-> element .-tagName .toLowerCase keyword)
  b (into {} (map (fn [[a b]] [(keyword a) b]) (js->clj (attributes 
element
  children (filter identity (map dom2edn (array-seq (.-childNodes 
element
  ]
  (if (not-empty children)
[a b children]
[a b]))
(if (.-textContent element)
  (let [
trimmed (-> element .-textContent .trim)
]
(if (not-empty trimmed) trimmed)

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Re: HTML DOM to Edn

2015-08-15 Thread Matthew Molloy
On Sunday, August 16, 2015 at 12:04:23 PM UTC+8, Khalid Jebbari wrote:
> I know that Enlive does this internally, it uses JSoup from Java to convert 
> to plain Clojure data structure. Not sure it exposes this functionality 
> directly though.

Well that's a Clojure solution, not Clojurescript.  Fortunately its such a 
powerful language that I can usually get most of what I want with a single 
function

(defn dom2edn [element]
  (if (.-tagName element)
(let [
  a (-> element .-tagName .toLowerCase keyword)
  b (into {} (map (fn [[a b]] [(keyword a) b]) (js->clj (attributes 
element
  children (filter identity (map dom2edn (array-seq (.-childNodes 
element
  ]
  (if (not-empty children)
[a b children]
[a b]))
(if (.-textContent element)
  (let [
trimmed (-> element .-textContent .trim)
]
(if (not-empty trimmed) trimmed)

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] HTML DOM to Edn

2015-08-15 Thread Khalid Jebbari
I know that Enlive does this internally, it uses JSoup from Java to convert to 
plain Clojure data structure. Not sure it exposes this functionality directly 
though. 

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Problem following quick start

2015-08-15 Thread bielllobera
I have followed the quick start successfully until the "Less Boilerplate" 
section 
(https://github.com/clojure/clojurescript/wiki/Quick-Start#less-boilerplate), 
but I get the following error in the console after modifying build.clj and 
index.html as suggested to remove the boilerplate: Uncaught ReferenceError: 
goog is not defined(anonymous function) @ min.'s:1

This is the error that we got at the beginning of the guide that forced us to 
add the boilerplate, but after adding :main to build.clj it shouldn't happen. I 
have double checked everything three times to make sure I have followed the 
instructions properly. I'm using OS X, any help will be appreciated.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] [ANN] Planck 1.5

2015-08-15 Thread Mike Fikes
http://planck.fikesfarm.com 

New Features

Brace highlighting (cursor temporarily jumps to previous matching brace)
Improved require & require-macros (:as etc., error reporting)
file-seq support
load-file REPL special
Exit codes (1 if unhandled exception, or explcit via planck.core/exit)
Hit Ctrl-C to get out of a form and get a new prompt
Doc output improvement
Google Closure indexed so you can require things from there.
Ship with cljs.test / cljs.pprint and lots of Google Closure.
-d / --dumb-terminal option (facilitates rlwrap)
-l / --legal to show licenses / copyrights
Changes

Rearranged so that there is now a planck.core to hold core fns
Smaller binary (gzipped ClojureScript runtime internally)
Fixes

Don't lock up on syntax error

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Leiningen for node.js + Cljs in Cljs

2015-08-15 Thread Divyansh Prakash
Something like planck but for linux would be good.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Leiningen for node.js + Cljs in Cljs

2015-08-15 Thread kovas boguta
As a data point, https://github.com/mfikes/planck starts up in about
200 milliseconds IIRC, so theres nothing fundamental about
Clojurescript that prevents what you're asking for.

On Sat, Aug 15, 2015 at 2:25 PM, Divyansh Prakash
 wrote:
> I love Clojure, but am severely hindered by not being able to write scripts 
> due to high start-up times. Once I have a REPL running and hot, I actually 
> don't mind it much, but it would still be fun to have a tool that lets me say
>
> lein-node new fun-script
> cd fun-script/
>
> And then have an instant REPL up by saying
>
> lein-node repl
>
> .. and generally hacking away like we do in Clojure.
> But all of it without the JVM.
> Basically, a first-class JS host for Cljs.
>
> I would love to be able to write quick and dirty scripts in Clojure.
> Is there something like this available that I'm missing out on?
> Or does this sound completely heretical?
>
> --
> Note that posts from new members are moderated - please be patient with your 
> first post.
> ---
> You received this message because you are subscribed to the Google Groups 
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojurescript+unsubscr...@googlegroups.com.
> To post to this group, send email to clojurescript@googlegroups.com.
> Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Leiningen for node.js + Cljs in Cljs

2015-08-15 Thread Christian Weilbach
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 15.08.2015 20:25, Divyansh Prakash wrote:
> I love Clojure, but am severely hindered by not being able to write
> scripts due to high start-up times. Once I have a REPL running and
> hot, I actually don't mind it much, but it would still be fun to
> have a tool that lets me say
> 
> lein-node new fun-script cd fun-script/
> 
> And then have an instant REPL up by saying
> 
> lein-node repl
> 
> .. and generally hacking away like we do in Clojure. But all of it
> without the JVM. Basically, a first-class JS host for Cljs.
> 
> I would love to be able to write quick and dirty scripts in
> Clojure. Is there something like this available that I'm missing
> out on? Or does this sound completely heretical?
> 
People in general have the wrong impression of the JVM as the
bottleneck. A simple hello world in Java or even a plain Clojure REPL
without leiningen takes less than a second to run (on newer machines
as my 5 year old laptop):

➜  ~  time clojure -e '(println "Hello world")'
Hello world
clojure -e '(println "Hello world")'  1,17s user 0,63s system 121% cpu
1,473 total

http://blog.ndk.io/2014/02/11/jvm-slow-startup.html

lein-exec also performs fairly quickly for me.

The problem is that you need to run the leiningen dependency
management and most likely the compilation of all the namespaces you
require. node.js in general is not faster than the JVM and a weaker
runtime (but it has some benefits like lower management requirements).
I think the problem is largely AOT compilation and caching as this is
how core cljs startup time itself got sped up. There have been some
attempts lately to bring down startup time of Clojure projects, but I
am haven't followed closely.

http://blog.ndk.io/2014/02/11/jvm-slow-startup.html
http://dev.clojure.org/display/design/'Lean'+Runtime

See also:
https://github.com/technomancy/leiningen/wiki/Faster

Christian
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQEcBAEBAgAGBQJVz4vKAAoJEKel+aujRZMkf6oH/0Q8Pl6fRTK6xY6UN/ghn7R/
6JZWlzlD9HVTcysXwxjVs3Zy5OCgCSfh7Vr9bnjgjc32QC3gCzSmSVs45rTxqSFC
INGX0ilRZ9IB2JKjy+O0f2zTqUps0WWI3YOc0W9KD79NVZnAB1oTiXFQ5fJXiBqd
/gNelFlHVewpsgnCyajd8WpDUc539b4dJcf+tdDo8maHeD12AbrtIKaKV72RKDE1
3OFsRa7BwuOraSM2W+56QGCZHCfkdO521zII/1u734mNCHjpNaLXXhec5Zbgauja
OCOCFCRIUtNRtxOA8ApXsqoToTcFPKuRIDd9ZLxRIN/1zcKvECgKtWtTwuM2m10=
=x6Wk
-END PGP SIGNATURE-

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Leiningen for node.js + Cljs in Cljs

2015-08-15 Thread Mike Fikes
Hi Divyansh,

Joel Martin has this for Node.js:

sudo npm install -g cljs-repl

and then you can start up a REPL with

   cljs

If you are on OS X you can try Planck:

   http://planck.fikesfarm.com

Neither use the JVM. (While Joel’s uses Node, Planck uses the JavaScriptCore 
that ships with OS X.)

Planck is specifically catering to scripting: 

  http://blog.fikesfarm.com/posts/2015-08-01-planck-scripting.html
  http://blog.fikesfarm.com/posts/2015-07-29-clojurescript-mainia.html

- Mike

> On Aug 15, 2015, at 2:25 PM, Divyansh Prakash  
> wrote:
> 
> I love Clojure, but am severely hindered by not being able to write scripts 
> due to high start-up times. Once I have a REPL running and hot, I actually 
> don't mind it much, but it would still be fun to have a tool that lets me say
> 
>lein-node new fun-script
>cd fun-script/
> 
> And then have an instant REPL up by saying
> 
>lein-node repl
> 
> .. and generally hacking away like we do in Clojure.
> But all of it without the JVM.
> Basically, a first-class JS host for Cljs.
> 
> I would love to be able to write quick and dirty scripts in Clojure.
> Is there something like this available that I'm missing out on? 
> Or does this sound completely heretical?
> 
> -- 
> Note that posts from new members are moderated - please be patient with your 
> first post.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojurescript+unsubscr...@googlegroups.com.
> To post to this group, send email to clojurescript@googlegroups.com.
> Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Leiningen for node.js + Cljs in Cljs

2015-08-15 Thread Divyansh Prakash
I love Clojure, but am severely hindered by not being able to write scripts due 
to high start-up times. Once I have a REPL running and hot, I actually don't 
mind it much, but it would still be fun to have a tool that lets me say

lein-node new fun-script
cd fun-script/

And then have an instant REPL up by saying
 
lein-node repl

.. and generally hacking away like we do in Clojure.
But all of it without the JVM.
Basically, a first-class JS host for Cljs.

I would love to be able to write quick and dirty scripts in Clojure.
Is there something like this available that I'm missing out on? 
Or does this sound completely heretical?

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Namespaces in ClojureScript that begin with "clojure"

2015-08-15 Thread kovas boguta
Whatever choices were made (and maybe those can be theoretically
debated) I highly doubt its worth revisiting them, cause that will
break code for very limited practical benefit. Its one of those things
one just has to learn and live with, not a fundamental limitation of
the system.


On Fri, Aug 14, 2015 at 11:47 PM, Lance Campbell  wrote:
> You understood my question. Thanks for the insight.
>
> On Friday, August 14, 2015 at 1:42:40 PM UTC-7, Linus Ericsson wrote:
>> I'm not sure if I understand your question, but there's no apparent way 
>> clojure.browser.dom would make any sense since it doesn't (or at least 
>> didn't) map to any specific JVM host language feature, but was very relevant 
>> in clojurescript, at least in the pre-react era.
>>
>> The stranger part is probably that some libraries are name for instance 
>> clojure.core.async and cljs.core.async for the different hosts. With the new 
>> conditional readers in 1.7.0 I think we could expect these libraries will 
>> harmonize the nameing to clojure.core...
>>
>> /Linus
>>
>> Just curious.
>>
>>
>>
>> There are several ClojureScript namespaces that begin with "clojure" that 
>> are available in both Clojure and ClojureScript, for example clojure.set and 
>> clojure.string.
>>
>>
>>
>> Then there are namespaces like clojure.browser.dom that do not have a 
>> corresponding namespace in Clojure.
>>
>>
>>
>> Why the difference?
>>
>>
>>
>> --
>>
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>>
>> ---
>>
>> You received this message because you are subscribed to the Google Groups 
>> "ClojureScript" group.
>>
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojurescrip...@googlegroups.com.
>>
>> To post to this group, send email to clojur...@googlegroups.com.
>>
>> Visit this group at http://groups.google.com/group/clojurescript.
>
> --
> Note that posts from new members are moderated - please be patient with your 
> first post.
> ---
> You received this message because you are subscribed to the Google Groups 
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojurescript+unsubscr...@googlegroups.com.
> To post to this group, send email to clojurescript@googlegroups.com.
> Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Études for ClojureScript: Chapter 8 review, please?

2015-08-15 Thread Moe Aboulkheir
On Fri, Aug 14, 2015 at 10:24 PM, J David Eisenberg
 wrote:

> Thanks again for the feedback. Is it OK if I list you in the credits for 
> people who assisted with the book?

Sure!

All the best,
Moe

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.