Skip to content

Instantly share code, notes, and snippets.

View lildata's full-sized avatar

Programming is fun lildata

View GitHub Profile
@lildata
lildata / gist:fd8ebfbd8d51932d5684
Created February 16, 2016 21:42 — forked from gorsuch/gist:1418850
clojure uuid
(defn uuid [] (str (java.util.UUID/randomUUID)))
@lildata
lildata / gist:c318a44b18d7d6de24a9
Created January 31, 2016 16:10 — forked from bayan/gist:3382884
Clojure DSL to generate static HTML
;; 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")
@lildata
lildata / 0-simple-clojure-web.md
Last active February 2, 2016 19:26
When you want to create a webpage with clojure but you're too lazy to use hiccup and garden

When you want to create a webpage with clojure but you're too lazy to use hiccup and garden

  • FOR XML RAW not mich just <rows
  • FOR XML AUTO it seems some kind of auto nesting based on the first column
  • FOR XML EXPLICIT control but kind of creepy and verbose
  • FOR XML PATH :-D
@lildata
lildata / clojure.core.comp.md
Last active December 12, 2015 21:58
clojure fn
(def strinc (comp str inc))
(strinc 3)
; => "4"
@lildata
lildata / fill-print-array.clj
Last active December 3, 2015 15:55
Fill & Print an array in clojure (is there a better way to do ??)
(def array (take 3 (partition 3 (partition 3 (iterate inc 1)))))
(doall (map #(doall (map println %)) array))
@lildata
lildata / gist:ae9dbe13b95dd228b580
Created November 11, 2015 18:17 — forked from daveray/gist:1055523
Async Workflows in Seesaw
(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))))
@lildata
lildata / jvm.md
Last active November 11, 2015 13:21

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

@lildata
lildata / table-test.clj
Created October 26, 2015 21:48 — forked from daveray/table-test.clj
Highlighting table rows with Seesaw
(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))
@lildata
lildata / busy-cursor.clj
Created October 26, 2015 21:48 — forked from daveray/busy-cursor.clj
Clojure/Seesaw busy cursor example
(ns busy-cursor.core
(:use seesaw.core))
(defn long-running-task
[]
(Thread/sleep 5000)
"The result")
(defn run-task-with-busy-cursor
[c]