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 / 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]
@ckirkendall
ckirkendall / gist:1380756
Created November 20, 2011 19:36
4clojure registration test
(deftest test-do-register
(let [uname "username"
lngname "thisisalongusername"
bname "$#%^$djc"
pwd "password"
shpwd "pass"
email "test@test.com"
bemail "testing.com"]
(em/defsnippit snippit1 "templates/template1.html" [:tbody :> 'first-child]
[fruit quantity]
[:tr :> 'first-child] (ef/content fruit)
[:tr :> 'last-child] (ef/content (str quantity)))
(em/deftemplate template1 "/templates/template1.html" [fruit-data]
[:#heading1] (ef/content "fruit")
[:thead :tr :> 'last-child] (ef/content "quantity")
[:tbody] (ef/content
(ns midje.cljs.basic)
(defn doubler [x] (* 2 x))
(defn world [] "world")
(defn hello []
(str "hello " (world)))
(ns goog-test.core
(:require [goog.testing.jsunit :as unit]
[goog.testing :as gt]
[goog.testing.TestCase :as tc])
(:use [midje.cljs.core :only [run-test]])
(:use-macros [midje.cljs.semi-sweet :only [expect fact run-tests]]
[midje.cljs.sweet :only [fact provided]]))
(defn world [] "world")