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
(apply str (map #(format "%02x" (bit-and % 0xff)) | |
(.digest (doto (MessageDigest/getInstance "MD5") | |
(.update (.getBytes input)))))) |
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
(defprotocol PFoo | |
(foo [x])) | |
(extend-protocol PFoo | |
Keyword | |
(foo [x] | |
"Keyword") | |
js/Object |
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
(defprotocol JSCodec | |
(clj->js [x]) | |
(key->js [x]) | |
(js->clj [x][x options])) | |
(extend-protocol JSCodec | |
default | |
(key->js [k] | |
(if (coll? k) | |
(prn-str k) |
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
mpenet@thinkbox:~/gitmu/clojurescript(feature-codecs)$ ./script/test | |
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/main | |
Caused by: java.lang.ClassNotFoundException: clojure.main | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:202) | |
at java.security.AccessController.doPrivileged(Native Method) | |
at java.net.URLClassLoader.findClass(URLClassLoader.java:190) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:306) | |
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) | |
Could not find the main class: clojure.main. Program will exit. |
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> (scaffold clojure.lang.ISeq) | |
clojure.lang.ISeq | |
(next [this]) | |
(cons [this G__30361]) | |
(first [this]) | |
(more [this]) | |
clojure.lang.IPersistentCollection | |
(count [this]) | |
(cons [this G__30362]) | |
(empty [this]) |
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
;; Examples based on code in https://github.com/ibdknox/jayq/tree/let-deferred | |
;; sugar for do-> ajax-m | |
(let-ajax [a {:url "http://localhost:8000/1.json" | |
:dataType :json} | |
b {:dataType :json :url "http://localhost:8000/2.json"}] | |
(utils/log a) | |
(utils/log b)) | |
;; sugar for do-> deferred-m |
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
(extend-type js/Object | |
IFn | |
(-invoke [this s] | |
(re-matches this s))) | |
java.lang.UnsupportedOperationException: nth not supported on this type: Symbol | |
(extend-type js/Object |
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
{:drop-index :foo} | |
{:drop-keyspace :foo} | |
{:drop-table :foo} | |
{:select (#qbits.hayt.cql.CQLFn{:name COUNT, :args (:*)}), :from :foo} | |
{:select (:*), :from :foo, :where {:ts #qbits.hayt.cql.CQLFn{:name now, :args nil}}} | |
{:select (#qbits.hayt.cql.CQLFn{:name WRITETIME, :args (:bar)}), :from :foo} | |
{:select (#qbits.hayt.cql.CQLFn{:name TTL, :args (bar)}), :from :foo} | |
{:select (#qbits.hayt.cql.CQLFn{:name unixTimestampOf, :args (bar)} #qbits.hayt.cql.CQLFn{:name dateOf, :args (:bar)}), :from :foo} | |
{:select (:*), :from :foo, :where {#qbits.hayt.cql.CQLFn{:name token, :args (:user-id)} [#<core$_GT_ clojure.core$_GT_@6177060f> #qbits.hayt.cql.CQLFn{:name token, :args (tom)}]}} | |
{:select (:*), :from :foo, :where {:ts #qbits.hayt.cql.CQLFn{:name now, :args 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
(use 'clojure.core.typed) | |
;; I would like to only allow {:a 1} {:b 2} or {:a 1, :b 2} | |
(def-alias A '{:a '1}) | |
(def-alias B '{:b '2}) | |
;; naive version would be to use a Union | |
(ann foo [(U A B) -> (Value 1)]) | |
(defn foo [x] 1) |
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 foo [x] (apply str x)) | |
(ann foo [(U (Vector* String) | |
(Seq* String) | |
(List* String)) | |
-> String]) | |
user> (cf (foo ["a" "b"])) | |
>> java.lang.String |