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
#!/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 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 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 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
#(:longest | |
(reduce | |
(fn [{:keys [longest cur] :as res} n] | |
(let [{:keys [cur] :as updated} (if (or (not (seq cur)) | |
(> n (last cur))) | |
(update-in res [:cur] conj n) | |
(assoc res :cur [n])) | |
longest-cnt (count longest) | |
cur-cnt (count cur)] | |
(if (and (> cur-cnt 1) |
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
(server/add-middleware my-middleware) |
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
(require '[noir.server :as server]) | |
(server/load-views "src/noir-example/views") | |
(def handler (server/gen-handler {:mode :dev | |
:ns 'noir-example})) |
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
(defpartial error-item [[first-error]] | |
[:p.error first-error]) | |
(defpartial user-fields [{:keys [firstname lastname]}] | |
(vali/on-error :firstname error-item) | |
(label "firstname" "First name: ") | |
(text-field "firstname" firstname) | |
(vali/on-error :lastname error-item) | |
(label "lastname" "Last name: ") | |
(text-field "lastname" lastname)) |
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
(defpage [:get ["/user/:id" :id #"\d+"]] {:keys [id]} | |
(str "You are user number " id)) |
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 my-bot [] | |
(doseq [ant (my-ants)] | |
(let [f (closest ant (food)) | |
food-dirs (shuffle (direction ant f)) | |
dirs (concat food-dirs (shuffle directions))] | |
(when-let [dir (first (drop-while #(not (valid-move? ant %)) dirs))] | |
(move ant dir))))) |
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
(defpartial post-item [{:keys [perma-link title md-body date tme]}] | |
[:li.post | |
[:h2 (link-to perma-link title)] | |
[:ul.datetime | |
[:li date] | |
[:li tme]] | |
[:div.content md-body]]) | |
(defpartial posts-list [items] | |
[:ul.posts |