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
;; Only one window on startup | |
(add-hook 'emacs-startup-hook 'delete-other-windows t) | |
;; same thing - longer version | |
(add-hook 'emacs-startup-hook | |
(lambda () (delete-other-windows)) t) |
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
;; override the default keybindings in paredit | |
(eval-after-load 'paredit | |
'(progn | |
(define-key paredit-mode-map (kbd "<M-right>") 'paredit-forward-slurp-sexp) | |
(define-key paredit-mode-map (kbd "<M-left>") 'paredit-forward-barf-sexp) | |
(define-key paredit-mode-map (kbd "<C-right>") nil) | |
(define-key paredit-mode-map (kbd "<C-left>") 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
;; Toggle between split windows and a single window | |
(defun toggle-windows-split() | |
"Switch back and forth between one window and whatever split of windows we might have in the frame. The idea is to maximize the current buffer, while being able to go back to the previous split of windows in the frame simply by calling this command again." | |
(interactive) | |
(if (not (window-minibuffer-p (selected-window))) | |
(progn | |
(if (< 1 (count-windows)) | |
(progn | |
(window-configuration-to-register ?u) | |
(delete-other-windows)) |
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 one-time-setup [] | |
(println "one time setup")) | |
(defn one-time-teardown [] | |
(println "one time teardown")) | |
(defn once-fixture [f] | |
(one-time-setup) | |
(println (type f)) | |
(f) |
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 one-time-setup [] | |
(println "one time setup")) | |
(defn one-time-teardown [] | |
(println "one time teardown")) | |
(defn once-fixture [f] | |
(one-time-setup) | |
(f) | |
(one-time-teardown)) |
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 setup [] | |
(println "setup")) | |
(defn teardown [] | |
(println "teardown")) | |
(defn each-fixture [f] | |
(setup) | |
(f) | |
(teardown)) |
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
(deftest test-encrypt-decrypt | |
(let [vault (->CryptoVault keystore-fname passw) | |
key (get-secret-key-from-keystore vault)] | |
(testing "Encrypt one simple string" | |
(let [fname "tiger.boy"] | |
(encrypt vault fname "Tiger Tiger Tiger") | |
(let [msg (decrypt vault fname)] | |
(is (not (nil? msg))) | |
(is (= "Tiger Tiger Tiger" msg))))) |
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
(testing "Encrypt one simple string" | |
(let [fname "tiger.boy"] | |
(try | |
(encrypt vault fname "Tiger Tiger Tiger") | |
(let [msg (decrypt vault fname)] | |
(is (not (nil? msg))) | |
(is (= "Tiger Tiger Tiger" msg))) | |
(finally (.delete (File. fname)))))) |
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
;; clojure.core/flatten from | |
;; http://clojuredocs.org/clojure_core/clojure.core/flatten | |
;; Copyright Rich Hickey | |
(defn flatten | |
"Takes any nested combination of sequential things (lists, vectors, | |
etc.) and returns their contents as a single, flat sequence. | |
(flatten nil) returns nil." | |
{:added "1.2" | |
:static true} |
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
;; answer from nikkomega to 4clojure.com problem 28 | |
(defn flt [s] | |
(if (sequential? s) | |
(mapcat flt s) | |
(list s))) |
OlderNewer