Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Downey hiredman

View GitHub Profile
View lrun.clj
(defn topo [graph]
(when-not (empty? graph)
(lazy-seq
(let [n (first (for [[node s] graph
:when (not (seq s))]
node))]
(assert n "if this fails there is a cycle")
(cons n (topo (into {} (for [[node deps] graph
:when (not= n node)]
[node (disj deps n)]))))))))
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 aot.org

The Problems With Clojure AOT Compilation.

  1. The name is not clear.
    • The name is short hand for something, but it can easily be bandied about and ends up being used without understanding what it signifies.
    • The compilation model
      • reader
      • compiler
        • not interpreted
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
(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 deployer.clj
(ns deployer
(:require [clojure.tools.deps.alpha :as deps]
[clojure.tools.deps.alpha.reader :as reader]
[clojure.java.io :as io]
[clojure.string :as string])
(:import (java.security MessageDigest)
(com.jcraft.jsch JSch)
(java.net URI)))
(def hex-alphabet (vec "0123456789ABCDEF"))
View scratch.clj
(require '[clojure.set :as set])
(def info
[{:year 2017
:month 4
:data "x"}
{:year 2017
:month 4
:data "y"}
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 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)
You can’t perform that action at this time.