Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Downey hiredman

View GitHub Profile
View scratch.sh
cat > /tmp/storeid.lisp <<EOF
#!/usr/bin/sbcl --script
(loop
(let* ((parts (list ""))
(_ (loop for c across (read-line) do
(cond
((equal c #\Space)
(setf parts (cons "" parts)))
('t
View scratch.clj
(defn generate-state-machine [init-state inputs states state transition? accum]
(gen/sized
(fn [size]
(if (zero? size)
(let [prev (into {} (for [[a b] (partion-all 2 1 (sort inputs))] [b a]))]
((fn f [events]
(gen/gen-pure
(rose/make-rose
events
View cont.clj
(defmacro return% [a]
`(fn return-fn# [success# error#]
#(try
(success# ~a)
(catch Throwable t#
(error# t#)))))
(defn bind% [m b]
(fn a [success error]
#(m (fn x [value] ((b value) success error)) error)))
View scratch.clj
(let [addr (java.net.UnixDomainSocketAddress/of "/tmp/222")
sc (doto (java.nio.channels.ServerSocketChannel/open java.net.StandardProtocolFamily/UNIX)
(.bind addr))]
(while true
(let [c (.accept sc)]
(future
(let [in (java.nio.channels.Channels/newInputStream c)
out (java.nio.channels.Channels/newOutputStream c)]
(binding [*in* (clojure.lang.LineNumberingPushbackReader.
(clojure.java.io/reader in))
View scratch.clj
(defn async-iteration [from-process
to-process
output-channel
& {:keys [values-selector some? init]
:or {values-selector vector
some? some?}}]
(async/go
(async/>! to-process init)
(loop [value (async/<! from-process)]
(if (some? value)
View packages.cljc
;; single file web app
;; run the following to start the process
;; clj -J-Xmx500M -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.server.repl="{:port 9457 :accept clojure.core.server/repl}" -Sdeps '{:deps {net.sourceforge.htmlunit/htmlunit {:mvn/version "2.53.0"} org.clojure/data.json {:mvn/version "2.4.0"} com.github.seancorfield/next.jdbc {:mvn/version "1.2.731"} org.postgresql/postgresql {:mvn/version "42.2.24"} org.clojure/clojurescript {:mvn/version "1.10.879"} io.undertow/undertow-core {:mvn/version "2.2.12.Final"} reagent/reagent {:mvn/version "1.1.0"} cljsjs/react {:mvn/version "17.0.2-0"} cljsjs/react-dom {:mvn/version "17.0.2-0"} com.cognitect/transit-clj {:mvn/version "1.0.324"} com.cognitect/transit-cljs {:mvn/version "0.8.269"}}}' -M -i src/packages.cljc -e '(packages/main)'
(ns packages
#?(:cljs (:require-macros [packages :as m]))
(:require
#?@(:clj ([clojure.data.json :as json]
[next.jdbc :as jdbc]
[cljs.build.api :as cljs]
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