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 map-vals [f coll] | |
(into (empty coll) (map (juxt key (comp f val)) coll))) |
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
(defmethod print-method RTable [tble ^String out] | |
"RTables print as SQL92 compliant SQL" | |
(when *debug* | |
(doseq [[k v] tble] | |
(.write out (format "%s\t\t\t\t%s\n" (str k) (str v))))) | |
(.write out (-> tble (compile nil) interpolate-sql))) |
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
ko.extenders.invalidatedBy = function(target, which) { | |
which.subscribe(function(newValue) { | |
target(""); | |
}); | |
return target; | |
}; |
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
C-u 0 M-x byte-recompile-directory |
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 shannon-entropy [col] | |
(let [xs (vals (frequencies col)) | |
n (apply + xs) | |
ln2 (Math/log 2)] | |
(- | |
(apply + | |
(for [x xs] | |
(let [a (/ x n)] | |
(* a (/ (Math/log a) ln2)))))))) |
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
(defproject foo "0.1.0-SNAPSHOT" | |
:description "Foo website" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.springframework.security/spring-security-web "3.1.0.RELEASE"] | |
[org.springframework.security/spring-security-config "3.1.0.RELEASE"] | |
[org.clojure/clojure "1.4.0"] | |
[ring "1.1.6"] | |
[org.slf4j/slf4j-api "1.6.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
sudo tcpdump -i en0 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*" |
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
#!/bin/sh | |
kill $(lsof -t -i :8080) |
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 check-item [p id] | |
(if-let [item (find-item id)] | |
(do (deliver p item) | |
nil) | |
(status 404 "Item not found"))) | |
(defn check-access [item] | |
(when-not (can-user-access? item) | |
(status 403 "Go away"))) |
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> (use 'net.cgrand.enlive-html) | |
nil | |
user> (sniptest "<tr><bb><div></div></bb></tr>" | |
[:tr] (clone-for [option-value-map [1]] | |
[:div] (content "a"))) | |
"<tr><bb><div>a</div></bb></tr>" | |
user> (sniptest "<tr><b><div></div></b></tr>" | |
[:tr] (clone-for [option-value-map [1]] | |
[:div] (content "a"))) | |
"<tr></tr><b></b><div><b></b></div><b></b>" |