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 future-live-update2 | |
"Will terminate in when @gate goes false." | |
[gate-ref my-function] | |
(my-function) | |
(and @gate-ref (recur gate-ref my-function))) |
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 | |
#^{:doc "This is allows us to create Decoratable collection. | |
The idea is that the we a state map and add a key :decs which points to | |
a set of keys. Each of which is associated with a Decoration. We then | |
define a recursive mutifunction that grabs this :decs set and processes | |
each in turn (order is described later). | |
There are three types of decoration function. Centre is the main function, in | |
respect to which are defined pre and post functions that occur before and | |
after centre is called, respectively. |
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 | |
#^{:doc "New definitions for a timeseries type"} | |
esjtools.ts | |
(:use clojure.test) | |
(:import (clojure.lang PersistentTreeSet))) | |
;;---------------------------------------------------------------------------- | |
(defprotocol Trim | |
"Trim a timeseries. There are performance advantages to having older+newer |
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 | |
#^{:doc "New definitions for a timeseries type"} | |
ts | |
(:use clojure.test) | |
(:import (clojure.lang PersistentTreeSet) | |
(java.io Writer))) | |
;;---------------------------------------------------------------------------- | |
(defprotocol Trim | |
"Trim a timeseries. There are performance advantages to having older+newer |
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 create-ts [dataset cons-method] | |
(reify | |
Object | |
(equals [this o] | |
(or (identical? this o) | |
(and (.isInstance name o) | |
(= dataset (. o dataset))))) | |
(hashCode [this] | |
(hash dataset)) |
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 pluralize | |
"Turn a string to plural" | |
[x] | |
(if (= (last (name x)) \y) | |
(apply str (concat (drop-last (name x)) [\i \e \s])) | |
(str (name x) "s"))) | |
(defn table [t] | |
(cql/table db (pluralize t))) |
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 accounting.database | |
(:require [clojureql.core :as cql] | |
[relational-model.core :as rel])) | |
(def db {:classname "com.mysql.jdbc.Driver" | |
:subprotocol "mysql" | |
:subname "//localhost:3306/accounting" | |
:user "root" | |
:password "" | |
:auto-commit true |
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
;;------------------------------------------------------------------------------ | |
(declare *connection*) | |
(defmacro with-redis | |
([host func] | |
`(binding [*connection* (Jedis. ~host)] | |
(try | |
(~@func) | |
(finally | |
(.disconnect *connection*)))))) |
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 it-works [] | |
(binding [*connection* "hello, world"] | |
(prn *connection*))) | |
(defn it-works-not [] | |
(binding [*connection* "hello, world"] | |
(map | |
(fn [_] (prn user/*connection*)) | |
[1 2]))) |
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
(declare *connection*) | |
(defn it-works [] | |
(binding [*connection* "hello, world"] | |
(prn *connection*))) | |
(defn it-works-now [] | |
(binding [*connection* "hello, world"] | |
(map | |
(bound-fn [_] (prn *connection*)) |
OlderNewer