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 component [ref render-fn & {:keys [on-mount on-unmount]}] | |
(let [comp (React/createClass (clj->js | |
{ :render (fn [] (crate/html (render-fn @ref))) | |
:componentDidMount (or on-mount identity) | |
:componentWillUnmount (or on-unmount identity) }))] | |
(add-watch ref :react | |
(fn [_ _ old new] | |
(when (not= old new) (.forceUpdate comp)))) | |
comp)) |
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
(require '[clojure.string :as str]) | |
(defn parse-line [line] | |
(let [line (str/replace line #"[\\]\s*(\n\s*|$)" "")] | |
(when-not (str/blank? line) | |
(let [[k v] (str/split line #"=" 2)] | |
[(str/trim k) (when-not (str/blank? v) (str/trim v))])))) | |
(defn parse [text] | |
(let [lines (str/split text #"(?<![\s\\])\s*\n")] |
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 ^:dynamic chunk-size 17) | |
(defn next-chunk [rdr] | |
(let [buf (char-array chunk-size) | |
s (.read rdr buf)] | |
(when (pos? s) | |
(java.nio.CharBuffer/wrap buf 0 s)))) | |
(defn chunk-seq [rdr] | |
(when-let [chunk (next-chunk rdr)] |
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 ini | |
(require [clojure.string :as str] | |
[clojure.tools.logging :as log]) | |
(use clojure.test)) | |
(defn read [content] | |
(-> content | |
(str/replace #"\\\s*($|\n\s*)" "") | |
(str/split-lines))) |
NewerOlder