wget https://raw.github.com/technomancy/leiningen/preview/bin/lein
lein self-install
lein plugin install lein-noir 1.2.1
lein noir new guestbook
cd guestbook
This file contains 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 model | |
(:require [clojure.java.jdbc :as sql])) | |
(def db {:classname "org.hsqldb.jdbcDriver" | |
:subprotocol "hsqldb" | |
:subname "user.db" | |
:create true}) | |
(defn db-read [query] | |
(sql/with-connection db |
This file contains 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 rss | |
(:use [clojure.xml :only [emit]]) | |
(:import java.util.Date)) | |
(defn format-time [time] | |
(.format (new java.text.SimpleDateFormat | |
"EEE, dd MMM yyyy HH:mm:ss ZZZZ") time)) | |
(defmacro tag [id attrs & content] | |
`{:tag ~id :attrs ~attrs :content [~@content]}) |
This file contains 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 metaballs | |
(:import | |
[javax.swing JFrame] | |
[java.awt Canvas Graphics Color] | |
java.awt.image.BufferStrategy)) | |
(def SIZE 250) | |
(defn direction [p v] | |
(if (or (> p SIZE) (neg? p)) (- v) v)) |
This file contains 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 metaballs | |
(:import | |
[javax.swing JFrame] | |
[java.awt Canvas Graphics Color] | |
java.awt.image.BufferStrategy)) | |
(set! *warn-on-reflection* true) | |
(def ^:const SIZE 250) | |
(defn direction [p v] |
wget https://raw.github.com/technomancy/leiningen/preview/bin/lein
chmod +x lein
lein self-install
lein new noir guestbook
cd guestbook
#Add dependencies
This file contains 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 sorted-key-list | |
[& maps] | |
(or | |
(->> | |
(mapcat keys maps) | |
set | |
(map str) | |
sort | |
(clojure.string/join ", ") | |
not-empty) |
This file contains 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
(function() { | |
var colorChooser, AlbumImage, AlbumColors; | |
/* colorChooser | |
* A series of function that is used to pick up 3 colors among 10 dominating colors | |
*/ | |
colorChooser = { | |
colorStringToRGBArray: function(colorString) { | |
var n, arr = colorString.split(','); |
This file contains 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 metaballs | |
(:import | |
[javax.swing JFrame] | |
[java.awt Canvas Graphics Color] | |
java.awt.image.BufferStrategy)) | |
(set! *warn-on-reflection* true) | |
(def SIZE 250) |
This file contains 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 parser) | |
(defn read-char [rdr] | |
(let [ch (.read rdr)] | |
(if-not (== -1 ch) (char ch)))) | |
(def expr-tags | |
{:if #(str "if tag args: " (clojure.string/join ", " %1))}) | |
(defn expr-tag [{:keys [tag-name args] :as tag} rdr] |