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 drop-items [coll x] | |
(loop [coll coll | |
x x | |
res [] | |
c 1] | |
(if (empty? coll) | |
res | |
(recur (rest coll) | |
x | |
(if (= c x) |
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 vecs->map [coll1 coll2] | |
(apply hash-map (mapcat vector coll1 coll2))) | |
(vecs->map [1 2 3] [\a \b \c]) | |
;; => {"1" \a, "2" \b, "3" \c} |
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 map->querystring [params] | |
(str | |
"?" | |
(reduce | |
#(str % "&" %2) | |
(map | |
#(str (first %) "=" (second %)) | |
params)))) | |
(map->querystring {"foo" 1 "bar" 2 "baz" "test"}) |
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 get-last [vect] | |
(first (reverse (seq vect)))) | |
(get-last [1 3 2]) | |
(get-last '(1 3 2)) |
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
;;; save-layout before killing emacs. (needs revive.el) https://github.com/nunb/revive-mode-config | |
(defun save-state-kill-emacs (&optional arg) | |
"Save state, buffers and kill emacs" | |
(interactive "p") | |
(emacs-save-layout) | |
(save-buffers-kill-emacs)) | |
(global-set-key (kbd "C-x C-c") 'save-state-kill-emacs) |
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
// To detect native support for the HTML5 placeholder attribute | |
var fakeInput = document.createElement("input"), | |
placeHolderSupport = ("placeholder" in fakeInput), | |
clearValue = function () { | |
if (searchField.val() === originalText) { | |
searchField.val(""); | |
} | |
}; | |
NewerOlder