tag:blogger.com,1999:blog-79670275150777819542024-03-05T04:15:06.014-08:00Clojure, Linux, Security, etc.mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.comBlogger64125tag:blogger.com,1999:blog-7967027515077781954.post-83535613804054778682019-02-24T10:20:00.002-08:002019-02-24T14:29:27.166-08:00Clojure compress / decompress data examples<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="https://gist.github.com/b2026b712ecb73012e680805c56af45f">https://gist.github.com/b2026b712ecb73012e680805c56af45f</a></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-3019199194631249372019-02-17T13:10:00.002-08:002019-02-17T14:29:10.392-08:00ED25519 Clojure Example<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="https://gist.github.com/0b44ab0fb2b8635c146c3e45227b826c">https://gist.github.com/0b44ab0fb2b8635c146c3e45227b826c</a><br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-58294886621884785252018-11-18T06:41:00.002-08:002018-11-18T07:44:04.815-08:00clojure async interceptors demo<div dir="ltr" style="text-align: left;" trbidi="on">
1. deps.edn file<br />
<pre style="background-color: #09172b; color: #a9b7c6; font-family: "Fira Code"; font-size: 9pt;">{<span style="color: #d79738; font-style: italic;">:paths </span>[<span style="color: #40ac10;">"src/clj" "src/cljs" "test" "resources" "target"</span>]
<span style="color: #d79738; font-style: italic;">:extra-paths </span>[<span style="color: #40ac10;">"resources" "resources/public"</span>] <span style="color: #4e6f91;">;; fix cambada packaging</span><span style="color: #4e6f91;">
</span><span style="color: #4e6f91;"> </span><span style="color: #d79738; font-style: italic;">:deps </span>{<span style="color: #8ac6f2;">org.clojure/clojure </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"1.10.0-beta6"</span>}
<span style="color: #8ac6f2;">org.clojure/core.async </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.4.474"</span>}
<span style="color: #8ac6f2;">org.clojure/spec.alpha </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.2.176"</span>}
<span style="color: #8ac6f2;">org.clojure/core.specs.alpha </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.2.44"</span>}
<span style="color: #8ac6f2;">http-kit/http-kit </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"2.3.0"</span>}
<span style="color: #8ac6f2;">metosin/sieppari </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.0.0-alpha6"</span>}
<span style="color: #8ac6f2;">metosin/reitit </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.2.7"</span>}
<span style="color: #8ac6f2;">fipp </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.6.14"</span>}}
<span style="color: #d79738; font-style: italic;">:aliases </span>{<span style="color: #d79738; font-style: italic;">:repl </span>{<span style="color: #d79738; font-style: italic;">:extra-deps </span>{<span style="color: #8ac6f2;">nrepl/nrepl </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.4.5"</span>}
<span style="color: #8ac6f2;">com.bhauman/rebel-readline </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.1.4"</span>}
<span style="color: #8ac6f2;">cider/piggieback </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.3.8"</span>}
<span style="color: #8ac6f2;">com.bhauman/figwheel-main </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.1.9"</span>}}
<span style="color: #d79738; font-style: italic;">:extra-paths </span>[<span style="color: #40ac10;">"src" "env/development/clj"</span>]
<span style="color: #d79738; font-style: italic;">:main-opts </span>[<span style="color: #40ac10;">"--main" "nrepl.cmdline" "--port" "7888" "--middleware" "[cider.piggieback/wrap-cljs-repl]"</span>]}}}</pre>
<br />
<br />
2. Source code<br />
<br />
<pre style="background-color: #09172b; color: #a9b7c6; font-family: "Fira Code"; font-size: 9pt;">(<span style="color: #8ac6f2;">ns test01.core</span><span style="color: #8ac6f2;"> </span>(<span style="color: #d79738; font-style: italic;">:gen-class</span>)
(<span style="color: #d79738; font-style: italic;">:require </span>[<span style="color: #8ac6f2;">org.httpkit.server </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">kit</span>]
[<span style="color: #8ac6f2;">org.httpkit.client </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">kit-client</span>]
[<span style="color: #8ac6f2;">sieppari.core </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">sieppari</span>]
[<span style="color: #8ac6f2;">sieppari.context</span>]
[<span style="color: #8ac6f2;">muuntaja.interceptor</span>]
[<span style="color: #8ac6f2;">clojure.core.async </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">a </span><span style="color: #d79738; font-style: italic;">:refer </span>[<span style="color: #8ac6f2;">go chan <! <!! >! >!! timeout close! put! take! alts! alts!!</span>]]
[<span style="color: #8ac6f2;">reitit.ring </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">ring</span>]
[<span style="color: #8ac6f2;">reitit.http </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">http</span>]
[<span style="color: #8ac6f2;">reitit.core </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">r</span>]
[<span style="color: #8ac6f2;">fipp.edn </span><span style="color: #d79738; font-style: italic;">:refer </span>(<span style="color: #8ac6f2;">pprint</span>)]
[<span style="color: #8ac6f2;">reitit.interceptor.sieppari</span>]))
(<span style="color: #8ac6f2;">def <async> </async></span>#(<span style="color: #8ac6f2;">a/go %</span>))
(<span style="color: #8ac6f2;">def <sync> identity</sync></span>)
(<span style="color: #8ac6f2;">def <thread> </thread></span>#(<span style="color: #8ac6f2;">a/thread %</span>))
(<span style="color: #8ac6f2;">defn prn-tap </span>[<span style="color: #8ac6f2;">v</span>]
(<span style="color: #8ac6f2;">println v</span>))
(<span style="color: #8ac6f2;">add-tap prn-tap</span>)
(<span style="color: #8ac6f2;">defn interceptor </span>[<span style="color: #8ac6f2;">f x</span>]
{<span style="color: #d79738; font-style: italic;">:enter </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>] (<span style="color: #8ac6f2;">f</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">update-in ctx </span>[<span style="color: #d79738; font-style: italic;">:request :via</span>] (<span style="color: #8ac6f2;">fnil conj </span>[]) {<span style="color: #d79738; font-style: italic;">:enter </span><span style="color: #8ac6f2;">x</span><span style="color: #8ac6f2;"> </span><span style="color: #d79738; font-style: italic;">:thread </span>(<span style="color: #8ac6f2;">.getName </span>(<span style="color: #8ac6f2;">Thread/currentThread</span>))})))
<span style="color: #d79738; font-style: italic;">:leave </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>] (<span style="color: #8ac6f2;">f</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">update-in ctx </span>[<span style="color: #d79738; font-style: italic;">:response :body</span>] <span style="color: #8ac6f2;">conj </span>{<span style="color: #d79738; font-style: italic;">:leave </span><span style="color: #8ac6f2;">x</span><span style="color: #8ac6f2;"> </span><span style="color: #d79738; font-style: italic;">:thread </span>(<span style="color: #8ac6f2;">.getName </span>(<span style="color: #8ac6f2;">Thread/currentThread</span>))})))})
(<span style="color: #8ac6f2;">defn handler </span>[<span style="color: #8ac6f2;">f data</span>]
(<span style="color: #8ac6f2;">fn </span>[{<span style="color: #d79738; font-style: italic;">:keys </span>[<span style="color: #8ac6f2;">via</span>] <span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">request</span>}]
(<span style="color: #8ac6f2;">f</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">do</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">pprint </span>(<span style="color: #8ac6f2;">dissoc request </span><span style="color: #d79738; font-style: italic;">:reitit.core/match :reitit.core/router</span>))
{<span style="color: #d79738; font-style: italic;">:status </span><span style="color: white;">200</span>,
<span style="color: #d79738; font-style: italic;">:body </span>(<span style="color: #8ac6f2;">conj via </span>(<span style="color: #8ac6f2;">str </span>{<span style="color: #d79738; font-style: italic;">:handler </span><span style="color: #8ac6f2;">data</span><span style="color: #8ac6f2;"> </span><span style="color: #d79738; font-style: italic;">:thread </span>(<span style="color: #8ac6f2;">.getName </span>(<span style="color: #8ac6f2;">Thread/currentThread</span>))}))}))))
(<span style="color: #8ac6f2;">def routes </span>(<span style="color: #8ac6f2;">http/router </span>[[<span style="color: #40ac10;">"/" </span>{<span style="color: #d79738; font-style: italic;">:get </span>{<span style="color: #d79738; font-style: italic;">:handler </span>(<span style="color: #8ac6f2;">handler <async> </async></span><span style="color: #40ac10;">"root"</span>)}}]
[<span style="color: #40ac10;">"/test1"</span><span style="color: #40ac10;"> </span>[<span style="color: #40ac10;">"" </span>{<span style="color: #d79738; font-style: italic;">:name ::test1</span><span style="color: #d79738; font-style: italic;"> :interceptors </span>[(<span style="color: #8ac6f2;">interceptor <sync> </sync></span><span style="color: #d79738; font-style: italic;">:test1</span>)]
<span style="color: #d79738; font-style: italic;">:get </span>{<span style="color: #d79738; font-style: italic;">:handler </span>(<span style="color: #8ac6f2;">handler <sync> </sync></span><span style="color: #40ac10;">"test1"</span>)}}]
[<span style="color: #40ac10;">"/test2" </span>{<span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">interceptor <async> </async></span><span style="color: #d79738; font-style: italic;">:test2-level</span>)]
<span style="color: #d79738; font-style: italic;">:get </span>{<span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">interceptor <thread> </thread></span><span style="color: #d79738; font-style: italic;">:test2-get</span>)]
<span style="color: #d79738; font-style: italic;">:handler </span>(<span style="color: #8ac6f2;">handler <async> </async></span><span style="color: #40ac10;">"test2"</span>)}}]]]))
<span style="color: #4e6f91;">;;(r/routes routes)</span><span style="color: #4e6f91;">
</span>(<span style="color: #8ac6f2;">def app </span>(<span style="color: #8ac6f2;">http/ring-handler routes</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">ring/create-default-handler</span>)
{<span style="color: #d79738; font-style: italic;">:executor </span><span style="color: #8ac6f2;">reitit.interceptor.sieppari/executor</span><span style="color: #8ac6f2;"> </span><span style="color: #d79738; font-style: italic;">:interceptors </span>[]}))
(<span style="color: #8ac6f2;">app </span>{<span style="color: #d79738; font-style: italic;">:uri </span><span style="color: #40ac10;">"/test1/test2"</span><span style="color: #40ac10;"> </span><span style="color: #d79738; font-style: italic;">:request-method :get</span>})
(<span style="color: #8ac6f2;">def params </span>{<span style="color: #d79738; font-style: italic;">:host </span><span style="color: #40ac10;">"0.0.0.0" </span><span style="color: #d79738; font-style: italic;">:port </span><span style="color: white;">8080</span>})
(<span style="color: #8ac6f2;">defn start-server</span><span style="color: #8ac6f2;"> </span>[<span style="color: #8ac6f2;">handler params</span>]
(<span style="color: #8ac6f2;">kit/run-server handler params</span>))
(<span style="color: #8ac6f2;">defn -main </span><span style="color: #40ac10;">"entry point"</span><span style="color: #40ac10;"> </span>[<span style="color: #8ac6f2;">& args</span>]
(<span style="color: #8ac6f2;">start-server app params</span>)
(<span style="color: #8ac6f2;">println </span><span style="color: #40ac10;">"server is started: " </span><span style="color: #8ac6f2;">params</span>))
<span style="color: #4e6f91;">;; ----------- client and repl zone---------------------------------------</span><span style="color: #4e6f91;">
</span>(<span style="color: #8ac6f2;">defn handle-response</span><span style="color: #8ac6f2;"> </span>[<span style="color: #8ac6f2;">resp</span>]
(<span style="color: #8ac6f2;">println </span>(<span style="color: #d79738; font-style: italic;">:body </span><span style="color: #8ac6f2;">resp</span>)))
(<span style="color: #8ac6f2;">comment</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">def stop-fn </span>(<span style="color: #8ac6f2;">start-server app params</span>))
(<span style="color: #8ac6f2;">time </span>(<span style="color: #8ac6f2;">dotimes </span>[<span style="color: #8ac6f2;">_ </span><span style="color: white;">10</span>]
(<span style="color: #8ac6f2;">kit-client/get </span><span style="color: #40ac10;">"http://localhost:8080" </span>{<span style="color: #d79738; font-style: italic;">:timeout </span><span style="color: white;">20000</span>} <span style="color: #8ac6f2;">handle-response</span>)))
(<span style="color: #8ac6f2;">time </span>(<span style="color: #8ac6f2;">slurp </span><span style="color: #40ac10;">"http://localhost:8080/test1"</span>))
(<span style="color: #8ac6f2;">stop-fn</span>))
</pre>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-51950571280484240282018-11-17T04:09:00.003-08:002018-11-17T04:09:40.433-08:00clojure reitit router<div dir="ltr" style="text-align: left;" trbidi="on">
all you need to know is here<br />
<pre style="background-color: #09172b; color: #a9b7c6; font-family: "Fira Code"; font-size: 9pt;">(<span style="color: #8ac6f2;">def routes </span>(<span style="color: #8ac6f2;">http/router </span>[[<span style="color: #40ac10;">"/" </span>{<span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">interceptor <async> </async></span><span style="color: #d79738; font-style: italic;">:async</span>) (<span style="color: #8ac6f2;">interceptor2 </span><span style="color: #d79738; font-style: italic;">:root-2</span>)]
<span style="color: #d79738; font-style: italic;">:get </span>{<span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">interceptor <async> </async></span><span style="color: #d79738; font-style: italic;">:get</span>) (<span style="color: #8ac6f2;">interceptor2 </span><span style="color: #d79738; font-style: italic;">:get-2</span>)]
<span style="color: #d79738; font-style: italic;">:handler </span>(<span style="color: #8ac6f2;">handler <async> </async></span><span style="color: #40ac10;">"root"</span>)}}]
[<span style="color: #40ac10;">"/test1" </span>{<span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">interceptor <async> </async></span><span style="color: #d79738; font-style: italic;">:level-test-1-1</span>) (<span style="color: #8ac6f2;">interceptor2 </span><span style="color: #d79738; font-style: italic;">:level-test-1-2</span>)]}
[<span style="color: #40ac10;">"" </span>{<span style="color: #d79738; font-style: italic;">:name ::test1</span><span style="color: #d79738; font-style: italic;"> :interceptors </span>[(<span style="color: #8ac6f2;">interceptor <async> </async></span><span style="color: #d79738; font-style: italic;">:test1-hanler-level-int1</span>) (<span style="color: #8ac6f2;">interceptor2 </span><span style="color: #d79738; font-style: italic;">:test1-hanler-level-int1</span>)]
<span style="color: #d79738; font-style: italic;">:get </span>{<span style="color: #d79738; font-style: italic;">:handler </span>(<span style="color: #8ac6f2;">handler <sync> </sync></span><span style="color: #40ac10;">"test1"</span>)}}]
[<span style="color: #40ac10;">"/test2" </span>{<span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">interceptor <async> </async></span><span style="color: #d79738; font-style: italic;">:level-test-2-1</span>) (<span style="color: #8ac6f2;">interceptor2 </span><span style="color: #d79738; font-style: italic;">:level-test-2-2</span>)]
<span style="color: #d79738; font-style: italic;">:get </span>{<span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">interceptor <async> </async></span><span style="color: #d79738; font-style: italic;">:test2-hanler-level-int1</span>) (<span style="color: #8ac6f2;">interceptor2 </span><span style="color: #d79738; font-style: italic;">:test2-hanler-level-int2</span>)]
<span style="color: #d79738; font-style: italic;">:handler </span>(<span style="color: #8ac6f2;">handler <sync> </sync></span><span style="color: #40ac10;">"test2"</span>)}}]]]))</pre>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-61014350864715960722018-10-21T05:20:00.002-07:002018-11-16T03:18:06.568-08:00clojure interceptors<div dir="ltr" style="text-align: left;" trbidi="on">
1. dep.edn<br />
<pre style="background-color: #09172b; color: #a9b7c6; font-family: "Fira Code"; font-size: 9pt;">{<span style="color: #d79738; font-style: italic;">:paths </span>[<span style="color: #40ac10;">"src/clj" "src/cljs" "test" "resources" "target"</span>]
<span style="color: #d79738; font-style: italic;">:extra-paths </span>[<span style="color: #40ac10;">"resources" "resources/public"</span>] <span style="color: #4e6f91;">;; fix cambada packaging</span><span style="color: #4e6f91;">
</span><span style="color: #4e6f91;"> </span><span style="color: #d79738; font-style: italic;">:deps </span>{<span style="color: #8ac6f2;">org.clojure/clojure </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"1.10.0-RC1"</span>}
<span style="color: #8ac6f2;">org.clojure/core.async </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.4.474"</span>}
<span style="color: #8ac6f2;">org.clojure/spec.alpha </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.2.176"</span>}
<span style="color: #8ac6f2;">org.clojure/core.specs.alpha </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.2.44"</span>}
<span style="color: #8ac6f2;">http-kit/http-kit </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"2.3.0"</span>}
<span style="color: #8ac6f2;">metosin/sieppari </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.0.0-alpha5"</span>}
<span style="color: #8ac6f2;">fipp </span>{<span style="color: #d79738; font-style: italic;">:mvn/version </span><span style="color: #40ac10;">"0.6.13"</span>}}}</pre>
<br />
2. source code<br />
<br />
<pre style="background-color: #09172b; color: #a9b7c6; font-family: "Fira Code"; font-size: 9pt;">(<span style="color: #8ac6f2;">ns test01.core</span><span style="color: #8ac6f2;"> </span>(<span style="color: #d79738; font-style: italic;">:gen-class</span>)
(<span style="color: #d79738; font-style: italic;">:require </span>[<span style="color: #8ac6f2;">org.httpkit.server </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">kit</span>]
[<span style="color: #8ac6f2;">org.httpkit.client </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">kit-client</span>]
[<span style="color: #8ac6f2;">sieppari.core </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">sieppari</span>]
[<span style="color: #8ac6f2;">sieppari.context</span>]
[<span style="color: #8ac6f2;">clojure.core.async </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">a </span><span style="color: #d79738; font-style: italic;">:refer </span>[<span style="color: #8ac6f2;">go chan <! <!! >! >!! timeout close! put! take! alts! alts!!</span>]]))
(<span style="color: #8ac6f2;">defn prn-tap </span>[<span style="color: #8ac6f2;">v</span>]
(<span style="color: #8ac6f2;">println v</span>))
(<span style="color: #8ac6f2;">add-tap prn-tap</span>)
<span style="color: #4e6f91;">;;(require '[fipp.edn :refer (pprint) :rename {pprint fipp}])</span><span style="color: #4e6f91;">
</span>(<span style="color: #8ac6f2;">def int-1</span><span style="color: #8ac6f2;"> </span>{<span style="color: #d79738; font-style: italic;">:name :int-1</span><span style="color: #d79738; font-style: italic;"> :enter </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>]
(<span style="color: #8ac6f2;">tap> </span><span style="color: #d79738; font-style: italic;">:int-1</span>)
<span style="color: #8ac6f2;">ctx</span>)
<span style="color: #d79738; font-style: italic;">:leave </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>]
(<span style="color: #8ac6f2;">tap> </span><span style="color: #d79738; font-style: italic;">:int-1-leave</span>)
<span style="color: #8ac6f2;">ctx</span>)})
(<span style="color: #8ac6f2;">def int-2</span><span style="color: #8ac6f2;"> </span>{<span style="color: #d79738; font-style: italic;">:name :int-2</span><span style="color: #d79738; font-style: italic;"> :enter </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>]
(<span style="color: #8ac6f2;">go</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;"><! </span>(<span style="color: #8ac6f2;">a/timeout </span><span style="color: white;">1000</span>))
(<span style="color: #8ac6f2;">tap> </span><span style="color: #d79738; font-style: italic;">:int-2</span>)
<span style="color: #8ac6f2;">ctx</span>))})
(<span style="color: #8ac6f2;">def int-3</span><span style="color: #8ac6f2;"> </span>{<span style="color: #d79738; font-style: italic;">:name :int-3</span><span style="color: #d79738; font-style: italic;"> :enter </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>]
(<span style="color: #8ac6f2;">sieppari.context/terminate ctx </span>{<span style="color: #d79738; font-style: italic;">:status </span><span style="color: white;">200</span><span style="color: white;"> </span><span style="color: #d79738; font-style: italic;">:headers </span>{<span style="color: #40ac10;">"Content-Type" "text/plain"</span>}
<span style="color: #d79738; font-style: italic;">:body </span><span style="color: #40ac10;">"yo! error!"</span>}))})
(<span style="color: #8ac6f2;">def int-4</span><span style="color: #8ac6f2;"> </span>{<span style="color: #d79738; font-style: italic;">:name :int-4</span><span style="color: #d79738; font-style: italic;"> :enter </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>]
(<span style="color: #8ac6f2;">/ </span><span style="color: white;">1 0</span>)
<span style="color: #8ac6f2;">ctx</span>)
<span style="color: #d79738; font-style: italic;">:error </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>]
(<span style="color: #8ac6f2;">tap> </span>[<span style="color: #40ac10;">"got error:" </span>(<span style="color: #8ac6f2;">-> ctx </span><span style="color: #d79738; font-style: italic;">:error </span><span style="color: #8ac6f2;">.getMessage</span>)])
<span style="color: #4e6f91;">;;(fipp ctx)</span><span style="color: #4e6f91;"> </span>(<span style="color: #8ac6f2;">assoc ctx </span><span style="color: #d79738; font-style: italic;">:error </span><span style="color: #8ac6f2; font-weight: bold;">nil</span><span style="color: #8ac6f2; font-weight: bold;"> </span><span style="color: #d79738; font-style: italic;">:response </span>{<span style="color: #d79738; font-style: italic;">:status </span><span style="color: white;">200</span><span style="color: white;"> </span><span style="color: #d79738; font-style: italic;">:headers </span>{<span style="color: #40ac10;">"Content-Type" "text/plain"</span>}
<span style="color: #d79738; font-style: italic;">:body </span>[<span style="color: #40ac10;">"got error: " </span>(<span style="color: #8ac6f2;">-> ctx </span><span style="color: #d79738; font-style: italic;">:error </span><span style="color: #8ac6f2;">.getMessage</span>)] }))})
(<span style="color: #8ac6f2;">defn handler </span>[<span style="color: #8ac6f2;">request</span>]
{<span style="color: #d79738; font-style: italic;">:status </span><span style="color: white;">200</span><span style="color: white;"> </span><span style="color: #d79738; font-style: italic;">:headers </span>{<span style="color: #40ac10;">"Content-Type" "text/plain"</span>}
<span style="color: #d79738; font-style: italic;">:body </span>(<span style="color: #d79738; font-style: italic;">:remote-addr </span><span style="color: #8ac6f2;">request</span>)})
(<span style="color: #8ac6f2;">def pipeline </span>[<span style="color: #8ac6f2;">int-1 int-2 </span><span style="color: #4e6f91;">#_int-3 #_int-4 </span><span style="color: #8ac6f2;">handler</span>])
(<span style="color: #8ac6f2;">defn exec-request </span>[<span style="color: #8ac6f2;">request</span>]
(<span style="color: #8ac6f2;">a/thread</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">tap> </span>[<span style="color: #40ac10;">"exec " </span>(<span style="color: #8ac6f2;">.getName </span>(<span style="color: #8ac6f2;">Thread/currentThread</span>))])
(<span style="color: #8ac6f2;">sieppari/execute pipeline request</span>)))
(<span style="color: #8ac6f2;">defn drain </span>[<span style="color: #8ac6f2;">c</span>]
(<span style="color: #8ac6f2;">go </span>(<span style="color: #8ac6f2;">while </span>(<span style="color: #8ac6f2;">not </span>(<span style="color: #8ac6f2;">nil? </span>(<span style="color: #8ac6f2;"><! c</span>)))
<span style="color: #8ac6f2; font-weight: bold;">nil</span>)))
(<span style="color: #8ac6f2;">defn async-kit-app</span><span style="color: #8ac6f2;"> </span>[<span style="color: #8ac6f2;">request</span>]
(<span style="color: #8ac6f2;">tap> </span>[<span style="color: #40ac10;">"async " </span>(<span style="color: #8ac6f2;">.getName </span>(<span style="color: #8ac6f2;">Thread/currentThread</span>))])
(<span style="color: #8ac6f2;">kit/with-channel request channel</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">do</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">take! </span>(<span style="color: #8ac6f2;">exec-request request</span>) #(<span style="color: #8ac6f2;">kit/send! channel %</span>))
(<span style="color: #8ac6f2;">tap> </span>[<span style="color: #40ac10;">"async2 " </span>(<span style="color: #8ac6f2;">.getName </span>(<span style="color: #8ac6f2;">Thread/currentThread</span>))]))))
(<span style="color: #8ac6f2;">def params </span>{<span style="color: #d79738; font-style: italic;">:host </span><span style="color: #40ac10;">"0.0.0.0" </span><span style="color: #d79738; font-style: italic;">:port </span><span style="color: white;">8080</span>})
(<span style="color: #8ac6f2;">defn start-kit</span><span style="color: #8ac6f2;"> </span>[<span style="color: #8ac6f2;">handler</span>]
(<span style="color: #8ac6f2;">kit/run-server handler params</span>))
(<span style="color: #8ac6f2;">defn -main </span><span style="color: #40ac10;">"entry point"</span><span style="color: #40ac10;"> </span>[<span style="color: #8ac6f2;">& args</span>]
(<span style="color: #8ac6f2;">start-kit async-kit-app</span>)
(<span style="color: #8ac6f2;">println </span><span style="color: #40ac10;">"started: " </span><span style="color: #8ac6f2;">params</span>))
(<span style="color: #8ac6f2;">defn handle-response</span><span style="color: #8ac6f2;"> </span>[<span style="color: #8ac6f2;">resp</span>]
(<span style="color: #8ac6f2;">println </span>(<span style="color: #d79738; font-style: italic;">:body </span><span style="color: #8ac6f2;">resp</span>)))
(<span style="color: #8ac6f2;">comment</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">def stop-fn </span>(<span style="color: #8ac6f2;">start-kit async-kit-app</span>))
(<span style="color: #8ac6f2;">time </span>(<span style="color: #8ac6f2;">dotimes </span>[<span style="color: #8ac6f2;">_ </span><span style="color: white;">1000</span>]
(<span style="color: #8ac6f2;">kit-client/get </span><span style="color: #40ac10;">"http://localhost:8080" </span>{<span style="color: #d79738; font-style: italic;">:timeout </span><span style="color: white;">20000</span>} <span style="color: #8ac6f2;">handle-response</span>)))
(<span style="color: #8ac6f2;">slurp </span><span style="color: #40ac10;">"http://localhost:8080"</span>)
(<span style="color: #8ac6f2;">stop-fn</span>))</pre>
<pre style="background-color: #09172b; color: #a9b7c6; font-family: "Fira Code"; font-size: 9pt;">
</pre>
<pre style="background-color: #09172b; color: #a9b7c6; font-family: "Fira Code"; font-size: 9pt;">
</pre>
<pre style="background-color: #09172b; color: #a9b7c6; font-family: "Fira Code"; font-size: 9pt;"><pre style="font-family: "Fira Code"; font-size: 9pt;">(<span style="color: #8ac6f2;">ns test01.ret</span><span style="color: #8ac6f2;"> </span>(<span style="color: #d79738; font-style: italic;">:gen-class</span>)
(<span style="color: #d79738; font-style: italic;">:require </span>[<span style="color: #8ac6f2;">org.httpkit.server </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">kit</span>]
[<span style="color: #8ac6f2;">org.httpkit.client </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">kit-client</span>]
[<span style="color: #8ac6f2;">sieppari.core </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">sieppari</span>]
[<span style="color: #8ac6f2;">sieppari.context</span>]
[<span style="color: #8ac6f2;">muuntaja.interceptor</span>]
[<span style="color: #8ac6f2;">clojure.core.async </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">a </span><span style="color: #d79738; font-style: italic;">:refer </span>[<span style="color: #8ac6f2;">go chan <! <!! >! >!! timeout close! put! take! alts! alts!!</span>]]
[<span style="color: #8ac6f2;">reitit.ring </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">ring</span>]
[<span style="color: #8ac6f2;">reitit.http </span><span style="color: #d79738; font-style: italic;">:as </span><span style="color: #8ac6f2;">http</span>]
[<span style="color: #8ac6f2;">reitit.interceptor.sieppari</span>]))
(<span style="color: #8ac6f2;">defn interceptor </span>[<span style="color: #8ac6f2;">f x</span>]
{<span style="color: #d79738; font-style: italic;">:enter </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>] (<span style="color: #8ac6f2;">f </span>(<span style="color: #8ac6f2;">update-in ctx </span>[<span style="color: #d79738; font-style: italic;">:request :via</span>] (<span style="color: #8ac6f2;">fnil conj </span>[]) {<span style="color: #d79738; font-style: italic;">:enter </span><span style="color: #8ac6f2;">x</span>})))
<span style="color: #d79738; font-style: italic;">:leave </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>] (<span style="color: #8ac6f2;">f </span>(<span style="color: #8ac6f2;">update-in ctx </span>[<span style="color: #d79738; font-style: italic;">:response :body</span>] <span style="color: #8ac6f2;">conj </span>{<span style="color: #d79738; font-style: italic;">:leave </span><span style="color: #8ac6f2;">x</span>})))})
(<span style="color: #8ac6f2;">defn interceptor2 </span>[<span style="color: #8ac6f2;">this-name</span>]
{
<span style="color: #d79738; font-style: italic;">:enter </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>] (<span style="color: #8ac6f2;">update-in ctx </span>[<span style="color: #d79738; font-style: italic;">:request :via</span>] (<span style="color: #8ac6f2;">fnil conj </span>[]) {<span style="color: #d79738; font-style: italic;">:enter </span><span style="color: #8ac6f2;">this-name</span>}))
<span style="color: #d79738; font-style: italic;">:leave </span>(<span style="color: #8ac6f2;">fn </span>[<span style="color: #8ac6f2;">ctx</span>] (<span style="color: #8ac6f2;">update-in ctx </span>[<span style="color: #d79738; font-style: italic;">:response :body</span>] <span style="color: #8ac6f2;">conj </span>{<span style="color: #d79738; font-style: italic;">:leave </span><span style="color: #8ac6f2;">this-name</span>}))})
(<span style="color: #8ac6f2;">defn handler </span>[<span style="color: #8ac6f2;">f</span>]
(<span style="color: #8ac6f2;">fn </span>[{<span style="color: #d79738; font-style: italic;">:keys </span>[<span style="color: #8ac6f2;">via</span>]}]
(<span style="color: #8ac6f2;">f </span>{<span style="color: #d79738; font-style: italic;">:status </span><span style="color: white;">200</span>,
<span style="color: #d79738; font-style: italic;">:body </span>(<span style="color: #8ac6f2;">conj via </span><span style="color: #d79738; font-style: italic;">:handler</span>)})))
(<span style="color: #8ac6f2;">def <async> </async></span>#(<span style="color: #8ac6f2;">a/go %</span>))
(<span style="color: #8ac6f2;">def <sync> identity</sync></span>)
(<span style="color: #8ac6f2;">def routes </span>(<span style="color: #8ac6f2;">http/router </span>[[<span style="color: #40ac10;">"/" </span>{<span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">interceptor <async> </async></span><span style="color: #d79738; font-style: italic;">:async</span>) (<span style="color: #8ac6f2;">interceptor2 </span><span style="color: #d79738; font-style: italic;">:root-2</span>)]
<span style="color: #d79738; font-style: italic;">:get </span>{<span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">interceptor <async> </async></span><span style="color: #d79738; font-style: italic;">:get</span>) (<span style="color: #8ac6f2;">interceptor2 </span><span style="color: #d79738; font-style: italic;">:get-2</span>)]
<span style="color: #d79738; font-style: italic;">:handler </span>(<span style="color: #8ac6f2;">handler <async></async></span>)}}]
]))
(<span style="color: #8ac6f2;">def app </span>(<span style="color: #8ac6f2;">http/ring-handler routes</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">ring/create-default-handler</span>)
{<span style="color: #d79738; font-style: italic;">:executor </span><span style="color: #8ac6f2;">reitit.interceptor.sieppari/executor</span><span style="color: #8ac6f2;"> </span><span style="color: #d79738; font-style: italic;">:interceptors </span>[(<span style="color: #8ac6f2;">muuntaja.interceptor/format-interceptor</span>)]}))
(<span style="color: #8ac6f2;">def params </span>{<span style="color: #d79738; font-style: italic;">:host </span><span style="color: #40ac10;">"0.0.0.0" </span><span style="color: #d79738; font-style: italic;">:port </span><span style="color: white;">8080</span>})
(<span style="color: #8ac6f2;">defn start-server</span><span style="color: #8ac6f2;"> </span>[<span style="color: #8ac6f2;">handler params</span>]
(<span style="color: #8ac6f2;">kit/run-server handler params</span>))
(<span style="color: #8ac6f2;">defn -main </span><span style="color: #40ac10;">"entry point"</span><span style="color: #40ac10;"> </span>[<span style="color: #8ac6f2;">& args</span>]
(<span style="color: #8ac6f2;">start-server app params</span>)
(<span style="color: #8ac6f2;">println </span><span style="color: #40ac10;">"server is started: " </span><span style="color: #8ac6f2;">params</span>))
<span style="color: #4e6f91;">;; ----------- client and repl zone---------------------------------------</span>(<span style="color: #8ac6f2;">defn handle-response</span><span style="color: #8ac6f2;"> </span>[<span style="color: #8ac6f2;">resp</span>]
(<span style="color: #8ac6f2;">println </span>(<span style="color: #d79738; font-style: italic;">:body </span><span style="color: #8ac6f2;">resp</span>)))
(<span style="color: #8ac6f2;">comment</span><span style="color: #8ac6f2;"> </span>(<span style="color: #8ac6f2;">def stop-fn </span>(<span style="color: #8ac6f2;">start-server app params</span>))
(<span style="color: #8ac6f2;">time </span>(<span style="color: #8ac6f2;">dotimes </span>[<span style="color: #8ac6f2;">_ </span><span style="color: white;">10</span>]
(<span style="color: #8ac6f2;">kit-client/get </span><span style="color: #40ac10;">"http://localhost:8080" </span>{<span style="color: #d79738; font-style: italic;">:timeout </span><span style="color: white;">20000</span>} <span style="color: #8ac6f2;">handle-response</span>)))
(<span style="color: #8ac6f2;">time </span>(<span style="color: #8ac6f2;">slurp </span><span style="color: #40ac10;">"http://localhost:8080"</span>))
(<span style="color: #8ac6f2;">stop-fn</span>))
</pre>
</pre>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-699706232975060212018-09-22T03:11:00.001-07:002018-09-22T03:11:24.202-07:00clojure websocket client example<div dir="ltr" style="text-align: left;" trbidi="on">
This is my deps.edn<br />
https://github.com/middlesphere/spacemacs-clojure-cheatsheet/blob/master/.clojure/deps.edn<br />
<br />
1) Start REPL with necessary deps.<br />
<br />
clojure -R:1.10:repl:add-lib:test:debug-tools:rebel:xml-bind -m nrepl.cmdline -p 7888 -i -m "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"<br />
nREPL server started on port 7888 on host 0:0:0:0:0:0:0:0 - nrepl://0:0:0:0:0:0:0:0:7888<br />
nREPL 0.4.5<br />
Clojure 1.10.0-alpha8<br />
Java HotSpot(TM) 64-Bit Server VM 10.0.2+13<br />
user=> (use 'clojure.tools.deps.alpha.repl)<br />
nil<br />
user=> (add-lib 'stylefruits/gniazdo {:mvn/version "1.0.1"})<br />
true<br />
user=> (add-lib 'http-kit {:mvn/version "2.2.0"})<br />
true<br />
<div>
<br /></div>
2) Create empty file (e.g a.clj), connect to REPL (port 7888) and put following code there:<br />
<br />
;; ------------server code --------------------<br />
<br />
(use 'org.httpkit.server)<br />
<br />
(defn async-handler [ring-request]<br />
;; unified API for WebSocket and HTTP long polling/streaming<br />
(with-channel ring-request channel ; get the channel<br />
(if (websocket? channel) ; if you want to distinguish them<br />
(on-receive channel (fn [data] ; two way communication<br />
(send! channel data)))<br />
(send! channel {:status 200<br />
:headers {"Content-Type" "text/plain"}<br />
:body "Long polling?"}))))<br />
<br />
(run-server async-handler {:port 8080})<br />
<br />
;; ------------client code --------------------<br />
<br />
(require '[gniazdo.core :as ws])<br />
<br />
(def socket (ws/connect "ws://localhost:8080/" :on-receive #(prn 'received %)))<br />
(ws/send-msg socket "hello")<br />
(ws/send-msg socket "world")<br />
<br />
(ws/close socket)<br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-48026516859022045752018-09-11T06:32:00.004-07:002018-09-12T00:14:55.514-07:00Run lein with cider from command line<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: black; color: #38c1ff; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div>
<br />
<b>Headless mode</b><br />
<br />
<span style="color: #457cf9; font-family: "fira code"; font-size: 12px;">lein</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">update-in</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">:dependencies</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">conj</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\[</span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">org.clojure/tools.nrepl</span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\ \"</span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">0.2.13</span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\"\ </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">\:exclusions</span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\ \[</span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">org.clojure/clojure</span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\]\]</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">--</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">update-in</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">:plugins</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">conj</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\[</span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">refactor-nrepl</span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\ \"</span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">2.4.0</span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\"\]</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">--</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">update-in</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">:plugins</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">conj</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\[</span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">cider/cider-nrepl</span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\ \"</span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">0.18.0</span><span style="color: #34bbc8; font-family: "fira code"; font-size: 12px;">\"\]</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">--</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">with-profile</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">+mike-local</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">repl</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">:headless</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">:host</span><span style="color: #28fe14; font-family: "fira code"; font-size: 12px;"> </span><span style="color: #38c1ff; font-family: "fira code"; font-size: 12px;">::</span></div>
<div>
<br /></div>
<div>
<b>Interactive mode</b><br />
<br />
<div style="background-color: black; color: #38c1ff; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="color: #457cf9; font-variant-ligatures: no-common-ligatures;">lein</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">update-in</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">:dependencies</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">conj</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\[</span><span style="font-variant-ligatures: no-common-ligatures;">org.clojure/tools.nrepl</span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\ \"</span><span style="font-variant-ligatures: no-common-ligatures;">0.2.13</span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\"\ </span><span style="font-variant-ligatures: no-common-ligatures;">\:exclusions</span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\ \[</span><span style="font-variant-ligatures: no-common-ligatures;">org.clojure/clojure</span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\]\]</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">--</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">update-in</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">:plugins</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">conj</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\[</span><span style="font-variant-ligatures: no-common-ligatures;">refactor-nrepl</span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\ \"</span><span style="font-variant-ligatures: no-common-ligatures;">2.4.0</span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\"\]</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">--</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">update-in</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">:plugins</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">conj</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\[</span><span style="font-variant-ligatures: no-common-ligatures;">cider/cider-nrepl</span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\ \"</span><span style="font-variant-ligatures: no-common-ligatures;">0.18.0</span><span style="color: #34bbc8; font-variant-ligatures: no-common-ligatures;">\"\]</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">--</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">with-profile</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">+mike-local</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">repl</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">:start</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">:host</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures;">::</span></div>
<br />
<br />
where mike-local is my profile<br />
<br />
Also, :port parameter can be used to run REPL on custom port.</div>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-3020092973866530542018-09-02T12:08:00.003-07:002018-09-02T21:44:39.300-07:00clojure cli repl rebel<div dir="ltr" style="text-align: left;" trbidi="on">
<b>First way</b><br />
<br />
In order to run REPL (nREPL) server via clojure cli tools with beautiful rebel capabilities just add following section into deps.edn file:<br />
<br />
<span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;">:aliases {</span><br style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;" /><span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;"> :repl {:extra-deps {cider/cider-nrepl {:mvn/version "0.18.0"}</span><br style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;" /><span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;"> nrepl {:mvn/version "0.4.5"}</span><br style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;" /><span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;"> refactor-nrepl {:mvn/version "2.4.0"}</span><br style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;" /><span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;"> com.bhauman/rebel-readline {:mvn/version "0.1.4"}}</span><br style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;" /><span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;"> :main-opts ["-e" "(require,(quote,cider-nrepl.main)),"</span><br style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;" /><span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;"> "-e" "(cider-nrepl.main/init,[\"refactor-nrepl.middleware/wrap-refactor\",\"cider.nrepl/cider-middleware\"])"</span><br style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;" /><span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;"> "-e" "(use,'rebel-readline.main),(rebel-readline.main/-main)"]}</span><br style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;" /><br style="caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;" /><span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.199999809265137px;">}</span><br />
<br />
Then just run with command: clojure -A:repl<br />
<br />
<b>Second way</b><br />
<br />
:aliases {<br />
:repl {:extra-deps {cider/cider-nrepl {:mvn/version "0.18.0"}<br />
nrepl {:mvn/version "0.4.5"}<br />
refactor-nrepl {:mvn/version "2.4.0"}<br />
com.bhauman/rebel-readline {:mvn/version "0.1.4"}}<br />
}<br />
}<br />
<br />
clj -R:repl -m nrepl.cmdline -p 7888 -i -m "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"<br />
<br />
This command runs repl without rebel capabilities. In order to enable rebel just call it:<br />
<br />
user=> (use 'rebel-readline.main)<br />
nil<br />
user=> (rebel-readline.main/-main)<br />
[Rebel readline] Type :repl/help for online help info<br />
user=><br />
<br />
<br />
Also, read the docs https://nrepl.readthedocs.io/en/latest/usage/<br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-88016236213937395162018-05-20T05:02:00.001-07:002018-05-20T05:05:55.979-07:00socks proxy on centos 7<div dir="ltr" style="text-align: left;" trbidi="on">
0. <span style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px;">yum install gcc pam-devel tcp_wrappers-devel</span><br />
<span style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px;"><br /></span>
1. <span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">yum install http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm</span><br />
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">2. </span><span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">yum --enablerepo=gf-plus install dante-server</span><br />
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">3. </span><span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">systemctl enable sockd.service</span><br />
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">4. </span><span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">mkdir /var/run/sockd</span><br />
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">5. </span><span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">cp /etc/sockd.conf /etc/sockd.conf.orig</span><br />
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">6. vi </span><span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">/etc/sockd.conf</span><br />
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<br />
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># the server will log both via syslog, to stdout and to /var/log/sockd.log </span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">logoutput</span><span style="font-variant-ligatures: no-common-ligatures;">: syslog stdout /var/log/sockd.log</span></div>
<div style="background-color: black; color: #cd7923; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">logoutput</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;">: stderr</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># The server will bind to the address 10.1.1.1, port 1080 and will only </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># accept connections going to that address. </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">#internal: 10.1.1.1 port = 1080 </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># Alternatively, the interface name can be used instead of the address. </span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">internal</span><span style="font-variant-ligatures: no-common-ligatures;">: eth0 port = 80</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># all outgoing connections from the server will use the IP address </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># 195.168.1.1 </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">#external: 192.168.1.1 </span></div>
<div style="background-color: black; color: #cd7923; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">external</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;">: eth0</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># list over acceptable authentication methods, order of preference. </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># An authentication method not set here will never be selected. </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># If the socksmethod field is not set in a rule, the global </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># socksmethod is filled in for that rule. </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># </span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># methods for socks-rules. </span></div>
<div style="background-color: black; color: #cd7923; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">socksmethod</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;">: username</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># User identities, an important section. </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># </span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># when doing something that can require privilege, it will use the </span></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># userid "sockd". </span></div>
<div style="background-color: black; color: #cd7923; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">user.privileged</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;">: root</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #d7391e; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"># when running as usual, it will use the unprivileged userid of "sockd". </span></div>
<br />
<div style="background-color: black; color: #cd7923; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">user.unprivileged</span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;">: nobody</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #34a327; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">client pass </span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;">{</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">from</span><span style="font-variant-ligatures: no-common-ligatures;">: 0.0.0.0/0 to: 0.0.0.0/0</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">log</span><span style="font-variant-ligatures: no-common-ligatures;">: error connect disconnect</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">}</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #34a327; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">client block </span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;">{</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">from</span><span style="font-variant-ligatures: no-common-ligatures;">: 0.0.0.0/0 to: 0.0.0.0/0</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">log</span><span style="font-variant-ligatures: no-common-ligatures;">: connect error</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">}</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #34a327; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">socks pass </span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;">{</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">from</span><span style="font-variant-ligatures: no-common-ligatures;">: 0.0.0.0/0 to: 0.0.0.0/0</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">log</span><span style="font-variant-ligatures: no-common-ligatures;">: error connect disconnect</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">}</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<span style="font-variant-ligatures: no-common-ligatures;"></span><br /></div>
<div style="background-color: black; color: #34a327; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">socks block </span><span style="color: #28fe14; font-variant-ligatures: no-common-ligatures;">{</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">from</span><span style="font-variant-ligatures: no-common-ligatures;">: 0.0.0.0/0 to: 0.0.0.0/0</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color: #cd7923; font-variant-ligatures: no-common-ligatures;">log</span><span style="font-variant-ligatures: no-common-ligatures;">: connect error</span></div>
<br />
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">}</span></div>
<div>
<span style="font-variant-ligatures: no-common-ligatures;"><br /></span></div>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">7. </span><span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">sudo useradd -s /bin/false proxyuser</span><br />
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">8. </span><span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">sudo passwd proxyuser</span><br />
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">9. </span><span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;">systemctl start sockd.service</span><br />
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span>
<span style="background-color: black; color: #28fe14; font-family: "fira code"; font-size: 12px;"><br /></span></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-42811226313710218432018-02-15T12:51:00.002-08:002018-02-15T12:51:55.686-08:00core.async tip from Tim Baldridge<div dir="ltr" style="text-align: left;" trbidi="on">
If I'm understand the problem I think this is by design. Closing a channel results in a logical termination value being put into the channel.<br />
<br />
This is so that, by default, core.async won't loose data.<br />
<br />
Most of the time when I encounter this problem I fix it by draining the channel:<br />
<br />
(defn drain [c]<br />
(go (while (not (nil? (<! c)))<br />
nil)))<br />
<br />
<br />
And then:<br />
<br />
(close! c)<br />
(drain c)</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-22107251975768176232018-02-14T13:13:00.001-08:002018-02-14T13:13:18.465-08:00clojure ring async example<div dir="ltr" style="text-align: left;" trbidi="on">
;;requirements<br />
<br />
[ring "1.6.3"]<br />
[ring/ring-jetty-adapter "1.6.3"]<br />
[org.clojure/core.async "0.4.474"]<br />
[org.immutant/web "2.1.10"]<br />
<br />
;;Jetty<br />
<br />
(ns test01.core<br />
(:gen-class)<br />
(:require [ring.adapter.jetty :as jetty]<br />
[clojure.core.async :refer [go chan <! <!! >! >!! timeout close!]]))<br />
<br />
<br />
(defn what-is-my-ip [request respond raise]<br />
(respond {:status 200<br />
:headers {"Content-Type" "text/plain"}<br />
:body (:remote-addr request)}))<br />
<br />
<br />
<br />
(defn what-is-my-ip2 [request respond raise]<br />
(let [ch (chan)]<br />
(go<br />
(respond (<! ch)))<br />
(go<br />
;;(<! (timeout 2000))<br />
(>! ch {:status 200<br />
:headers {"Content-Type" "text/plain"}<br />
:body (:remote-addr request)}))))<br />
<br />
(defn start-server<br />
[handler]<br />
(jetty/run-jetty handler {:host "localhost" :async? true :port 8080 :path "/" :join? false}))<br />
<br />
<br />
(defn -main<br />
"entry point"<br />
[& args]<br />
(println "Hello, world."))<br />
<br />
;; (def s (start-server what-is-my-ip))<br />
;; (.stop s)<br />
;;(def s (start-server what-is-my-ip2))<br />
<br />
;;Immutant<br />
<br />
(ns test01.imm<br />
(:require [immutant.web :as web]<br />
[immutant.web.async :as async]))<br />
<br />
<br />
(defn app [request]<br />
(async/as-channel request<br />
{:on-open (fn [stream]<br />
(async/send! stream {:status 200<br />
:headers {"Content-Type" "text/plain"}<br />
:body (:remote-addr request)}<br />
{:close? true}))}))<br />
<br />
<br />
(defn start-server [h]<br />
(web/run h {:host "localhost" :port 8080}))<br />
<br />
(def s (start-server app))<br />
<br />
(web/stop s)<br />
<div>
<br /></div>
<br />
<br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-56197391532854078162017-12-27T13:05:00.002-08:002017-12-27T13:27:22.843-08:00clojure cli and nrepl<div dir="ltr" style="text-align: left;" trbidi="on">
Today, I will show you how to run nrepl server and connect emacs to it.<br />
<br />
1. Create empty folder <b>helloproject</b><br />
<br />
2. Create file <b>deps.edn</b> in <b>helloproject</b> folder and put here the following content:<br />
<pre style="background-color: #f0f0f0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; border-top-left-radius: 2px; border-top-right-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.600000381469727px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;"><span class="p">{</span><span class="ss" style="color: #517918;">:deps</span> <span class="p">{</span><span class="nv" style="color: #bb60d5;">clj-time</span> <span class="p">{</span><span class="ss" style="color: #517918;">:mvn/version</span> <span class="s" style="color: #4070a0;">"0.14.2"</span><span class="p">}}</span>
<span class="ss" style="color: #517918;">:aliases</span> <span class="p">{</span><span class="ss" style="color: #517918;">:repl</span> <span class="p">{</span><span class="ss" style="color: #517918;">:extra-deps</span>
<span class="p">{</span><span class="nv" style="color: #bb60d5;">cider/cider-nrepl</span> <span class="p">{</span><span class="ss" style="color: #517918;">:mvn/version</span> <span class="s" style="color: #4070a0;">"0.16.0-SNAPSHOT"</span><span class="p">}</span>
<span class="nv" style="color: #bb60d5;">org.clojure/tools.nrepl</span> <span class="p">{</span><span class="ss" style="color: #517918;">:mvn/version</span> <span class="s" style="color: #4070a0;">"0.2.12"</span><span class="p">}</span>
<span class="nv" style="color: #bb60d5;">refactor-nrepl</span> <span class="p">{</span><span class="ss" style="color: #517918;">:mvn/version</span> <span class="s" style="color: #4070a0;">"2.3.1"</span><span class="p">}}}}}</span></pre>
<br />
Here we import library clj-time from Maven repo, and import extra deps under alias :repl<br />
<br />
3. Now create <b>src</b> folder in <b>helloproject</b> folder,.i.e <b>helloproject/src</b><br />
<br />
4. Create file <b>hello.clj</b> in <b>helloproject/src</b> folder and put here the following content:<br />
<pre style="background-color: #f0f0f0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; border-top-left-radius: 2px; border-top-right-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.600000381469727px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;"><span class="p">(</span><span class="kd" style="color: #007020; font-weight: bold;">ns </span><span class="nv" style="color: #bb60d5;">hello</span>
<span class="p">(</span><span class="ss" style="color: #517918;">:require</span> <span class="p">[</span><span class="nv" style="color: #bb60d5;">clj-time.core</span> <span class="ss" style="color: #517918;">:as</span> <span class="nv" style="color: #bb60d5;">t</span><span class="p">]</span>
<span class="p">[</span><span class="nv" style="color: #bb60d5;">clj-time.format</span> <span class="ss" style="color: #517918;">:as</span> <span class="nv" style="color: #bb60d5;">f</span><span class="p">]))</span>
<span class="p">(</span><span class="kd" style="color: #007020; font-weight: bold;">defn </span><span class="nv" style="color: #bb60d5;">time-str</span>
<span class="s" style="color: #4070a0;">"Returns a string representation of a datetime in the local time zone."</span>
<span class="p">[</span><span class="nv" style="color: #bb60d5;">dt</span><span class="p">]</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">f/unparse</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">f/with-zone</span> <span class="p">(</span><span class="nf" style="color: #06287e;">f/formatter</span> <span class="s" style="color: #4070a0;">"hh:mm aa"</span><span class="p">)</span> <span class="p">(</span><span class="nf" style="color: #06287e;">t/default-time-zone</span><span class="p">))</span>
<span class="nv" style="color: #bb60d5;">dt</span><span class="p">))</span>
<span class="p">(</span><span class="kd" style="color: #007020; font-weight: bold;">defn </span><span class="nv" style="color: #bb60d5;">-main</span> <span class="p">[]</span>
<span class="p">(</span><span class="nb" style="color: #007020;">println </span><span class="s" style="color: #4070a0;">"Hello world, the time is"</span> <span class="p">(</span><span class="nf" style="color: #06287e;">time-str</span> <span class="p">(</span><span class="nf" style="color: #06287e;">t/now</span><span class="p">))))</span></pre>
<br />
5. Now we are ready to run repl. Change dir to <b>helloproject </b>and run command: <b>clj -R:repl</b><br />
The clj parameter -R:repl is important to load extra deps. If you have several aliases then you should list them comma separated, i.e. <b>clj -R:alias1,alias2</b><br />
<br />
After run command <b>clj -R:repl </b>you should see the prompt:<br />
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 15px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">Clojure 1.9.0</span></div>
<div style="background-color: black; color: #28fe14; font-family: "Fira Code"; font-size: 15px; font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">user=> </span></div>
<br />
6. Now we may start nrepl server. Enter the following two commands in repl:<br />
<br />
<span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-name" style="background-color: #f8f8f8; color: #dd1144; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; font-weight: bold; white-space: pre;">require</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> '[clojure.tools.nrepl.server </span><span class="hljs-symbol" style="background-color: #f8f8f8; color: #990073; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">:refer</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> [start-server]]
'[cider.nrepl </span><span class="hljs-symbol" style="background-color: #f8f8f8; color: #990073; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">:refer</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> [cider-nrepl-handler]])</span><br />
<br />
<span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">(</span><span class="hljs-name" style="background-color: #f8f8f8; color: #dd1144; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; font-weight: bold; white-space: pre;"><span class="hljs-builtin-name" style="color: #0086b3;">let</span></span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> [port (</span><span class="hljs-name" style="background-color: #f8f8f8; color: #dd1144; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; font-weight: bold; white-space: pre;"><span class="hljs-builtin-name" style="color: #0086b3;">or</span></span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> (</span><span class="hljs-name" style="background-color: #f8f8f8; color: #dd1144; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; font-weight: bold; white-space: pre;">some-></span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> (</span><span class="hljs-name" style="background-color: #f8f8f8; color: #dd1144; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; font-weight: bold; white-space: pre;"><span class="hljs-builtin-name" style="color: #0086b3;">first</span></span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> *command-line-args*)
(</span><span class="hljs-name" style="background-color: #f8f8f8; color: #dd1144; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; font-weight: bold; white-space: pre;">java.lang.Long/parseLong</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">))
</span><span class="hljs-number" style="background-color: #f8f8f8; color: #009999; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">7888</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">)]
(</span><span class="hljs-name" style="background-color: #f8f8f8; color: #dd1144; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; font-weight: bold; white-space: pre;">start-server</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> </span><span class="hljs-symbol" style="background-color: #f8f8f8; color: #990073; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">:port</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> port </span><span class="hljs-symbol" style="background-color: #f8f8f8; color: #990073; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">:handler</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> cider-nrepl-handler)
(</span><span class="hljs-name" style="background-color: #f8f8f8; color: #dd1144; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; font-weight: bold; white-space: pre;">println</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> </span><span class="hljs-string" style="background-color: #f8f8f8; color: #dd1144; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;">"Started nREPL on port"</span><span style="background-color: #f8f8f8; color: #333333; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace; font-size: 14px; white-space: pre;"> port))</span><br />
<br />
<br />
7. After successful nrepl server start you may open <b>helloproject/src/hello.clj</b> in your favourite editor and connect to remote repl.<br />
<br />
In Emacs: M-x cider-connect<br />
then enter: localhost and 7888<br />
<br />
<br />
<br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-6693984671939317882017-12-03T07:52:00.001-08:002017-12-03T07:55:15.341-08:00http/2 client example in clojure<div dir="ltr" style="text-align: left;" trbidi="on">
1. Add [com.squareup.okhttp3/okhttp "3.9.1"] as dependecy in project.clj<br />
<br />
2. Download <span style="background-color: white; color: #24292e; font-family: , "blinkmacsystemfont" , "segoe ui" , "helvetica" , "arial" , sans-serif , "apple color emoji" , "segoe ui emoji" , "segoe ui symbol"; font-size: 16px;"> </span><a href="http://unrestful.io/2015/10/09/alpn-java.html" rel="nofollow" style="box-sizing: border-box; color: #0366d6; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px; text-decoration: none;">Jetty's ALPN boot JAR</a><span style="background-color: white; color: #24292e; font-family: , "blinkmacsystemfont" , "segoe ui" , "helvetica" , "arial" , sans-serif , "apple color emoji" , "segoe ui emoji" , "segoe ui symbol"; font-size: 16px;">. from </span><a href="http://repo1.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/"><span style="font-size: large;">here</span></a><br />
<br />
3. Add jvm options to boot ALPN and optionally truststore to JKS<br />
<br />
:jvm-opts ["-Xbootclasspath/p:/opt/libs/alpn-boot-8.1.9.v20160720.jar"<br />
"-Djavax.net.ssl.trustStore=test/keystore.jks"<br />
"-Djavax.net.ssl.trustStorePassword=SecretPwd"] <br />
<br />
4. Simple http/2 client code looks like this.<br />
<br />
<pre style="background-color: #f0f0f0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; border-top-left-radius: 2px; border-top-right-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.600000381469727px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;"><span class="p">(</span><span class="kd" style="color: #007020; font-weight: bold;">ns </span><span class="nv" style="color: #bb60d5;">test01.core</span>
<span class="p">(</span><span class="ss" style="color: #517918;">:gen-class</span><span class="p">)</span>
<span class="p">(</span><span class="ss" style="color: #517918;">:import</span> <span class="p">(</span><span class="nf" style="color: #06287e;">okhttp3</span> <span class="nv" style="color: #bb60d5;">OkHttpClient</span> <span class="nv" style="color: #bb60d5;">Request</span> <span class="nv" style="color: #bb60d5;">Request$Builder</span> <span class="nv" style="color: #bb60d5;">Response</span><span class="p">)))</span>
<span class="p">(</span><span class="kd" style="color: #007020; font-weight: bold;">defn </span><span class="nv" style="color: #bb60d5;">-main</span> <span class="p">[</span><span class="o" style="color: #666666;">&</span> <span class="nv" style="color: #bb60d5;">args</span><span class="p">]</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">let </span><span class="p">[</span><span class="nv" style="color: #bb60d5;">client</span> <span class="p">(</span><span class="nf" style="color: #06287e;">OkHttpClient.</span><span class="p">)</span>
<span class="nv" style="color: #bb60d5;">request</span> <span class="p">(</span><span class="nb" style="color: #007020;">-> </span><span class="p">(</span><span class="nf" style="color: #06287e;">Request$Builder.</span><span class="p">)</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">.url</span> <span class="s" style="color: #4070a0;">"https://localhost:50443"</span><span class="p">)</span>
<span class="nv" style="color: #bb60d5;">.build</span><span class="p">)</span>
<span class="nv" style="color: #bb60d5;">response</span> <span class="p">(</span><span class="nb" style="color: #007020;">-> </span><span class="nv" style="color: #bb60d5;">client</span> <span class="p">(</span><span class="nf" style="color: #06287e;">.newCall</span> <span class="nv" style="color: #bb60d5;">request</span><span class="p">)</span> <span class="nv" style="color: #bb60d5;">.execute</span><span class="p">)]</span>
<span class="p">(</span><span class="nb" style="color: #007020;">println </span><span class="p">(</span><span class="nb" style="color: #007020;">-> </span><span class="nv" style="color: #bb60d5;">response</span> <span class="nv" style="color: #bb60d5;">.body</span> <span class="nv" style="color: #bb60d5;">.string</span><span class="p">))</span>
<span class="p">(</span><span class="nb" style="color: #007020;">println </span><span class="p">(</span><span class="nb" style="color: #007020;">-> </span><span class="nv" style="color: #bb60d5;">response</span> <span class="nv" style="color: #bb60d5;">.protocol</span> <span class="nv" style="color: #bb60d5;">.toString</span><span class="p">))))</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">-main</span><span class="p">)</span></pre>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-62941200165770400982017-12-02T14:37:00.002-08:002017-12-02T14:37:48.826-08:00java 9 http client in clojure<div dir="ltr" style="text-align: left;" trbidi="on">
Hello.<br />
<br />
Here is a small example, how to use HttpClient from java 9.<br />
<br />
1) add to project.clj section :jvm-opts ["--add-modules" "jdk.incubator.httpclient"] cause HttpClient is available as separate module.<br />
<br />
2)<br />
<pre style="background-color: #f0f0f0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; border-top-left-radius: 2px; border-top-right-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.600000381469727px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;"><span class="p">(</span><span class="nb" style="color: #007020;">import </span><span class="o" style="color: #666666;">'</span><span class="p">(</span><span class="nf" style="color: #06287e;">jdk.incubator.http</span> <span class="nv" style="color: #bb60d5;">HttpClient</span> <span class="nv" style="color: #bb60d5;">HttpRequest</span> <span class="nv" style="color: #bb60d5;">HttpResponse</span> <span class="nv" style="color: #bb60d5;">HttpResponse$BodyHandler</span><span class="p">))</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">def </span><span class="nv" style="color: #bb60d5;">http-client</span> <span class="p">(</span><span class="nf" style="color: #06287e;">HttpClient/newHttpClient</span><span class="p">))</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">def </span><span class="nv" style="color: #bb60d5;">request</span> <span class="p">(</span><span class="nb" style="color: #007020;">-> </span><span class="p">(</span><span class="nf" style="color: #06287e;">HttpRequest/newBuilder</span><span class="p">)</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">.uri</span> <span class="p">(</span><span class="nf" style="color: #06287e;">java.net.URI.</span> <span class="s" style="color: #4070a0;">"https://www.javabullets.com"</span><span class="p">))</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">.GET</span><span class="p">)</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">.build</span><span class="p">)))</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">def </span><span class="nv" style="color: #bb60d5;">response</span> <span class="p">(</span><span class="nf" style="color: #06287e;">.send</span> <span class="nv" style="color: #bb60d5;">http-client</span> <span class="nv" style="color: #bb60d5;">request</span> <span class="p">(</span><span class="nf" style="color: #06287e;">HttpResponse$BodyHandler/asString</span><span class="p">)))</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">.statusCode</span> <span class="nv" style="color: #bb60d5;">response</span><span class="p">)</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">.body</span> <span class="nv" style="color: #bb60d5;">response</span><span class="p">)</span></pre>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-36164686397663673412017-11-06T11:49:00.000-08:002017-11-07T02:55:46.616-08:00clojure monorepo how-to<div dir="ltr" style="text-align: left;" trbidi="on">
Monorepo is the way to manage several related projects from one point. In this note I'll show you how to organize monorepo using Amperity plugin <a href="https://github.com/amperity/lein-monolith">lein-monolith</a> .<br />
<br />
0. Lets create root project and some subprojects<br />
rootproject<br />
project.clj ;;project file for root project<br />
/apps<br />
/app01 ;; project folder for app01 project<br />
/libs<br />
/lib01 ;; project folder for lib01 project which is needed for app01<br />
/lib02 ;; some other lib <br />
<br />
<br />
1. We should put section :plugins [[lein-monolith "1.0.1"]] to root project.clj and to project.clj of all subprojects.<br />
<br />
<pre style="background-color: #f0f0f0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; border-top-left-radius: 2px; border-top-right-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.600000381469727px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;"><span class="p">(</span><span class="kd" style="color: #007020; font-weight: bold;">defproject </span><span class="nv" style="color: #bb60d5;">rootproject/all</span> <span class="s" style="color: #4070a0;">"MONOLITH"</span>
<span class="ss" style="color: #517918;">:description</span> <span class="s" style="color: #4070a0;">"Mono repo"</span>
<span class="ss" style="color: #517918;">:plugins</span> <span class="p">[[</span><span class="nv" style="color: #bb60d5;">lein-monolith</span> <span class="s" style="color: #4070a0;">"1.0.1"</span><span class="p">]</span>
<span class="p">[</span><span class="nv" style="color: #bb60d5;">lein-cprint</span> <span class="s" style="color: #4070a0;">"1.3.0"</span><span class="p">]]</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; some repo which is used in all subprojects</span>
<span class="ss" style="color: #517918;">:repositories</span> <span class="p">{</span><span class="s" style="color: #4070a0;">"readytalk"</span> <span class="p">{</span><span class="ss" style="color: #517918;">:url</span> <span class="s" style="color: #4070a0;">"https://dl.bintray.com/readytalk/maven/"</span><span class="p">}}</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; this is local deps that belongs only root project until section :dependencies is included in :inherit section. But for :inherit section we will use :managed-dependencies instead.</span>
<span class="ss" style="color: #517918;">:dependencies</span> <span class="p">[[</span><span class="nv" style="color: #bb60d5;">org.clojure/clojure</span> <span class="s" style="color: #4070a0;">"1.9.0-beta4"</span><span class="p">]]</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; this managed-deps will be delivered to all subprojects</span>
<span class="ss" style="color: #517918;">:managed-dependencies</span> <span class="p">[[</span><span class="nv" style="color: #bb60d5;">org.clojure/clojure</span> <span class="s" style="color: #4070a0;">"1.9.0-beta4"</span><span class="p">]]</span>
<span class="ss" style="color: #517918;">:monolith</span> <span class="p">{</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; here we tell lein-monolith to merge :repositories and :managed-dependencies</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; to all subprojects.</span>
<span class="ss" style="color: #517918;">:inherit</span> <span class="p">[</span><span class="ss" style="color: #517918;">:repositories</span> <span class="ss" style="color: #517918;">:managed-dependencies</span><span class="p">]</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; here we tell that section profiles from root projects should be merged to all subprojects.</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; in this example we tell that in uberjar we should omit source files.</span>
<span class="ss" style="color: #517918;">:inherit-leaky</span> <span class="p">[</span><span class="ss" style="color: #517918;">:profiles</span><span class="p">]</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; where is our subprojects located</span>
<span class="ss" style="color: #517918;">:project-dirs</span> <span class="p">[</span><span class="s" style="color: #4070a0;">"apps/*"</span> <span class="s" style="color: #4070a0;">"libs/*"</span><span class="p">]}</span>
<span class="ss" style="color: #517918;">:profiles</span> <span class="p">{</span><span class="ss" style="color: #517918;">:uberjar</span> <span class="p">{</span><span class="ss" style="color: #517918;">:omit-source</span> <span class="nv" style="color: #bb60d5;">true</span><span class="p">}}</span>
<span class="ss" style="color: #517918;">:env</span> <span class="p">{</span><span class="ss" style="color: #517918;">:foo</span> <span class="s" style="color: #4070a0;">"bar"</span><span class="p">})</span></pre>
<br />
2. Every project.clj of all subprojects we prepare like this:<br />
<br />
<pre style="background-color: #f0f0f0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; border-top-left-radius: 2px; border-top-right-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.600000381469727px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;"><span class="p">(</span><span class="kd" style="color: #007020; font-weight: bold;">defproject </span><span class="nv" style="color: #bb60d5;">rootproject/app01</span> <span class="s" style="color: #4070a0;">"2.0.0-SNAPSHOT"</span>
<span class="ss" style="color: #517918;">:description</span> <span class="s" style="color: #4070a0;">"FIXME: write description"</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; here we include lein-monolith for subproject</span>
<span class="ss" style="color: #517918;">:plugins</span> <span class="p">[[</span><span class="nv" style="color: #bb60d5;">lein-monolith</span> <span class="s" style="color: #4070a0;">"1.0.1"</span><span class="p">]</span>
<span class="p">[</span><span class="nv" style="color: #bb60d5;">lein-cprint</span> <span class="s" style="color: #4070a0;">"1.3.0"</span><span class="p">]]</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; here we tell that we need to inherit all sections from root project</span>
<span class="ss" style="color: #517918;">:monolith/inherit</span> <span class="nv" style="color: #bb60d5;">true</span>
<span class="ss" style="color: #517918;">:deployable</span> <span class="nv" style="color: #bb60d5;">true</span>
<span class="ss" style="color: #517918;">:dependencies</span> <span class="p">[[</span><span class="nv" style="color: #bb60d5;">rootproject/lib01</span> <span class="s" style="color: #4070a0;">"0.1.0-SNAPSHOT"</span><span class="p">]]</span>
<span class="ss" style="color: #517918;">:main</span> <span class="o" style="color: #666666;">^</span><span class="ss" style="color: #517918;">:skip-aot</span> <span class="nv" style="color: #bb60d5;">lib01.core</span>
<span class="ss" style="color: #517918;">:target-path</span> <span class="s" style="color: #4070a0;">"target/%s"</span>
<span class="ss" style="color: #517918;">:profiles</span> <span class="p">{</span><span class="ss" style="color: #517918;">:uberjar</span> <span class="p">{</span><span class="ss" style="color: #517918;">:aot</span> <span class="ss" style="color: #517918;">:all</span><span class="p">}})</span></pre>
<br />
3. Now we can run commands from root project<br />
<blockquote class="tr_bq">
lein monolith each do clean, uberjar </blockquote>
This command will clean and make uberjars for all subprojects. Remember, that we should run<br />
<blockquote class="tr_bq">
lein install</blockquote>
for lib01 to install to a local repo for app01 which use it. Also we can run command only for particular subproject<br />
<blockquote class="tr_bq">
lein monolith each :start rootproject/app01 do uberjar </blockquote>
This command will run uberjar target only for particular project.<br />
<br />
Interesting fact that we can point out clojure version only in root project - project.clj, in section :managed-dependencies and this version of clojure will be delivered to all subprojects. So we don't need to include clojure version in subprojects.<br />
<br />
Also from root project we can run different tests for different subproject using selectors. First of all wee should put metadata to all deftest like here<br />
<a href="https://github.com/technomancy/leiningen/blob/2.4.3/src/leiningen/test.clj#L164">https://github.com/technomancy/leiningen/blob/2.4.3/src/leiningen/test.clj#L164</a><br />
<br />
In example above it is integrations test with <span style="background-color: white; color: #032f62; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">^:integration metadata</span>. Then we should put section<br />
<table class="highlight tab-size js-file-line-container" data-tab-size="8" style="border-collapse: collapse; border-spacing: 0px; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; tab-size: 8;"><tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;"><td class="blob-code blob-code-inner js-file-line" id="LC11" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; line-height: 20px; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span class="pl-e" style="box-sizing: border-box; color: #6f42c1;">
:test-selectors</span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="12" id="L12" style="-webkit-user-select: none; box-sizing: border-box; color: rgba(27, 31, 35, 0.298039); cursor: pointer; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; line-height: 20px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC12" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; line-height: 20px; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;">{<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">:unit</span> (<span class="pl-en" style="box-sizing: border-box; color: #6f42c1;">complement</span> <span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">:integration</span>)</td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="13" id="L13" style="-webkit-user-select: none; box-sizing: border-box; color: rgba(27, 31, 35, 0.298039); cursor: pointer; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; line-height: 20px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC13" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; line-height: 20px; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">:integration</span> <span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">:integration</span>}</td></tr>
</tbody></table>
<br />
in root project.clj and put <span style="background-color: white; color: #005cc5; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 12px; white-space: pre;">:test-selectors</span> to :inherit section. </div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-1579782645679108202017-10-15T04:02:00.002-07:002017-10-15T04:02:35.317-07:00clojure debugging 2<div dir="ltr" style="text-align: left;" trbidi="on">
(defmacro safe-eval<br />
"This macro is used to execute any function inside try-catch block.<br />
returns value or nil in case of Exception and prints debug info. "<br />
[& forms]<br />
`(try<br />
~@forms<br />
(catch Exception e#<br />
(println "--------------")<br />
(println "file :" *file* \newline)<br />
(println "s-exp:" (quote ~@forms))<br />
(println "src :" ~(meta &form))<br />
(println "=>" (.getMessage e#)))))</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-28415621916801519782017-10-08T15:22:00.000-07:002017-10-08T15:53:25.384-07:00clojure debugging <div dir="ltr" style="text-align: left;" trbidi="on">
Add to project.clj<br />
<blockquote class="tr_bq">
<blockquote class="tr_bq">
;;scope capture for debugging</blockquote>
<blockquote class="tr_bq">
[vvvvalvalval/scope-capture "0.1.0"]</blockquote>
</blockquote>
<br />
(require 'sc.api)<br />
<br />
(defn abc [x]<br />
(let [y (* 2 x)<br />
z (Math/pow x 4)]<br />
(sc.api/spy {:abc [x y z]})))<br />
<br />
(abc 2)<br />
;;prints during execution: SPY [1 -2] where 1 is id for defsc<br />
<br />
(sc.api/defsc 1)<br />
<br />
;;show me the state of local vars from let using given id 4<br />
(sc.api/letsc 4 [x y z])<br />
;; recreate the last operation result from let using given id 2<br />
(sc.api/letsc 2 {:abc [x y z]})<br />
<br />
;;show me the info map at the spy execution point using id 2<br />
(sc.api/ep-info 2)<br />
<br />
see video: https://vimeo.com/237220354<br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-63003992736321557292017-10-01T06:13:00.004-07:002017-12-17T12:40:38.932-08:00network async communication<div dir="ltr" style="text-align: left;" trbidi="on">
Nikita made a good library <span style="color: #24292e; font-family: , "consolas" , "liberation mono" , "menlo" , "courier" , monospace; font-size: 13.600000381469727px;">[net.async/async "0.1.0"] </span>for asynchronous network communication.<br />
<a href="https://github.com/tonsky/net.async">https://github.com/tonsky/net.async</a><br />
<br />
<br />
Just add this to your project.clj<br />
<br />
<pre style="background-color: #f0f0f0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; border-top-left-radius: 2px; border-top-right-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.600000381469727px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;"> <span class="p">[</span><span class="nv" style="color: #bb60d5;">org.clojure/clojure</span> <span class="s" style="color: #4070a0;">"1.8.0"</span><span class="p">]</span>
<span class="c1" style="color: #60a0b0; font-style: italic;">;; async network communications</span>
<span class="p">[</span><span class="nv" style="color: #bb60d5;">net.async/async</span> <span class="s" style="color: #4070a0;">"0.1.0"</span> <span class="ss" style="color: #517918;">:exclusions</span> <span class="p">[[</span><span class="nv" style="color: #bb60d5;">org.clojure/clojure</span><span class="p">]</span>
<span class="p">[</span><span class="nv" style="color: #bb60d5;">org.clojure/tools.logging</span><span class="p">]</span>
<span class="p">[</span><span class="nv" style="color: #bb60d5;">org.clojure/core.async</span><span class="p">]]]</span>
<span class="p">[</span><span class="nv" style="color: #bb60d5;">org.clojure/core.async</span> <span class="s" style="color: #4070a0;">"0.3.443"</span> <span class="ss" style="color: #517918;">:exclusions</span> <span class="p">[</span><span class="nv" style="color: #bb60d5;">org.clojure/tools.reader</span><span class="p">]]</span>
<span class="p">[</span><span class="nv" style="color: #bb60d5;">org.clojure/tools.logging</span> <span class="s" style="color: #4070a0;">"0.4.0"</span><span class="p">]</span></pre>
<br />
Here is an output of example below:<br />
-------------------------------<br />
server: 4263<br />
client: ECHO/4263<br />
-------------------------------<br />
server: 16640<br />
client: ECHO/16640<br />
-------------------------------<br />
server: 75968<br />
client: ECHO/75968<br />
-------------------------------<br />
server: 11092<br />
client: ECHO/11092<br />
-------------------------------<br />
server: 61707<br />
client: ECHO/61707<br />
-------------------------------<br />
server: 50773<br />
client: ECHO/50773<br />
-------------------------------<br />
server: 16803<br />
client: ECHO/16803<br />
-------------------------------<br />
<br />
Here is a source code of echo server and client:<br />
<br />
<pre style="background-color: #f0f0f0; border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; border-top-left-radius: 2px; border-top-right-radius: 2px; border: 1px solid rgb(204, 204, 204); font-family: Consolas, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 13px; letter-spacing: 0.015em; line-height: 15.600000381469727px; overflow-x: auto; overflow-y: hidden; padding: 0.5em;"><span class="p">(</span><span class="nf" style="color: #06287e;">require</span> <span class="o" style="color: #666666;">'</span><span class="p">[</span><span class="nv" style="color: #bb60d5;">clojure.core.async</span> <span class="ss" style="color: #517918;">:refer</span> <span class="p">[</span><span class="nv" style="color: #bb60d5;"><!</span> <span class="nv" style="color: #bb60d5;">>!</span> <span class="nv" style="color: #bb60d5;"><!!</span> <span class="nv" style="color: #bb60d5;">>!!</span> <span class="nv" style="color: #bb60d5;">close!</span> <span class="nv" style="color: #bb60d5;">go</span><span class="p">]])</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">use</span> <span class="ss" style="color: #517918;">'net.async.tcp</span><span class="p">)</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">def </span><span class="nv" style="color: #bb60d5;">event-l-client</span> <span class="p">(</span><span class="nf" style="color: #06287e;">event-loop</span><span class="p">))</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">def </span><span class="nv" style="color: #bb60d5;">event-l-server</span> <span class="p">(</span><span class="nf" style="color: #06287e;">event-loop</span><span class="p">))</span>
<span class="p">(</span><span class="kd" style="color: #007020; font-weight: bold;">defn </span><span class="nv" style="color: #bb60d5;">echo-server</span> <span class="p">[</span><span class="nv" style="color: #bb60d5;">evt-loop</span><span class="p">]</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">let </span><span class="p">[</span><span class="nv" style="color: #bb60d5;">acceptor</span> <span class="p">(</span><span class="nf" style="color: #06287e;">accept</span> <span class="nv" style="color: #bb60d5;">evt-loop</span> <span class="p">{</span><span class="ss" style="color: #517918;">:port</span> <span class="mi" style="color: #40a070;">8899</span><span class="p">})]</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">loop </span><span class="p">[]</span>
<span class="p">(</span><span class="nb" style="color: #007020;">when-let </span><span class="p">[</span><span class="nv" style="color: #bb60d5;">server</span> <span class="p">(</span><span class="nf" style="color: #06287e;"><!!</span> <span class="p">(</span><span class="ss" style="color: #517918;">:accept-chan</span> <span class="nv" style="color: #bb60d5;">acceptor</span><span class="p">))]</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">go</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">loop </span><span class="p">[]</span>
<span class="p">(</span><span class="nb" style="color: #007020;">when-let </span><span class="p">[</span><span class="nv" style="color: #bb60d5;">msg</span> <span class="p">(</span><span class="nf" style="color: #06287e;"><!</span> <span class="p">(</span><span class="ss" style="color: #517918;">:read-chan</span> <span class="nv" style="color: #bb60d5;">server</span><span class="p">))]</span>
<span class="p">(</span><span class="nb" style="color: #007020;">when-not </span><span class="p">(</span><span class="nb" style="color: #007020;">keyword? </span><span class="nv" style="color: #bb60d5;">msg</span><span class="p">)</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">>!</span> <span class="p">(</span><span class="ss" style="color: #517918;">:write-chan</span> <span class="nv" style="color: #bb60d5;">server</span><span class="p">)</span> <span class="p">(</span><span class="nf" style="color: #06287e;">.getBytes</span> <span class="p">(</span><span class="nb" style="color: #007020;">str </span><span class="s" style="color: #4070a0;">"ECHO/"</span> <span class="p">(</span><span class="nf" style="color: #06287e;">String.</span> <span class="nv" style="color: #bb60d5;">msg</span><span class="p">))))</span>
<span class="p">(</span><span class="nb" style="color: #007020;">println </span><span class="s" style="color: #4070a0;">"server: "</span> <span class="p">(</span><span class="nf" style="color: #06287e;">String.</span> <span class="nv" style="color: #bb60d5;">msg</span><span class="p">)))</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">recur</span><span class="p">))))</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">recur</span><span class="p">)))))</span>
<span class="p">(</span><span class="kd" style="color: #007020; font-weight: bold;">defn </span><span class="nv" style="color: #bb60d5;">echo-client</span> <span class="p">[</span><span class="nv" style="color: #bb60d5;">evt-loop</span><span class="p">]</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">let </span><span class="p">[</span><span class="nv" style="color: #bb60d5;">client</span> <span class="p">(</span><span class="nf" style="color: #06287e;">connect</span> <span class="nv" style="color: #bb60d5;">evt-loop</span> <span class="p">{</span><span class="ss" style="color: #517918;">:host</span> <span class="s" style="color: #4070a0;">"127.0.0.1"</span> <span class="ss" style="color: #517918;">:port</span> <span class="mi" style="color: #40a070;">8899</span><span class="p">})]</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">loop </span><span class="p">[]</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">go</span> <span class="p">(</span><span class="nf" style="color: #06287e;">>!</span> <span class="p">(</span><span class="ss" style="color: #517918;">:write-chan</span> <span class="nv" style="color: #bb60d5;">client</span><span class="p">)</span> <span class="p">(</span><span class="nf" style="color: #06287e;">.getBytes</span> <span class="p">(</span><span class="nb" style="color: #007020;">str </span><span class="p">(</span><span class="nb" style="color: #007020;">rand-int </span><span class="mi" style="color: #40a070;">100000</span><span class="p">)))))</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">loop </span><span class="p">[]</span>
<span class="p">(</span><span class="k" style="color: #007020; font-weight: bold;">let </span><span class="p">[</span><span class="nb" style="color: #007020;">read </span><span class="p">(</span><span class="nf" style="color: #06287e;"><!!</span> <span class="p">(</span><span class="ss" style="color: #517918;">:read-chan</span> <span class="nv" style="color: #bb60d5;">client</span><span class="p">))]</span>
<span class="p">(</span><span class="nb" style="color: #007020;">when </span><span class="p">(</span><span class="nf" style="color: #06287e;">bytes?</span> <span class="nv" style="color: #bb60d5;">read</span><span class="p">)</span> <span class="p">(</span><span class="nb" style="color: #007020;">println </span><span class="s" style="color: #4070a0;">"client: "</span> <span class="p">(</span><span class="nf" style="color: #06287e;">String.</span> <span class="nv" style="color: #bb60d5;">read</span><span class="p">)))</span>
<span class="p">(</span><span class="nb" style="color: #007020;">when </span><span class="p">(</span><span class="nb" style="color: #007020;">and </span><span class="p">(</span><span class="nb" style="color: #007020;">keyword? </span><span class="nv" style="color: #bb60d5;">read</span><span class="p">)</span>
<span class="p">(</span><span class="nb" style="color: #007020;">not= </span><span class="ss" style="color: #517918;">:connected</span> <span class="nv" style="color: #bb60d5;">read</span><span class="p">))</span>
<span class="p">(</span><span class="nb" style="color: #007020;">println </span><span class="s" style="color: #4070a0;">"disconnected from server. trying to reconnect using timeout"</span><span class="p">)</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">recur</span><span class="p">))))</span>
<span class="p">(</span><span class="nb" style="color: #007020;">println </span><span class="s" style="color: #4070a0;">"-------------------------------"</span><span class="p">)</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">Thread/sleep</span> <span class="p">(</span><span class="nb" style="color: #007020;">rand-int </span><span class="mi" style="color: #40a070;">3000</span><span class="p">))</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">recur</span><span class="p">))))</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">future</span> <span class="p">(</span><span class="nf" style="color: #06287e;">echo-server</span> <span class="nv" style="color: #bb60d5;">event-l-server</span><span class="p">))</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">future</span> <span class="p">(</span><span class="nf" style="color: #06287e;">echo-client</span> <span class="nv" style="color: #bb60d5;">event-l-client</span><span class="p">))</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">shutdown!</span> <span class="nv" style="color: #bb60d5;">event-l-server</span><span class="p">)</span>
<span class="p">(</span><span class="nf" style="color: #06287e;">shutdown!</span> <span class="nv" style="color: #bb60d5;">event-l-client</span><span class="p">)</span></pre>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-62023585579021142072017-08-23T12:31:00.001-07:002017-08-23T13:00:52.426-07:00react learning: sorting table<div dir="ltr" style="text-align: left;" trbidi="on">
(enable-console-print!)<br />
(println "js app is started.")<br />
<br />
(def excel-data (reagent/atom {:h ["book" "author" "language" "published" "sales"]<br />
:b <span style="font-size: x-small;">[["The Lord of the Rings" "J. R. R. Tolkien" "English" "1954–1955" "150 million"]</span><br />
<span style="font-size: x-small;"> ["Le Petit Prince (The Little Prince)" "Antoine de Saint-Exupéry" "French" "1943" "140 million"]</span><br />
<span style="font-size: x-small;"> ["Harry Potter and the Philosopher's Stone" "J. K. Rowling" "English" "1997" "107 million"]</span><br />
<span style="font-size: x-small;"> ["And Then There Were None" "Agatha Christie" "English" "1939" "100 million"]</span><br />
<span style="font-size: x-small;"> ["Dream of the Red Chamber" "Cao Xueqin" "Chinese" "1754–1791" "100 million"]</span><br />
<span style="font-size: x-small;"> ["The Hobbit" "J. R. R. Tolkien" "English" "1937" "100 million"]</span><br />
<span style="font-size: x-small;"> ["She: A History of Adventure" "H. Rider Haggard" "English" "1887" "100 million"]]</span><br />
:sort-type {true > false <}<br />
:sort-current true<br />
:sort-column 0}))<br />
<br />
(defn table-body<br />
[body]<br />
(for [row body]<br />
^{:key (gensym)} [:tr (for [cell row]<br />
^{:key (gensym)} [:td cell])]))<br />
<br />
(defn change-sort-direction-if-needed<br />
[column-index]<br />
;; when click on the same column then change sort direction<br />
(when (= column-index (:sort-column @excel-data))<br />
(swap! excel-data assoc-in [:sort-current] (not (:sort-current @excel-data)))))<br />
<br />
(defn sort-table [column-index]<br />
(change-sort-direction-if-needed column-index)<br />
(let [sort-fn ((:sort-type @excel-data) (:sort-current @excel-data))<br />
sorted-data (sort-by #(nth % column-index) sort-fn (:b @excel-data))]<br />
(swap! excel-data assoc-in [:b] sorted-data)<br />
(swap! excel-data assoc-in [:sort-column] column-index)))<br />
<br />
(defn table-header<br />
[header]<br />
[:tr<br />
(doall<br />
(for [header-item header]<br />
^{:key (gensym)} [:th (if (= (.indexOf header header-item) (:sort-column @excel-data))<br />
(str header-item (if (:sort-current @excel-data) \u2193 \u2191))<br />
header-item)]))])<br />
<br />
(defn excel-app<br />
"Excel prototype application"<br />
[excel-data]<br />
[:div<br />
[:table<br />
[:thead {:on-click #(sort-table (-> % .-target .-cellIndex))} (table-header (:h @excel-data))]<br />
[:tbody (table-body (:b @excel-data))]]])<br />
<br />
(reagent/render-component [excel-app excel-data]<br />
(.getElementById js/document "app"))<br />
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
looks like this:</div>
<div>
<br /></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw6rOosLXn4uQuGENRD-RTsiVI9oNByFAOGLb07sWucjMqYJFE36ncMnIGffJe3HSj5tDMDCgVhAmmm-b3Ak9LngrOwgc6-wFykt8xNyO3OlOkAlaqsPEd8UtAvLOgtFAkWFY-rAbXJY8/s1600/%25D0%25A1%25D0%25BD%25D0%25B8%25D0%25BC%25D0%25BE%25D0%25BA+%25D1%258D%25D0%25BA%25D1%2580%25D0%25B0%25D0%25BD%25D0%25B0+2017-08-23+%25D0%25B2+22.31.01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="518" data-original-width="1554" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw6rOosLXn4uQuGENRD-RTsiVI9oNByFAOGLb07sWucjMqYJFE36ncMnIGffJe3HSj5tDMDCgVhAmmm-b3Ak9LngrOwgc6-wFykt8xNyO3OlOkAlaqsPEd8UtAvLOgtFAkWFY-rAbXJY8/s640/%25D0%25A1%25D0%25BD%25D0%25B8%25D0%25BC%25D0%25BE%25D0%25BA+%25D1%258D%25D0%25BA%25D1%2580%25D0%25B0%25D0%25BD%25D0%25B0+2017-08-23+%25D0%25B2+22.31.01.png" width="640" /></a></div>
<div>
<br /></div>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-55361528075689560622017-08-22T14:17:00.002-07:002017-08-22T16:22:52.974-07:00react learning: simple table<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
(enable-console-print!)</div>
<div>
(println "js app is started.")</div>
<div>
<br /></div>
<div>
(def excel-data (reagent/atom {:h ["book" "author" "language" "published" "sales"]</div>
<div>
:b <span style="font-size: x-small;">[["The Lord of the Rings" "J. R. R. Tolkien" "English" "1954–1955" "150 million"]</span></div>
<div>
<span style="font-size: x-small;"> ["Le Petit Prince (The Little Prince)" "Antoine de Saint-Exupéry" "French" "1943" "140 million"]</span></div>
<div>
<span style="font-size: x-small;"> ["Harry Potter and the Philosopher's Stone" "J. K. Rowling" "English" "1997" "107 million"]</span></div>
<div>
<span style="font-size: x-small;"> ["And Then There Were None" "Agatha Christie" "English" "1939" "100 million"]</span></div>
<div>
<span style="font-size: x-small;"> ["Dream of the Red Chamber" "Cao Xueqin" "Chinese" "1754–1791" "100 million"]</span></div>
<div>
<span style="font-size: x-small;"> ["The Hobbit" "J. R. R. Tolkien" "English" "1937" "100 million"]</span></div>
<div>
<span style="font-size: x-small;"> ["She: A History of Adventure" "H. Rider Haggard" "English" "1887" "100 million"]]</span>}))</div>
<div>
<br /></div>
<div>
(defn table-body</div>
<div>
[body]</div>
<div>
(for [row body]</div>
<div>
[:tr (for [cell row]</div>
<div>
[:td cell])]))</div>
<div>
<br /></div>
<div>
(defn table-header</div>
<div>
[header]</div>
<div>
[:tr (for [e header]</div>
<div>
[:th e])])</div>
<div>
<br /></div>
<div>
(defn excel-app</div>
<div>
"Excel prototype application"</div>
<div>
[excel-data]</div>
<div>
[:div</div>
<div>
[:table</div>
<div>
[:thead (table-header (:h @excel-data))]</div>
<div>
[:tbody (table-body (:b @excel-data))]]])</div>
<div>
<br /></div>
<div>
(reagent/render-component [excel-app excel-data]</div>
<div>
(.getElementById js/document "app"))</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
It looks like this:</div>
<div>
<br /></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinFT1_rhLIUQDFhB-B1lGLaec6A27GoNQyVOLSym7xtL_x3wriEU662j1e9aUFVxLPH9wmymkRvDkc7DmEqxM3hJzWbR9pVIqhqC8Fur4zQ8A6xkle9QAOmc4cVI-gsHJQhHBjez8oI_o/s1600/%25D0%25A1%25D0%25BD%25D0%25B8%25D0%25BC%25D0%25BE%25D0%25BA+%25D1%258D%25D0%25BA%25D1%2580%25D0%25B0%25D0%25BD%25D0%25B0+2017-08-23+%25D0%25B2+0.16.29.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="540" data-original-width="1556" height="220" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinFT1_rhLIUQDFhB-B1lGLaec6A27GoNQyVOLSym7xtL_x3wriEU662j1e9aUFVxLPH9wmymkRvDkc7DmEqxM3hJzWbR9pVIqhqC8Fur4zQ8A6xkle9QAOmc4cVI-gsHJQhHBjez8oI_o/s640/%25D0%25A1%25D0%25BD%25D0%25B8%25D0%25BC%25D0%25BE%25D0%25BA+%25D1%258D%25D0%25BA%25D1%2580%25D0%25B0%25D0%25BD%25D0%25B0+2017-08-23+%25D0%25B2+0.16.29.png" width="640" /></a></div>
<div>
<br />
PS: Use ^{:key (gensym)} before :th, :tr, :td to avoid warning about unique key</div>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-603162694465065962017-08-20T12:19:00.001-07:002017-08-25T05:31:18.605-07:00react learning: shared state example<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-size: large;"><b>Using Reagent</b></span><br />
<span style="font-size: large;"><b><br /></b></span>
(def str-area (reagent/atom "init"))<br />
(def length (reagent/atom 0))<br />
<br />
(defn my-text-area [area-value]<br />
[:textarea {:id :comments<br />
:defaultValue @area-value<br />
:on-change #(do<br />
(reset! str-area (-> % .-target .-value))<br />
(reset! length (count (-> % .-target .-value))))}])<br />
<br />
(defn text-counter []<br />
[:div<br />
"Counter: " @length])<br />
<br />
(defn text-value []<br />
[:div<br />
"Value: " @str-area])<br />
<br />
(defn app []<br />
[:div<br />
[my-text-area str-area]<br />
[text-counter]<br />
[text-value]])<br />
<br />
(reagent/render-component [app]<br />
(.getElementById js/document "app"))<br />
<br />
It looks like this:<br />
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlMAXdi3yj0kQ9Fn0GTiYwSHsusmvJ-5PDB7B3Vd_HF5T47iFQwc9BssnCV6NKzK5jrgNnjYSSaimHjWdAwkPMvqpp4vFHX1yRi6siD5cDnLPze9LyDMitf-PB2yHwV5JWtJoFhPU0eqY/s1600/%25D0%25A1%25D0%25BD%25D0%25B8%25D0%25BC%25D0%25BE%25D0%25BA+%25D1%258D%25D0%25BA%25D1%2580%25D0%25B0%25D0%25BD%25D0%25B0+2017-08-20+%25D0%25B2+22.20.02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="247" data-original-width="558" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlMAXdi3yj0kQ9Fn0GTiYwSHsusmvJ-5PDB7B3Vd_HF5T47iFQwc9BssnCV6NKzK5jrgNnjYSSaimHjWdAwkPMvqpp4vFHX1yRi6siD5cDnLPze9LyDMitf-PB2yHwV5JWtJoFhPU0eqY/s320/%25D0%25A1%25D0%25BD%25D0%25B8%25D0%25BC%25D0%25BE%25D0%25BA+%25D1%258D%25D0%25BA%25D1%2580%25D0%25B0%25D0%25BD%25D0%25B0+2017-08-20+%25D0%25B2+22.20.02.png" width="320" /></a></div>
<br /></div>
<div>
<span style="font-size: large;"><b>Using RUM</b></span><br />
<br />
(enable-console-print!)<br />
<br />
(rum/defc count-label<br />
[value]<br />
[:div [:label (str "Count:" (count @value))]])<br />
<br />
(rum/defcs app < (rum/local "hi!" ::value)<br />
[state]<br />
(let [v (::value state)]<br />
[:div<br />
[:div [:textarea {:default-value @v :on-change (fn [e] (reset! v (-> e .-target .-value)))}]]<br />
(count-label v)<br />
[:div [:label (str "Value:" @v)]]]))<br />
<br />
(rum/mount (app) (.getElementById js/document "app"))<br />
<div>
<br /></div>
<div>
<br /></div>
<br />
<br /></div>
</div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-47806961292152684702017-08-06T12:47:00.002-07:002017-08-06T12:48:24.468-07:00Enable Java Mission Control<div dir="ltr" style="text-align: left;" trbidi="on">
Just put these flags as JVM parameters:<br />
<br />
<i>-Dcom.sun.management.jmxremote.rmi.port=7091 -Dcom.sun.management.jmxremote.port=7091 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:+UnlockCommercialFeatures -XX:+FlightRecorder</i><br />
<br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-80145623009892248432017-07-12T21:27:00.003-07:002017-07-13T12:38:47.695-07:00my if <div dir="ltr" style="text-align: left;" trbidi="on">
;; what if "if" is unavailable?<br />
;; what if we cannot use code branch execution fn's? (case, cond, if, etc..)<br />
;; let's create our own if<br />
<br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-87468118861689218152017-06-14T08:35:00.001-07:002017-06-14T09:36:51.501-07:00Event Sourcing part 1<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://bit.ly/2s0MUaW">http://bit.ly/2s0MUaW</a><br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0tag:blogger.com,1999:blog-7967027515077781954.post-82283924706460421572017-06-14T06:20:00.002-07:002017-06-14T06:20:24.175-07:00Spacemacs + smartscan<div dir="ltr" style="text-align: left;" trbidi="on">
Very handy package - Smartscan for Clojure code editing, renaming local vars in fn, jumping to usages & more.<br />
<a href="https://github.com/mickeynp/smart-scan">https://github.com/mickeynp/smart-scan</a><br />
<br />
<br /></div>
mikehttp://www.blogger.com/profile/05183612003119232402noreply@blogger.com0