When you want to create a webpage with clojure but you're too lazy to use hiccup and garden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn uuid [] (str (java.util.UUID/randomUUID))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Generating static HTML using Clojure macros | |
;; It is possible to write a DSL in Clojure that generates HTML markup without the need to write a separate parser and compiler (e.g. HAML). | |
;; Our aim here would be to write code that converts the following Clojure code into the HTML below it | |
;; (html | |
;; (head) | |
;; (body | |
;; (h1 "An example") |
FOR XML RAW
not mich just<row
sFOR XML AUTO
it seems some kind of auto nesting based on the first columnFOR XML EXPLICIT
control but kind of creepy and verboseFOR XML PATH
:-D
(def strinc (comp str inc))
(strinc 3)
; => "4"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def array (take 3 (partition 3 (partition 3 (iterate inc 1))))) | |
(doall (map #(doall (map println %)) array)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns seesaw.async | |
(:use [seesaw core])) | |
; see http://dotnetslackers.com/articles/net/Programming-user-interfaces-using-f-sharp-workflows.aspx#1478 | |
(defmacro async | |
"Macro that executes an async call (the first form), ignores its result, and the | |
executes the body normally." | |
[async-call & body] | |
`(~@(apply list (first async-call) `(fn [& args#] ~@body) (rest async-call)))) |
The JVM is a virtual stack machine
**BTW A stack computer is programmed with a reverse Polish notation instruction set.
All the bytecode is typed in the JVM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns table-test.core | |
(:use [seesaw core table swingx])) | |
; A predicate that decides whether a row should be highlighted | |
; adapter is an instance of JXTable.TableAdapter | |
; http://projects.joshy.org/projects/painterreview/swingx/org/jdesktop/swingx/JXTable.TableAdapter.html | |
(defn hl-predicate [renderer adapter] | |
; Highligh all rows where :age is over thirty | |
(> (.getValueAt adapter (.row adapter) 0) 30)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns busy-cursor.core | |
(:use seesaw.core)) | |
(defn long-running-task | |
[] | |
(Thread/sleep 5000) | |
"The result") | |
(defn run-task-with-busy-cursor | |
[c] |