Skip to content

Instantly share code, notes, and snippets.

ibdknox / socket.clj
Created Oct 31, 2010
compojure with websockets
View socket.clj
(ns wl.core
(:use compojure.core, aleph.core, aleph.http, hiccup.core,
(:require [compojure.route :as route])
(def broadcast-channel (channel))
(defn chat-handler [ch handshake]
(receive ch
(fn [name]
View ducky.clj
(def ducky {})
(nil? (ducky :excitement))
ibdknox / alephpost.clj
Created Nov 6, 2010
Trying to use aleph with compojure routes, but the post params never make it through on the aleph server, while they are working fine on the jetty one.
View alephpost.clj
(ns wl.simple
(:use compojure.core, aleph.http, hiccup.core, hiccup.form-helpers, ring.adapter.jetty)
(defn show-params [values]
(println (str values))
(html [:p (str values)]))
(defroutes myroutes
(GET "/" [] (html (form-to [:post "/"]
ibdknox /
Created May 10, 2011
Socket.IO-netty example
import com.ibdknox.socket_io_netty.INSIOClient;
import com.ibdknox.socket_io_netty.INSIOHandler;
public class EchoHandler implements INSIOHandler {
public void OnConnect(INSIOClient client) {
System.out.println("A user connected :: " + client.getSessionID());
ibdknox / welcome.clj
Created Jun 21, 2011
clj-noir welcome block
View welcome.clj
(defpartial layout [& content]
[:title "Noir"]]
(defpage "/welcome" []
[:h1 "Welcome to Noir!"]))
ibdknox /
Created Jun 21, 2011
get started step 1
lein plugin install lein-noir 1.2.1
lein noir new my-website
cd my-website
lein run
ibdknox / step2.clj
Created Jun 21, 2011
get started step 2
View step2.clj
(defpartial todo-item [{:keys [id title due]}]
[:li {:id id} ;; maps define HTML attributes
[:h3 title]
[:span.due due]]) ;; add a class
(defpartial todos-list [items]
[:ul#todoItems ;; set the id attribute
(map todo-item items)])
(todos-list [{:id "todo1"
ibdknox / todos.clj
Created Jun 21, 2011
get started step3
View todos.clj
;;Create a page that lists out all our todos
(defpage "/todos" {}
(let [items (all-todos)]
[:h1 "Todo list!"]
(todos-list items))))
;; Handle an HTTP POST to /todos, returning a
;; json object if successful
(defpage [:post "/todos"] {:keys [title due]}
ibdknox / step4.clj
Created Jun 21, 2011
get started step 4
View step4.clj
;; add a value to the session
(defpage "/login" {}
(session/put! :admin true)
[:p "Are you loggedin? "]
[:p (session/get :admin)]))
;; set a cookie and get its value
(defpage "/cookie" []
(cookie/put! :noir "stuff")
ibdknox / welcome.clj
Created Jun 22, 2011
alternate welcome block
View welcome.clj
(ns my-app
(:use noir.core)
(:require [noir.server :as server]))
(defpage "/welcome" []
"Welcome to Noir!")
(server/start 8080)
You can’t perform that action at this time.