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 print-it [it] | |
(println it)) | |
;;; the test needs to be in the form (expect expected actual), | |
;;; and the line we're testing is (println it) | |
;;; so you could envision a test similar to the one below | |
(expect (println 5) | |
(print-it 5)) |
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 print-it [it] | |
(println it)) | |
;;; the test needs to be in the form (expect expected actual), | |
;;; and the line we're testing is (println it) | |
;;; so you could envision a test similar to the one below | |
(expect (interaction (println 5)) | |
(print-it 5)) |
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
(expect (interaction (spit #"/tmp/" "some data" :append true)) | |
(do | |
(spit "/tmp/somewhere-else" "nil") | |
(spit "/tmp/hello-world" "some data" :append 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
(expect (interaction (spit #"/tmp/" String :append true)) | |
(do | |
(spit "/tmp/somewhere-else" "nil") | |
(spit "/tmp/hello-world" "some data" :append 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
(defn true-or-nil? [x] | |
(or (true? x) (nil? x))) | |
;; this test passes | |
(expect (interaction (spit #"/tmp/" String :append true-or-nil?)) | |
(do | |
(spit "/tmp/somewhere-else" "nil") | |
(spit "/tmp/hello-world" "some data" :append true))) | |
;; so does this test |
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
(expect (interaction (spit String #"some da" keyword? (contains-kvs :a :b :c :d))) | |
(spit "/tmp/hello-world" "some data" :append {:a :b :c :d :e :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
Programming career distilled. | |
- holy shit programming in language X isn't that hard. | |
- okay, I have a hammer, everything is a nail. | |
- holy shit there are other tools that make working even faster. | |
- I can solve this problem using 3 different tools I know well. | |
- I'm bored by learning other tools, I solve everything using my favorite tool. | |
- become a manager. |
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
;; a simple server that's generating a new int that's < 100, every millisecond | |
(ns synchro.core | |
(:import [org.jetlang.fibers ThreadFiber])) | |
(defonce server-list (atom [])) | |
(defonce appender (atom nil)) | |
(defonce fiber (doto (ThreadFiber.) .start)) |
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
;; server | |
(defonce server-list (atom [])) | |
(defonce appender (atom nil)) | |
(defonce appending-fiber (atom nil)) | |
(defonce subscriber (atom identity)) | |
(defn subscribe [f] | |
(reset! subscriber 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
;; client | |
(defonce client-list (atom nil)) | |
(defn handle-update [{:keys [type val]}] | |
(if (= type :snapshot) | |
(reset! client-list val) | |
(when @client-list | |
(when (< 9 (count @client-list)) | |
(swap! client-list butlast)) | |
(swap! client-list conj val)))) |