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
(def users [{:id 1 | |
:email "[email protected]" | |
:first_name "Michael" | |
:last_name "Lawson" | |
:avatar "https://reqres.in/img/faces/1-image.jpg"} | |
{:id 2 | |
:email "[email protected]" | |
:first_name "Lindsay" | |
:last_name "Ferguson" | |
:avatar "https://reqres.in/img/faces/2-image.jpg"} |
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
(ns otca.shorts) | |
(defn wait-return [s r] | |
(Thread/sleep (* s 1000)) | |
r) | |
#_(defn time-taken [expr] | |
(let [start (. System (nanoTime)) |
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
(ns scratch.core) | |
;; | |
;; x "once" | |
;; debouncer / rate limiter | |
;; namespaces | |
;; multiple windows | |
;; invalidation | |
;; peek |
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
(ns scratch.core) | |
(defn say-hi [username] | |
(let [s (str "hello, " username)] | |
(Thread/sleep (rand 100)) | |
(println s) | |
s)) | |
(comment (say-hi "Steve")) |
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
(ns scratch.core) | |
(defn say-hi [username] | |
(let [s (str "hello, " username)] | |
(Thread/sleep (rand 100)) | |
(println s) | |
s)) | |
(defn wrap-once-in-a-while [msecs-period f] |
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
(ns scratch | |
(:require [clojure.string :as str])) | |
;; (def input [1, 2, 3, 4, 5, 7, 1, 9, 10]) | |
(def input (map #(Integer/parseInt %) (str/split-lines (slurp "input-data.txt")))) | |
(take 3 input) | |
(def combined-input (loop [input-nums input | |
values-to-check []] |
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 filter-multiple [n v] | |
(if (= 1 n) v | |
(filter (fn [x] | |
(or | |
(= x n) | |
(not= 0 (mod x n)))) v))) | |
(defn sieve [input] | |
(let [limit (Math/sqrt input) | |
numbers (range 2 input)] |