Skip to content

Instantly share code, notes, and snippets.


Eero Helenius eerohele

View GitHub Profile
View maybe-stupid-repl.clj
(def eval-context (atom {}))
(defn handle
"Imaginary message handler that sets the namespace received out of band."
(swap! eval-context assoc #'*ns* (find-ns ns)))
(defn repl
(loop []
View bytecode.clj
(ns tutkain.bytecode
(:require [ :as io]
[tutkain.backchannel :refer [handle respond-to]])
(:import ( PrintWriter StringWriter)
(java.util.spi ToolProvider)
(java.nio.file Files)
(java.nio.file.attribute FileAttribute)))
(set! *warn-on-reflection* true)
eerohele / hello-again.clj
Last active Nov 19, 2021
JEP 408 Clojure Hello World
View hello-again.clj
(import '( HttpHandlers HttpServer Headers Filter))
(import '( InetSocketAddress))
(import '(java.util.function UnaryOperator))
(defn make-handler
[{:keys [status headers body]}]
(HttpHandlers/of status (Headers/of headers) body))
(def identity-filter
(Filter/adaptRequest "Identity"
eerohele / stacktrace.edn
Created May 31, 2021
ClojureScript stack trace
View stacktrace.edn
#error {
:cause nil
[{:type clojure.lang.ExceptionInfo
:message failed compiling file:src/hello_world/core.cljs
:data {:file #object[ 0x630a647c src/hello_world/core.cljs], :clojure.error/phase :compilation}
:at [cljs.compiler$compile_file$fn__4001 invoke compiler.cljc 1747]}
{:type clojure.lang.ExceptionInfo
:message nil
:data #:clojure.error{:source src/hello_world/core.cljs, :line 6, :column 3, :phase :compilation}
eerohele /
Last active Dec 20, 2021
Start Clojure Socket REPL server and write the port number into .repl-port

In your ~/.clojure/deps.edn, add an alias like this:

:socket-repl {:extra-deps {me.flowthing/shiv {:git/url ""
                                              :sha "339ef83def69e62ac969a2fd797a9be1d3c1fe83"}}
              :exec-fn shiv/start-server
              :exec-args {:name "server"
                          :port 0
                          :accept clojure.core.server/repl
 :server-daemon false}}
View cljs-macro-compiler-stack-overflow.txt
79 |
80 |
81 | (deftest surgeon
82 | (spec/test-with (spec/browser) page
StackOverflowError: (cljs_hacks.cljc:154) (cljs_hacks.cljc:148)
ZlGCeaVIOme2sCc k7aM5azZDf8EwrX 4dUaIaKru5MOfW7 xDTolSOzxKTDA2f
q36EErpEcULTthd 1khuiM9BjaUTCKq 6Xr2MZHgg6smaIL BpjOvAsq7EbxijZ
fSj5kuHbySVTnuH YIWUnXY5GoHnZlS aqDRMsNR9btNJlP pzv7I0aNlDoMQsU
Z1imMSmbnfS2TgB avyYaeJjLH8GrrZ jTEzl0Qz5Z.
View core.clj
(require '[clojure.main :as m])
:init #(apply require m/repl-requires)
:eval (fn [form]
(require '[clojure.pprint :refer [pp pprint]])
(require '[hashp.core])
(eval form))))
eerohele / learnxinyminutes-clojure.markdown
Last active Nov 21, 2019
A Markdown version of the Clojure variant of learnxinyminutes
View learnxinyminutes-clojure.markdown

This is a version of learnxinyminutes for Clojure adapted for use with Useless.

All I've done is lifted most of the comments out of the code blocks, removed the ; => bits, and some minor copy editing.

Clojure is a Lisp family language developed for the Java Virtual Machine. It has a much stronger emphasis on pure functional programming than Common Lisp, but includes several STM utilities to handle state as it comes up.

This combination allows it to handle concurrent processing very simply, and often automatically.

View core.async-walkthrough.markdown

core.async walkthrough

This is a Markdown version of the core.async walkthrough.clj.

This walkthrough introduces the core concepts of core.async.

The clojure.core.async namespace contains the public API.