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
aoeuaoeu |
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
687a0ac |
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
8d69b3b |
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
b87b5ff --> |
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
37167d096394547c3fbbdb28e99ca3e4dec8fb2c --> |
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
;; maybe something related to locals clearing and/or forwarding of bindings (?) | |
;; warning: this will lead to heap overflow quite fast! | |
(let [s (range)] | |
(if true | |
(future | |
(loop [s s] | |
(recur (rest s)))) | |
:whatever)) |
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
;; www.Quanto.ga | |
;; | |
;; * You have a stream of data where generating each new element for the stream takes some time. | |
;; * You consume and do some calculations on each element from the stream; this too takes some time. | |
;; * When the consumer is done with its calculations for a element (or chunk of elements!) you do | |
;; not want it to wait around for the code that fetches new elements to finish fetching a new element | |
;; -- because this could be done in the background while you where doing the calculations. | |
;; | |
;; A way to deal with this is to use SEQUE which will keep production N steps in advance of consumption | |
;; via a background thread that works on Clojue seqs. |
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
;; www.Quanto.ga | |
;; | |
;; I've found this to be useful at times: | |
(defn async-consume-buffer | |
"Consume as many values from `ch` as possible without blocking. | |
Once `ch` blocks (i.e. its buffer is empty), the values are returned as a vector." | |
([ch] | |
(async-consume-buffer ch false)) |
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 %bnds (get-thread-bindings)) ;; TODO: Seems kind of hacky, but needed as sometimes (EWrapper/error Exception) is sourced from different threads(!). | |
(deftype IB | |
[^:unsynchronized-mutable ^int next-order-id | |
^:unsynchronized-mutable ^com.ib.client.EClient eclient | |
^:unsynchronized-mutable ^com.ib.client.EReaderSignal ereader-signal] | |
com.ib.client.EWrapper |
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
;; ...and yes; I know there are more efficient ways to do this. | |
(defn sma ^doubles [^doubles pseries ^long ma-len] | |
"Simple Moving Average: https://en.wikipedia.org/wiki/Moving_average#Simple_moving_average | |
Returns a JVM double[]. Head is padded with ##NaN entries to align it with `pseries`." | |
(if (= ma-len 1) | |
pseries | |
(let [pseries-len (alength pseries), ret (double-array pseries-len ##NaN)] |
NewerOlder