Skip to content

Instantly share code, notes, and snippets.

@zehnpaard
zehnpaard / simple-modular-ring.core.clj
Created October 28, 2016 06:07
Simple Ring Demo with Separate Modules and GET/POST forms
(ns simple-modular-ring.core
(require
[ring.adapter.jetty :refer [run-jetty]]
[simple-modular-ring.handler :as h]
[simple-modular-ring.middleware :as m]
))
(def app
(-> h/post-form
m/logger
@zehnpaard
zehnpaard / ring-with-routing.core.clj
Created October 29, 2016 13:32
Simple Ring Demo with Routing
(ns ring-with-routing.core
(require
[ring.adapter.jetty :refer [run-jetty]]
[ring-with-routing.handler :as h]
[ring-with-routing.middleware :as m]
))
(def app
(-> h/handler-with-routing
m/logger
@zehnpaard
zehnpaard / min-cljsbuild.core.cljs
Created November 5, 2016 00:26
Nearly Minimal Clojurescript Compilation with cljsbuild
(ns min-cljsbuild.core)
(js/alert "Hello ClojureScript!")
(ns try-cljsbuild.core)
(js/alert "Hello Clojurescript!")
@zehnpaard
zehnpaard / min-figwheel.core.cljs
Created November 8, 2016 12:16
Minimal Figwheel Project Structure
(ns min-figwheel.core)
(js/alert "Hello ClojureScript!")
@zehnpaard
zehnpaard / clicker.core.cljs
Created November 13, 2016 21:38
Reagent Form-2 Component Nesting (Purely Demonstrative Purposes)
(ns clicker.core
(:require [reagent.core :as r]))
(defn clicker []
(let [john? (r/atom true)]
(fn []
(let [clicks (r/atom 0)]
(fn []
[:div
[:h1 {:on-click #(swap! john? not)} (if @john? "John" "James")]
@zehnpaard
zehnpaard / clicker2.core.cljs
Created November 13, 2016 21:46
Reagent Form-2 Component Nesting Part 2 (Purely Demonstrative Purposes)
(ns clicker2.core
(:require [reagent.core :as r]))
(def message (r/atom "Hello"))
(defn clicker [some-message]
(let [john? (r/atom true)]
(fn [some-message]
(let [clicks (r/atom 0)]
(fn [some-message]
@zehnpaard
zehnpaard / react-tutorial-v3.core.cljs
Last active November 16, 2016 08:20
Reagent port of official React tutorial code upto Declaring a Winner https://facebook.github.io/react/tutorial/tutorial.html#declaring-a-winner
(ns react-tutorial.core
(:require
[reagent.core :as r]))
(defn calculateWinner [squares]
(let [lines [[0 1 2]
[3 4 5]
[6 7 8]
[0 3 6]
@zehnpaard
zehnpaard / react-tutorial.core.cljs
Last active November 16, 2016 08:21
Reagent port of initial state for official React tutorial code https://facebook.github.io/react/tutorial/tutorial.html
(ns react-tutorial.core
(:require
[reagent.core :as r]))
(defn Square []
[:button.square])
(defn Board []
(let [renderSquare (fn [i] [Square])
status (r/atom "Next player: X")]
@zehnpaard
zehnpaard / react-tutorial-v4.core-parts.cljs
Last active November 17, 2016 10:02
Reagent port of official React tutorial code for the Storing a History section https://facebook.github.io/react/tutorial/tutorial.html#storing-a-history
(defn Board [squares click-fn]
(let [renderSquare (fn [i]
[Square (get squares i) #(click-fn i)])]
[:div
[:div.board-row
[renderSquare 0]
[renderSquare 1]
[renderSquare 2]]
[:div.board-row
[renderSquare 3]