Skip to content

Instantly share code, notes, and snippets.

View ckirkendall's full-sized avatar

Creighton Kirkendall ckirkendall

  • Blue Manta Consulting
  • Cincinnati, Ohio
View GitHub Profile
@ckirkendall
ckirkendall / design.markdown
Last active January 3, 2016 22:59
Enliven Component Model

##Sketch for Enliven Component Model

This design page is a sketch of how I see enliven being used for dynamic templates in the browser.

Design Principles

  1. All state is in an application state object.
  2. State is scoped through lenses.
  3. Users should not have to manage lenses manually.
  4. There is no tree walking; paths/lenses, for dom manipulation, are determined at compile time.
@ckirkendall
ckirkendall / core.clj
Created January 22, 2014 11:44
This was just for fun to see how much effort it would take. It is a functional clojure version of the java bouncy ball tutorial.
(ns bouncy.core
(:require [goog.math :as math :refer [Vec2]]
[goog.math.Vec2 :as vec]))
(declare step draw-circle)
(def app {:elems [{:pos (Vec2. 100 100) :speed (Vec2. -3 5) :radius 20}
{:pos (Vec2. 200 200) :speed (Vec2. 5 3) :radius 30}
{:pos (Vec2. 300 200) :speed (Vec2. 7 6) :radius 5}
{:pos (Vec2. 400 200) :speed (Vec2. -5 -6) :radius 10}
@ckirkendall
ckirkendall / segments.clj
Last active August 29, 2015 13:56
distilled version of enliven segments as an external lib
(ns segments)
(defrecord Lens [fetch putback])
(defprotocol Segment
(-fetch [seg value])
(-putback [seg value subvalue]))
(defn fetch [value seg]
(-fetch seg value))
@ckirkendall
ckirkendall / miner.clj
Last active August 29, 2015 13:56
Musing about a game engine
(defprotocol KeyListener
(key [this key-code]))
(defprotocol CollisionListener
(collision [this other]))
(defprotocol BoundsListener
(bounds [this other]))
(defprotocol GravityListener
(ns baseball.core
(:require [clojure.core.async :refer (chan >!! <!! >! <! close! go go-loop)]
[clojure.core.match :refer (match)]))
;; http://www.variousandsundry.com/cs/blog/2014/02/20/baseball-processes/
;; It’s like playing catch in the backyard. You don’t want to play by yourself. So you tell a friend
;; to stand about 20 paces away from you. Once they’re there, they wave their arms to be sure you can
;; see them. Having seen them, you throw them the ball. They throw it back as a solid line drive
;; right at your mitt. End of process.
// After reading the trials and tribulations here
// http://www.learningclojure.com/2014/05/fizz-buzz-interview-question.html?utm_source=dlvr.it&utm_medium=twitter
// I decided to see how easy this is using sum types.
// Anser: Pretty easy. :D
object Program {
def numbers(n: Int): Stream[Int] = Stream.cons(n, numbers(n + 1))
(ns ocr-kata.core
(:require [clojure.java.io :refer [writer reader resource]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; we treat this OCR parser similar to a language
;; parser where input into an AST that is
;; transform and tagged by diffrent analysis steps
;; the ast is then passed to an emmiter.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def numbers {[0 1 0 1 0 1 1 1 1] 0
@ckirkendall
ckirkendall / core.clj
Created February 16, 2015 03:39
monadic parser combinators
(ns parser.core
(:require
[clojure.algo.monads :refer [defmonad with-monad state-t m-reduce]]))
(defmonad either-m
[m-result (fn [[side value]] {:side side, :value value})
m-bind (fn [mv mf] (mf [(:side mv) (:value mv)]))])
(defn left [v]
<security-domain name="other" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
(ns wine-fun.data
(:require [clojure.java.io :as io]
[clojure.data.csv :as csv]))
(def training-data
(let [data (with-open [in-file (io/reader "data/winequality-data.csv")]
(drop 1 (doall
(csv/read-csv in-file))))
control-count (int (/ (count data) 10))