Skip to content

Instantly share code, notes, and snippets.

Happy prototyping with ClojureScript

Jon jiyinyiyong

View GitHub Profile
jiyinyiyong / pudica-history.edn
Created Mar 28, 2019
Old history data from Pudica Viewer
View pudica-history.edn
{:states {},
:router {:name :viewer},
:content {:tasks {"S1z3WZSk7X" {:id "S1z3WZSk7X",
:text "没有尾递归的介绍",
:done? false,
:sort-id "T",
:created-time 1531035908457,
:done-time nil,
:archived-time nil},
"W6GwOL21l" {:id "W6GwOL21l",
jiyinyiyong /
Last active Sep 17, 2018
cljs intro in FCC

ClojureScript 的开发体验(演示)


View browser-file-tree.text
├── assets
│ └── index.html
├── package.json
├── shadow-cljs.edn
├── src
│ └── app
│ ├── lib.cljs
│ └── main.cljs

函数式语言 ClojureScript 在前端开发的体验


题叶, ChenYong, 上海

Teambition, 饿了么, 积梦智能(工业大数据).

jiyinyiyong / orthogonality.text
Created Apr 12, 2018
Find a orthogonality vector based on two existing vectors
View orthogonality.text
line1 = a*i + b*j + c*k
line2 = d*i + e*j + f*k
line3 = x*i + y*j + z*k
line1 .* line3 = ax + by + cz = 0
line1 .* line3 = dx + ey + fz = 0
z = -(ax + by)/c


ClojureScript and Clojure

ClojureScript and Clojure share the same syntax but distinguish by .cljs extension name. The most different part is the difference in host platforms, like JavaScript is known as single-threaded and restricted by browser APIs.

Libraries of both sides release code on Clojars in jar files.

ClojureScript and npm

With JavaScript InterOp, you may call some JavaScript code from in Clojure syntax. ClojureScript is designed to use features from host platform. You are free to import npm modules in ClojureScript, most of them will work correctly, especially in shadow-cljs and Lumo.

jiyinyiyong /
Created Apr 4, 2018
Hijack `get`, `set` and `apply`, then everything is a lie...
createAny = (path, collector) ->
new Proxy (->),
get: (target, key, receiver) ->
createAny path.concat([key]), collector
set: (target, key, value, receiver) ->
newPath = path.concat [key]
collector ['set', newPath, value]
apply: (target, ctx, args) ->
collector ['apply', path, args]

|Lumo is a standalone ClojureScript environment that runs on Node.js and the V8 JavaScript engine. It starts up instantaneously and has out-of-the-box access to the entire Node.js ecosystem.

To install:

$ brew install lumo
# or
$ npm install -g lumo-cljs

Easy to install

shadow-cljs can be installed from npm as command-line tool. JVM installation is required, but shadow-cljs handles configurations for you.

npm install -g shadow-cljs
# or
yarn global add shadow-cljs
jiyinyiyong /
Last active Mar 18, 2018
Respo home page drafts

|Create elements in Clojure syntax:

(div {:class-name "demo"
      :style {:color :red
              :font-size 16
              :font-family "Josefin Sans"}
      :on-click (fn [event dispatch! mutate!])})

; respo.macros/div
You can’t perform that action at this time.