This file contains hidden or 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
(defmacro make-servlet | |
"Call to generate a servlet class given the class name and a ring handler." | |
[servlet handler] | |
(let [servlet (name servlet), prefix (str servlet "-")] | |
`(do (println "Compiling Servlet" ~servlet) | |
(gen-class :name ~servlet | |
:prefix ~prefix | |
:extends javax.servlet.http.HttpServlet) | |
(s/defservice ~prefix ~handler)))) |
This file contains hidden or 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 secret-santa.logic | |
(:refer-clojure :exclude [==]) | |
(:require [clojure.core.logic :refer :all])) | |
(defrel cannot-give ^:index p1 ^:index p2) | |
(fact cannot-give 'adam 'ashley) | |
(fact cannot-give 'bill 'brandon) | |
(fact cannot-give 'carl 'cynthia) |
This file contains hidden or 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
(defn p19-solution [] | |
(let [multiple? #(zero? (rem %1 %2)) | |
leap-year? #(or (and (multiple? % 4) | |
(not (multiple? % 100))) | |
(multiple? % 400)) | |
february #(if (leap-year? %) 29 28) | |
mdays [31 28 31 30 31 30 31 31 30 31 30 31] | |
mdays (map #(constantly %) mdays) | |
mdays (apply juxt (assoc (vec mdays) 1 february)) | |
months (mapcat mdays (range 1901 2001)) |
This file contains hidden or 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
;; Extra xterm bindings | |
(require 'xterm) | |
(define-key xterm-function-map "\e[1;9A" [M-up]) | |
(define-key xterm-function-map "\e[1;9B" [M-down]) | |
(define-key xterm-function-map "\e[1;9C" [M-right]) | |
(define-key xterm-function-map "\e[1;9D" [M-left]) | |
(define-key xterm-function-map "\e[1;9F" [M-end]) | |
(define-key xterm-function-map "\e[1;9H" [M-home]) |
This file contains hidden or 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 bench.core | |
(:require [criterium [core :as c]])) | |
(def | |
^{:arglists '([coll x] [coll x & xs]) | |
:doc "conj[oin]. Returns a new collection with the xs | |
'added'. (conj nil item) returns (item). The 'addition' may | |
happen at different 'places' depending on the concrete type." | |
:added "1.0" | |
:static true} |
This file contains hidden or 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
(defn ^:private mean-sd-step | |
[[n m s] ^double x] | |
(let [n (long n), m (double m), s (double s) | |
n (inc n), d (- x m), m (+ m (/ d n)), s (+ s (* d (- x m)))] | |
[n m s])) | |
(defn mean-sd | |
"Calculate mean and (sample) standard-deviation of `vals`." | |
[vals] | |
(let [[n m s] (reduce mean-sd-step [0 0.0 0.0] vals)] |
This file contains hidden or 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
#! /bin/bash -e | |
PACKAGE=leiningen | |
VERSION=2.1.2 | |
ITERATION=1 | |
DEBVERSION=${VERSION}+dbla.${ITERATION} | |
BINDIR=/opt/damballa/bin | |
LIBDIR=/opt/damballa/lib/leiningen |
This file contains hidden or 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 lenskit-hello.core | |
(:require [clojure.java.io :as io]) | |
(:import [org.grouplens.lenskit | |
ItemRecommender ItemScorer Recommender RecommenderBuildException] | |
[org.grouplens.lenskit.baseline | |
BaselineScorer ItemMeanRatingItemScorer UserMeanBaseline | |
UserMeanItemScorer] | |
[org.grouplens.lenskit.core | |
LenskitConfiguration LenskitRecommender] | |
[org.grouplens.lenskit.cursors Cursors] |
This file contains hidden or 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 ropasc.core | |
(:refer-clojure :exclude [==]) | |
(:require [clara.rules :as cr :refer [defrule defquery ==]])) | |
(defrecord Action [player choice]) | |
(defrecord Victory [winner loser]) | |
(defrecord Tie [player1 player2]) |
This file contains hidden or 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
(defmacro defmulti-group | |
"Define a group of related multimethods." | |
[& forms] `(do ~@(map #(cons 'defmulti %) forms))) | |
(defmacro defmethod-group | |
"Implement a group of related multimethods sharing common dispatch values." | |
[& specs] | |
(letfn [(parse-impls [specs] | |
(lazy-seq | |
(when (seq specs) |