This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.set :as set]) | |
(def info | |
[{:year 2017 | |
:month 4 | |
:data "x"} | |
{:year 2017 | |
:month 4 | |
:data "y"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn double-map [f] | |
(let [^clojure.lang.IFn$DD f f] | |
(fn [f1] | |
(if (instance? clojure.lang.IFn$DDD f1) | |
(let [^clojure.lang.IFn$DDD f1 f1] | |
(fn | |
([] (f1)) | |
(^double [^double result] (.invokePrim ^clojure.lang.IFn$DD f1 result)) | |
(^double [^double result ^double input] | |
(.invokePrim f1 result (.invokePrim f input))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This is at: https://gist.github.com/8655399 | |
;; So we want a rhyming dictionary in Clojure. Jack Rusher put up | |
;; this code here: | |
;; | |
;; https://gist.github.com/jackrusher/8640437 | |
;; | |
;; I'm going to study this code and learn as I go. | |
;; | |
;; First I put it in a namespace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns lisp-ch1) | |
(def self-evaluating? | |
(some-fn number? string? char? | |
true? false? vector?)) | |
(defn -atom? [s] | |
(or (self-evaluating? s) | |
(symbol? s))) |