Skip to content

Instantly share code, notes, and snippets.

View cddr's full-sized avatar

Andy Chambers cddr

View GitHub Profile
(defn encrypt [attr]
(reify
clojure.lang.Named
(getNamespace [this]
(.getNamespace attr))
(getName [this]
(.getName attr))
clojure.lang.IFn
(invoke [_ obj]
@cddr
cddr / dept.clj
Last active August 29, 2015 14:15
(defentity Department
:schema {:id Int
:name Str}
:uniqueness {:id :db.unique/identity})
@cddr
cddr / emp.clj
Created February 12, 2015 16:09
(defentity Employee
:schema {:id Int, :name Str}
:links [(link :department [Department :id])]
:uniqueness {:id :db.unique/identity})
(defentity Cart
:schema {:id Int
:name Str
:items [{:id Int
:qty Int
:price Num}]}
:uniqueness {:id :db.unique/identity})
@cddr
cddr / Emacs.md
Last active August 29, 2015 14:19

Setting up Emacs daemon on OS X

Tired of waiting for emacs to start on OS X? This step by step guide will teach you how to install the latest version of emacs and configure it to start in the background (daemon mode) and use emacsclient as your main editor.

Install Homebrew

First you'll need to install the [Homebrew package manager][brew] if yo haven't already. It is amazing.

@cddr
cddr / gist:5cf86ddd7fd7a6d96234
Created July 15, 2015 21:10
Hello Samza output log
$ deploy/samza/bin/run-job.sh --config-factory=org.apache.samza.config.factories.PropertiesConfigFactory --config-path=file://$PWD/deploy/samza/config/wikipedia-feed.properties
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
java -Dlog4j.configuration=file:deploy/samza/bin/log4j-console.xml -Dsamza.log.dir=/Users/andychambers/workspace/hello-samza/deploy/samza -Djava.io.tmpdir=/Users/andychambers/workspace/hello-samza/deploy/samza/tmp -Xmx768M -XX:+PrintGCDateStamps -Xloggc:/Users/andychambers/workspace/hello-samza/deploy/samza/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10241024 -d64 -cp /Users/andychambers/.samza/conf:/Users/andychambers/workspace/hello-samza/deploy/samza/lib/activation-1.1.jar:/Users/andychambers/workspace/hello-samza/deploy/samza/lib/akka-actor_2.10-2.1.2.jar:/Users/andychambers/workspace/hello-samza/deploy/samza/lib/aopalliance-1.0.jar:/Users/andychambers/workspac
(def ^:dynamic *foo*)
(defn call-with-foo [foo-fn]
(binding [*foo* 42]
(foo-fn)))
(call-with-foo (fn []
(map (fn [_]
*foo*)
(range 10))))
;; This one doesn't agree with Danny's test-cases but I think it matches the spirit of
;; the problem a little better in that it doesn't include an entry for the coin if
;; the quantity of that coin would be zero.
;;
;; Also, we're global, so I used UK coins
;;
;; So e.g. (change-coins 18) = {10 1, 5 1, 2 1, 1 1}
(def coins [100 50 20 10 5 2 1])
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/util/Args, compiling:(cemerick/pomegranate/aether.clj:42:54)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6730)
at clojure.lang.Compiler.analyze(Compiler.java:6524)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6711)
at clojure.lang.Compiler.analyze(Compiler.java:6524)
at clojure.lang.Compiler.analyze(Compiler.java:6485)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5861)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5296)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3925)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6721)
# Shell prompt based on the Solarized Dark theme.
# Screenshot: http://i.imgur.com/EkEtphC.png
# Heavily inspired by @necolas’s prompt: https://github.com/necolas/dotfiles
# iTerm → Profiles → Text → use 13pt Monaco with 1.1 vertical spacing.
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM='gnome-256color';
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM='xterm-256color';
fi;