Skip to content

Instantly share code, notes, and snippets.

View ck's full-sized avatar
💭
I may be slow to respond.

ck ck

💭
I may be slow to respond.
  • United States
  • 22:28 (UTC -04:00)
View GitHub Profile
@ck
ck / gist:8873154
Created February 7, 2014 22:18
Immutant Test Failure with Java Class
% lein immutant test active/ialab (immutant-and-java-classes ⚡)
Running tests inside Immutant...
Starting JBoss
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/bin/java -Xms64m -Xmx1024m -XX:MaxPermSize=1024m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSClassUnloadingEnabled -Djboss.home.dir=/Users/ck/.immutant/current/jboss -Dlogging.configuration=file:/Users/ck/.immutant/current/jboss/standalone/configuration/logging.properties -Dorg.jboss.boot.log.file=/Users/ck/code/active/ialab/target/isolated-immutant/standalone/log/boot.log -jar /Users/ck/.immutant/current/jboss/jboss-modules.jar -mp /Users/ck/.immutant/current/jboss/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.server.base.dir=/Users/ck/code/active/ialab/target/isolated-immutant/standalone -Djboss.socket.binding.port-offset=67
Deploying /Users/ck/code/active/ialab
;; stolen from http://cemerick.com/2010/08/02/defrecord-slot-defaults/
(defmacro defrecord+defaults
"Defines a new record, along with a new-RecordName factory function that
returns an instance of the record initialized with the default values
provided as part of the record's slot declarations. e.g.
(defrecord+ Foo [a 5 b \"hi\"])
(new-Foo)
=> #user.Foo{:a 5, :b \"hi\"}"
[name slots & etc]
@ck
ck / integration.clj
Created March 6, 2011 22:34
Pick Aggregate
(database-test test-pick
(is (= @(-> (select users (where (= :id 4)))
(pick :name))
"Frank"))
(is (= @(-> users
(aggregate [:count/id :as :cnt])
(pick :cnt))
4)))
@ck
ck / levenshtein.clj
Created May 7, 2011 18:33 — forked from vishnuvyas/levenshtein.clj
A purely functional implementation of levenshtein distance in clojure
(ns levenshtein
^{:doc "A purely functional implementation of the levenshtien distance in clojure"})
(defn- compute-next-row
"computes the next row using the prev-row current-element and the other seq"
[prev-row current-element other-seq pred]
(reduce
(fn [row [diagonal above other-element]]
(let [update-val
(if (pred other-element current-element)
@ck
ck / part1.clj
Created October 9, 2011 15:58 — forked from frenchy64/part1.clj
Evolving a logic programming language
;; Evolving a logic programming language
;; Based on sketches at https://github.com/frenchy64/Logic-Starter/blob/master/src/logic_introduction/decl_model.clj
;; A logic statement reduces to true or false.
true
;=> true
false
;=> false
@ck
ck / gist:1670187
Created January 24, 2012 13:31 — forked from swannodette/gist:1667847
hierarchy.clj
(ns hierarchy.core
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]))
(def order [:domain :kingdom :phylum :class :order :family :genus :species])
(def homo-sapiens
{:domain :eukarya
:kingdom :animalia-metazoa
:phylum :chordata
@ck
ck / simplifier.clj
Created February 13, 2012 12:36 — forked from alandipert/simplifier.clj
A Simplifier for all Expressions
;; A Simplifier for all Expressions
;; Example:
;; (simplify '(* 1 (+ x (- y y)))) ;=> x
;; (simplify '(and a (and (and) b))) ;=> (and a b)
;; See section 4.4, "Syntactic Abstraction" of Norvig and Pitman's
;; "Tutorial on Good Lisp Programming Style":
;; http://norvig.com/luv-slides.ps
@ck
ck / gist:2030140
Created March 13, 2012 17:42 — forked from stuarthalloway/gist:1980351
frinj unit conversion running inside a Datomic datalog query
;; lein settings
(defproject foo "1.0.0-SNAPSHOT"
:description "Test App"
:dependencies [[com.datomic/datomic "0.1.2678"]
[frinj "0.1.2" :exclusions [org.clojure/clojure]]])
;; load libs
(use 'frinj.core 'frinj.calc)
(frinj-init!)
(use '[datomic.api :only (q db) :as d])
@ck
ck / gist:2652983
Created May 10, 2012 13:27 — forked from stuarthalloway/gist:2645453
Datomic queries against Clojure collections
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
@ck
ck / gist:2846903
Created May 31, 2012 22:42 — forked from stuarthalloway/gist:2002582
Datomic extent query
;; Datomic example code
;;
;; The extent of entity ?x is all datoms that are about ?x.
;; Drop this into your rules.
;;
;; Demonstrates
;;
;; 1. recursive query (extent calls itself)
;; 2. disjunction (different extent bodies are ORed)
;; 3. component attributes (e.g. your arm is a component, your brother isn't)