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.core.async :as ca]) | |
(def some-ch (ca/chan)) | |
(def result-ch (ca/reduce | |
(fn [xs msg] | |
(if (= msg :done) | |
(reduced xs) | |
(conj xs msg))) | |
[] | |
some-ch)) |
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
;;say you have something that looks like | |
(fnx a b) | |
(fnx a b2) | |
(fnx a b c) | |
(fnx a1 b2 c) | |
(fnx a2 b2 c2 d) | |
;;my goal is to avoid the repetition of fnx |
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 query '[:find ?e ?fname ?lname | |
:in $ ?fname ?lname | |
:where [?e :user/firstname ?fname] | |
[?e :user/lastName ?lname]]) | |
(defn group-by-kw [v] | |
(map (fn [[[f] l]] (conj [f] l)) | |
(partition 2 (partition-by keyword? v)))) | |
(defn query-vec-as-map [vquery] |
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
[:find ?e ?ident | |
:where [?e :db/ident ?ident] | |
[(namespace ?ident) ?ns] | |
[(= ?ns "db.excise")]] |
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
$.when.apply(null, (ajaxRequest p for p in items)).done -> | |
console.log "all ajaxRequests complete" |
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
CodeMirror.extendMode("clojure", { | |
newlineAfterToken: function(type, content, textAfter) { | |
console.log(type, content, textAfter); | |
return /[\(\{\[].+\s/.test(content); | |
} | |
}); | |
// Applies automatic mode-aware indentation to the specified range | |
CodeMirror.defineExtension("autoIndentRange", function (from, to) { | |
var cmInstance = 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
[:find ?id ?name ?attr | |
:in $ ?in-ns | |
:where [?id :db/ident ?name] | |
[(name ?name) ?attr] | |
[(namespace ?name) ?ns] | |
[(= ?ns ?in-ns)]] |
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
;;takes datomic query and turns it into map so it may be interrogated | |
(defn query-info [query] | |
(let [parts (partition-by keyword? query) | |
is-kw #(keyword? (first %))] | |
(zipmap | |
(map first (filter is-kw parts)) | |
(remove is-kw parts)))) | |
;;eg | |
((query-info '[:find ?x ?y ?z :in $ ?d :where [?x :some/thing ?y] [?x :some/otherthing ?z]]) :find) |
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
String.prototype.$tag = (args...) -> | |
args.unshift "<#{@toString()}/>" | |
$.apply window, args | |
("ul".$tag | |
class: "someUL" | |
html: "li".$tag | |
text: "some text in an li" | |
class: "some class" | |
click: -> |
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
#this is absolutely just for fun | |
keyWordDispatcher = (obj, msg) -> | |
selectorName = "" | |
args = [] | |
for k, v of msg | |
selectorName += k + "_" | |
args.push v | |
if obj[selectorName]? |
NewerOlder