Skip to content

Instantly share code, notes, and snippets.

View lnostdal's full-sized avatar
🎧
Clojure, PostgreSQL, Linux

Lars Rune Nøstdal lnostdal

🎧
Clojure, PostgreSQL, Linux
View GitHub Profile
The next day, I was going to give a demonstration of cracking encryption. And then that night at my cocktail party, like 12 guys show up from the Department of Defense. Dude, I had the CIA, freaking NSA. I had everybody. And so they pulled me out there and I was like, OK, dude, the thing you're going to present tomorrow, the White House has been briefed. You're not presenting it tomorrow. And I'm like, look, no one's probably going to show up anyway. Like, no, everyone's showing up tomorrow. Iran is showing up. North Korea has got people there. And I'm like, dude, we've done legal research on this. Science has to be allowable. They said, yeah, you're right. But if you present it, we can't guarantee that your car will not meet up with a C4 brick on the way to the airport when you leave. And that's when I was like, OK, you had me at C4. So then I basically gave this prayer. I command and declare this Stargate is now open. And the moment I said the word open, I shit you not. All of the power in Giza went out.
@lnostdal
lnostdal / trend-1 XBTUSD 2h [bt-9 branch].txt
Last active March 11, 2019 21:29
trend-1 XBTUSD 2h [bt-9 branch]
687a0ac
@lnostdal
lnostdal / trend-1 XBTUSD 15sec [bt-8 branch].txt
Created February 27, 2019 10:41
trend-1 XBTUSD 15sec [bt-8 branch]
8d69b3b
@lnostdal
lnostdal / trend-1 XBTUSD 1min [bt-7 branch].txt
Last active February 27, 2019 06:17
trend-1 XBTUSD 1min [bt-7 branch]
b87b5ff -->
@lnostdal
lnostdal / trend-1 XBTUSD 5min [bt-6 branch].txt
Last active February 26, 2019 13:04
trend-1 XBTUSD 5min [bt-6 branch]
37167d096394547c3fbbdb28e99ca3e4dec8fb2c -->
@lnostdal
lnostdal / clj_bug.clj
Last active February 6, 2019 03:55
clojure compiler bug?
;; 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))
@lnostdal
lnostdal / lazy-seq + seque.clj
Last active January 19, 2019 05:27
Clojure for fast processing of streams of data via LAZY-SEQ and SEQUE
;; 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.
@lnostdal
lnostdal / async-consume-buffer.clj
Last active January 10, 2019 02:29
clojure.core.async: consume channel buffer without blocking
;; 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))
@lnostdal
lnostdal / interactive_brokers_test.clj
Last active July 31, 2018 22:26
Interactive Brokers API test in Clojure
(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