View segments.clj
This file contains 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 segments) | |
(defrecord Lens [fetch putback]) | |
(defprotocol Segment | |
(-fetch [seg value]) | |
(-putback [seg value subvalue])) | |
(defn fetch [value seg] | |
(-fetch seg value)) |
View miner.clj
This file contains 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
(defprotocol KeyListener | |
(key [this key-code])) | |
(defprotocol CollisionListener | |
(collision [this other])) | |
(defprotocol BoundsListener | |
(bounds [this other])) | |
(defprotocol GravityListener |
View baseball.clj
This file contains 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 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. |
View Program.scala
This file contains 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
// 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)) | |
View bank_orc.clj
This file contains 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 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 |
View core.clj
This file contains 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 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] |
View gist:1380756
This file contains 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
(deftest test-do-register | |
(let [uname "username" | |
lngname "thisisalongusername" | |
bname "$#%^$djc" | |
pwd "password" | |
shpwd "pass" | |
email "test@test.com" | |
bemail "testing.com"] |
View gist:1418965
This file contains 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
(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 |
View basic.cljs
This file contains 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 midje.cljs.basic) | |
(defn doubler [x] (* 2 x)) | |
(defn world [] "world") | |
(defn hello [] | |
(str "hello " (world))) |
View core.cljs
This file contains 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 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") | |
OlderNewer