Skip to content

Instantly share code, notes, and snippets.

View ztellman's full-sized avatar
💭
boiling the ocean

Zach Tellman ztellman

💭
boiling the ocean
View GitHub Profile
(def b (->> "a-file"
java.io.File.
java.io.FileInputStream.
aleph.formats/bytes->byte-array))
(use 'aleph.http)
(def s
(start-http-server
(wrap-ring-handler
(def ^ThreadLocal stack-depth (ThreadLocal.))
(def ^Executor overflow-protection-pool
(let [cnt (atom 0)]
(Executors/newCachedThreadPool
(thread-factory #(str "manifold-overflow-protection-pool-" (swap! cnt inc))))))
(def ^:const max-depth 50)
(defmacro without-overflow [& body]
(ns trice.stack
(:require
[clj-radix :as r])
(:import
[java.lang.reflect
Array]
[java.lang.management
ThreadMXBean
ManagementFactory
ThreadInfo]
(deftest test-let-flow
(is (= 5
@(let [z (future 1)]
(let-flow [x (future (future z))
y (future (+ z x))]
(future (+ x x y z)))))))
(future
(loop [next-update (+ (System/currentTimeMillis) 1e3)]
(with-open [w (io/writer path)]
(.write w (str (.time ^PartialFlake @f))))
;; sleep for a second before writing the next timestamp
(Thread/sleep (- next-update (System/currentTimeMillis)))
(recur (+ next-update 1e3))))
diff --git a/src/jvm/clojure/lang/PersistentUnrolledMap.java b/src/jvm/clojure/lang/PersistentUnrolledMap.java
new file mode 100644
index 0000000..c5b401c
--- /dev/null
+++ b/src/jvm/clojure/lang/PersistentUnrolledMap.java
@@ -0,0 +1,3292 @@
+/**
+ * Copyright (c) Rich Hickey. All rights reserved.
+ * The use and distribution terms for this software are covered by the
+ * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)

Keybase proof

I hereby claim:

  • I am ztellman on github.
  • I am ztellman (https://keybase.io/ztellman) on keybase.
  • I have a public key whose fingerprint is 38F1 E8B7 E2E2 92D7 78EF 5993 36A8 9F3F 7E4C 9221

To claim this, I am signing this object:

(require
'[clojure.string as str]
'[manifold.stream :as s]
'[byte-streams :as bs])
;; approach #1
(defn handler [s _]
(s/connect
(s/map #(str/upper-case (bs/to-string %)))
s))
(require '[manifold.stream :as s])
(defn streaming-response [ch]
{:status 200
:headers {"content-type" "text/plain"}
:body (s/->stream ch)})
(require
'[manifold.deferred :as d]
'[manifold.stream :as s])
(defn take-first! [pred s]
(d/loop []
(d/chain (s/take! s ::none)
#(cond
(identical? ::none %)
nil