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 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 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 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 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 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 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 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 primitive? [o] | |
(some #{true} | |
(map | |
(partial isa? (.getClass o)) | |
[Boolean Character Byte Short Integer Long Float Double String]))) | |
(defn read-object [o] | |
(when o | |
(cond | |
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 small-site.server | |
(:require [noir.server :as server] | |
[noir.content.pages :as pages] | |
[clj-http.client :as client]) | |
(:use noir.core | |
hiccup.core | |
hiccup.page-helpers)) | |
(def code (slurp "src/small_site/server.clj")) | |
(def hilite-url "http://hilite.me/api") |
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
object Matmul { | |
def matgen(n: Integer): Array[Array[Double]] = { | |
var a = new Array[Array[Double]](n, n) | |
val tmp = 1. / n / n | |
Range(0, n) map ((i) => | |
Range(0, n) map ((j) => | |
a(i)(j) = tmp * (i - j) * (i + j))) | |
return a | |
} |
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
package main | |
import scala.util.Random | |
import scala.collection.immutable.HashMap | |
import java.awt._ | |
import javax.swing._ | |
import scala.actors._ | |
import scala.actors.Actor._ |
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
package main | |
import java.awt.Graphics | |
import java.awt.Dimension | |
import javax.swing.JFrame | |
import java.awt.Color | |
import java.awt.Canvas | |
object Metaball extends Canvas { | |
val WIDTH = 600 |
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 nn) | |
(defstruct network :ai :ah :ao :wi :wo :ci :co) | |
(defn rand-in-range [a b] | |
(+ (* (- b a) (rand)) a)) | |
(defn make-matrix | |
([i j] (make-matrix i j 0.0)) | |
([i j fill] (repeat i (repeat j fill)))) |