Skip to content

Instantly share code, notes, and snippets.

View weavejester's full-sized avatar

James Reeves weavejester

View GitHub Profile
user=> (require 'capra.account)
nil
user=> (capra.account/register "jbloggs" "jbloggs@example.com")
nil
user=> (require 'capra.package)
nil
user=> (capra.package/create
{:account "jbloggs"
:name "hello-world"
:version "1.0"
:description "Hello World!"
:files ["./build/hello-world.jar"]})
>> Uploading...
>> Done.
(defn wrap-session [handler options]
(let [cookie (options :cookie-name "ring-session")]
(wrap-cookies
(fn [request]
(let [session-key (get-in request [:cookies cookie :value])
session (atom (read-session session-key options))
request (assoc request :session session)
response (handler request)
new-session-key (if @session
(write-session @session options)
(ns hello-world
(:use compojure.core
ring.util.response
ring.adapter.jetty))
(defroutes main-routes
(GET "/" []
"Hello World")
(ANY "*" []
(page-not-found)))
(ns benchmark
(:require [hiccup.core :as hiccup]
[clj-html.core :as clj-html]))
(defn clj-html-benchmark []
(let [text "Some text"]
(clj-html/html
[:html
[:head
[:title "Literal String"]]
(defn hello-world [request]
{:status 200
:headers {"Content-Type" "text/plain"}
:body "Hello World"})
(defproject hello-world "1.0.0-SNAPSHOT"
:description "FIXME: write"
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0"]
[compojure "0.4.0-SNAPSHOT"]
[ring/ring-jetty-adapter "0.2.0"]])
(defproject post-example "1.0.0-SNAPSHOT"
:description "FIXME: write"
:dependencies [[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0"]
[compojure "0.4.0-SNAPSHOT"]
[hiccup "0.2.3"]
[ring/ring-jetty-adapter "0.2.0"]])
(ns testing.core
(:use compojure.core
[hiccup core form-helpers page-helpers])
(:require [compojure.route :as route]))
(defn view-layout [& content]
(xhtml {:lang "en"}
[:head [:title "Datum"]]
[:body content]))
;; When executed, this file will run a basic web server
;; on http://localhost:8080 that will display the text
;; 'Hello World'.
(ns ring.example.hello-world
(:use ring.adapter.jetty))
(defn handler [request]
{:status 200
:headers {"Content-Type" "text/plain"}