Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Downey hiredman

View GitHub Profile
View pi.clj
;; (load-file "/home/kevin/src/pi.clj")
(require '[clojure.pprint :as pp]
'[clojure.java.io :as io])
(def grammar
[[:program [:process 'eof?]]
[:process [:receive]]
[:process [:send]]
[:process [:par]]
View ref.clj
(set! *warn-on-reflection* true)
(defonce ref-ids (atom 0))
(declare ^java.util.concurrent.atomic.AtomicReferenceFieldUpdater ref-updater)
(deftype ARef [id
^:volatile-mutable value
offers]
clojure.lang.IDeref
View gist:c16705da66977475bf3bf75625457a41
Mar 19 03:16:39 circe systemd-oomd[483140]: Swap used (7642112000) / total (8489267200) is more than 90.00%
Mar 19 03:16:39 circe systemd[253067]: dbus-:1.2-org.freedesktop.secrets@0.service: Deactivated successfully.
Mar 19 03:16:39 circe systemd[1]: session-5.scope: systemd-oomd killed 1185 process(es) in this unit.
Mar 19 03:16:39 circe systemd-logind[1041]: Session 5 logged out. Waiting for processes to exit.
View *eshell*.txt
thursday=> (info "foo")
#:log{:z "2021-03-02T19:12:51.470Z" :v :info :n thursday :l 1 :m "foo"}
nil
thursday=> (info "foo" {::a 1})
#:log{:z "2021-03-02T19:13:06.505Z" :v :info :n thursday :l 1 :m "foo" :thursday/a 1}
nil
thursday=> (info "foo" (Exception.))
#:log{:z "2021-03-02T19:15:19.396Z" :v :info :n thursday :l 1 :m "foo" :thrown
#error {
:cause nil
View yield.clj
(ns com.manigfeald.yield
(:require [clojure.tools.analyzer :as an]
[clojure.tools.analyzer.ast :as ast]
[clojure.tools.analyzer.env :as env]
[clojure.tools.analyzer.jvm :as an-jvm]
[clojure.tools.analyzer.passes :refer [schedule]]
[clojure.tools.analyzer.passes.jvm.annotate-loops
:refer [annotate-loops]]
[clojure.tools.analyzer.passes.jvm.emit-form :as e]
[clojure.tools.analyzer.passes.jvm.warn-on-reflection
View scratch.clj
(require '[clojure.tools.namespace.find :as find]
'[clojure.java.io :as io])
(defn infer-deps
"Given an m2 (a maven repo) and a directory of clojure source code,
make up some dependencies."
[m2 src]
(let [repo (io/file m2 "repository")]
{:deps
(into
View scratch.clj
(do
(clojure.core.server/start-server
{:port 4567
:name "my-prepl"
:accept 'clojure.core.server/io-prepl})
(with-open [s (java.net.Socket. "localhost" 4567)
i (-> (.getInputStream s)
View cont.clj
(ns com.manigfeald.http2.cont)
(defn bind% [m f]
(fn [kont bundle]
(m (fn [value] ((f value) kont bundle)) bundle)))
(defmacro return% [value]
`(fn [kont# bundle#]
((try
(let [v# ~value]
View scratch.clj
(require '[clojure.core.async :as async])
(defn swim [me in out rtt announcements seed f]
(when seed
(async/put! out {:op :ping :from me :to seed}))
(async/go-loop [s {}]
(let [[val chan] (async/alts!
(cons in (for [[_ v] s :when (:chan v)] (:chan v))))
to (fn []
(async/go
View scratch.clj
(defn send-repl [& [obj]]
(let [in-in (java.io.PipedInputStream.)
in-out (java.io.PipedOutputStream. in-in)
out-in (java.io.PipedInputStream.)
out-out (java.io.PipedOutputStream. out-in)
err-in (java.io.PipedInputStream.)
err-out (java.io.PipedOutputStream. err-in)]
(tap> {:repl/in (clojure.java.io/writer in-out)
:repl/out (clojure.java.io/reader out-in)