Clojure: DSL for CSS
Looking at http://clojure-libraries.appspot.com/cat/Web+Server+Libraries and http://clojure.org/libraries, there are what it looks like the options are:
- cssgen - http://github.com/paraseba/cssgen
- clj-style - https://github.com/rathwell/clj-style
- neman.css - http://bitbucket.org/ksojat/neman/
- Gaka - https://github.com/briancarper/gaka
I haven't used any of them, but it looks like you'll probably get the best results with cssgen or clj-style.
DSL for Clojure image synthesis
OK, so I eventually figured out a nice way of doing this.
The trick was to represent functions as a vector of code (in the "code is data" sense, e.g.
[(Math/sin (* 10 x))
(Math/cos (* 12 y))
(Math/cos (+ (* 5 x) (* 8 y)))]
This can then be "compiled" to create 3 objects that implement a Java interface with the following method:
public double calc(double x, double y, double z, double t) {
.....
}
And these function objects can be called with primitive values to get the Red, Green and Blue colour values for each pixel. Results are something like:
Finally, it's possible to compose the functions using a simple DSL, e.g. to scale up a texture you can do:
(vscale 10 some-function-vector)
I've published all the code on GitHub for anyone interested:
https://github.com/mikera/clisk
In Clojure, Is it idiomatically correct to use require ... as rather than use... in the ns macro
Yes. The second form is the prefered approach.
There is some discussion related here
Something like the old visual basic for web development
I believe that what you are asking for can be built using libraries from the Clojure ecosystem. Basic building blocks would include
- A wrapper around HTTP,
- A library taking care of interactions with a relational database,
- An HTML generator or a templating engine,
- A DSL abstracting away the nightmare of CSS, and
- ClojureScript, which compiles Clojure to JavaScript.
As a result all languages listed in your question would be hidden behind abstractions written in Clojure, including both the back- and front-end of the application.
I cannot point you to any complete web application stack which fully solves the problem you're describing. The reason is the fact that in the Clojure ecosystem it is conventional to build and publish small libraries which focus on a single problem. As a result you're free to choose the subset of tools which is most appropriate for your use case. You don't get the gorilla and the jungle.
Clojure, Closure, WebSocket, Online Chat Demo
There's such an example for Aleph
The only thing you need to do wrt Closure's WebSocket object, is change the constructor for the wrapped socket to whatever Firefox's websocket is for Firefox (can't remember what it is, but it's not WebSocket), or at least that's what you used to have to do, but it works with Chrome anyway. Websockets work with Chrome, Firefox, Opera but not IE but you can use a lib that fixes things to use Flash if IE is that important
Parsing xml in clojure with arbitrary tags using clj-xpath
Here is how to extract first 5 titles:
user=> (map #($x:text "./title" %) (take 5 ($x "//event" (xmldoc))))
("9th International Belgrade Early Music Festival" "Belgrade Baroque Academy, Mijanovic, Gosta / 9th Belgrade Early Music Festival / Monteverdi: \"L'Incoronazione di Poppea\"" "Belgrade Baroque Academy, Mijanovic, Gosta / 9th Belgrade Early Music Festival / Monteverdi: \"L'Incoronazione di Poppea\"" "ICTM Study Group on Music and Dance in Southeastern Europe Conference" "New Belgrade Opera, Madlenianum Opera-Theatre, New Trinity Baroque; Mijanovic, Gosta / 9th Belgrade Early Music Festival / Monteverdi: \"L'incoronazione di Poppea\"")
It your example doseq
inproperly closed and you need to complile expression to use against xml->doc
result.
You can create a helper function that will return function to extract text from tag:
(defn tag-fn [tag] (partial $x:text tag))
Now, you can generate functions for "title" and "url":
user=> (tag-fn "title")
#<core$partial$fn__4190 clojure.core$partial$fn__4190@71cc2b7a>
and
user=> (map (tag-fn "title") (take 5 ($x "//event" (xmldoc))))
("9th International Belgrade Early Music Festival" "Belgrade Baroque Academy, Mijanovic, Gosta / 9th Belgrade Early Music Festival / Monteverdi: \"L'Incoronazione di Poppea\"" "Belgrade Baroque Academy, Mijanovic, Gosta / 9th Belgrade Early Music Festival / Monteverdi: \"L'Incoronazione di Poppea\"" "ICTM Study Group on Music and Dance in Southeastern Europe Conference" "New Belgrade Opera, Madlenianum Opera-Theatre, New Trinity Baroque; Mijanovic, Gosta / 9th Belgrade Early Music Festival / Monteverdi: \"L'incoronazione di Poppea\"")
or url and title:
user=> (map (juxt (tag-fn "url") (tag-fn "title")) (take 2 ($x "//event" (xmldoc))))
(["http://eventful.com/belgrade/events/9th-international-belgrade-/E0-001-064654999-7@2014061420?utm_source=apis&utm_medium=apim&utm_campaign=apic" "9th International Belgrade Early Music Festival"] ["http://eventful.com/belgrade/events/belgrade-baroque-academy-mijanovic-gosta-9th-belg-/E0-001-059734872-8?utm_source=apis&utm_medium=apim&utm_campaign=apic" "Belgrade Baroque Academy, Mijanovic, Gosta / 9th Belgrade Early Music Festival / Monteverdi: \"L'Incoronazione di Poppea\""])
or both url and title:
user=> (map (apply juxt (map tag-fn ["url" "title"])) (take 2 ($x "//event" (xmldoc))))
(["http://eventful.com/belgrade/events/9th-international-belgrade-/E0-001-064654999-7@2014061420?utm_source=apis&utm_medium=apim&utm_campaign=apic" "9th International Belgrade Early Music Festival"] ["http://eventful.com/belgrade/events/belgrade-baroque-academy-mijanovic-gosta-9th-belg-/E0-001-059734871-9?utm_source=apis&utm_medium=apim&utm_campaign=apic" "Belgrade Baroque Academy, Mijanovic, Gosta / 9th Belgrade Early Music Festival / Monteverdi: \"L'Incoronazione di Poppea\""])
Language/libraries for downloading & parsing web pages?
If you want to spend some time with Clojure (a very good idea IMO!), give Enlive a shot. The GitHub description reads
a selector-based (à la CSS) templating and transformation system for Clojure — Read more
In addition to being useful for templating, it's a capable webscraping library; see the initial part of this tutorial for some simple scraping examples. (The third one is the New York Times homepage, so actually not as simple as all that.)
There are other tutorials available on the Web if you look for them; Enlive itself comes with some docs / examples. (Plus the code is < 1000 lines in total and very readable, though I suppose this might be less so for someone new to the language.)
Related Topics
Pointer Events: None, Filter, Works in Ie8 and Anywhere, Not Ie9
Adding Background Image to Shiny Navbarpage
How to Add Class to Form in Yii Framework
Zoomed-Out Sizing in Twitter Bootstrap
CSS Infinite Animation After Hidden Is Not Reset (Chrome)
More Than 12 Cols Per Row in Bootstrap
Force Absolute Div to Listen to Parent's Padding
Is This How You Would Structure Your CSS Stylesheet
Scss Function for Animation Keyframes
How to Use Overflow:Hidden Without an Explicit Height Somehow
Sticky Scrollbar at Bottom of Table
Repeated Series of Number via CSS
Add CSS to Head from Template File in Magento
Font-Awesome Caret Up and Caret Down Stacked on Top of Each Other