This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;... | |
(:import java.awt.Toolkit) | |
(:import (java.awt.datatransfer DataFlavor)) | |
;... | |
(defn- printer | |
[in] | |
(go (while true (println (<! in))))) | |
(defn- clipboard-listener |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn sleep [msec] | |
(let [deadline (+ msec (.getTime (js/Date.)))] | |
(while (> deadline (.getTime (js/Date.)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns frontend.api.core | |
(:require [ajax.core :as ajax] | |
[cljs.core.async :refer [chan put! close!]] | |
[frontend.async.core :refer [channel-error]])) | |
(defn <?GET [url] | |
"Async. Returns a maybe-channel." | |
(let [<?chan (chan)] | |
(ajax/GET url | |
{:handler #(do (put! <?chan %) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#?(:clj | |
(defn- cljs-env? | |
"Take the &env from a macro, and tell whether we are expanding into cljs. | |
Source: http://v.gd/rmKNdf" | |
[env] | |
(boolean (:ns env)))) | |
#?(:clj | |
(defmacro is-exception-thrown | |
"(is (thrown-with-msg? ...)) for specified exceptions in Clojure/ClojureScript." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns frontend.counter | |
(:require [frontend.ui :as ui] | |
[cljs.core.match :refer-macros [match]] | |
[reagent.core :as r])) | |
(defn init | |
"Creates a model intance." | |
[x] | |
x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns app.components.react-bootstrap | |
(:require [cljsjs.react-bootstrap] | |
[reagent.core :as r])) | |
(def Alert (r/adapt-react-class (.-Alert js/ReactBootstrap))) | |
(def Button (r/adapt-react-class (.-Button js/ReactBootstrap))) | |
; ... | |
(def FormControl (r/adapt-react-class (.-FormControl js/ReactBootstrap))) ; WARNING: use FormControlFixed for text input controls instead | |
(defn FormControlFixed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def child-process (js/require "child_process")) | |
(def on-exit (js/require "signal-exit")) | |
(defn -spawn | |
"Thin wrapper around NodeJS function. | |
Spawns the process in the background. Returns the created ChildProcess instance." | |
[command args options] | |
(let [name (str command " " (str/join " " args))] | |
(println "ᐅ" name) | |
(-> (.spawn child-process |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" | |
Naming conventions: | |
go - executes code which contains special blocking operations (e.g. <!), returns a channel, throws global uncaught exceptions | |
<! - reads from channel without any special treatment of returned error values | |
<? - reads from maybe-channel, if there's an error value - throws it | |
<?go - the same as go but \"swallows\" exceptions and returns a maybe-channel | |
<foo/<?foo: | |
1) channel/maybe-channel | |
2) a function returning a channel (e.g. <?fetch-items) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns libs.spec-plus | |
"Helpers for core.spec. Only tested in Lumo at the moment." | |
(:require [clojure.spec.alpha :as s] | |
[clojure.spec.test.alpha :as st] | |
[clojure.set :as set] | |
[cljs.analyzer :as ana]) | |
#?(:cljs (:require-macros [libs.spec-plus]))) | |
(defmacro speced-keys | |
"The same as s/keys but asserts that all keys have specs already registered. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn -js->clj+ | |
"For cases when built-in js->clj doesn't work. Source: https://stackoverflow.com/a/32583549/4839573" | |
[x] | |
(into {} (for [k (js-keys x)] | |
[k (aget x k)]))) | |
(defn env | |
"Returns current env vars as a Clojure map." | |
[] | |
(-js->clj+ (.-env js/process))) |
OlderNewer