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 example.locks | |
(:import [clojure.lang IDeref IBlockingDeref] | |
[java.util.concurrent TimeUnit] | |
[java.util.concurrent.locks Lock ReadWriteLock | |
ReentrantReadWriteLock])) | |
(defmacro ^:private with-lock | |
([lock body] | |
`(try (.lock ~lock) ~@body (finally (.unlock ~lock)))) | |
([lock timeout-ms timeout-val body] |
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
(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 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
(def ^:private type-max | |
{'byte Byte/MAX_VALUE, | |
'short Short/MAX_VALUE, | |
'int Integer/MAX_VALUE}) | |
(defn ^:private signed* | |
[type x] | |
(let [max (type-max type), roll (->> max long inc (* 2))] | |
`(~type (let [x# (long ~x)] (if (<= x# ~max) x# (- x# ~roll)))))) |
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
(defn parse-nx | |
"Parse & filter raw NX records. Truncate QNAMEs to E2LDs." | |
[[sensor rest]] | |
(ignore-errors | |
(am/domonad am/maybe-m | |
[:when (not (v-sensor? sensor)) | |
[ts client domain :as fields] (str/split rest #"\t" 3) | |
:when (valid-fields? 3 fields) | |
ts (Long/parseLong ts 10) | |
domain (flat/domain-e2ld @etlds domain) |
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 parkour.examples.mmo | |
"Where `mmo` stands for Multiple Map Output." | |
(:require [clojure.string :as str] | |
[clojure.core.reducers :as r] | |
[parkour (conf :as conf) (fs :as fs) (wrapper :as w) | |
(mapreduce :as mr) (graph :as pg) (tool :as tool)] | |
[parkour.io (dseq :as dseq) (text :as text) (dux :as dux)] | |
[parkour.util :refer [returning]])) | |
(defn ->prefix |
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 ... | |
(:import [clojure.lang IDeref] | |
...) | |
(definterface UUPrecalc) | |
(defprovider uu-precalc | |
^UUPrecalc [^UserDAO udao, ^UserEventDAO uedao] | |
(let [data ...] | |
(reify UUPrecalc IDeref (deref [_] data)))) |
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
(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) |
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 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 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 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 |
NewerOlder