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 todos.views.welcome | |
(:require [todos.views.common :as common] | |
[noir.content.pages :as pages] | |
[noir.response :as resp]) | |
(:use noir.core | |
hiccup.core | |
hiccup.form-helpers | |
hiccup.page-helpers)) | |
(defonce todos (atom {1 "Get milk" |
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
#!/bin/bash | |
name=webnoir | |
pidfile=/var/run/$name.pid | |
if [ -f "$pidfile" ]; then | |
pid=`cat $pidfile` | |
running=`ps p $pid |wc -l` | |
if [ $running -eq 1 ]; then | |
pid= |
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 cljs-test.client) | |
(defn now [] | |
(. (js/Date.) (getTime))) | |
(let [nums (doall (range 0 1000000)) | |
start (now)] | |
(doseq [n nums] | |
) | |
(. js/console (log (- (now) start)))) |
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 cljs-test.client) | |
(defn now [] | |
(. (js/Date.) (getTime))) | |
(let [nums (doall (range 0 1000000)) | |
start (now)] | |
(doseq [n nums] | |
) | |
(. js/console (log (str "pre-seq: " (- (now) start))))) |
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
(require '[noir.server :as server]) | |
(use 'noir.core 'aleph.http 'lamina.core) | |
(defn async-response [response-channel request] | |
(enqueue response-channel | |
{:status 200 | |
:headers {"content-type" "text/plain"} | |
:body "async response"})) | |
(defpage "/" [] "hey from Noir!") |
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
let vimclojure#HighlightBuiltins=1 | |
let vimclojure#HighlightContrib=1 | |
let vimclojure#DynamicHighlighting=1 | |
let vimclojure#ParenRainbow=1 | |
let vimclojure#WantNailgun = 1 | |
let vimclojure#NailgunClient = "/users/chris/.vim/bundle/vimclojure-2.3.0/lib/ng" |
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 irc | |
(:import (java.net Socket) | |
(java.io PrintWriter InputStreamReader BufferedReader)) | |
(:require 'clojure.contrib.duck-streams) | |
(:use [clj-time.core :only [in-secs interval epoch now]])) |
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
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named (NO_SOURCE_FILE:0) | |
at clojure.lang.Compiler.eval(Compiler.java:5440) | |
at clojure.lang.Compiler.eval(Compiler.java:5391) | |
at clojure.core$eval.invoke(core.clj:2382) | |
at clojure.main$eval_opt.invoke(main.clj:235) | |
at clojure.main$initialize.invoke(main.clj:254) | |
at clojure.main$script_opt.invoke(main.clj:270) | |
at clojure.main$main.doInvoke(main.clj:354) | |
at clojure.lang.RestFn.invoke(RestFn.java:457) | |
at clojure.lang.Var.invoke(Var.java:377) |
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
(defmacro mainpage [route params & body] | |
`(defpage ~route ~params | |
(common/main-layout | |
~@body))) | |
;;Or if you wanted to get really crazy, so that you don't have to duplicate that macro | |
;;you could write a macro that writes the macros for you: | |
(defmacro layout-page [name layout] | |
`(defmacro ~name [route# params# & body#] |
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
(defpage "/blah/:n" {:keys [n]} | |
(session/put! :b n)) | |
(deftest session-vals | |
(with-noir | |
(session/put! :b 3) | |
(render "/blah/:n" {:n 1}) | |
(is (= (session/get :b) 1)))) |