This file contains 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 log-opts [logger level msg & params] | |
(let [amap (apply array-map params) | |
expected (count (re-seq #"%s|%d|%j" msg)) | |
args (flatten [amap msg (if (not (empty? amap)) (take expected (vals amap)))])] | |
(.apply (aget logger level) logger (clj->js (remove nil? args))))) |
This file contains 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
;; merge two sorted linked lists | |
;; h1 => 2 => 3 => 5 | |
;; h2 => 4 => 4 => 6 => 7 | |
;; h => 2 => 3 => 4 => 4 => 5 => 6 => 7 | |
(defn splitter [lst1 lst2] | |
(cond (empty? lst1) [lst2 nil nil] | |
(empty? lst2) [lst1 nil nil] | |
:else (let [[l1 l2] (if (< (first lst1) (first lst2)) [lst1 lst2] [lst2 lst1])] |
This file contains 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
cljs.user=> (type '(1 2 3)) | |
cljs.core/List | |
cljs.user=> (= clojure.core/List (type (cons 1 '(2)))) | |
false | |
cljs.user=> (type (cons 1 '(2))) | |
cljs.core/Cons |
This file contains 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
getFilesMatching = (pattern) -> | |
splitted = pattern.split '/' | |
[dir, pattern] = [((_.initial splitted).join '/'), _.last splitted] | |
pattern = (pattern.replace '.', '\.').replace '*', '.*' # convert shell regex to PCRE | |
_.compact _.map (fs.readdirSync dir), (f) -> if f.match pattern then "#{dir}/#{f}" |
This file contains 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
class CommandHistory | |
constructor: -> | |
@stack = [] | |
@curPos = -1 | |
@pushShouldReplaceLast = false | |
put = (index, cmd) => | |
if @pushShouldReplaceLast then @stack[index..index] = cmd | |
else @stack.push cmd | |
@curPos = index |