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) |
View thursday.clj
(defonce ^Logger logger (doto (Logger/getLogger "clojure") | |
(.setUseParentHandlers false) | |
(.addHandler | |
(doto (ConsoleHandler.) | |
(.setLevel Level/ALL) | |
(.setFormatter | |
(proxy [SimpleFormatter] [] | |
(format [^LogRecord record] | |
(let [sb (StringBuilder.)] | |
(.append sb "#:log{") |
View http2.clj
(defn header-encoder% [client-channel] | |
(let-cont% | |
[header-encode-service (return% (cml/channel)) | |
_ (fork% | |
(let-cont% | |
[ten (label%) | |
frame (sync% (cml/rx header-encode-service)) | |
_ (if (cml/event? frame) | |
(let-cont% | |
[eleven (label%) |
View setup.el
(delete-other-windows) | |
(let* ((left-window (selected-window)) | |
(right-top-window (split-window-right)) | |
(_ (select-window right-top-window)) | |
(right-bottom-window (split-window-below))) | |
(progn | |
(select-window left-window) | |
(find-file "~/src/thursday/thursday.clj") | |
(select-window right-top-window) |
View vpn_nat.sh
#!/bin/sh | |
VPN_IF="wg0" | |
LAN_IF="eno1" | |
MAPPED="192.168.38.1/24" | |
LAN="192.168.1.0/24" | |
VPN="10.20.40.0/24" | |
ifconfig eno1 add 192.168.1.27 |
View scratch.clj
;; use spec to define stateful protocols inspired by UBF(b) | |
;; https://ubf.github.io/ubf/ubf-user-guide.en.html | |
(require '[clojure.spec.alpha :as s] | |
'[clojure.core.async :as async]) | |
(defn ubfish | |
"Takes a protocol definition and four channels. Checks for protocol | |
violations while copying from-server to-client and from-client | |
to-server." |
View scratch.clj
(require '[clojure.core.async.impl.protocols :as impl] | |
'[clojure.core.async.impl.dispatch :as dispatch] | |
'[clojure.core.async.impl.channels :as c] | |
'[clojure.core.async :as async]) | |
;;=> nil | |
(defn wait [watchable expected?] | |
(reify | |
impl/ReadPort |
View scratch.clj
(require '[clojure.core.async.impl.protocols :as impl] | |
'[clojure.core.async.impl.dispatch :as dispatch]) | |
;;=> nil | |
(extend-type java.util.concurrent.CompletionStage | |
impl/ReadPort | |
(take! [this handler] | |
(.whenCompleteAsync this | |
(reify |
View q.clj
(defn message-queue-read-port [take-message ack-message nack-message] | |
(let [q (java.util.concurrent.LinkedBlockingQueue.)] | |
(async/thread | |
(loop [msg nil | |
handler nil] | |
(cond (and msg handler) | |
(let [_ (.lock handler) | |
take-cb (when (and (clojure.core.async.impl.protocols/active? handler) | |
(clojure.core.async.impl.protocols/commit handler)) | |
handler) |
NewerOlder