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
user=> (ns foo (:import [java.util.Date])) | |
nil | |
foo=> (Date.) | |
CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Date, compiling:(NO_SOURCE_PATH:21:1) | |
foo=> (ns foo (:import java.util.Date)) | |
nil | |
foo=> (Date.) | |
#inst "2015-12-20T13:39:43.209-00:00" |
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
kingfisher.core=> (s/check {s/Any s/Any} {"ooh" "OK"}) | |
nil | |
kingfisher.core=> (s/defschema MySchema {:query {s/Any s/Any} :some_id java.lang.Long :foos {s/Any s/Any} :id String}) | |
#'kingfisher.core/MySchema | |
kingfisher.core=> (s/check MySchema {:query {}}) | |
{:some_id missing-required-key, :foos missing-required-key, :id missing-required-key} | |
kingfisher.core=> (s/check MySchema {:query {} :some_id 1 :foos {} :id "OK"}) | |
nil |
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
$ java -jar .m2/repository/org/clojure/clojure/1.7.0/clojure-1.7.0.jar -e '(doseq [line (line-seq (java.io.BufferedReader. *in*))] (println "read" line))' | |
hi | |
read hi | |
aklsdjf | |
read aklsdjf |
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
user=> (future (do (Thread/sleep 12000) (/ 1 0))) | |
#object[clojure.core$future_call$reify__6958 0x7f3d150b {:status :pending, :val nil}] | |
user=> (realized? *1) | |
true | |
user=> *2 | |
#object[clojure.core$future_call$reify__6958 0x7f3d150b {:status :failed, :val #error { | |
:cause "Divide by zero" | |
:via | |
[{:type java.util.concurrent.ExecutionException | |
:message "java.lang.ArithmeticException: Divide by zero" |
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
kingfisher.core=> (defprotocol IFoo (bar [this] [this baz])) | |
IFoo | |
kingfisher.core=> (defrecord Quux [] IFoo (bar [this] "hi") (bar [this baz] "bye")) | |
kingfisher.core.Quux | |
kingfisher.core=> (bar (Quux.)) | |
"hi" | |
kingfisher.core=> (bar (Quux.) nil) | |
"bye" | |
kingfisher.core=> (defrecord Quux [] IFoo (bar [this] "hi") (bar [this baz] (str "bye" baz))) | |
kingfisher.core=> (bar (Quux.) "bye") |
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
=> (slurp (.decode (java.util.Base64/getDecoder) (.encode (java.util.Base64/getEncoder) (.getBytes "test")))) | |
"test" |
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
user=> (def w (proxy [java.io.OutputStream] [] (write [i] (println i) (.flush *out*)))) | |
#'user/w | |
user=> (.write w (.getBytes "HELLO")) | |
#object[[B 0x4dca533c [B@4dca533c] | |
nil | |
user=> (def w (proxy [java.io.OutputStream] [] (write [i] (println (String. i "UTF-8")) (.flush *out*)))) | |
#'user/w | |
user=> (.write w (.getBytes "HELLO")) | |
HELLO | |
nil |
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
user=> (require '[alembic.still :as still]) | |
nil | |
user=> (still/distill '[[clj-time "0.10.0"]]) | |
WARN: org.clojure/clojure version 1.6.0 requested, but 1.7.0-beta1 already on classpath. | |
Loaded dependencies: | |
[[clj-time "0.10.0"] [joda-time "2.7"]] | |
Dependencies not loaded due to conflict with previous jars : | |
[[org.clojure/clojure "1.6.0"]] | |
nil |
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
kingfisher.core=> (alter-var-root #'in-ns (fn [f] (fn [& args] (println "switching ns!") (apply f args)))) | |
#object[kingfisher.core$eval31119$fn__31120$fn__31121 0x16c9cab3 "kingfisher.core$eval31119$fn__31120$fn__31121@16c9cab3"] | |
kingfisher.core=> (in-ns 'user) | |
switching ns! | |
#object[clojure.lang.Namespace 0x6406ea3c "user"] |
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
kingfisher.core=> (require '[criterium.core :as crit]) | |
nil | |
kingfisher.core=> (crit/bench ((comp peek vector) :a :b)) | |
WARNING: Final GC required 7.188201060322719 % of runtime | |
Evaluation count : 2572102380 in 60 samples of 42868373 calls. | |
Execution time mean : 21.377345 ns | |
Execution time std-deviation : 0.162153 ns | |
Execution time lower quantile : 21.193369 ns ( 2.5%) | |
Execution time upper quantile : 21.724186 ns (97.5%) | |
Overhead used : 2.009774 ns |