Skip to content

Instantly share code, notes, and snippets.

Avatar

Creighton Kirkendall ckirkendall

  • Blue Manta Consulting
  • Cincinnati, Ohio
View GitHub Profile
@ckirkendall
ckirkendall / gist:1380756
Created Nov 20, 2011
4clojure registration test
View gist:1380756
(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
(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
(ns midje.cljs.basic)
(defn doubler [x] (* 2 x))
(defn world [] "world")
(defn hello []
(str "hello " (world)))
View core.cljs
(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")
@ckirkendall
ckirkendall / sample.clj
Created May 2, 2012
multimethods clojure
View sample.clj
;you have a map with a key :action
;this contains a known list of actions:
;:login, :register, :play, :logout
(defmulti appy-action :action)
;input looks like this
;{:action :login :username "test" :password "test"}
(defmethod apply-action :login [msg]
(let [username (:username msg)
@ckirkendall
ckirkendall / clojure-match.clj
Created Jun 15, 2012 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
View clojure-match.clj
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@ckirkendall
ckirkendall / output.txt
Created Jun 18, 2012
J Program for creation of AST Add(Variable 'a',Multiply(Number 2, Variable 'b'))
View output.txt
┌───┬────────────┬──────────────────────────────────┐
│Add│┌────────┬─┐│┌────────┬──────────┬────────────┐│
│ ││Variable│a│││Multiply│┌──────┬─┐│┌────────┬─┐││
│ │└────────┴─┘││ ││Number│2│││Variable│b│││
│ │ ││ │└──────┴─┘│└────────┴─┘││
│ │ │└────────┴──────────┴────────────┘│
└───┴────────────┴──────────────────────────────────┘
@ckirkendall
ckirkendall / ExpressionTree.rb
Created Jun 18, 2012 — forked from jimweirich/Expression Tree
Another expression tree evaluator
View ExpressionTree.rb
Number = lambda { |env, num| num }
Variable = lambda { |env, var| env[var] }
Add = lambda { |env, a, b| evaluate(env, a) + evaluate(env, b) }
Multiply = lambda { |env, a, b| evaluate(env, a) * evaluate(env, b) }
def evaluate(env, exp)
op, *args = exp
op.(env, *args)
end
@ckirkendall
ckirkendall / Lambda.scala
Created Jun 18, 2012 — forked from bkyrlach/AST.cs
Lambda for Scala...
View Lambda.scala
object Lambda extends App {
val number = (num: Int) => (env: Map[Symbol, Int]) => num
val variable = (id: Symbol) => (env: Map[Symbol, Int]) => env(id)
val add = (a: (Map[Symbol, Int]) => Int, b: (Map[Symbol, Int]) => Int ) => (env: Map[Symbol, Int]) => a(env) + b(env)
val multiply = (a: (Map[Symbol, Int]) => Int, b: (Map[Symbol, Int]) => Int ) => (env: Map[Symbol, Int]) => a(env) * b(env)
val environment = Map('a -> 1, 'b -> 2, 'c -> 3)
val expr_tree = add(variable('a), multiply(number(2), variable('b)))
println(expr_tree(environment))
@ckirkendall
ckirkendall / A-sum-higher-kinds.clj
Created Jun 19, 2012 — forked from bkyrlach/GenericVersion.scala
Polymorphism - Summation of Higher Kinds(Clojure, Ocaml, Haskell, Scala, Java).
View A-sum-higher-kinds.clj
(defrecord Tree [left elm right])
(defprotocol Monoid
(append [a b] )
(identity [a] ))
(defprotocol Foldable
(foldl [l f i])
(mfirst [l]))