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
(import '[javax.script ScriptEngineManager]) | |
(let [engine (.getEngineByName (ScriptEngineManager.) "nashorn")] | |
(println (= (.eval engine "' \\r\\n' == 0") true))) |
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
; CIDER 0.6.0alpha (package: 20140316.1007) (Clojure 1.5.1, nREPL 0.2.3) | |
user> (.maxMemory (Runtime/getRuntime)) | |
103284736 | |
user> (require '[clojure.java.io :as io]) | |
nil | |
user> (with-open [f (io/writer "/tmp/foo")] (doseq [x (range 50000)] (.write f (prn-str [x (range 1000)])))) | |
nil | |
user> (.length (io/file "/tmp/foo")) | |
194988890 | |
user> (slurp "/tmp/foo") |
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
(in-ns 'eclj.core) | |
(defprotocol Fn | |
:on-interface clojure.lang.Fn | |
"Marker interface indicating invokeables that are explictly functions") | |
(defprotocol IFn | |
:on-interface clojure.lang.IFn | |
(^{:on :invoke} -invoke | |
[this] |
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
(ns kleene) | |
;; | |
;; Inspired by "Regexes, Kleene Algebras and Real Ultimate Power" | |
;; http://plastic-idolatry.com/erik/oslo2014.pdf | |
;; | |
;; What do we want to do?... | |
;; | |
;; (def p1 (times (Var. "w") (Var. "o") (Var. "w")) | |
;; (matches? p1 "wow") ;; true |
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
;; ## State Methods | |
(defmulti initial-state | |
"Multimethod that returns the initial state for the supplied | |
page." :name) | |
(s/defmethod initial-state :default [r :- Route s :- (s/maybe AppState)] {}) | |
(defmulti page-title | |
"Returns the current page title for the supplied route." :name) |
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
(ns example.macros | |
(:require | |
[cljs.analyzer :as a] | |
[cljs.compiler :as c])) | |
(defmacro complies? | |
"True if x satisfies and implements all methods of a protocol. | |
Ex. |
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
(deftype AdditionalData [data] | |
silk/Pattern | |
(-match [_ _] | |
data) | |
(-unmatch [_ _] | |
nil) | |
(-match-validator [_] | |
(constantly true)) | |
(-unmatch-validators [_] | |
{})) |
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
/* | |
On OS X, basic text manipulations (left, right, command+left, etc) make use of the system key bindings, | |
and don't need to be repeated here. Anything listed here will take precedence, however. | |
*/ | |
[ | |
{ "keys": ["super+shift+n"], "command": "new_window" }, | |
{ "keys": ["super+shift+w"], "command": "close_window" }, | |
{ "keys": ["super+o"], "command": "prompt_open" }, | |
{ "keys": ["super+shift+t"], "command": "reopen_last_file" }, | |
{ "keys": ["super+alt+up"], "command": "switch_file", "args": {"extensions": ["cpp", "cxx", "cc", "c", "hpp", "hxx", "h", "ipp", "inl", "m", "mm"]} }, |
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
(ns my-great-project.core-spec | |
(:require [speclj.core :refer :all] | |
[simple-check.core :as sc] | |
[simple-check.generators :as gen] | |
[simple-check.properties :as prop] | |
[my-great-project.core :refer :all])) | |
(defmacro check-that [desc n property] | |
`(it ~desc | |
(let [check# (sc/quick-check ~n ~property) |
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 reset-components [db eid attr new-comps] | |
(let [current-comps (-> (d/pull db [attr] eid) attr) | |
;; First we do a value based comparison ignoring component entity ids. | |
current-comp-vals (into #{} (map #(dissoc % :db/id) current-comps)) | |
new-comp-vals (into #{} new-comps) | |
deletions (clojure.set/difference current-comp-vals new-comp-vals) | |
additions (clojure.set/difference new-comp-vals current-comp-vals) |
OlderNewer